Commit 228b22af authored by Jean-Baptiste Pasquier's avatar Jean-Baptiste Pasquier

update: autoset jabberID

parent be35fa6f
Pipeline #6746 passed with stage
in 27 seconds
......@@ -9,6 +9,7 @@ class TeamInline(admin.TabularInline):
class ProjectAdmin(GuardedModelAdmin):
exclude = ('jabberID', 'jabberRoom')
inlines = [TeamInline]
from django.conf import settings
from django.db import models
from django.dispatch import receiver
from django.db.models.signals import post_save
from django.db.models.signals import pre_save, post_save
from djangoldp.models import Model
from .permissions import ProjectPermissions, ProjectMemberPermissions
......@@ -87,6 +87,21 @@ class Member(Model):
super(Member, self).save(*args, **kwargs)
@receiver(pre_save, sender=Project)
def set_jabberid(sender, instance, **kwargs):
if settings.JABBER_DEFAULT_HOST and not instance.jabberID:
instance.jabberID = '{}@conference.{}'.format(
random.choice(string.ascii_letters + string.digits)
for n in range(12)
instance.jabberRoom = True
@receiver(post_save, sender=Project)
def set_captain_as_member(instance, created, **kwargs):
# add captain as an admin member, if they've not already been added
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment