Define on_delete argument for ForeignKey and OneToOneField
Required since Django 2.0
This commit is contained in:
parent
eadc06d4c5
commit
d863598d81
|
@ -29,7 +29,7 @@ class Account(auth.AbstractBaseUser):
|
|||
validators.RegexValidator(r'^[\w.-]+$', _("Enter a valid username."), 'invalid')
|
||||
])
|
||||
main_systemuser = models.ForeignKey(settings.ACCOUNTS_SYSTEMUSER_MODEL, null=True,
|
||||
related_name='accounts_main', editable=False)
|
||||
related_name='accounts_main', editable=False, on_delete=models.SET_NULL)
|
||||
short_name = models.CharField(_("short name"), max_length=64, blank=True)
|
||||
full_name = models.CharField(_("full name"), max_length=256)
|
||||
email = models.EmailField(_('email address'), help_text=_("Used for password recovery"))
|
||||
|
|
|
@ -24,7 +24,7 @@ from . import settings
|
|||
|
||||
class BillContact(models.Model):
|
||||
account = models.OneToOneField('accounts.Account', verbose_name=_("account"),
|
||||
related_name='billcontact')
|
||||
related_name='billcontact', on_delete=models.CASCADE)
|
||||
name = models.CharField(_("name"), max_length=256, blank=True,
|
||||
help_text=_("Account full name will be used when left blank."))
|
||||
address = models.TextField(_("address"))
|
||||
|
@ -102,9 +102,9 @@ class Bill(models.Model):
|
|||
|
||||
number = models.CharField(_("number"), max_length=16, unique=True, blank=True)
|
||||
account = models.ForeignKey('accounts.Account', verbose_name=_("account"),
|
||||
related_name='%(class)s')
|
||||
related_name='%(class)s', on_delete=models.CASCADE)
|
||||
amend_of = models.ForeignKey('self', null=True, blank=True, verbose_name=_("amend of"),
|
||||
related_name='amends')
|
||||
related_name='amends', on_delete=models.SET_NULL)
|
||||
type = models.CharField(_("type"), max_length=16, choices=TYPES)
|
||||
created_on = models.DateField(_("created on"), auto_now_add=True)
|
||||
closed_on = models.DateField(_("closed on"), blank=True, null=True, db_index=True)
|
||||
|
@ -416,7 +416,7 @@ class ProForma(Bill):
|
|||
|
||||
class BillLine(models.Model):
|
||||
""" Base model for bill item representation """
|
||||
bill = models.ForeignKey(Bill, verbose_name=_("bill"), related_name='lines')
|
||||
bill = models.ForeignKey(Bill, verbose_name=_("bill"), related_name='lines', on_delete=models.CASCADE)
|
||||
description = models.CharField(_("description"), max_length=256)
|
||||
rate = models.DecimalField(_("rate"), blank=True, null=True, max_digits=12, decimal_places=2)
|
||||
quantity = models.DecimalField(_("quantity"), blank=True, null=True, max_digits=12,
|
||||
|
@ -434,7 +434,7 @@ class BillLine(models.Model):
|
|||
created_on = models.DateField(_("created"), auto_now_add=True)
|
||||
# Amendment
|
||||
amended_line = models.ForeignKey('self', verbose_name=_("amended line"),
|
||||
related_name='amendment_lines', null=True, blank=True)
|
||||
related_name='amendment_lines', null=True, blank=True, on_delete=models.CASCADE)
|
||||
|
||||
class Meta:
|
||||
get_latest_by = 'id'
|
||||
|
@ -495,7 +495,7 @@ class BillSubline(models.Model):
|
|||
)
|
||||
|
||||
# TODO: order info for undoing
|
||||
line = models.ForeignKey(BillLine, verbose_name=_("bill line"), related_name='sublines')
|
||||
line = models.ForeignKey(BillLine, verbose_name=_("bill line"), related_name='sublines', on_delete=models.CASCADE)
|
||||
description = models.CharField(_("description"), max_length=256)
|
||||
total = models.DecimalField(max_digits=12, decimal_places=2)
|
||||
type = models.CharField(_("type"), max_length=16, choices=TYPES, default=OTHER)
|
||||
|
|
|
@ -33,7 +33,7 @@ class Contact(models.Model):
|
|||
objects = ContactQuerySet.as_manager()
|
||||
|
||||
account = models.ForeignKey('accounts.Account', verbose_name=_("Account"),
|
||||
related_name='contacts', null=True)
|
||||
related_name='contacts', null=True, on_delete=models.SET_NULL)
|
||||
short_name = models.CharField(_("short name"), max_length=128)
|
||||
full_name = models.CharField(_("full name"), max_length=256, blank=True)
|
||||
email = models.EmailField()
|
||||
|
|
|
@ -20,8 +20,8 @@ class Database(models.Model):
|
|||
type = models.CharField(_("type"), max_length=32,
|
||||
choices=settings.DATABASES_TYPE_CHOICES,
|
||||
default=settings.DATABASES_DEFAULT_TYPE)
|
||||
account = models.ForeignKey('accounts.Account', verbose_name=_("Account"),
|
||||
related_name='databases')
|
||||
account = models.ForeignKey('accounts.Account', on_delete=models.CASCADE,
|
||||
verbose_name=_("Account"), related_name='databases')
|
||||
comments = models.TextField(default="", blank=True)
|
||||
|
||||
class Meta:
|
||||
|
@ -60,8 +60,8 @@ class DatabaseUser(models.Model):
|
|||
type = models.CharField(_("type"), max_length=32,
|
||||
choices=settings.DATABASES_TYPE_CHOICES,
|
||||
default=settings.DATABASES_DEFAULT_TYPE)
|
||||
account = models.ForeignKey('accounts.Account', verbose_name=_("Account"),
|
||||
related_name='databaseusers')
|
||||
account = models.ForeignKey('accounts.Account', on_delete=models.CASCADE,
|
||||
verbose_name=_("Account"), related_name='databaseusers')
|
||||
|
||||
class Meta:
|
||||
verbose_name_plural = _("DB users")
|
||||
|
|
|
@ -31,9 +31,9 @@ class Domain(models.Model):
|
|||
validators.validate_allowed_domain
|
||||
])
|
||||
account = models.ForeignKey('accounts.Account', verbose_name=_("Account"), blank=True,
|
||||
related_name='domains', help_text=_("Automatically selected for subdomains."))
|
||||
related_name='domains', on_delete=models.CASCADE, help_text=_("Automatically selected for subdomains."))
|
||||
top = models.ForeignKey('domains.Domain', null=True, related_name='subdomain_set',
|
||||
editable=False, verbose_name=_("top domain"))
|
||||
editable=False, verbose_name=_("top domain"), on_delete=models.CASCADE)
|
||||
serial = models.IntegerField(_("serial"), default=utils.generate_zone_serial, editable=False,
|
||||
help_text=_("A revision number that changes whenever this domain is updated."))
|
||||
refresh = models.CharField(_("refresh"), max_length=16, blank=True,
|
||||
|
@ -318,7 +318,7 @@ class Record(models.Model):
|
|||
SOA: (validators.validate_soa_record,),
|
||||
}
|
||||
|
||||
domain = models.ForeignKey(Domain, verbose_name=_("domain"), related_name='records')
|
||||
domain = models.ForeignKey(Domain, verbose_name=_("domain"), related_name='records', on_delete=models.CASCADE)
|
||||
ttl = models.CharField(_("TTL"), max_length=8, blank=True,
|
||||
help_text=_("Record TTL, defaults to %s") % settings.DOMAINS_DEFAULT_TTL,
|
||||
validators=[validators.validate_zone_interval])
|
||||
|
|
|
@ -161,10 +161,10 @@ class Ticket(models.Model):
|
|||
|
||||
|
||||
class Message(models.Model):
|
||||
ticket = models.ForeignKey('issues.Ticket', verbose_name=_("ticket"),
|
||||
related_name='messages')
|
||||
author = models.ForeignKey(djsettings.AUTH_USER_MODEL, verbose_name=_("author"),
|
||||
related_name='ticket_messages')
|
||||
ticket = models.ForeignKey('issues.Ticket', on_delete=models.CASCADE,
|
||||
verbose_name=_("ticket"), related_name='messages')
|
||||
author = models.ForeignKey(djsettings.AUTH_USER_MODEL, on_delete=models.SET_NULL,
|
||||
verbose_name=_("author"), related_name='ticket_messages')
|
||||
author_name = models.CharField(_("author name"), max_length=256, blank=True)
|
||||
content = models.TextField(_("content"))
|
||||
created_at = models.DateTimeField(_("created at"), auto_now_add=True)
|
||||
|
@ -191,9 +191,10 @@ class Message(models.Model):
|
|||
|
||||
class TicketTracker(models.Model):
|
||||
""" Keeps track of user read tickets """
|
||||
ticket = models.ForeignKey(Ticket, verbose_name=_("ticket"), related_name='trackers')
|
||||
user = models.ForeignKey(djsettings.AUTH_USER_MODEL, verbose_name=_("user"),
|
||||
related_name='ticket_trackers')
|
||||
ticket = models.ForeignKey(Ticket, on_delete=models.CASCADE,
|
||||
verbose_name=_("ticket"), related_name='trackers')
|
||||
user = models.ForeignKey(djsettings.AUTH_USER_MODEL, on_delete=models.CASCADE,
|
||||
verbose_name=_("user"), related_name='ticket_trackers')
|
||||
|
||||
class Meta:
|
||||
unique_together = (
|
||||
|
|
|
@ -30,7 +30,7 @@ class List(models.Model):
|
|||
admin_email = models.EmailField(_("admin email"),
|
||||
help_text=_("Administration email address"))
|
||||
account = models.ForeignKey('accounts.Account', verbose_name=_("Account"),
|
||||
related_name='lists')
|
||||
related_name='lists', on_delete=models.CASCADE)
|
||||
# TODO also admin
|
||||
is_active = models.BooleanField(_("active"), default=True,
|
||||
help_text=_("Designates whether this account should be treated as active. "
|
||||
|
|
|
@ -23,7 +23,7 @@ class Mailbox(models.Model):
|
|||
])
|
||||
password = models.CharField(_("password"), max_length=128)
|
||||
account = models.ForeignKey('accounts.Account', verbose_name=_("account"),
|
||||
related_name='mailboxes')
|
||||
related_name='mailboxes', on_delete=models.CASCADE)
|
||||
filtering = models.CharField(max_length=16,
|
||||
default=settings.MAILBOXES_MAILBOX_DEFAULT_FILTERING,
|
||||
choices=[(k, v[0]) for k,v in sorted(settings.MAILBOXES_MAILBOX_FILTERINGS.items())])
|
||||
|
@ -97,14 +97,14 @@ class Address(models.Model):
|
|||
validators=[validators.validate_emailname],
|
||||
help_text=_("Address name, left blank for a <i>catch-all</i> address"))
|
||||
domain = models.ForeignKey(settings.MAILBOXES_DOMAIN_MODEL,
|
||||
verbose_name=_("domain"), related_name='addresses')
|
||||
verbose_name=_("domain"), related_name='addresses', on_delete=models.CASCADE)
|
||||
mailboxes = models.ManyToManyField(Mailbox, verbose_name=_("mailboxes"),
|
||||
related_name='addresses', blank=True)
|
||||
forward = models.CharField(_("forward"), max_length=256, blank=True,
|
||||
validators=[validators.validate_forward],
|
||||
help_text=_("Space separated email addresses or mailboxes"))
|
||||
account = models.ForeignKey('accounts.Account', verbose_name=_("Account"),
|
||||
related_name='addresses')
|
||||
related_name='addresses', on_delete=models.CASCADE)
|
||||
|
||||
class Meta:
|
||||
verbose_name_plural = _("addresses")
|
||||
|
@ -168,7 +168,7 @@ class Address(models.Model):
|
|||
|
||||
class Autoresponse(models.Model):
|
||||
address = models.OneToOneField(Address, verbose_name=_("address"),
|
||||
related_name='autoresponse')
|
||||
related_name='autoresponse', on_delete=models.CASCADE)
|
||||
# TODO initial_date
|
||||
subject = models.CharField(_("subject"), max_length=256)
|
||||
message = models.TextField(_("message"))
|
||||
|
|
|
@ -67,7 +67,7 @@ class SMTPLog(models.Model):
|
|||
(SUCCESS, _("Success")),
|
||||
(FAILURE, _("Failure")),
|
||||
)
|
||||
message = models.ForeignKey(Message, editable=False, related_name='logs')
|
||||
message = models.ForeignKey(Message, editable=False, related_name='logs', on_delete=models.CASCADE)
|
||||
result = models.CharField(max_length=16, choices=RESULTS, default=SUCCESS)
|
||||
date = models.DateTimeField(auto_now_add=True)
|
||||
log_message = models.TextField()
|
||||
|
|
|
@ -42,10 +42,10 @@ class MiscService(models.Model):
|
|||
|
||||
|
||||
class Miscellaneous(models.Model):
|
||||
service = models.ForeignKey(MiscService, verbose_name=_("service"),
|
||||
related_name='instances')
|
||||
account = models.ForeignKey('accounts.Account', verbose_name=_("account"),
|
||||
related_name='miscellaneous')
|
||||
service = models.ForeignKey(MiscService, on_delete=models.CASCADE,
|
||||
verbose_name=_("service"), related_name='instances')
|
||||
account = models.ForeignKey('accounts.Account', on_delete=models.CASCADE,
|
||||
verbose_name=_("account"), related_name='miscellaneous')
|
||||
identifier = NullableCharField(_("identifier"), max_length=256, null=True, unique=True,
|
||||
db_index=True, help_text=_("A unique identifier for this service."))
|
||||
description = models.TextField(_("description"), blank=True)
|
||||
|
|
|
@ -90,7 +90,7 @@ class BackendLog(models.Model):
|
|||
|
||||
backend = models.CharField(_("backend"), max_length=256)
|
||||
state = models.CharField(_("state"), max_length=16, choices=STATES, default=RECEIVED)
|
||||
server = models.ForeignKey(Server, verbose_name=_("server"), related_name='execution_logs')
|
||||
server = models.ForeignKey(Server, verbose_name=_("server"), related_name='execution_logs', on_delete=models.CASCADE)
|
||||
script = models.TextField(_("script"))
|
||||
stdout = models.TextField(_("stdout"))
|
||||
stderr = models.TextField(_("stderr"))
|
||||
|
@ -135,10 +135,10 @@ class BackendOperation(models.Model):
|
|||
"""
|
||||
Encapsulates an operation, storing its related object, the action and the backend.
|
||||
"""
|
||||
log = models.ForeignKey('orchestration.BackendLog', related_name='operations')
|
||||
log = models.ForeignKey('orchestration.BackendLog', related_name='operations', on_delete=models.CASCADE)
|
||||
backend = models.CharField(_("backend"), max_length=256)
|
||||
action = models.CharField(_("action"), max_length=64)
|
||||
content_type = models.ForeignKey(ContentType)
|
||||
content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE)
|
||||
object_id = models.PositiveIntegerField(null=True)
|
||||
instance_repr = models.CharField(_("instance representation"), max_length=256)
|
||||
|
||||
|
@ -199,7 +199,7 @@ class Route(models.Model):
|
|||
"""
|
||||
backend = models.CharField(_("backend"), max_length=256,
|
||||
choices=ServiceBackend.get_choices())
|
||||
host = models.ForeignKey(Server, verbose_name=_("host"), related_name='routes')
|
||||
host = models.ForeignKey(Server, verbose_name=_("host"), related_name='routes', on_delete=models.CASCADE)
|
||||
match = models.CharField(_("match"), max_length=256, blank=True, default='True',
|
||||
help_text=_("Python expression used for selecting the targe host, "
|
||||
"<em>instance</em> referes to the current object."))
|
||||
|
|
|
@ -150,12 +150,12 @@ class OrderQuerySet(models.QuerySet):
|
|||
|
||||
|
||||
class Order(models.Model):
|
||||
account = models.ForeignKey('accounts.Account', verbose_name=_("account"),
|
||||
related_name='orders')
|
||||
content_type = models.ForeignKey(ContentType)
|
||||
account = models.ForeignKey('accounts.Account', on_delete=models.CASCADE,
|
||||
verbose_name=_("account"), related_name='orders')
|
||||
content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE)
|
||||
object_id = models.PositiveIntegerField(null=True)
|
||||
service = models.ForeignKey(settings.ORDERS_SERVICE_MODEL, verbose_name=_("service"),
|
||||
related_name='orders')
|
||||
service = models.ForeignKey(settings.ORDERS_SERVICE_MODEL, on_delete=models.PROTECT,
|
||||
verbose_name=_("service"), related_name='orders')
|
||||
registered_on = models.DateField(_("registered"), default=timezone.now, db_index=True)
|
||||
cancelled_on = models.DateField(_("cancelled"), null=True, blank=True)
|
||||
billed_on = models.DateField(_("billed"), null=True, blank=True)
|
||||
|
@ -294,7 +294,8 @@ class MetricStorageQuerySet(models.QuerySet):
|
|||
|
||||
class MetricStorage(models.Model):
|
||||
""" Stores metric state for future billing """
|
||||
order = models.ForeignKey(Order, verbose_name=_("order"), related_name='metrics')
|
||||
order = models.ForeignKey(Order, on_delete=models.CASCADE,
|
||||
verbose_name=_("order"), related_name='metrics')
|
||||
value = models.DecimalField(_("value"), max_digits=16, decimal_places=2)
|
||||
created_on = models.DateField(_("created"), auto_now_add=True, editable=True)
|
||||
# TODO time field?
|
||||
|
|
|
@ -18,7 +18,7 @@ class PaymentSourcesQueryset(models.QuerySet):
|
|||
|
||||
class PaymentSource(models.Model):
|
||||
account = models.ForeignKey('accounts.Account', verbose_name=_("account"),
|
||||
related_name='paymentsources')
|
||||
related_name='paymentsources', on_delete=models.CASCADE)
|
||||
method = models.CharField(_("method"), max_length=32,
|
||||
choices=PaymentMethod.get_choices())
|
||||
data = JSONField(_("data"), default={})
|
||||
|
@ -109,7 +109,7 @@ class Transaction(models.Model):
|
|||
"should be created for recharging."),
|
||||
}
|
||||
|
||||
bill = models.ForeignKey('bills.bill', verbose_name=_("bill"),
|
||||
bill = models.ForeignKey('bills.bill', on_delete=models.CASCADE, verbose_name=_("bill"),
|
||||
related_name='transactions')
|
||||
source = models.ForeignKey(PaymentSource, null=True, blank=True, on_delete=models.SET_NULL,
|
||||
verbose_name=_("source"), related_name='transactions')
|
||||
|
|
|
@ -37,9 +37,10 @@ class Plan(models.Model):
|
|||
|
||||
|
||||
class ContractedPlan(models.Model):
|
||||
plan = models.ForeignKey(Plan, verbose_name=_("plan"), related_name='contracts')
|
||||
account = models.ForeignKey('accounts.Account', verbose_name=_("account"),
|
||||
related_name='plans')
|
||||
plan = models.ForeignKey(Plan, on_delete=models.CASCADE,
|
||||
verbose_name=_("plan"), related_name='contracts')
|
||||
account = models.ForeignKey('accounts.Account', on_delete=models.CASCADE,
|
||||
verbose_name=_("account"), related_name='plans')
|
||||
|
||||
class Meta:
|
||||
verbose_name_plural = _("plans")
|
||||
|
@ -69,10 +70,10 @@ class RateQuerySet(models.QuerySet):
|
|||
|
||||
|
||||
class Rate(models.Model):
|
||||
service = models.ForeignKey('services.Service', verbose_name=_("service"),
|
||||
related_name='rates')
|
||||
plan = models.ForeignKey(Plan, verbose_name=_("plan"), related_name='rates', null=True,
|
||||
blank=True)
|
||||
service = models.ForeignKey('services.Service', on_delete=models.CASCADE,
|
||||
verbose_name=_("service"), related_name='rates')
|
||||
plan = models.ForeignKey(Plan, on_delete=models.SET_NULL, null=True, blank=True,
|
||||
verbose_name=_("plan"), related_name='rates')
|
||||
quantity = models.PositiveIntegerField(_("quantity"), null=True, blank=True,
|
||||
help_text=_("See rate algorihm help text."))
|
||||
price = models.DecimalField(_("price"), max_digits=12, decimal_places=2)
|
||||
|
|
|
@ -42,7 +42,7 @@ class Resource(models.Model):
|
|||
"digits and hyphen only."),
|
||||
validators=[validators.validate_name])
|
||||
verbose_name = models.CharField(_("verbose name"), max_length=256)
|
||||
content_type = models.ForeignKey(ContentType,
|
||||
content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE,
|
||||
help_text=_("Model where this resource will be hooked."))
|
||||
aggregation = models.CharField(_("aggregation"), max_length=16,
|
||||
choices=Aggregation.get_choices(), default=Aggregation.get_choices()[0][0],
|
||||
|
@ -178,8 +178,8 @@ class ResourceDataQuerySet(models.QuerySet):
|
|||
|
||||
class ResourceData(models.Model):
|
||||
""" Stores computed resource usage and allocation """
|
||||
resource = models.ForeignKey(Resource, related_name='dataset', verbose_name=_("resource"))
|
||||
content_type = models.ForeignKey(ContentType, verbose_name=_("content type"))
|
||||
resource = models.ForeignKey(Resource, on_delete=models.CASCADE, related_name='dataset', verbose_name=_("resource"))
|
||||
content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE, verbose_name=_("content type"))
|
||||
object_id = models.PositiveIntegerField(_("object id"))
|
||||
used = models.DecimalField(_("used"), max_digits=16, decimal_places=3, null=True,
|
||||
editable=False)
|
||||
|
@ -267,7 +267,7 @@ class MonitorData(models.Model):
|
|||
""" Stores monitored data """
|
||||
monitor = models.CharField(_("monitor"), max_length=256, db_index=True,
|
||||
choices=ServiceMonitor.get_choices())
|
||||
content_type = models.ForeignKey(ContentType, verbose_name=_("content type"))
|
||||
content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE, verbose_name=_("content type"))
|
||||
object_id = models.PositiveIntegerField(_("object id"))
|
||||
created_at = models.DateTimeField(_("created"), default=timezone.now, db_index=True)
|
||||
value = models.DecimalField(_("value"), max_digits=16, decimal_places=2)
|
||||
|
|
|
@ -26,8 +26,8 @@ class SaaS(models.Model):
|
|||
name = models.CharField(_("Name"), max_length=64,
|
||||
help_text=_("Required. 64 characters or fewer. Letters, digits and ./- only."),
|
||||
validators=[validators.validate_hostname])
|
||||
account = models.ForeignKey('accounts.Account', verbose_name=_("account"),
|
||||
related_name='saas')
|
||||
account = models.ForeignKey('accounts.Account', on_delete=models.CASCADE,
|
||||
verbose_name=_("account"), related_name='saas')
|
||||
is_active = models.BooleanField(_("active"), default=True,
|
||||
help_text=_("Designates whether this service should be treated as active. "))
|
||||
data = JSONField(_("data"), default={},
|
||||
|
@ -36,7 +36,8 @@ class SaaS(models.Model):
|
|||
help_text=_("Optional and alternative URL for accessing this service instance. "
|
||||
"i.e. <tt>https://wiki.mydomain/doku/</tt><br>"
|
||||
"A related website will be automatically configured if needed."))
|
||||
database = models.ForeignKey('databases.Database', null=True, blank=True)
|
||||
database = models.ForeignKey('databases.Database',
|
||||
on_delete=models.SET_NULL, null=True, blank=True)
|
||||
|
||||
# Some SaaS sites may need a database, with this virtual field we tell the ORM to delete them
|
||||
databases = VirtualDatabaseRelation('databases.Database')
|
||||
|
|
|
@ -58,7 +58,8 @@ class Service(models.Model):
|
|||
', '.join(settings.SERVICES_IGNORE_ACCOUNT_TYPE).rsplit(', ', 1)).lower()
|
||||
|
||||
description = models.CharField(_("description"), max_length=256, unique=True)
|
||||
content_type = models.ForeignKey(ContentType, verbose_name=_("content type"),
|
||||
content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE,
|
||||
verbose_name=_("content type"),
|
||||
help_text=_("Content type of the related service objects."))
|
||||
match = models.CharField(_("match"), max_length=256, blank=True,
|
||||
help_text=_(
|
||||
|
|
|
@ -38,7 +38,7 @@ class SystemUser(models.Model):
|
|||
validators=[validators.validate_username])
|
||||
password = models.CharField(_("password"), max_length=128)
|
||||
account = models.ForeignKey('accounts.Account', verbose_name=_("Account"),
|
||||
related_name='systemusers')
|
||||
related_name='systemusers', on_delete=models.CASCADE)
|
||||
home = models.CharField(_("home"), max_length=256, blank=True,
|
||||
help_text=_("Starting location when login with this no-shell user."))
|
||||
directory = models.CharField(_("directory"), max_length=256, blank=True,
|
||||
|
|
|
@ -15,8 +15,8 @@ class VPS(models.Model):
|
|||
template = models.CharField(_("template"), max_length=64,
|
||||
choices=settings.VPS_TEMPLATES, default=settings.VPS_DEFAULT_TEMPLATE,
|
||||
help_text=_("Initial template."))
|
||||
account = models.ForeignKey('accounts.Account', verbose_name=_("Account"),
|
||||
related_name='vpss')
|
||||
account = models.ForeignKey('accounts.Account', on_delete=models.CASCADE,
|
||||
verbose_name=_("Account"), related_name='vpss')
|
||||
is_active = models.BooleanField(_("active"), default=True)
|
||||
|
||||
class Meta:
|
||||
|
|
|
@ -19,12 +19,12 @@ class WebApp(models.Model):
|
|||
name = models.CharField(_("name"), max_length=128, validators=[validators.validate_name],
|
||||
help_text=_("The app will be installed in %s") % settings.WEBAPPS_BASE_DIR)
|
||||
type = models.CharField(_("type"), max_length=32, choices=AppType.get_choices())
|
||||
account = models.ForeignKey('accounts.Account', verbose_name=_("Account"),
|
||||
related_name='webapps')
|
||||
account = models.ForeignKey('accounts.Account', on_delete=models.CASCADE,
|
||||
verbose_name=_("Account"), related_name='webapps')
|
||||
data = JSONField(_("data"), blank=True, default={},
|
||||
help_text=_("Extra information dependent of each service."))
|
||||
target_server = models.ForeignKey('orchestration.Server', verbose_name=_("Target Server"),
|
||||
related_name='webapps')
|
||||
target_server = models.ForeignKey('orchestration.Server', on_delete=models.CASCADE,
|
||||
verbose_name=_("Target Server"), related_name='webapps')
|
||||
comments = models.TextField(default="", blank=True)
|
||||
|
||||
# CMS webapps usually need a database and dbuser, with these virtual fields we tell the ORM to delete them
|
||||
|
@ -98,8 +98,8 @@ class WebApp(models.Model):
|
|||
|
||||
|
||||
class WebAppOption(models.Model):
|
||||
webapp = models.ForeignKey(WebApp, verbose_name=_("Web application"),
|
||||
related_name='options')
|
||||
webapp = models.ForeignKey(WebApp, on_delete=models.CASCADE,
|
||||
verbose_name=_("Web application"), related_name='options')
|
||||
name = models.CharField(_("name"), max_length=128,
|
||||
choices=AppType.get_group_options_choices())
|
||||
value = models.CharField(_("value"), max_length=256)
|
||||
|
|
|
@ -21,8 +21,8 @@ class Website(models.Model):
|
|||
|
||||
name = models.CharField(_("name"), max_length=128,
|
||||
validators=[validators.validate_name])
|
||||
account = models.ForeignKey('accounts.Account', verbose_name=_("Account"),
|
||||
related_name='websites')
|
||||
account = models.ForeignKey('accounts.Account', on_delete=models.CASCADE,
|
||||
verbose_name=_("Account"), related_name='websites')
|
||||
protocol = models.CharField(_("protocol"), max_length=16,
|
||||
choices=settings.WEBSITES_PROTOCOL_CHOICES,
|
||||
default=settings.WEBSITES_DEFAULT_PROTOCOL,
|
||||
|
@ -34,8 +34,8 @@ class Website(models.Model):
|
|||
domains = models.ManyToManyField(settings.WEBSITES_DOMAIN_MODEL, blank=True,
|
||||
related_name='websites', verbose_name=_("domains"))
|
||||
contents = models.ManyToManyField('webapps.WebApp', through='websites.Content')
|
||||
target_server = models.ForeignKey('orchestration.Server', verbose_name=_("Target Server"),
|
||||
related_name='websites')
|
||||
target_server = models.ForeignKey('orchestration.Server', on_delete=models.CASCADE,
|
||||
verbose_name=_("Target Server"), related_name='websites')
|
||||
is_active = models.BooleanField(_("active"), default=True)
|
||||
comments = models.TextField(default="", blank=True)
|
||||
|
||||
|
@ -120,8 +120,8 @@ class Website(models.Model):
|
|||
|
||||
|
||||
class WebsiteDirective(models.Model):
|
||||
website = models.ForeignKey(Website, verbose_name=_("web site"),
|
||||
related_name='directives')
|
||||
website = models.ForeignKey(Website, on_delete=models.CASCADE,
|
||||
verbose_name=_("web site"), related_name='directives')
|
||||
name = models.CharField(_("name"), max_length=128, db_index=True,
|
||||
choices=SiteDirective.get_choices())
|
||||
value = models.CharField(_("value"), max_length=256, blank=True)
|
||||
|
@ -144,8 +144,10 @@ class WebsiteDirective(models.Model):
|
|||
|
||||
class Content(models.Model):
|
||||
# related_name is content_set to differentiate between website.content -> webapp
|
||||
webapp = models.ForeignKey('webapps.WebApp', verbose_name=_("web application"))
|
||||
website = models.ForeignKey('websites.Website', verbose_name=_("web site"))
|
||||
webapp = models.ForeignKey('webapps.WebApp', on_delete=models.CASCADE,
|
||||
verbose_name=_("web application"))
|
||||
website = models.ForeignKey('websites.Website', on_delete=models.CASCADE,
|
||||
verbose_name=_("web site"))
|
||||
path = models.CharField(_("path"), max_length=256, blank=True,
|
||||
validators=[validators.validate_url_path])
|
||||
|
||||
|
|
Loading…
Reference in New Issue