Merge pull request #448 from eReuse/feature/4343-share-lot

Feature/4343 share lot
This commit is contained in:
cayop 2023-05-04 10:59:29 +02:00 committed by GitHub
commit b8593bd63f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 32 additions and 12 deletions

View file

@ -1323,12 +1323,18 @@ class ExportsView(View):
'Receiver Note Date',
'Receiver Note Units',
'Receiver Note Weight',
'Customer Company Name',
'Customer Location',
]
)
for lot in Lot.query.filter_by(owner=g.user):
all_lots = set(Lot.query.filter_by(owner=g.user).all())
share_lots = [s.lot for s in ShareLot.query.filter_by(user_to=g.user)]
all_lots = all_lots.union(share_lots)
for lot in all_lots:
delivery_note = lot.transfer and lot.transfer.delivery_note or ''
receiver_note = lot.transfer and lot.transfer.receiver_note or ''
customer = lot.transfer and lot.transfer.customer_details or ''
wb_devs = 0
placeholders = 0
@ -1341,10 +1347,13 @@ class ExportsView(View):
elif snapshots[-1].software in [SnapshotSoftware.Workbench]:
wb_devs += 1
type_lot = lot.type_transfer()
if lot in share_lots:
type_lot = "Shared"
row = [
lot.id,
lot.name,
lot.type_transfer(),
type_lot,
lot.transfer and (lot.transfer.closed and 'Closed' or 'Open') or '',
lot.transfer and lot.transfer.code or '',
lot.transfer and lot.transfer.date or '',
@ -1362,6 +1371,8 @@ class ExportsView(View):
receiver_note and receiver_note.date or '',
receiver_note and receiver_note.units or '',
receiver_note and receiver_note.weight or '',
customer and customer.company_name or '',
customer and customer.location or '',
]
cw.writerow(row)
@ -1391,11 +1402,14 @@ class ExportsView(View):
for dev in self.find_devices():
for lot in dev.lots:
type_lot = lot.type_transfer()
if lot.is_shared:
type_lot = "Shared"
row = [
dev.devicehub_id,
lot.id,
lot.name,
lot.type_transfer(),
type_lot,
lot.transfer and (lot.transfer.closed and 'Closed' or 'Open') or '',
lot.transfer and lot.transfer.code or '',
lot.transfer and lot.transfer.date or '',

View file

@ -193,7 +193,7 @@
{% else %}
<a class="nav-link collapsed" data-bs-target="#incoming-lots-nav" data-bs-toggle="collapse" href="#">
{% endif %}
<i class="bi bi-arrow-down-right"></i><span>Incoming Lots</span><i class="bi bi-chevron-down ms-auto"></i>
<i class="bi bi-arrow-down-right"></i><span>Incoming</span><i class="bi bi-chevron-down ms-auto"></i>
</a>
{% if lot and lot.is_incoming %}
<ul id="incoming-lots-nav" class="nav-content collapse show" data-bs-parent="#sidebar-nav">
@ -223,7 +223,7 @@
{% else %}
<a class="nav-link collapsed" data-bs-target="#outgoing-lots-nav" data-bs-toggle="collapse" href="#">
{% endif %}
<i class="bi bi-arrow-up-right"></i><span>Outgoing Lots</span><i class="bi bi-chevron-down ms-auto"></i>
<i class="bi bi-arrow-up-right"></i><span>Outgoing</span><i class="bi bi-chevron-down ms-auto"></i>
</a>
{% if lot and lot.is_outgoing %}
<ul id="outgoing-lots-nav" class="nav-content collapse show" data-bs-parent="#sidebar-nav">
@ -253,7 +253,7 @@
{% else %}
<a class="nav-link collapsed" data-bs-target="#temporal-lots-nav" data-bs-toggle="collapse" href="#">
{% endif %}
<i class="bi bi-layout-text-window-reverse"></i><span>Temporary Lots</span><i
<i class="bi bi-layout-text-window-reverse"></i><span>Temporary</span><i
class="bi bi-chevron-down ms-auto"></i>
</a>
{% if lot and lot.is_temporary %}
@ -283,7 +283,7 @@
<i class="bi bi-share-fill"></i><span>Shared with me</span><i
class="bi bi-chevron-down ms-auto"></i>
</a>
{% if lot.is_shared %}
{% if lot and lot.is_shared %}
<ul id="share-lots-nav" class="nav-content collapse show" data-bs-parent="#sidebar-nav">
{% else %}
<ul id="share-lots-nav" class="nav-content collapse " data-bs-parent="#sidebar-nav">

View file

@ -13,13 +13,13 @@
<li class="breadcrumb-item active">Unassigned</li>
{% endif %}
{% elif lot.is_temporary %}
<li class="breadcrumb-item active">Temporary Lot</li>
<li class="breadcrumb-item active">Temporary</li>
<li class="breadcrumb-item active">{{ lot.name }}</li>
{% elif lot.is_incoming %}
<li class="breadcrumb-item active">Incoming Lot</li>
<li class="breadcrumb-item active">Incoming</li>
<li class="breadcrumb-item active">{{ lot.name }}</li>
{% elif lot.is_outgoing %}
<li class="breadcrumb-item active">Outgoing Lot</li>
<li class="breadcrumb-item active">Outgoing</li>
<li class="breadcrumb-item active">{{ lot.name }}</li>
{% elif lot.is_shared %}
<li class="breadcrumb-item active">Shared with me</li>
@ -352,6 +352,12 @@
Devices Spreadsheet
</a>
</li>
<li>
<a href="javascript:export_file('devices_lots')" class="dropdown-item">
<i class="bi bi-file-spreadsheet"></i>
Devices Lots Spreadsheet
</a>
</li>
</ul>
</div>
{% endif %}

View file

@ -1,2 +1,2 @@
"Lot Id";"Lot Name";"Lot Type";"Transfer Status";"Transfer Code";"Transfer Date";"Transfer Creation Date";"Transfer Update Date";"Transfer Description";"Devices Number";"Devices Snapshots";"Devices Placeholders";"Delivery Note Number";"Delivery Note Date";"Delivery Note Units";"Delivery Note Weight";"Receiver Note Number";"Receiver Note Date";"Receiver Note Units";"Receiver Note Weight"
"d992faea-5411-4a47-9388-073d67e9ee2d";"lot1";"Temporary";"";"";"";"";"";"";"1";"1";"0";"";"";"";"";"";"";"";""
"Lot Id";"Lot Name";"Lot Type";"Transfer Status";"Transfer Code";"Transfer Date";"Transfer Creation Date";"Transfer Update Date";"Transfer Description";"Devices Number";"Devices Snapshots";"Devices Placeholders";"Delivery Note Number";"Delivery Note Date";"Delivery Note Units";"Delivery Note Weight";"Receiver Note Number";"Receiver Note Date";"Receiver Note Units";"Receiver Note Weight";"Customer Company Name";"Customer Location"
"31174349-d3a4-4bea-a8fc-aef6cc099041";"lot1";"Temporary";"";"";"";"";"";"";"1";"1";"0";"";"";"";"";"";"";"";"";"";""

1 Lot Id Lot Name Lot Type Transfer Status Transfer Code Transfer Date Transfer Creation Date Transfer Update Date Transfer Description Devices Number Devices Snapshots Devices Placeholders Delivery Note Number Delivery Note Date Delivery Note Units Delivery Note Weight Receiver Note Number Receiver Note Date Receiver Note Units Receiver Note Weight Customer Company Name Customer Location
2 d992faea-5411-4a47-9388-073d67e9ee2d 31174349-d3a4-4bea-a8fc-aef6cc099041 lot1 Temporary 1 1 0