diff --git a/app/forms.py b/app/forms.py index 1317c21..2a90a45 100644 --- a/app/forms.py +++ b/app/forms.py @@ -29,6 +29,9 @@ class OrderForm(Form): location_id = SelectField( "Location", coerce=str, validators=[validators.required()] ) + organizing_id = SelectField( + "Organizing", coerce=str, validators=[validators.required()] + ) starttime = DateTimeField( "Starttime", default=datetime.now, format="%d-%m-%Y %H:%M" ) @@ -47,6 +50,7 @@ class OrderForm(Form): (current_user.id, current_user.username), ] self.location_id.choices = [(l.id, l.name) for l in location_definitions] + self.organizing_id.choices = [("zeus", "Zeus WPI")] if self.stoptime.data is None: self.stoptime.data = datetime.now() + timedelta(hours=1) diff --git a/app/models/order.py b/app/models/order.py index b990f04..d4601f7 100644 --- a/app/models/order.py +++ b/app/models/order.py @@ -18,6 +18,7 @@ class Order(db.Model): starttime = db.Column(db.DateTime) stoptime = db.Column(db.DateTime) public = db.Column(db.Boolean, default=True) + organizing_id = db.Column(db.String(64), default="") items = db.relationship("OrderItem", backref="order", lazy="dynamic") @@ -31,9 +32,9 @@ class Order(db.Model): def __repr__(self) -> str: # pylint: disable=R1705 if self.location: - return "Order %d @ %s" % (self.id, self.location.name or "None") + return "Order %d @ %s for %s" % (self.id, self.location.name or "None", self.organizing_id or "None") else: - return "Order %d" % (self.id) + return "Order %d for %s" % (self.id, self.organizing_id or "None") def update_from_hlds(self) -> None: """ diff --git a/app/templates/orders.html b/app/templates/orders.html index e472461..8205f75 100644 --- a/app/templates/orders.html +++ b/app/templates/orders.html @@ -38,6 +38,11 @@ {{ form.location_id(class='form-control select') }} {{ util.render_form_field_errors(form.location_id) }} +
+ {{ form.organizing_id.label(class='control-label') }}
+ {{ form.organizing_id(class='form-control select') }} + {{ util.render_form_field_errors(form.courier_id) }} +
{% if current_user.is_admin() %}
{{ form.starttime.label(class='control-label') }} diff --git a/app/templates/utils.html b/app/templates/utils.html index 15d85eb..9c45543 100644 --- a/app/templates/utils.html +++ b/app/templates/utils.html @@ -1,25 +1,34 @@ {% macro render_order(order) -%}
-
+
+ {% if order.organizing_id %} + + {% endif %}
+
+
{{ order.location_name }}
{{ order.items.count() }} orders

+ {% if order.organizing_name %} +

{{order.organizing_name}}

+ {% endif %} {% if order.stoptime %} - Closes {{ order.stoptime.strftime("%H:%M") }}{{ order.stoptime|countdown }} - {% else %}open{% endif %}
+ Closes {{ order.stoptime.strftime("%H:%M") }}{{ order.stoptime|countdown }} + {% else %}open{% endif %}
{%- endmacro %} {% macro render_form_field_errors(field) %} {%- if field.errors %} - {%- for error in field.errors %} -

{{error}}

- {%- endfor %} +{%- for error in field.errors %} +

{{error}}

+{%- endfor %} {%- elif field.description -%} -

{{field.description|safe}}

+

{{field.description|safe}}

{%- endif %} -{% endmacro %} +{% endmacro %} \ No newline at end of file