mirror of
https://github.com/house-of-vanity/OutFleet.git
synced 2025-07-06 17:14:07 +00:00
This commit is contained in:
@ -51,6 +51,11 @@ class ACL(models.Model):
|
|||||||
def __str__(self):
|
def __str__(self):
|
||||||
return f"{self.user.username} - {self.server.name}"
|
return f"{self.user.username} - {self.server.name}"
|
||||||
|
|
||||||
|
def save(self, *args, **kwargs):
|
||||||
|
super().save(*args, **kwargs)
|
||||||
|
if not self.links.exists():
|
||||||
|
ACLLink.objects.create(acl=self, link=shortuuid.ShortUUID().random(length=16))
|
||||||
|
|
||||||
@receiver(post_save, sender=ACL)
|
@receiver(post_save, sender=ACL)
|
||||||
def acl_created_or_updated(sender, instance, created, **kwargs):
|
def acl_created_or_updated(sender, instance, created, **kwargs):
|
||||||
sync_user.delay_on_commit(instance.user.id, instance.server.id)
|
sync_user.delay_on_commit(instance.user.id, instance.server.id)
|
||||||
@ -62,10 +67,10 @@ def acl_deleted(sender, instance, **kwargs):
|
|||||||
|
|
||||||
class ACLLink(models.Model):
|
class ACLLink(models.Model):
|
||||||
acl = models.ForeignKey(ACL, related_name='links', on_delete=models.CASCADE)
|
acl = models.ForeignKey(ACL, related_name='links', on_delete=models.CASCADE)
|
||||||
link = models.CharField(max_length=64, unique=True, blank=True, null=True, verbose_name="Access link", help_text="Access link to get dynamic configuration")
|
link = models.CharField(max_length=64, default="", unique=True, blank=True, null=True, verbose_name="Access link", help_text="Access link to get dynamic configuration")
|
||||||
|
|
||||||
def save(self, *args, **kwargs):
|
def save(self, *args, **kwargs):
|
||||||
if not self.link:
|
if self.link == "":
|
||||||
self.link = shortuuid.ShortUUID().random(length=16)
|
self.link = shortuuid.ShortUUID().random(length=16)
|
||||||
super().save(*args, **kwargs)
|
super().save(*args, **kwargs)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user