예제 #1
0
def get_appointment(uid):
    result = Appointment.find(uid)

    if result is None:
        abort(404,
              description=gettext(u'appointment with id %(id)s is not found',
                                  id=uid))
    return result
예제 #2
0
            gettext(
                u'the customer belongs to %(sales_name)s, force assign to %(new_sales)s',
                sales_name=npe.customer.sales.username,
                new_sales=User.find(data.get('sales_id')).username))

    reception = Reception(**data)
    # default receptionist_id if not passed from client
    if convert_int(reception.receptionist_id) <= 0:
        reception.receptionist_id = get_user_id()
    reception.customer.enlist()

    reception.created_on = datetime.now()
    reception.customer.last_reception_date = reception.created_on

    if reception.appointment_id is not None:
        appt = Appointment.find(reception.appointment_id)
        if not appt:
            reception.appointment_id = None
        else:
            if appt.type == 'deliver':
                reception.rx_type = 'other'
            elif not Reception.has_reception_before(appt.customer.id):
                reception.rx_type = 'appt_new'
            else:
                reception.rx_type = 'appt'
            appt.status = 'closed'

    reception.save_and_flush()

    new_reception_created.send(new_reception=reception)