示例#1
0
 def get(self):
     the_get = Get()
     group_id = the_get.get_id(self)
     if group_id:
         instance_staff = DBOHHOStaff()
         instance_group_staff_relation = OHHOPermission().group_and_staff
         staffs = instance_staff.get_query()
         staffs = instance_staff.get_valid(staffs)
         staffs = instance_staff.get_all(staffs)
         staff_list = list()
         group_staff_list = list()
         group_staffs = instance_group_staff_relation.get_by_group_id(
             group_id)
         group_staffs = instance_group_staff_relation.get_all(group_staffs)
         if staffs:
             for staff in staffs:
                 if group_staffs:
                     for group_staff in group_staffs:
                         if staff.username == group_staff.username:
                             group_staff_list.append(staff)
                 staff_list.append(staff)
         staff_list = list(set(staff_list) - set(group_staff_list))
         return self.render(
             PERMISSION_GROUP_STAFF_RELATION_HTML,
             add_url=PERMISSION_GROUP_STAFF_RELATION_ADD_URL,
             delete_url=PERMISSION_GROUP_STAFF_RELATION_DELETE_URL,
             list_url=PERMISSION_GROUP_BACKSTAGE_LIST_URL,
             group_id=group_id,
             staff_list=staff_list,
             group_staff_list=group_staff_list,
         )
     else:
         return self.redirect(PERMISSION_GROUP_BACKSTAGE_LIST_URL)
 def get(self):
     the_get = Get()
     group_id = the_get.get_id(self)
     if group_id:
         instance_user = DBOHHOUser()
         instance_group_user_relation = OHHOPermission().group_and_user
         users = instance_user.get_query()
         users = instance_user.get_valid(users)
         users = instance_user.get_all(users)
         user_list = list()
         group_user_list = list()
         group_users = instance_group_user_relation.get_by_group_id(
             group_id)
         group_users = instance_group_user_relation.get_all(group_users)
         if users:
             for user in users:
                 if group_users:
                     for group_user in group_users:
                         if user.username == group_user.username:
                             group_user_list.append(user)
                 user_list.append(user)
         user_list = list(set(user_list) - set(group_user_list))
         return self.render(
             PERMISSION_GROUP_USER_RELATION_HTML,
             add_url=PERMISSION_GROUP_USER_RELATION_ADD_URL,
             delete_url=PERMISSION_GROUP_USER_RELATION_DELETE_URL,
             list_url=PERMISSION_GROUP_BACKSTAGE_LIST_URL,
             group_id=group_id,
             user_list=user_list,
             group_user_list=group_user_list,
         )
     else:
         return self.redirect(PERMISSION_GROUP_BACKSTAGE_LIST_URL)