コード例 #1
0
def new_customer():
    data_schema = CustomerCreateInputSchema()
    try:
        handle_request_validation(data_schema)
    except ValidationError as err:
        return jsonify(err.message), 400
    if not is_logged():
        return (jsonify({'message': 'Not Authorized'})), 401
    return CustomerService.save(request.get_json())
コード例 #2
0
def new_waiting_line():
    req_data = request.get_json()
    data_schema = WaitingLineCreateInputSchema()
    try:
        handle_request_validation(data_schema)
    except ValidationError as err:
        return jsonify(err.message), 400

    if not is_logged(
    ) or req_data['company_id'] != g.user.company_id or not is_admin():
        return (jsonify({'message': 'Not Authorized'})), 401

    return WaitingLineService.save(req_data)
コード例 #3
0
def save(data):
  line_up = LineUp(waiting_line_id= data['waiting_line_id'],
                     customer_id= data['customer_id'],
                     status=0, # ENTROU NA FILA
                     joined_at=datetime.now())

  if not is_logged(): # TODO: VALIDAR SE O USUÁRIO PERTENCE A EMPRESA
      return (jsonify({'message': 'Not Authorized' })), 401

  if line_up.query.filter(and_(LineUp.customer_id==data['customer_id'],LineUp.status < 3)).first() is not None:
      return (jsonify({'message': 'Customer already in an active Waiting Line'}), 400)

  db.session.add(line_up)
  db.session.commit()

  response = flask.make_response(jsonify({ 'data': {
                                      'id': line_up.id,
                                      'customer_id': line_up.customer_id,
                                      'waiting_line_id': line_up.waiting_line_id,
                                      'status': line_up.status,
                                      'joined_at': format_datetime(line_up.joined_at)}}), 201)
  response.headers["Content-Type"] = "application/json"
  return response
コード例 #4
0
def get_waiting_lines():
    if not is_logged():
        return (jsonify({'message': 'Not Authorized'})), 401

    return WaitingLineService.getAll()
コード例 #5
0
def call_customer(id):

    if not is_logged():  # TODO: VALIDAR SE O USUÁRIO PERTENCE A EMPRESA
        return (jsonify({'message': 'Not Authorized'})), 401
    return LineUpService.call_customer(id)
コード例 #6
0
def get_next_customer():

    if not is_logged():  # TODO: VALIDAR SE O USUÁRIO PERTENCE A EMPRESA
        return (jsonify({'message': 'Not Authorized'})), 401
    waiting_line_id = request.args['waiting_line_id']
    return LineUpService.get_next_customer(waiting_line_id)
コード例 #7
0
ファイル: UserRoute.py プロジェクト: twsImpacta/tua-mesa-back
def get_current_user():
    if not is_logged():
        return (jsonify({'message': 'Not Authorized'})), 401
    return UserService.get_current_user()
コード例 #8
0
def get_company(id):
    if not is_logged() or id != g.user.company_id or not is_admin():
        return (jsonify({'message': 'Not Authorized' })), 401
    return CompanyService.get(id)
コード例 #9
0
def get_customer(id):
    if not is_logged():
        return (jsonify({'message': 'Not Authorized'})), 401
    return CustomerService.get(id)