diff --git a/src/registrar/admin.py b/src/registrar/admin.py index 82a2c0945..aace052c9 100644 --- a/src/registrar/admin.py +++ b/src/registrar/admin.py @@ -56,6 +56,8 @@ class DomainAdmin(AuditedAdmin): """Custom domain admin class to add extra buttons.""" + search_fields = ["name"] + search_help_text = "Search by domain name." change_form_template = "django/admin/domain_change_form.html" readonly_fields = ["state"] @@ -85,7 +87,6 @@ class ContactAdmin(AuditedAdmin): """Custom contact admin class to add search.""" search_fields = ["email", "first_name", "last_name"] - search_help_text = "Search by firstname, lastname or email." @@ -94,13 +95,9 @@ class DomainApplicationAdmin(AuditedAdmin): """Customize the applications listing view.""" list_display = ["requested_domain", "status", "organization_type", "created_at", "submitter", "investigator"] - list_filter = ('status', "organization_type", "investigator") - search_fields = ["requested_domain__name", "submitter__email", "submitter__first_name", "submitter__last_name"] - search_help_text = "Search by domain or submitter." - fieldsets = [ (None, {"fields": ["status", "investigator", "creator"]}), ("Type of organization", {"fields": ["organization_type", "federally_recognized_tribe", "state_recognized_tribe", "tribe_name", "federal_agency", "federal_type", "is_election_board", "type_of_work", "more_organization_information"]}), @@ -115,6 +112,7 @@ class DomainApplicationAdmin(AuditedAdmin): ("Anything else we should know?", {"fields": ["anything_else"]}), ("Requirements for operating .gov domains", {"fields": ["is_policy_acknowledged"]}), ] + readonly_fields = ["creator", "type_of_work", "more_organization_information", "address_line1", "address_line2", "zipcode", "requested_domain", "alternative_domains", "purpose", "submitter", "no_other_contacts_rationale", "anything_else", "is_policy_acknowledged"] # Trigger action when a fieldset is changed def save_model(self, request, obj, form, change): @@ -134,8 +132,6 @@ class DomainApplicationAdmin(AuditedAdmin): original_obj.in_review(obj) super().save_model(request, obj, form, change) - - readonly_fields = ["creator", "type_of_work", "more_organization_information", "address_line1", "address_line2", "zipcode", "requested_domain", "alternative_domains", "purpose", "submitter", "no_other_contacts_rationale", "anything_else", "is_policy_acknowledged"] def get_readonly_fields(self, request, obj=None): if request.user.is_superuser: diff --git a/src/registrar/fixtures.py b/src/registrar/fixtures.py index 3aefbe68b..a18b9d814 100644 --- a/src/registrar/fixtures.py +++ b/src/registrar/fixtures.py @@ -10,6 +10,8 @@ from registrar.models import ( Website, ) +from django.contrib.auth.models import Permission + fake = Faker() logger = logging.getLogger(__name__) @@ -50,6 +52,14 @@ class UserFixture: "last_name": "Dixon", }, ] + + STAFF = [ + { + "username": "319c490d-453b-43d9-bc4d-7d6cd8ff6844", + "first_name": "Rachid-Analyst", + "last_name": "Mrad-Analyst", + }, + ] @classmethod def load(cls): @@ -68,6 +78,30 @@ class UserFixture: logger.debug("User object created for %s" % admin["first_name"]) except Exception as e: logger.warning(e) + for staff in cls.STAFF: + try: + user, _ = User.objects.get_or_create( + username=staff["username"], + ) + user.is_superuser = False + user.first_name = admin["first_name"] + user.last_name = admin["last_name"] + user.is_staff = True + user.is_active = True + # CISA ANALYST permissions + # id 24 = codename view_logentry (auditlog) + # id 32 = codename view_contact + # id 38 = codename change_domainapplication + # id 44 = codename view_domain + permission_ids = [24, 32, 38, 44] # List of permission IDs to assign + # Retrieve the corresponding permission objects + permissions = Permission.objects.filter(id__in=permission_ids) + # Add the permissions to the user + user.user_permissions.add(*permissions) + user.save() + logger.debug("User object created for %s" % admin["first_name"]) + except Exception as e: + logger.warning(e) logger.debug("All users loaded.")