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 %}