diff --git a/app/forms.py b/app/forms.py index e75893a..b40a1ee 100644 --- a/app/forms.py +++ b/app/forms.py @@ -14,7 +14,7 @@ from utils import euro_string class OrderForm(Form): "Class which defines the form for a new Order" # pylint: disable=R0903 - courrier_id = SelectField("Courrier", coerce=int) + courier_id = SelectField("Courier", coerce=int) location_id = SelectField( "Location", coerce=int, validators=[validators.required()] ) @@ -25,13 +25,13 @@ class OrderForm(Form): submit_button = SubmitField("Submit") def populate(self) -> None: - "Fill in the options for courrier for an Order" + "Fill in the options for courier for an Order" if current_user.is_admin(): - self.courrier_id.choices = [(0, None)] + [ + self.courier_id.choices = [(0, None)] + [ (u.id, u.username) for u in User.query.order_by("username") ] else: - self.courrier_id.choices = [ + self.courier_id.choices = [ (0, None), (current_user.id, current_user.username), ] diff --git a/app/models/order.py b/app/models/order.py index 1be6106..17309f4 100644 --- a/app/models/order.py +++ b/app/models/order.py @@ -10,18 +10,18 @@ from .user import User class Order(db.Model): "Class used for configuring the Order model in the database" id = db.Column(db.Integer, primary_key=True) - courrier_id = db.Column(db.Integer, nullable=True) + courier_id = db.Column(db.Integer, nullable=True) location_id = db.Column(db.Integer, db.ForeignKey("location.id")) starttime = db.Column(db.DateTime) stoptime = db.Column(db.DateTime) public = db.Column(db.Boolean, default=True) items = db.relationship("OrderItem", backref="order", lazy="dynamic") - def configure(self, courrier: User, location: Location, + def configure(self, courier: User, location: Location, starttime: db.DateTime, stoptime: db.DateTime,) -> None: "Configure the Order" # pylint: disable=W0201 - self.courrier = courrier + self.courier = courier self.location = location self.starttime = starttime self.stoptime = stoptime @@ -69,6 +69,6 @@ class Order(db.Model): if user_id: user = User.query.filter_by(id=user_id).first() print(user) - if self.courrier_id == user_id or (user and user.is_admin()): + if self.courier_id == user_id or (user and user.is_admin()): return True return False diff --git a/app/models/orderitem.py b/app/models/orderitem.py index 06b62c1..9850783 100644 --- a/app/models/orderitem.py +++ b/app/models/orderitem.py @@ -56,6 +56,6 @@ class OrderItem(db.Model): if user_id is None: return False user = User.query.filter(User.id == user_id).first() - if user and (user.is_admin() or user == self.order.courrier): + if user and (user.is_admin() or user == self.order.courier): return True return False diff --git a/app/models/user.py b/app/models/user.py index 463075e..35596d1 100644 --- a/app/models/user.py +++ b/app/models/user.py @@ -10,9 +10,9 @@ class User(db.Model): bias = db.Column(db.Integer) runs = db.relation( "Order", - backref="courrier", - primaryjoin="Order.courrier_id==User.id", - foreign_keys="Order.courrier_id", + backref="courier", + primaryjoin="Order.courier_id==User.id", + foreign_keys="Order.courier_id", ) orderItems = db.relationship("OrderItem", backref="user", lazy="dynamic") diff --git a/app/notification.py b/app/notification.py index 4fe4653..023b346 100644 --- a/app/notification.py +++ b/app/notification.py @@ -15,13 +15,13 @@ def webhook_text(order_item: Order) -> typing.Optional[str]: if "Testlocation" in order_item.location.name: return None - if order_item.courrier is not None: + if order_item.courier is not None: # pylint: disable=C0301 return " {3} is going to {1}, order <{0}|here>! Deadline in {2} minutes!".format( url_for("order_bp.order_from_id", order_id=order_item.id, _external=True), order_item.location.name, remaining_minutes(order_item.stoptime), - order_item.courrier.username.title(), + order_item.courier.username.title(), ) return " New order for {}. Deadline in {} minutes. <{}|Open here.>".format( diff --git a/app/templates/order.html b/app/templates/order.html index 40066f6..6783119 100644 --- a/app/templates/order.html +++ b/app/templates/order.html @@ -1,7 +1,7 @@ {% extends "layout.html" %} {% set active_page = "orders" -%} {% set order_items = order.group_by_user() -%} -{% set courier_or_admin = not current_user.is_anonymous() and (current_user.is_admin() or current_user.id == order.courrier_id) -%} +{% set courier_or_admin = not current_user.is_anonymous() and (current_user.is_admin() or current_user.id == order.courier_id) -%} {% import "utils.html" as util %} @@ -18,8 +18,8 @@ Edit {%- endif %} - courier: {{ order.courrier.username }} - {% if order.courrier == None and not current_user.is_anonymous() %} + courier: {{ order.courier.username }} + {% if order.courier == None and not current_user.is_anonymous() %}
diff --git a/app/templates/order_edit.html b/app/templates/order_edit.html index 143903b..2f28781 100644 --- a/app/templates/order_edit.html +++ b/app/templates/order_edit.html @@ -13,10 +13,10 @@