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
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
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
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
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