adding the lots in the correct section

This commit is contained in:
Cayo Puigdefabregas 2021-12-30 19:46:34 +01:00
parent b7a723866b
commit 715702658f
2 changed files with 31 additions and 21 deletions

View File

@ -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)

View File

@ -255,16 +255,15 @@
<i class="bi bi-arrow-down-right"></i><span>Incoming Lots</span><i class="bi bi-chevron-down ms-auto"></i>
</a>
<ul id="incoming-lots-nav" class="nav-content collapse" data-bs-parent="#sidebar-nav">
{% for lot in lots %}
{% if lot.is_incominig %}
<li>
<a href="#TODO incoming lot #1 details">
<i class="bi bi-circle"></i><span>Incoming lot #1</span>
</a>
</li>
<li>
<a href="#TODO incoming lot #2 details">
<i class="bi bi-circle"></i><span>Incoming lot #2</span>
<a href="{{ url_for('inventory.devices.lotdevicelist', id=lot.id) }}">
<i class="bi bi-circle"></i><span>{{ lot.name }}</span>
</a>
</li>
{% endif %}
{% endfor %}
</ul>
</li><!-- End Incoming Lots Nav -->
@ -273,16 +272,15 @@
<i class="bi bi-arrow-up-right"></i><span>Outgoing Lots</span><i class="bi bi-chevron-down ms-auto"></i>
</a>
<ul id="outgoing-lots-nav" class="nav-content collapse " data-bs-parent="#sidebar-nav">
{% for lot in lots %}
{% if lot.is_outgoing %}
<li>
<a href="#TODO">
<i class="bi bi-circle"></i><span>Outgoing lot #1</span>
</a>
</li>
<li>
<a href="#TODO">
<i class="bi bi-circle"></i><span>Outgoing lot #2</span>
<a href="{{ url_for('inventory.devices.lotdevicelist', id=lot.id) }}">
<i class="bi bi-circle"></i><span>{{ lot.name }}</span>
</a>
</li>
{% endif %}
{% endfor %}
</ul>
</li><!-- End Outgoing Lots Nav -->
@ -296,16 +294,15 @@
<i class="bi bi-plus" style="font-size: larger;"></i><span>New temporal lot</span>
</a>
</li>
{% for lot in lots %}
{% if lot.is_temporary %}
<li>
<a href="#TODO">
<i class="bi bi-circle"></i><span>Temporal lot #1</span>
</a>
</li>
<li>
<a href="#TODO">
<i class="bi bi-circle"></i><span>Temporal lot #2</span>
<a href="{{ url_for('inventory.devices.lotdevicelist', id=lot.id) }}">
<i class="bi bi-circle"></i><span>{{ lot.name }}</span>
</a>
</li>
{% endif %}
{% endfor %}
</ul>
</li><!-- End Temporal Lots Nav -->