Exemplo n.º 1
0
 def test_node(self):
     group = Group()
     group.name = "team1"
     group.screen_name = "team1"
     user1 = User()
     user1.name = "bob"
     user1.screen_name = "bob"
     group.create()
     user1.create()
     hoge = ModelC()
     hoge.node = group
     hoge.create()
     piyo = ModelC()
     piyo.node = user1
     piyo.create()
     foo = ModelC()
     foo.node = group._id
     foo.create()
     bar= ModelC()
     bar.node = user1._id
     bar.create()
     self.assertEqual(hoge.node, group)
     self.assertEqual(piyo.node, user1)
     self.assertEqual(foo.node, group)
     self.assertEqual(bar.node, user1)
     pass
Exemplo n.º 2
0
 def create(self, request):
     post = request.post()
     try:
         group = Group()
         group.screen_name = post["screen_name"]
         group.name = post["name"]
         group.create()
         return Response.json(group.to_dict())
     except KeyError as err:
         error = err
         return Response.json({
             "error": err.__class__.__name__,
             "message": err.message,
             "args": err.args,
         })
Exemplo n.º 3
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
Exemplo n.º 4
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
     })