Commit 062882d6 authored by Calum Mackervoy's avatar Calum Mackervoy Committed by Jean-Baptiste Pasquier

Member name bugfixes

parent 6d61b7b4
......@@ -79,12 +79,16 @@ class Member(Model):
unique_together = ['user', 'project']
def __str__(self):
if self.name is None:
return ""
return self.name
def save(self, *args, **kwargs):
# cannot be duplicated Members
if not self.pk and Member.objects.filter(project=self.project, user=self.user).exists():
return
# override existing member
existing = Member.objects.get(project=self.project, user=self.user)
existing.delete()
super(Member, self).save(*args, **kwargs)
......@@ -109,4 +113,5 @@ def set_captain_as_member(instance, created, **kwargs):
# add captain as an admin member, if they've not already been added
if created and instance.captain is not None and\
not instance.members.filter(user=instance.captain).exists():
Member.objects.create(user=instance.captain, project=instance, is_admin=True, name=instance.captain.name())
captain = Member(user=instance.captain, project=instance, is_admin=True)
captain.save()
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