Ejemplo n.º 1
0
 def post(self):
     the_post = Post()
     group_id = the_post.get_id(self)
     group_staffs_name = self.get_body_arguments("group_user")
     staffs_name = self.get_body_arguments("name")
     data = dict()
     instance = OHHOPermission().group_and_staff
     success = ""
     if group_id:
         if staffs_name:
             for staff_name in staffs_name:
                 group_name = instance.get_by_group_id_and_username(
                     group_id, staff_name)
                 if group_name:
                     success = instance.delete(group_name)
         if group_staffs_name:
             for staff_name in group_staffs_name:
                 group_name = instance.get_by_group_id_and_username(
                     group_id, staff_name)
                 if not group_name:
                     data["group_id"] = group_id
                     data["username"] = staff_name
                     success = instance.add(data)
     else:
         pass
     if success:
         return self.redirect(PERMISSION_GROUP_BACKSTAGE_LIST_URL)
     return self.redirect(PERMISSION_GROUP_STAFF_RELATION_ADD_URL +
                          "?group_id=" + group_id)
    def post(self):
        the_post = Post()
        name = the_post.get_name(self)
        description = the_post.get_description(self)
        data = dict()
        instance = OHHOPermission().group

        if name:
            data["name"] = name
            if description:
                data["description"] = description
            success = instance.add(data)
            if success:
                return self.redirect(PERMISSION_GROUP_BACKSTAGE_LIST_URL)

        return self.redirect(PERMISSION_GROUP_BACKSTAGE_ADD_URL)