Пример #1
0
    def get(self):
        the_get = Get()
        user_id = the_get.get_user_id(self)
        friend_user_id = the_get.get_friend_id(self)
        is_delete = the_get.get_delete(self)
        user = User()
        meet = Meet()
        the_user = user.get_by_id(user_id)
        the_friend = user.get_by_id(friend_user_id)
        if is_delete:
            met_instance = meet.get_met_by_users(user_id, friend_user_id)
            success = meet.met.delete(met_instance)
            if success:
                result = Result.result_success("delete successfully!")
            else:
                result = Result.result_failed("delete failed!")
        else:
            if the_user and the_friend:

                success = meet.add_apply(user_id, friend_user_id)
                if success:
                    apply = meet.get_apply_by_user_and_friend(
                        user_id, friend_user_id)
                    if apply:
                        data = dict()
                        data["apply_id"] = apply.id
                        data["user_id"] = user_id
                        data["another_user_id"] = friend_user_id
                        success = meet.add_met(data)
                        if success:
                            result = Result.result_success("add successfully!")
                        else:
                            result = Result.result_failed("add met failed!")
                    else:
                        result = Result.result_failed("get apply failed!")
                else:
                    result = Result.result_failed("add apply failed!")
            else:
                result = Result.result_failed("user does not exist!")

        self.write(OHHOOperation.dict2json(result))
    def get(self):
        the_get = Get()
        permission = OHHOPermission()
        group_id = the_get.get_group_id(self)
        group = permission.group.get_by_id(group_id)
        group_name = group.name if group else ""
        page_name = the_get.get_page_name(self)
        page_permission_id = int(the_get.get_page_permission_id(self))
        insert = the_get.get_insert(self)
        insert = int(insert) if insert else 0
        delete = the_get.get_delete(self)
        delete = int(delete) if delete else 0
        update = the_get.get_update(self)
        update = int(update) if update else 0
        select = the_get.get_select(self)
        select = int(select) if select else 0
        message = the_get.get_data(self)

        return self.render(PERMISSION_GROUP_PAGE_RELATION_BACKSTAGE_DELETE_HTML,
                           page_name=page_name,
                           page_permission_id=page_permission_id,
                           insert=insert,
                           delete=delete,
                           update=update,
                           select=select,
                           group_id=group_id,
                           group_name=group_name,
                           home_list_url=MANAGEMENT_PERMISSION_HOME_URL,
                           list_url=PERMISSION_GROUP_PAGE_RELATION_BACKSTAGE_LIST_URL + "?id=" + str(group_id),
                           detail_url=PERMISSION_GROUP_PAGE_RELATION_BACKSTAGE_DETAIL_URL + "?page_permission_id=%d&data=%s&page_name=%s&insert=%d&delete=%d&update=%d&select=%d&group_id=%d" % (
                               int(page_permission_id), message, page_name, int(insert), int(delete), int(update),
                               int(select),
                               int(group_id)),
                           add_url=PERMISSION_GROUP_PAGE_RELATION_BACKSTAGE_ADD_URL + "?group_id=" + str(group_id),
                           delete_url=PERMISSION_GROUP_PAGE_RELATION_BACKSTAGE_DELETE_URL + "?page_permission_id=%d&data=%s&page_name=%s&insert=%d&delete=%d&update=%d&select=%d&group_id=%d" % (
                               int(page_permission_id), message, page_name, int(insert), int(delete), int(update),
                               int(select),
                               int(group_id)),
                           message=message
                           )