Skip to content

Commit

Permalink
django admin tooling for dissem (#3342)
Browse files Browse the repository at this point in the history
  • Loading branch information
timoballard authored Feb 2, 2024
1 parent 36a9d42 commit b9c05d1
Show file tree
Hide file tree
Showing 3 changed files with 372 additions and 24 deletions.
266 changes: 254 additions & 12 deletions backend/dissemination/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,259 @@
Note,
Passthrough,
SecondaryAuditor,
OneTimeAccess,
)

admin.site.register(AdditionalEin)
admin.site.register(AdditionalUei)
admin.site.register(CapText)
admin.site.register(FederalAward)
admin.site.register(Finding)
admin.site.register(FindingText)
admin.site.register(General)
admin.site.register(Note)
admin.site.register(Passthrough)
admin.site.register(SecondaryAuditor)
admin.site.register(OneTimeAccess)

class AdditionalEinAdmin(admin.ModelAdmin):
def has_add_permission(self, request, obj=None):
return False

def has_change_permission(self, request, obj=None):
return False

def has_delete_permission(self, request, obj=None):
return False

def has_module_permission(self, request, obj=None):
return request.user.is_staff

def has_view_permission(self, request, obj=None):
return request.user.is_staff

list_display = (
"report_id",
"additional_ein",
)

search_fields = ("report_id",)


class AdditionalUeiAdmin(admin.ModelAdmin):
def has_add_permission(self, request, obj=None):
return False

def has_change_permission(self, request, obj=None):
return False

def has_delete_permission(self, request, obj=None):
return False

def has_module_permission(self, request, obj=None):
return request.user.is_staff

def has_view_permission(self, request, obj=None):
return request.user.is_staff

list_display = (
"report_id",
"additional_uei",
)

search_fields = ("report_id",)


class CapTextAdmin(admin.ModelAdmin):
def has_add_permission(self, request, obj=None):
return False

def has_change_permission(self, request, obj=None):
return False

def has_delete_permission(self, request, obj=None):
return False

def has_module_permission(self, request, obj=None):
return request.user.is_staff

def has_view_permission(self, request, obj=None):
return request.user.is_staff

list_display = (
"report_id",
"finding_ref_number",
)

search_fields = ("report_id",)


class FederalAwardAdmin(admin.ModelAdmin):
def has_add_permission(self, request, obj=None):
return False

def has_change_permission(self, request, obj=None):
return False

def has_delete_permission(self, request, obj=None):
return False

def has_module_permission(self, request, obj=None):
return request.user.is_staff

def has_view_permission(self, request, obj=None):
return request.user.is_staff

list_display = (
"report_id",
"award_reference",
)

search_fields = ("report_id",)


class FindingAdmin(admin.ModelAdmin):
def has_add_permission(self, request, obj=None):
return False

def has_change_permission(self, request, obj=None):
return False

def has_delete_permission(self, request, obj=None):
return False

def has_module_permission(self, request, obj=None):
return request.user.is_staff

def has_view_permission(self, request, obj=None):
return request.user.is_staff

list_display = (
"report_id",
"award_reference",
"reference_number",
)

search_fields = ("report_id",)


class FindingTextAdmin(admin.ModelAdmin):
def has_add_permission(self, request, obj=None):
return False

def has_change_permission(self, request, obj=None):
return False

def has_delete_permission(self, request, obj=None):
return False

def has_module_permission(self, request, obj=None):
return request.user.is_staff

def has_view_permission(self, request, obj=None):
return request.user.is_staff

list_display = (
"report_id",
"finding_ref_number",
)

search_fields = ("report_id",)


class GeneralAdmin(admin.ModelAdmin):
def has_add_permission(self, request, obj=None):
return False

def has_change_permission(self, request, obj=None):
return False

def has_delete_permission(self, request, obj=None):
return False

def has_module_permission(self, request, obj=None):
return request.user.is_staff

def has_view_permission(self, request, obj=None):
return request.user.is_staff

list_display = (
"report_id",
"auditee_name",
"date_created",
)

search_fields = ("report_id",)


class NoteAdmin(admin.ModelAdmin):
def has_add_permission(self, request, obj=None):
return False

def has_change_permission(self, request, obj=None):
return False

def has_delete_permission(self, request, obj=None):
return False

def has_module_permission(self, request, obj=None):
return request.user.is_staff

def has_view_permission(self, request, obj=None):
return request.user.is_staff

list_display = (
"report_id",
"note_title",
)

search_fields = ("report_id",)


class PassThroughAdmin(admin.ModelAdmin):
def has_add_permission(self, request, obj=None):
return False

def has_change_permission(self, request, obj=None):
return False

def has_delete_permission(self, request, obj=None):
return False

def has_module_permission(self, request, obj=None):
return request.user.is_staff

def has_view_permission(self, request, obj=None):
return request.user.is_staff

list_display = (
"report_id",
"award_reference",
"passthrough_id",
)

search_fields = ("report_id",)


class SecondaryAuditorAdmin(admin.ModelAdmin):
def has_add_permission(self, request, obj=None):
return False

def has_change_permission(self, request, obj=None):
return False

def has_delete_permission(self, request, obj=None):
return False

def has_module_permission(self, request, obj=None):
return request.user.is_staff

def has_view_permission(self, request, obj=None):
return request.user.is_staff

list_display = (
"report_id",
"auditor_ein",
)

search_fields = ("report_id",)


admin.site.register(AdditionalEin, AdditionalEinAdmin)
admin.site.register(AdditionalUei, AdditionalUeiAdmin)
admin.site.register(CapText, CapTextAdmin)
admin.site.register(FederalAward, FederalAwardAdmin)
admin.site.register(Finding, FindingAdmin)
admin.site.register(FindingText, FindingTextAdmin)
admin.site.register(General, GeneralAdmin)
admin.site.register(Note, NoteAdmin)
admin.site.register(Passthrough, PassThroughAdmin)
admin.site.register(SecondaryAuditor, SecondaryAuditorAdmin)
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# Generated by Django 4.2.6 on 2024-02-02 19:08

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("dissemination", "0011_onetimeaccess"),
]

operations = [
migrations.AlterField(
model_name="additionalein",
name="report_id",
field=models.TextField(
help_text="GSAFAC generated identifier", verbose_name="Report ID"
),
),
migrations.AlterField(
model_name="additionaluei",
name="report_id",
field=models.TextField(
help_text="GSAFAC generated identifier", verbose_name="Report ID"
),
),
migrations.AlterField(
model_name="captext",
name="report_id",
field=models.TextField(
help_text="GSAFAC generated identifier", verbose_name="Report ID"
),
),
migrations.AlterField(
model_name="federalaward",
name="report_id",
field=models.TextField(
help_text="GSAFAC generated identifier", verbose_name="Report ID"
),
),
migrations.AlterField(
model_name="finding",
name="report_id",
field=models.TextField(
help_text="GSAFAC generated identifier", verbose_name="Report ID"
),
),
migrations.AlterField(
model_name="findingtext",
name="report_id",
field=models.TextField(
help_text="GSAFAC generated identifier", verbose_name="Report ID"
),
),
migrations.AlterField(
model_name="general",
name="report_id",
field=models.TextField(
help_text="GSAFAC generated identifier",
unique=True,
verbose_name="Report ID",
),
),
migrations.AlterField(
model_name="note",
name="report_id",
field=models.TextField(
help_text="GSAFAC generated identifier", verbose_name="Report ID"
),
),
migrations.AlterField(
model_name="onetimeaccess",
name="report_id",
field=models.TextField(
help_text="GSAFAC generated identifier", verbose_name="Report ID"
),
),
migrations.AlterField(
model_name="passthrough",
name="report_id",
field=models.TextField(
help_text="GSAFAC generated identifier", verbose_name="Report ID"
),
),
migrations.AlterField(
model_name="secondaryauditor",
name="report_id",
field=models.TextField(
help_text="GSAFAC generated identifier", verbose_name="Report ID"
),
),
]
Loading

0 comments on commit b9c05d1

Please sign in to comment.