From 715702658f1c805baaee011ec22e1f444bd886c7 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Thu, 30 Dec 2021 19:46:34 +0100 Subject: [PATCH] adding the lots in the correct section --- ereuse_devicehub/resources/lot/models.py | 13 +++++++ .../templates/ereuse_devicehub/base_site.html | 39 +++++++++---------- 2 files changed, 31 insertions(+), 21 deletions(-) diff --git a/ereuse_devicehub/resources/lot/models.py b/ereuse_devicehub/resources/lot/models.py index 9699c969..8833412c 100644 --- a/ereuse_devicehub/resources/lot/models.py +++ b/ereuse_devicehub/resources/lot/models.py @@ -5,6 +5,7 @@ from typing import Union from boltons import urlutils from citext import CIText from flask import g +from flask_login import current_user from sqlalchemy import TEXT from sqlalchemy.dialects.postgresql import UUID from sqlalchemy_utils import LtreeType @@ -103,6 +104,18 @@ class Lot(Thing): def is_temporary(self): return False if self.trade else True + @property + def is_incominig(self): + if self.trade and self.trade.user_to == current_user: + return True + return False + + @property + def is_outgoing(self): + if self.trade and self.trade.user_from == current_user: + return True + return False + @classmethod def descendantsq(cls, id): _id = UUIDLtree.convert(id) diff --git a/ereuse_devicehub/templates/ereuse_devicehub/base_site.html b/ereuse_devicehub/templates/ereuse_devicehub/base_site.html index f233903d..9db77874 100644 --- a/ereuse_devicehub/templates/ereuse_devicehub/base_site.html +++ b/ereuse_devicehub/templates/ereuse_devicehub/base_site.html @@ -255,16 +255,15 @@ Incoming Lots @@ -273,16 +272,15 @@ Outgoing Lots @@ -296,16 +294,15 @@ New temporal lot + {% for lot in lots %} + {% if lot.is_temporary %}
  • - - Temporal lot #1 - -
  • -
  • - - Temporal lot #2 + + {{ lot.name }}
  • + {% endif %} + {% endfor %}