Remove queryset reimplementation

This commit is contained in:
zandercymatics 2023-12-19 10:57:19 -07:00
parent 724b549d70
commit ccce752138
No known key found for this signature in database
GPG key ID: FF4636ABEC9682B7

View file

@ -489,6 +489,9 @@ class DomainInformationAdmin(ListHeaderAdmin):
# For each filter_horizontal, init in admin js extendFilterHorizontalWidgets
# to activate the edit/delete/view buttons
filter_horizontal = ("other_contacts",)
# Table ordering
ordering = ["domain__name"]
# lists in filter_horizontal are not sorted properly, sort them
# by first_name
@ -656,6 +659,9 @@ class DomainApplicationAdmin(ListHeaderAdmin):
filter_horizontal = ("current_websites", "alternative_domains", "other_contacts")
# Table ordering
ordering = ["requested_domain__name"]
# lists in filter_horizontal are not sorted properly, sort them
# by website
def formfield_for_manytomany(self, db_field, request, **kwargs):
@ -670,11 +676,6 @@ class DomainApplicationAdmin(ListHeaderAdmin):
return db_field.formfield(**kwargs)
return super().formfield_for_foreignkey(db_field, request, **kwargs)
def get_queryset(self, request):
"""Queryset reimplementation to order the table alphabetically"""
query_set = super().get_queryset(request)
return query_set.order_by("requested_domain__name")
# Trigger action when a fieldset is changed
def save_model(self, request, obj, form, change):
if obj and obj.creator.status != models.User.RESTRICTED:
@ -845,6 +846,9 @@ class DomainAdmin(ListHeaderAdmin):
change_list_template = "django/admin/domain_change_list.html"
readonly_fields = ["state", "expiration_date"]
# Table ordering
ordering = ["name"]
def export_data_type(self, request):
# match the CSV example with all the fields
response = HttpResponse(content_type="text/csv")