Added better support for domain account migration
This commit is contained in:
parent
86745f16e7
commit
1b9007a1f1
2
TODO.md
2
TODO.md
|
@ -179,3 +179,5 @@ Remember that, as always with QuerySets, any subsequent chained methods which im
|
||||||
|
|
||||||
|
|
||||||
* Subdomain saving should not trigger bind slave
|
* Subdomain saving should not trigger bind slave
|
||||||
|
|
||||||
|
* Domain account change, unselected checkbox: migrate subdomains
|
||||||
|
|
|
@ -55,7 +55,7 @@ class DomainInline(admin.TabularInline):
|
||||||
|
|
||||||
class DomainAdmin(ChangeListDefaultFilter, AccountAdminMixin, ExtendedModelAdmin):
|
class DomainAdmin(ChangeListDefaultFilter, AccountAdminMixin, ExtendedModelAdmin):
|
||||||
# TODO name link
|
# TODO name link
|
||||||
fields = ('name', 'account')
|
fields = ('name', ('account', 'migrate_subdomains'),)
|
||||||
list_display = (
|
list_display = (
|
||||||
'structured_name', 'display_is_top', 'websites', 'account_link'
|
'structured_name', 'display_is_top', 'websites', 'account_link'
|
||||||
)
|
)
|
||||||
|
@ -112,5 +112,11 @@ class DomainAdmin(ChangeListDefaultFilter, AccountAdminMixin, ExtendedModelAdmin
|
||||||
qs = qs.prefetch_related('websites')
|
qs = qs.prefetch_related('websites')
|
||||||
return qs
|
return qs
|
||||||
|
|
||||||
|
def save_related(self, request, form, formsets, change):
|
||||||
|
super(DomainAdmin, self).save_related(request, form, formsets, change)
|
||||||
|
if form.cleaned_data['migrate_subdomains']:
|
||||||
|
domain = form.instance
|
||||||
|
domain.subdomains.update(account_id=domain.account_id)
|
||||||
|
|
||||||
|
|
||||||
admin.site.register(Domain, DomainAdmin)
|
admin.site.register(Domain, DomainAdmin)
|
||||||
|
|
|
@ -8,6 +8,9 @@ from .models import Domain
|
||||||
|
|
||||||
|
|
||||||
class DomainAdminForm(forms.ModelForm):
|
class DomainAdminForm(forms.ModelForm):
|
||||||
|
migrate_subdomains = forms.BooleanField(label=_("Migrate subdomains"), required=False,
|
||||||
|
initial=False, help_text=_("Propagate the account owner change to subdomains."))
|
||||||
|
|
||||||
def clean(self):
|
def clean(self):
|
||||||
""" inherit related top domain account, when exists """
|
""" inherit related top domain account, when exists """
|
||||||
cleaned_data = super(DomainAdminForm, self).clean()
|
cleaned_data = super(DomainAdminForm, self).clean()
|
||||||
|
|
Loading…
Reference in a new issue