paperwork: Allow exempting departments from having a mailing list
This commit is contained in:
parent
ca43798ce6
commit
74bbbb713e
@ -18,7 +18,13 @@ from .certification_emails import all_certification_emails
|
||||
@admin.register(Department)
|
||||
class Department(admin.ModelAdmin):
|
||||
search_fields = ["name"]
|
||||
list_display = ["name", "parent", "list_moderator_flag", "list_reply_to_address"]
|
||||
list_display = [
|
||||
"name",
|
||||
"parent",
|
||||
"has_mailing_list",
|
||||
"list_moderator_flag",
|
||||
"list_reply_to_address",
|
||||
]
|
||||
|
||||
|
||||
class CertificationVersionInline(admin.TabularInline):
|
||||
|
@ -28,7 +28,7 @@ class DepartmentViewSet(viewsets.ModelViewSet):
|
||||
Generate a mailing list for each department, containing all
|
||||
certified users for tools in that department or child departments
|
||||
"""
|
||||
departments = self.queryset.prefetch_related(
|
||||
departments = self.queryset.filter(has_mailing_list=True).prefetch_related(
|
||||
"children",
|
||||
"list_moderator_flag",
|
||||
Prefetch(
|
||||
|
18
paperwork/migrations/0007_department_has_mailing_list.py
Normal file
18
paperwork/migrations/0007_department_has_mailing_list.py
Normal file
@ -0,0 +1,18 @@
|
||||
# Generated by Django 4.1.3 on 2023-01-19 21:02
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("paperwork", "0006_department_alter_certificationdefinition_department"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name="department",
|
||||
name="has_mailing_list",
|
||||
field=models.BooleanField(default=False),
|
||||
),
|
||||
]
|
@ -59,6 +59,7 @@ class Department(models.Model):
|
||||
parent = models.ForeignKey(
|
||||
"self", on_delete=models.PROTECT, related_name="children", blank=True, null=True
|
||||
)
|
||||
has_mailing_list = models.BooleanField(default=False)
|
||||
list_moderator_flag = models.ForeignKey(
|
||||
MembershipWorksFlag,
|
||||
on_delete=models.PROTECT,
|
||||
|
Loading…
Reference in New Issue
Block a user