Ejemplo n.º 1
0
def insert_delivery(courier: Courier):
    assign_time = isodatetime.datetime.now()
    insert_items(
        "deliveries",
        [Delivery(courier.type, None, courier.id, assign_time, False)])
    delivery = get_current_courier_delivery(courier.id)
    return delivery
Ejemplo n.º 2
0
def delete(delivery_id):
	if not is_admin():
		abort(401)
	if not delivery_id or delivery_id < 1:
		abort(404)
	if Delivery.delete_item(delivery_id) < 1:
		abort(404)
	return make_response(jsonify(result = True), 200)
Ejemplo n.º 3
0
def update(delivery_id):
	if not is_admin():
		abort(401)
	if not delivery_id or delivery_id < 1:
		abort(404)
	if Delivery.edit_item(MessagePacket.encode(request.data)) < 1:
		abort(404)
	return make_response(jsonify(result = True, redirect = url_for("deliveries.index")), 200)
Ejemplo n.º 4
0
def delivery_edit(delivery_id):
	if delivery_id is None or delivery_id < 1:
		abort(404)
	else:
		return render_template("delivery_details.html", title = "{0}: {1}".format(strings.DELIVERIES_EDIT, delivery_id),
		                       is_logged = is_logged(), is_admin = is_admin(),
		                       delivery = MessagePacket.generate(Delivery.getdetails(delivery_id)),
		                       products = MessagePacket.generate(Product.getallshort()),
		                       contragents = MessagePacket.generate(Contragent.getallshort()))
Ejemplo n.º 5
0
 def get_delivery_num(self, date, delivery_type):
     delivery = Delivery.query.filter_by(
         target_type=self.target_type,
         target_id=self.target_id,
         date=date,
         delivery_type=delivery_type).first()
     if not delivery:
         delivery = Delivery.add(self.target_type, self.id, date,
                                 delivery_type, 0)
     return delivery.value
Ejemplo n.º 6
0
 def set_delivery_num(self, date, delivery_type, num):
     delivery = Delivery.query.filter_by(
         target_type=self.target_type,
         target_id=self.target_id,
         date=date,
         delivery_type=delivery_type).first()
     if not delivery:
         delivery = Delivery.add(self.target_type, self.id, date,
                                 delivery_type, num)
     else:
         delivery.value = max(delivery.value, num)
         delivery.save()
Ejemplo n.º 7
0
def add():
	if not is_admin():
		abort(401)
	return make_response(jsonify(result = Delivery.add_item(MessagePacket.encode(request.data)) > 0,
	                             redirect = url_for("deliveries.index")), 201)
Ejemplo n.º 8
0
def index():
	return render_template(pages["deliveries"]["template"], title = pages["deliveries"]["title"],
	                       is_logged = is_logged(), is_admin = is_admin(),
	                       deliveries = MessagePacket.generate(Delivery.getall()))