mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-05-19 10:59:21 +02:00
included DraftDomain, Websites and Host
This commit is contained in:
parent
8b1d692457
commit
ab5b0be466
2 changed files with 38 additions and 14 deletions
|
@ -20,6 +20,9 @@ need to be exported:
|
|||
* DomainRequest
|
||||
* DomainInformation
|
||||
* DomainUserRole
|
||||
* DraftDomain
|
||||
* Websites
|
||||
* Host
|
||||
|
||||
### Import
|
||||
|
||||
|
@ -37,9 +40,6 @@ Delete all rows from tables in the following order through django admin:
|
|||
* Domain
|
||||
* User (all but the current user)
|
||||
* Contact
|
||||
|
||||
It may not be necessary, but advisable to also remove rows from these tables:
|
||||
|
||||
* Websites
|
||||
* DraftDomain
|
||||
* Host
|
||||
|
@ -49,8 +49,11 @@ It may not be necessary, but advisable to also remove rows from these tables:
|
|||
Once target environment is prepared, files can be imported in the following
|
||||
order:
|
||||
|
||||
* User
|
||||
* User (After importing User table, you need to delete all rows from Contact table before importing Contacts)
|
||||
* Contact
|
||||
* Host
|
||||
* DraftDomain
|
||||
* Websites
|
||||
* Domain
|
||||
* DomainRequest
|
||||
* DomainInformation
|
||||
|
|
|
@ -54,18 +54,15 @@ class FsmModelResource(resources.ModelResource):
|
|||
from data in the row."""
|
||||
|
||||
# Get fields which are fsm fields
|
||||
fsm_fields = []
|
||||
fsm_fields = {}
|
||||
|
||||
for f in self._meta.model._meta.fields:
|
||||
if isinstance(f, FSMField):
|
||||
if row and f.name in row:
|
||||
fsm_fields.append((f.name, row[f.name]))
|
||||
fsm_fields[f.name] = row[f.name]
|
||||
|
||||
# Convert fsm_fields fields_and_values to kwargs
|
||||
kwargs = dict(fsm_fields)
|
||||
|
||||
# Initialize model instance with kwargs
|
||||
return self._meta.model(**kwargs)
|
||||
# Initialize model instance with fsm_fields
|
||||
return self._meta.model(**fsm_fields)
|
||||
|
||||
def import_field(self, field, obj, data, is_m2m=False, **kwargs):
|
||||
"""Overrides the import_field method of ModelResource. If the
|
||||
|
@ -760,9 +757,17 @@ class HostIPInline(admin.StackedInline):
|
|||
model = models.HostIP
|
||||
|
||||
|
||||
class MyHostAdmin(AuditedAdmin):
|
||||
class HostResource(resources.ModelResource):
|
||||
|
||||
class Meta:
|
||||
model = models.Host
|
||||
|
||||
|
||||
class MyHostAdmin(AuditedAdmin, ImportExportModelAdmin):
|
||||
"""Custom host admin class to use our inlines."""
|
||||
|
||||
resource_classes = [HostResource]
|
||||
|
||||
search_fields = ["name", "domain__name"]
|
||||
search_help_text = "Search by domain or host name."
|
||||
inlines = [HostIPInline]
|
||||
|
@ -899,9 +904,17 @@ class ContactAdmin(ListHeaderAdmin, ImportExportModelAdmin):
|
|||
return super().change_view(request, object_id, form_url, extra_context=extra_context)
|
||||
|
||||
|
||||
class WebsiteAdmin(ListHeaderAdmin):
|
||||
class WebsiteResource(resources.ModelResource):
|
||||
|
||||
class Meta:
|
||||
model = models.Website
|
||||
|
||||
|
||||
class WebsiteAdmin(ListHeaderAdmin, ImportExportModelAdmin):
|
||||
"""Custom website admin class."""
|
||||
|
||||
resource_classes = [WebsiteResource]
|
||||
|
||||
# Search
|
||||
search_fields = [
|
||||
"website",
|
||||
|
@ -2139,9 +2152,17 @@ class DomainAdmin(ListHeaderAdmin, ImportExportModelAdmin):
|
|||
return super().has_change_permission(request, obj)
|
||||
|
||||
|
||||
class DraftDomainAdmin(ListHeaderAdmin):
|
||||
class DraftDomainResource(resources.ModelResource):
|
||||
|
||||
class Meta:
|
||||
model = models.DraftDomain
|
||||
|
||||
|
||||
class DraftDomainAdmin(ListHeaderAdmin, ImportExportModelAdmin):
|
||||
"""Custom draft domain admin class."""
|
||||
|
||||
resource_classes = [DraftDomainResource]
|
||||
|
||||
search_fields = ["name"]
|
||||
search_help_text = "Search by draft domain name."
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue