updated documentation and code comments

This commit is contained in:
David Kennedy 2024-05-10 07:36:23 -04:00
parent 5673889a55
commit 645c85e147
No known key found for this signature in database
GPG key ID: 6528A5386E66B96B
3 changed files with 18 additions and 3 deletions

View file

@ -60,4 +60,7 @@ order:
* Websites * Websites
* DomainRequest * DomainRequest
* DomainInformation * DomainInformation
* UserDomainRole * UserDomainRole
Optional step:
* Run fixtures to load fixture users back in

View file

@ -80,6 +80,7 @@ class FsmModelResource(resources.ModelResource):
class UserResource(resources.ModelResource): class UserResource(resources.ModelResource):
"""defines how each field in the referenced model should be mapped to the corresponding fields in the import/export file"""
class Meta: class Meta:
model = models.User model = models.User
@ -758,6 +759,7 @@ class HostIPInline(admin.StackedInline):
class HostResource(resources.ModelResource): class HostResource(resources.ModelResource):
"""defines how each field in the referenced model should be mapped to the corresponding fields in the import/export file"""
class Meta: class Meta:
model = models.Host model = models.Host
@ -774,6 +776,7 @@ class MyHostAdmin(AuditedAdmin, ImportExportModelAdmin):
class HostIpResource(resources.ModelResource): class HostIpResource(resources.ModelResource):
"""defines how each field in the referenced model should be mapped to the corresponding fields in the import/export file"""
class Meta: class Meta:
model = models.HostIP model = models.HostIP
@ -787,6 +790,7 @@ class HostIpAdmin(AuditedAdmin, ImportExportModelAdmin):
class ContactResource(resources.ModelResource): class ContactResource(resources.ModelResource):
"""defines how each field in the referenced model should be mapped to the corresponding fields in the import/export file"""
class Meta: class Meta:
model = models.Contact model = models.Contact
@ -918,6 +922,7 @@ class ContactAdmin(ListHeaderAdmin, ImportExportModelAdmin):
class WebsiteResource(resources.ModelResource): class WebsiteResource(resources.ModelResource):
"""defines how each field in the referenced model should be mapped to the corresponding fields in the import/export file"""
class Meta: class Meta:
model = models.Website model = models.Website
@ -976,6 +981,7 @@ class WebsiteAdmin(ListHeaderAdmin, ImportExportModelAdmin):
class UserDomainRoleResource(resources.ModelResource): class UserDomainRoleResource(resources.ModelResource):
"""defines how each field in the referenced model should be mapped to the corresponding fields in the import/export file"""
class Meta: class Meta:
model = models.UserDomainRole model = models.UserDomainRole
@ -1067,6 +1073,7 @@ class DomainInvitationAdmin(ListHeaderAdmin):
class DomainInformationResource(resources.ModelResource): class DomainInformationResource(resources.ModelResource):
"""defines how each field in the referenced model should be mapped to the corresponding fields in the import/export file"""
class Meta: class Meta:
model = models.DomainInformation model = models.DomainInformation
@ -1208,6 +1215,7 @@ class DomainInformationAdmin(ListHeaderAdmin, ImportExportModelAdmin):
class DomainRequestResource(FsmModelResource): class DomainRequestResource(FsmModelResource):
"""defines how each field in the referenced model should be mapped to the corresponding fields in the import/export file"""
class Meta: class Meta:
model = models.DomainRequest model = models.DomainRequest
@ -1761,6 +1769,7 @@ class DomainInformationInline(admin.StackedInline):
class DomainResource(FsmModelResource): class DomainResource(FsmModelResource):
"""defines how each field in the referenced model should be mapped to the corresponding fields in the import/export file"""
class Meta: class Meta:
model = models.Domain model = models.Domain
@ -2166,6 +2175,7 @@ class DomainAdmin(ListHeaderAdmin, ImportExportModelAdmin):
class DraftDomainResource(resources.ModelResource): class DraftDomainResource(resources.ModelResource):
"""defines how each field in the referenced model should be mapped to the corresponding fields in the import/export file"""
class Meta: class Meta:
model = models.DraftDomain model = models.DraftDomain

View file

@ -100,7 +100,7 @@ class CreateOrUpdateOrganizationTypeHelper:
# Update the field # Update the field
self._update_fields(organization_type_needs_update, generic_org_type_needs_update) self._update_fields(organization_type_needs_update, generic_org_type_needs_update)
def _handle_existing_instance(self, force_update_when_no_are_changes_found=False): def _handle_existing_instance(self, force_update_when_no_changes_are_found=False):
# == Init variables == # # == Init variables == #
try: try:
# Instance is already in the database, fetch its current state # Instance is already in the database, fetch its current state
@ -119,7 +119,7 @@ class CreateOrUpdateOrganizationTypeHelper:
raise ValueError("Cannot update organization_type and generic_org_type simultaneously.") raise ValueError("Cannot update organization_type and generic_org_type simultaneously.")
elif not organization_type_changed and (not generic_org_type_changed and not is_election_board_changed): elif not organization_type_changed and (not generic_org_type_changed and not is_election_board_changed):
# No changes found # No changes found
if force_update_when_no_are_changes_found: if force_update_when_no_changes_are_found:
# If we want to force an update anyway, we can treat this record like # If we want to force an update anyway, we can treat this record like
# its a new one in that we check for "None" values rather than changes. # its a new one in that we check for "None" values rather than changes.
self._handle_new_instance() self._handle_new_instance()
@ -132,6 +132,8 @@ class CreateOrUpdateOrganizationTypeHelper:
# Update the field # Update the field
self._update_fields(organization_type_needs_update, generic_org_type_needs_update) self._update_fields(organization_type_needs_update, generic_org_type_needs_update)
except self.sender.DoesNotExist: except self.sender.DoesNotExist:
# this exception should only be raised when import_export utility attempts to import
# a new row and already has an id
pass pass
def _update_fields(self, organization_type_needs_update, generic_org_type_needs_update): def _update_fields(self, organization_type_needs_update, generic_org_type_needs_update):