Manage hosting service suspension in the panel
This commit is contained in:
1 parent
deaa18b2f3
commit
296401a436
15 files changed
+832
-11
No files matched your search
@@ -266,6 +266,7 @@ class HostingAccount(models.Model):
|
||||
customer = models.ForeignKey(
|
||||
Customer, on_delete=models.PROTECT, null=True, blank=True
|
||||
)
|
||||
services_suspended = models.BooleanField(default=False)
|
||||
scheduled_backups_to_keep = models.PositiveSmallIntegerField(
|
||||
null=True,
|
||||
blank=True,
|
||||
@@ -570,6 +571,55 @@ class ProvisioningJob(models.Model):
|
||||
return "running" if self.started_at else "queued"
|
||||
|
||||
|
||||
class AccountServiceChange(models.Model):
|
||||
account = models.ForeignKey(
|
||||
HostingAccount,
|
||||
on_delete=models.CASCADE,
|
||||
related_name="service_changes",
|
||||
)
|
||||
suspended = models.BooleanField()
|
||||
is_retry = models.BooleanField(default=False)
|
||||
operator_username = models.CharField(max_length=150)
|
||||
requested_at = models.DateTimeField(default=timezone.now)
|
||||
|
||||
class Meta:
|
||||
ordering = ("-pk",)
|
||||
permissions = [
|
||||
(
|
||||
"suspend_hosting_services",
|
||||
"Can suspend and resume hosting services",
|
||||
)
|
||||
]
|
||||
|
||||
|
||||
class AccountServiceJob(ProvisioningJob):
|
||||
class Kind(models.TextChoices):
|
||||
WEB = "web", "Website"
|
||||
SFTP = "sftp", "SFTP"
|
||||
DATABASE = "database", "Database"
|
||||
MAILBOX = "mailbox", "Mailbox"
|
||||
|
||||
change = models.ForeignKey(
|
||||
AccountServiceChange, on_delete=models.CASCADE, related_name="jobs"
|
||||
)
|
||||
kind = models.CharField(max_length=8, choices=Kind)
|
||||
target = models.CharField(max_length=254)
|
||||
manifest = models.JSONField()
|
||||
applied_suspended = models.BooleanField(default=False)
|
||||
|
||||
class Meta:
|
||||
ordering = ("kind", "target")
|
||||
indexes = [
|
||||
models.Index(fields=("kind", "finished_at", "requested_at"))
|
||||
]
|
||||
constraints = [
|
||||
models.UniqueConstraint(
|
||||
fields=("change", "kind", "target"),
|
||||
name="hosting_service_change_unique_target",
|
||||
)
|
||||
]
|
||||
|
||||
|
||||
class WebActivation(ProvisioningJob):
|
||||
plan = models.OneToOneField(
|
||||
WebProvisioningPlan,
|
||||
|
||||
Reference in new issue
Block a user