Compare commits
1 commit
master
...
show-logo-
Author | SHA1 | Date | |
---|---|---|---|
|
cb2c9df23b |
4 changed files with 30 additions and 11 deletions
|
@ -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)
|
||||
|
||||
|
|
|
@ -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:
|
||||
"""
|
||||
|
|
|
@ -38,6 +38,11 @@
|
|||
{{ form.location_id(class='form-control select') }}
|
||||
{{ util.render_form_field_errors(form.location_id) }}
|
||||
</div>
|
||||
<div class="form-group select2 {{ 'has-errors' if form.courier_id.errors else ''}}">
|
||||
{{ form.organizing_id.label(class='control-label') }}<br>
|
||||
{{ form.organizing_id(class='form-control select') }}
|
||||
{{ util.render_form_field_errors(form.courier_id) }}
|
||||
</div>
|
||||
{% if current_user.is_admin() %}
|
||||
<div class="form-group{{ ' has-error' if form.starttime.errors }}{{ ' required' if form.starttime.flags.required }}{{ ' hidden' if not current_user.is_admin() }}">
|
||||
{{ form.starttime.label(class='control-label') }}
|
||||
|
|
|
@ -1,25 +1,34 @@
|
|||
{% macro render_order(order) -%}
|
||||
<div class="row order_row">
|
||||
<div class="col-md-8 col-lg-9 order_data">
|
||||
<div class="col-md-2 col-lg-3">
|
||||
{% if order.organizing_id %}
|
||||
<img class="my_image" src="https://dsa.ugent.be/api/verenigingen/{{order.organizing_id}}/logo?size=large">
|
||||
{% endif %}<br />
|
||||
</div>
|
||||
<div class="col-md-5 col-lg-6 order_data">
|
||||
<h5>{{ order.location_name }}</h5>
|
||||
<b class="amount_of_orders">{{ order.items.count() }} orders</b></p>
|
||||
<p class="time_data">
|
||||
{% if order.organizing_name %}
|
||||
<p>{{order.organizing_name}}</p>
|
||||
{% endif %}
|
||||
{% if order.stoptime %}
|
||||
<span><b>Closes </b>{{ order.stoptime.strftime("%H:%M") }}</span>{{ order.stoptime|countdown }}
|
||||
{% else %}open{% endif %}<br/>
|
||||
{% else %}open{% endif %}<br />
|
||||
</div>
|
||||
<div class="col-md-4 col-lg-3 expand_button_wrapper">
|
||||
<a class="btn btn-primary btn-block align-bottom expand_button" href="{{ url_for('order_bp.order_from_id', order_id=order.id) }}">Expand</a>
|
||||
<a class="btn btn-primary btn-block align-bottom expand_button"
|
||||
href="{{ url_for('order_bp.order_from_id', order_id=order.id) }}">Expand</a>
|
||||
</div>
|
||||
</div>
|
||||
{%- endmacro %}
|
||||
|
||||
{% macro render_form_field_errors(field) %}
|
||||
{%- if field.errors %}
|
||||
{%- for error in field.errors %}
|
||||
<p class="help-block">{{error}}</p>
|
||||
{%- endfor %}
|
||||
{%- for error in field.errors %}
|
||||
<p class="help-block">{{error}}</p>
|
||||
{%- endfor %}
|
||||
{%- elif field.description -%}
|
||||
<p class="help-block">{{field.description|safe}}</p>
|
||||
<p class="help-block">{{field.description|safe}}</p>
|
||||
{%- endif %}
|
||||
{% endmacro %}
|
Loading…
Reference in a new issue