예제 #1
0
 def test_group(self):
     group = Group()
     group.name = "team1"
     group.screen_name = "team1"
     user1 = User()
     user1.name = "bob"
     user1.screen_name = "bob"
     user1.email = "*****@*****.**"
     user2 = User()
     user2.name = "charlie"
     user2.screen_name = "charlie"
     user2.email = "*****@*****.**"
     group.create()
     user1.create()
     user2.create()
     group.append(user1)
     self.assertTrue(group.is_in(user1))
     self.assertFalse(group.is_in(user2))
     pass
예제 #2
0
 def create(self, req):
     template = self.view.get_template("group/create.html")
     groups = Group.list()
     error = ""
     if req.method == "POST":
         try:
             form = GroupCreateForm(req.post())
             group = Group()
             group.name = form["name"]
             group.screen_name = form["screen_name"]
             group.icon = resize_icon(form["icon"])
             group.create()
             if form["parent"] is not None:
                 Group.retrieve(form["parent"]).append(group)
             group.append(req.user)
             return Response.redirect(self.app.convert_url("/groups"))
         except ValidationError as err:
             error = str(err)
     return Response.render(template, {
         "groups": groups,
         "icon": load_noimage_group(),
         "error": error
     })