Exemplo n.º 1
0
    def validate_get(self, args):
        if not any([
                args.get("username"),
                args.get("status"),
                args.get("server"),
                args.get("id")
        ]):
            return {
                'error': [{
                    "message":
                    "an id, a server, a status, or a username must be provided"
                }]
            }

        if args.get("id") and not ModReqModel.objects(uid=args.get("id")):
            return {'error': [{"message": "invalid id"}]}

        if args.get("server") and Server.verify_fid(args.get("server")):
            return {
                'error': [{
                    "message": "the server field must be a valid fid"
                }]
            }

        if args.get("username") and not validate_username(
                args.get("username")):
            return {'error': [{"message": "invalid username"}]}
Exemplo n.º 2
0
    def validate_get(self, args):
        if not any([args.get("username"), args.get("status"), args.get("server"), args.get("id")]):
            return {'error': [{"message": "an id, a server, a status, or a username must be provided"}]}

        if args.get("id") and not ModReqModel.objects(uid=args.get("id")):
            return {'error': [{"message": "invalid id"}]}

        if args.get("server") and Server.verify_fid(args.get("server")):
            return {'error': [{"message": "the server field must be a valid fid"}]}

        if args.get("username") and not validate_username(args.get("username")):
            return {'error': [{"message": "invalid username"}]}
Exemplo n.º 3
0
    def post(self, modreq_id):
        args = self.post_parser.parse_args()
        validate_args = self.validate_post(args)
        if validate_args:
            return validate_args, 400

        elevate_group = args.get("group")

        modreq = ModReqModel.objects(uid=modreq_id).first()

        modreq.elevate_group = elevate_group
        modreq.save()

        return {'modreq': construct_modreq_data(modreq)}
Exemplo n.º 4
0
    def post(self, modreq_id):
        args = self.post_parser.parse_args()
        validate_args = self.validate_post(args)
        if validate_args:
            return validate_args, 400

        elevate_group = args.get("group")

        modreq = ModReqModel.objects(uid=modreq_id).first()

        modreq.elevate_group = elevate_group
        modreq.save()

        return {'modreq': construct_modreq_data(modreq)}
Exemplo n.º 5
0
    def post(self, modreq_id):
        args = self.post_parser.parse_args()
        validate_args = self.validate_post(args)
        if validate_args:
            return validate_args, 400

        handled_by = args.get("handled_by")
        close_message = args.get("close_message")

        modreq = ModReqModel.objects(uid=modreq_id).first()

        modreq.status = "closed"
        modreq.handled_by = handled_by
        modreq.close_message = close_message
        modreq.close_time = datetime.datetime.utcnow()
        modreq.save()

        return {'modreq': construct_modreq_data(modreq)}
Exemplo n.º 6
0
    def post(self, modreq_id):
        args = self.post_parser.parse_args()
        validate_args = self.validate_post(args)
        if validate_args:
            return validate_args, 400

        handled_by = args.get("handled_by")
        close_message = args.get("close_message")

        modreq = ModReqModel.objects(uid=modreq_id).first()

        modreq.status = "closed"
        modreq.handled_by = handled_by
        modreq.close_message = close_message
        modreq.close_time = datetime.datetime.utcnow()
        modreq.save()

        return {'modreq': construct_modreq_data(modreq)}
Exemplo n.º 7
0
def get_modreqs(uid=None, server=None, status=None, username=None):
    query = dict()

    if uid is not None:
        query['uid'] = uid
    if server is not None:
        query['server'] = server
    if status is not None:
        query['status'] = status
    if username is not None:
        query['username'] = re.compile(username, re.IGNORECASE)

    modreqs_data = ModReqModel.objects(**query)

    modreqs_response = []
    for modreq_data in modreqs_data:
        modreqs_response.append(construct_modreq_data(modreq_data))

    return modreqs_response
Exemplo n.º 8
0
def get_modreqs(uid=None, server=None, status=None, username=None):
    query = dict()

    if uid is not None:
        query['uid'] = uid
    if server is not None:
        query['server'] = server
    if status is not None:
        query['status'] = status
    if username is not None:
        query['username'] = re.compile(username, re.IGNORECASE)

    modreqs_data = ModReqModel.objects(**query)

    modreqs_response = []
    for modreq_data in modreqs_data:
        modreqs_response.append(construct_modreq_data(modreq_data))

    return modreqs_response
Exemplo n.º 9
0
    def post(self, modreq_id):
        args = self.post_parser.parse_args()
        validate_args = self.validate_post(args)
        if validate_args:
            return validate_args, 400

        claim = args.get("claim")
        handled_by = args.get("handled_by")

        modreq = ModReqModel.objects(uid=modreq_id).first()

        if claim:
            modreq.status = "claimed"
            modreq.handled_by = handled_by
        else:
            modreq.status = "open"
            modreq.handled_by = ""

        modreq.save()

        return {'modreq': construct_modreq_data(modreq)}
Exemplo n.º 10
0
    def post(self, modreq_id):
        args = self.post_parser.parse_args()
        validate_args = self.validate_post(args)
        if validate_args:
            return validate_args, 400

        claim = args.get("claim")
        handled_by = args.get("handled_by")

        modreq = ModReqModel.objects(uid=modreq_id).first()

        if claim:
            modreq.status = "claimed"
            modreq.handled_by = handled_by
        else:
            modreq.status = "open"
            modreq.handled_by = ""

        modreq.save()

        return {'modreq': construct_modreq_data(modreq)}