Replace ForeignKey.field.rel.to --> field.model
rel.to dropped on Django 2.0
This commit is contained in:
parent
d863598d81
commit
7d975637d5
|
@ -175,7 +175,7 @@ def delete_related_services(modeladmin, request, queryset):
|
|||
for model, objs in collector.model_objs.items():
|
||||
count = 0
|
||||
# discount main systemuser
|
||||
if model is modeladmin.model.main_systemuser.field.rel.to:
|
||||
if model is modeladmin.model.main_systemuser.field.model:
|
||||
count = len(objs) - 1
|
||||
# Discount account
|
||||
elif model is not modeladmin.model and model in registered_services:
|
||||
|
|
|
@ -47,7 +47,7 @@ def create_account_creation_form():
|
|||
# Previous validation error
|
||||
return
|
||||
errors = {}
|
||||
systemuser_model = Account.main_systemuser.field.rel.to
|
||||
systemuser_model = Account.main_systemuser.field.model
|
||||
if systemuser_model.objects.filter(username=account.username).exists():
|
||||
errors['username'] = _("A system user with this name already exists.")
|
||||
for model, key, related_kwargs, __ in create_related:
|
||||
|
|
|
@ -21,7 +21,7 @@ def validate_contact(request, bill, error=True):
|
|||
message = msg.format(relation=_("Related"), account=account, url=url)
|
||||
send(request, mark_safe(message))
|
||||
valid = False
|
||||
main = type(bill).account.field.rel.to.objects.get_main()
|
||||
main = type(bill).account.field.model.objects.get_main()
|
||||
if not hasattr(main, 'billcontact'):
|
||||
account = force_text(main)
|
||||
url = reverse('admin:accounts_account_change', args=(main.id,))
|
||||
|
|
|
@ -12,7 +12,7 @@ from .models import List
|
|||
|
||||
class RelatedDomainSerializer(AccountSerializerMixin, RelatedHyperlinkedModelSerializer):
|
||||
class Meta:
|
||||
model = List.address_domain.field.rel.to
|
||||
model = List.address_domain.field.model
|
||||
fields = ('url', 'id', 'name')
|
||||
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ class Mailbox(models.Model):
|
|||
def active(self):
|
||||
try:
|
||||
return self.is_active and self.account.is_active
|
||||
except type(self).account.field.rel.to.DoesNotExist:
|
||||
except type(self).account.field.model.DoesNotExist:
|
||||
return self.is_active
|
||||
|
||||
def disable(self):
|
||||
|
|
|
@ -8,7 +8,7 @@ from .models import Mailbox, Address
|
|||
|
||||
class RelatedDomainSerializer(AccountSerializerMixin, RelatedHyperlinkedModelSerializer):
|
||||
class Meta:
|
||||
model = Address.domain.field.rel.to
|
||||
model = Address.domain.field.model
|
||||
fields = ('url', 'id', 'name')
|
||||
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ def cancel_orders(sender, **kwargs):
|
|||
if sender._meta.app_label not in settings.ORDERS_EXCLUDED_APPS:
|
||||
instance = kwargs['instance']
|
||||
# Account delete will delete all related orders, no need to maintain order consistency
|
||||
if isinstance(instance, Order.account.field.rel.to):
|
||||
if isinstance(instance, Order.account.field.model):
|
||||
return
|
||||
if type(instance) in services:
|
||||
for order in Order.objects.by_object(instance).active():
|
||||
|
|
|
@ -42,7 +42,7 @@ def clean_custom_url(saas):
|
|||
)
|
||||
except Website.DoesNotExist:
|
||||
# get or create domain
|
||||
Domain = Website.domains.field.rel.to
|
||||
Domain = Website.domains.field.model
|
||||
try:
|
||||
domain = Domain.objects.get(name=url.netloc)
|
||||
except Domain.DoesNotExist:
|
||||
|
@ -110,7 +110,7 @@ def create_or_update_directive(saas):
|
|||
account=account,
|
||||
)
|
||||
except Website.DoesNotExist:
|
||||
Domain = Website.domains.field.rel.to
|
||||
Domain = Website.domains.field.model
|
||||
domain = Domain.objects.get(name=url.netloc)
|
||||
# Create new website for custom_url
|
||||
tgt_server = Server.objects.get(name='web.pangea.lan')
|
||||
|
|
|
@ -61,7 +61,7 @@ class SystemUser(models.Model):
|
|||
def active(self):
|
||||
try:
|
||||
return self.is_active and self.account.is_active
|
||||
except type(self).account.field.rel.to.DoesNotExist:
|
||||
except type(self).account.field.model.DoesNotExist:
|
||||
return self.is_active
|
||||
|
||||
@cached_property
|
||||
|
|
|
@ -13,13 +13,13 @@ from .validators import validate_domain_protocol
|
|||
|
||||
class RelatedDomainSerializer(AccountSerializerMixin, RelatedHyperlinkedModelSerializer):
|
||||
class Meta:
|
||||
model = Website.domains.field.rel.to
|
||||
model = Website.domains.field.model
|
||||
fields = ('url', 'id', 'name')
|
||||
|
||||
|
||||
class RelatedWebAppSerializer(AccountSerializerMixin, RelatedHyperlinkedModelSerializer):
|
||||
class Meta:
|
||||
model = Content.webapp.field.rel.to
|
||||
model = Content.webapp.field.model
|
||||
fields = ('url', 'id', 'name', 'type')
|
||||
|
||||
|
||||
|
|
|
@ -90,7 +90,7 @@ class RelatedPermission(Permission):
|
|||
if obj is None:
|
||||
parent = cls
|
||||
for relation in relations:
|
||||
parent = getattr(parent, relation).field.rel.to
|
||||
parent = getattr(parent, relation).field.model
|
||||
else:
|
||||
parent = functools.reduce(getattr, relations, obj)
|
||||
|
||||
|
|
Loading…
Reference in New Issue