Пример #1
0
 def test_duplicate_name(self):
     account = Account.objects.get(pk=1)
     g1 = Group(account=account, name="samenamegame")
     g1.save()
     g2 = Group(account=account, name="samenamegame")
     try:
         g2.save()
         raise False
     except:
         # It seems that the exception raised is DB specific.
         # So we just catch all exceptions here.
         pass
Пример #2
0
def create_group_in_db(creator, name, type, members, summary):
    group = Group(creator=creator, name=name, type=type, summary=summary)
    group.save()
    for user in members:
        print(user.email)
        group.members.add(user)
        group.save()
    return group.pk
Пример #3
0
 def test_duplicate_name(self):
     account = Account.objects.get(pk=1)
     g1 = Group(account = account, name = "samenamegame")
     g1.save()
     g2 = Group(account = account, name = "samenamegame")
     try:
         g2.save()
         raise False
     except:
         # It seems that the exception raised is DB specific.
         # So we just catch all exceptions here. 
         pass
Пример #4
0
 def save(self):
     group = Group(name=self.cleaned_data['name'])
     group.save()
     for perm in self.cleaned_data['permissions']:
         group.permissions.add(perm)
     return group
Пример #5
0
 def save (self):
     group = Group(name=self.cleaned_data['name'])
     group.save()
     for perm in self.cleaned_data['permissions']:
         group.permissions.add(perm)
     return group