예제 #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
파일: forms.py 프로젝트: Czlyc/ylinux
 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