Beispiel #1
0
    def post(self):

        data = request.get_json(force=True, silent=True)

        # Validation
        if not verify_code(data['secretkey']):
            return abort(403, message="Incorrect authorization, access denied")

        payload = data['payload']

        if 'email' not in payload:
            user_id, valid_password = ds.validate_user(payload['password'],
                                                       login=payload['login'])
            result = {'user_id': user_id, 'valid_password': valid_password}
            return result

        elif 'login' not in payload:
            user_id, valid_password = ds.validate_user(payload['password'],
                                                       email=payload['email'])
            result = {'user_id': user_id, 'valid_password': valid_password}
            return result

        else:
            user_id, valid_password = ds.validate_user(payload['password'],
                                                       login=payload['login'],
                                                       email=payload['email'])
            result = {'user_id': user_id, 'valid_password': valid_password}
            return result
Beispiel #2
0
    def post(self):

        data = request.get_json(force=True, silent=True)

        # Validation
        if not verify_code(data['secretkey']):
            return abort(403, message="Incorrect authorization, access denied")

        payload = data['payload']

        result = ds.get_ticket(payload['ticket_id'])
        return result.to_json()
Beispiel #3
0
    def post(self):

        data = request.get_json(force=True, silent=True)

        # Validation
        if not verify_code(data['secretkey']):
            return abort(403, message="Incorrect authorization, access denied")

        payload = data['payload']

        ds.save_relationship(payload['user'], payload['ticket'],
                             payload['role'])
        return
Beispiel #4
0
    def post(self):

        raw_data = request.get_json(force=True, silent=True)

        # Validation
        if not verify_code(raw_data['secretkey']):
            return abort(403, message="Incorrect authorization, access denied")

        payload = raw_data['payload']
        user = User.from_json(payload)

        ds.save_user(user)
        return
Beispiel #5
0
    def post(self):

        data = request.get_json(force=True, silent=True)

        # Validation
        if not verify_code(data['secretkey']):
            return abort(403, message="Incorrect authorization, access denied")

        payload = data['payload']
        ticket = Ticket.from_json(payload)

        id = ds.save_ticket(ticket)
        rm.assign_developer(id)
        return id
Beispiel #6
0
    def post(self):

        data = request.get_json(force=True, silent=True)

        # Validation
        if not verify_code(data['secretkey']):
            return abort(403, message="Incorrect authorization, access denied")

        payload = data['payload']

        result = ds.search_user(payload['id'])
        final = []

        for user in result:

            final.append(user.to_json())

        return final
Beispiel #7
0
    def post(self):

        data = request.get_json(force=True, silent=True)

        # Validation
        if not verify_code(data['secretkey']):
            return abort(403, message="Incorrect authorization, access denied")

        payload = data['payload']
        post = Post.from_json(payload)
        logging.info(payload)
        if post.status_change:
            logging.info("im in")
            ticket = ds.get_ticket(post.ticket_id)
            ticket.status = post.status_change
            ds.session.commit()
        ds.save_post(post)

        return
Beispiel #8
0
    def post(self):

        data = data = request.get_json(force=True, silent=True)

        # Validation
        if not verify_code(data['secretkey']):
            return abort(403, message="Incorrect authorization, access denied")

        payload = data['payload']

        result = ds.search_post(ticket=payload['ticket'])

        final = []

        for post in result:
            item = post.to_json()
            item['user'] = ds.get_user(post.author_id).to_json()
            final.append(item)

        return final
Beispiel #9
0
    def post(self):

        data = data = request.get_json(force=True, silent=True)

        # Validation
        if not verify_code(data['secretkey']):
            return abort(403, message="Incorrect authorization, access denied")

        payload = data['payload']
        if 'order_by' in payload:
            if payload['order_by'] == 'role':
                logging.info('Tickets have to be ordered')

                if 'role' in payload:
                    result = ds.search_ticket_ordered_by_role(
                        payload['user'], payload['role'])
                else:
                    result = ds.search_ticket_ordered_by_role(payload['user'])
        else:
            if 'role' in payload:
                result = ds.search_ticket(payload['user'], payload['role'])
            else:
                result = ds.search_ticket(payload['user'])

        final = []

        for ticket, role in result:
            if payload['closed']:
                if ticket.status == 'Completed':
                    item = ticket.to_json()
                    item['role'] = role
                    final.append(item)

            else:
                if ticket.status != 'Completed':
                    item = ticket.to_json()
                    item['role'] = role

                    final.append(item)

        return final