示例#1
0
 def require_group(self, group_name):
     # Initialize group, return 404 if it doesn't exist in db
     unescaped_group_name = urllib.unquote_plus(group_name)
     group = Group(unescaped_group_name)
     if not group.exists_in_db():
         abort(404)
     return group
示例#2
0
 def require_group(self, group_name):
     # Initialize group, return 404 if it doesn't exist in db
     unescaped_group_name = urllib.unquote_plus(group_name)
     group = Group(unescaped_group_name)
     if not group.exists_in_db():
         abort(404)
     return group
示例#3
0
    def post(self):
        # TODO: create generic parser
        parser = reqparse.RequestParser()
        parser.add_argument('name', type=str, required=True, help='Unique group name')

        args = parser.parse_args()
        arg_dict = {k : v for k,v in args.iteritems()}

        group = Group(arg_dict)
        try:
            if group.insert():
                return "{0} inserted".format(group.group_name)
            else:
                abort(400)
        except PrimaryKeyException as e:
            abort(403)
        except:
            abort(400)
示例#4
0
    def post(self):
        # TODO: create generic parser
        parser = reqparse.RequestParser()
        parser.add_argument('name',
                            type=str,
                            required=True,
                            help='Unique group name')

        args = parser.parse_args()
        arg_dict = {k: v for k, v in args.iteritems()}

        group = Group(arg_dict)
        try:
            if group.insert():
                return "{0} inserted".format(group.group_name)
            else:
                abort(400)
        except PrimaryKeyException as e:
            abort(403)
        except:
            abort(400)