Fix lint errors

This commit is contained in:
Erin 2024-03-19 15:19:44 -07:00
parent 166ccbf5ea
commit 601ded68ac
No known key found for this signature in database
GPG key ID: 1CAD275313C62460
3 changed files with 9 additions and 7 deletions

View file

@ -15,8 +15,7 @@ from django.contrib.contenttypes.models import ContentType
from django.urls import reverse from django.urls import reverse
from dateutil.relativedelta import relativedelta # type: ignore from dateutil.relativedelta import relativedelta # type: ignore
from epplibwrapper.errors import ErrorCode, RegistryError from epplibwrapper.errors import ErrorCode, RegistryError
from registrar.models import Contact, Domain, DomainRequest, DraftDomain, User, Website, FederalAgency from registrar.models import Contact, Domain, DomainRequest, DraftDomain, User, Website
from registrar.utility import csv_export
from registrar.utility.errors import FSMApplicationError, FSMErrorCodes from registrar.utility.errors import FSMApplicationError, FSMErrorCodes
from registrar.views.utility.mixins import OrderableFieldsMixin from registrar.views.utility.mixins import OrderableFieldsMixin
from django.contrib.admin.views.main import ORDER_VAR from django.contrib.admin.views.main import ORDER_VAR
@ -1789,6 +1788,7 @@ class VerifiedByStaffAdmin(ListHeaderAdmin):
obj.requestor = request.user if request.user.is_authenticated else None obj.requestor = request.user if request.user.is_authenticated else None
super().save_model(request, obj, form, change) super().save_model(request, obj, form, change)
class FederalAgencyAdmin(ListHeaderAdmin): class FederalAgencyAdmin(ListHeaderAdmin):
list_display = ["agency"] list_display = ["agency"]
search_fields = ["agency"] search_fields = ["agency"]

View file

@ -6,10 +6,12 @@ from django.db import migrations, models
from registrar.models import FederalAgency from registrar.models import FederalAgency
from typing import Any from typing import Any
# For linting: RunPython expects a function reference. # For linting: RunPython expects a function reference.
def create_federal_agencies(apps, schema_editor) -> Any: def create_federal_agencies(apps, schema_editor) -> Any:
FederalAgency.create_federal_agencies(apps, schema_editor) FederalAgency.create_federal_agencies(apps, schema_editor)
class Migration(migrations.Migration): class Migration(migrations.Migration):
dependencies = [ dependencies = [

View file

@ -10,7 +10,7 @@ class FederalAgency(TimeStampedModel):
class Meta: class Meta:
verbose_name = "Federal agency" verbose_name = "Federal agency"
verbose_name_plural = "Federal agencies" verbose_name_plural = "Federal agencies"
agency = models.CharField( agency = models.CharField(
null=True, null=True,
blank=True, blank=True,
@ -18,12 +18,12 @@ class FederalAgency(TimeStampedModel):
) )
def __str__(self) -> str: def __str__(self) -> str:
return self.agency return f"{self.agency}"
# TODO: Update parameters to put in # TODO: Update parameters to put in
def create_federal_agencies(apps, schema_editor): def create_federal_agencies(apps, schema_editor):
"""This method gets run from a data migration.""" """This method gets run from a data migration."""
# Hard to pass self to these methods as the calls from migrations # Hard to pass self to these methods as the calls from migrations
# are only expecting apps and schema_editor, so we'll just define # are only expecting apps and schema_editor, so we'll just define
# apps, schema_editor in the local scope instead # apps, schema_editor in the local scope instead
@ -213,10 +213,10 @@ class FederalAgency(TimeStampedModel):
"Woodrow Wilson International Center for Scholars", "Woodrow Wilson International Center for Scholars",
"World War I Centennial Commission", "World War I Centennial Commission",
] ]
FederalAgency = apps.get_model("registrar", "FederalAgency") FederalAgency = apps.get_model("registrar", "FederalAgency")
logger.info("Creating federal agency table.") logger.info("Creating federal agency table.")
try: try:
for agency in AGENCIES: for agency in AGENCIES:
federal_agencies_list, _ = FederalAgency.objects.get_or_create( federal_agencies_list, _ = FederalAgency.objects.get_or_create(