render organizing group image by organizing_id, like zeus, from dsa thing
This commit is contained in:
parent
1f7ddcdb33
commit
cb2c9df23b
4 changed files with 30 additions and 11 deletions
|
@ -29,6 +29,9 @@ class OrderForm(Form):
|
||||||
location_id = SelectField(
|
location_id = SelectField(
|
||||||
"Location", coerce=str, validators=[validators.required()]
|
"Location", coerce=str, validators=[validators.required()]
|
||||||
)
|
)
|
||||||
|
organizing_id = SelectField(
|
||||||
|
"Organizing", coerce=str, validators=[validators.required()]
|
||||||
|
)
|
||||||
starttime = DateTimeField(
|
starttime = DateTimeField(
|
||||||
"Starttime", default=datetime.now, format="%d-%m-%Y %H:%M"
|
"Starttime", default=datetime.now, format="%d-%m-%Y %H:%M"
|
||||||
)
|
)
|
||||||
|
@ -47,6 +50,7 @@ class OrderForm(Form):
|
||||||
(current_user.id, current_user.username),
|
(current_user.id, current_user.username),
|
||||||
]
|
]
|
||||||
self.location_id.choices = [(l.id, l.name) for l in location_definitions]
|
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:
|
if self.stoptime.data is None:
|
||||||
self.stoptime.data = datetime.now() + timedelta(hours=1)
|
self.stoptime.data = datetime.now() + timedelta(hours=1)
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@ class Order(db.Model):
|
||||||
starttime = db.Column(db.DateTime)
|
starttime = db.Column(db.DateTime)
|
||||||
stoptime = db.Column(db.DateTime)
|
stoptime = db.Column(db.DateTime)
|
||||||
public = db.Column(db.Boolean, default=True)
|
public = db.Column(db.Boolean, default=True)
|
||||||
|
organizing_id = db.Column(db.String(64), default="")
|
||||||
|
|
||||||
items = db.relationship("OrderItem", backref="order", lazy="dynamic")
|
items = db.relationship("OrderItem", backref="order", lazy="dynamic")
|
||||||
|
|
||||||
|
@ -31,9 +32,9 @@ class Order(db.Model):
|
||||||
def __repr__(self) -> str:
|
def __repr__(self) -> str:
|
||||||
# pylint: disable=R1705
|
# pylint: disable=R1705
|
||||||
if self.location:
|
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:
|
else:
|
||||||
return "Order %d" % (self.id)
|
return "Order %d for %s" % (self.id, self.organizing_id or "None")
|
||||||
|
|
||||||
def update_from_hlds(self) -> None:
|
def update_from_hlds(self) -> None:
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -38,6 +38,11 @@
|
||||||
{{ form.location_id(class='form-control select') }}
|
{{ form.location_id(class='form-control select') }}
|
||||||
{{ util.render_form_field_errors(form.location_id) }}
|
{{ util.render_form_field_errors(form.location_id) }}
|
||||||
</div>
|
</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() %}
|
{% 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() }}">
|
<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') }}
|
{{ form.starttime.label(class='control-label') }}
|
||||||
|
|
|
@ -1,15 +1,24 @@
|
||||||
{% macro render_order(order) -%}
|
{% macro render_order(order) -%}
|
||||||
<div class="row order_row">
|
<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>
|
<h5>{{ order.location_name }}</h5>
|
||||||
<b class="amount_of_orders">{{ order.items.count() }} orders</b></p>
|
<b class="amount_of_orders">{{ order.items.count() }} orders</b></p>
|
||||||
<p class="time_data">
|
<p class="time_data">
|
||||||
|
{% if order.organizing_name %}
|
||||||
|
<p>{{order.organizing_name}}</p>
|
||||||
|
{% endif %}
|
||||||
{% if order.stoptime %}
|
{% if order.stoptime %}
|
||||||
<span><b>Closes </b>{{ order.stoptime.strftime("%H:%M") }}</span>{{ order.stoptime|countdown }}
|
<span><b>Closes </b>{{ order.stoptime.strftime("%H:%M") }}</span>{{ order.stoptime|countdown }}
|
||||||
{% else %}open{% endif %}<br />
|
{% else %}open{% endif %}<br />
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-4 col-lg-3 expand_button_wrapper">
|
<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>
|
||||||
</div>
|
</div>
|
||||||
{%- endmacro %}
|
{%- endmacro %}
|
||||||
|
|
Loading…
Reference in a new issue