resolve conflict

This commit is contained in:
Cayo Puigdefabregas 2022-02-25 12:56:01 +01:00
commit 71d30548cc
3 changed files with 67 additions and 35 deletions

View File

@ -10,14 +10,29 @@ from werkzeug.exceptions import NotFound
from ereuse_devicehub import messages from ereuse_devicehub import messages
from ereuse_devicehub.inventory.forms import ( from ereuse_devicehub.inventory.forms import (
AllocateForm, DataWipeForm, LotDeviceForm, LotForm, NewActionForm, AllocateForm,
NewDeviceForm, TagDeviceForm, TagForm, TagUnnamedForm, TradeDocumentForm, DataWipeForm,
TradeForm, UploadSnapshotForm) LotDeviceForm,
LotForm,
NewActionForm,
NewDeviceForm,
TagDeviceForm,
TagForm,
TagUnnamedForm,
TradeDocumentForm,
TradeForm,
UploadSnapshotForm
)
from ereuse_devicehub.resources.action.models import Trade from ereuse_devicehub.resources.action.models import Trade
from ereuse_devicehub.resources.device.models import ( from ereuse_devicehub.resources.device.models import (
Computer, DataStorage, Device) Computer,
DataStorage,
Device
)
from ereuse_devicehub.resources.documents.device_row import ( from ereuse_devicehub.resources.documents.device_row import (
ActionRow, DeviceRow) ActionRow,
DeviceRow
)
from ereuse_devicehub.resources.hash_reports import insert_hash from ereuse_devicehub.resources.hash_reports import insert_hash
from ereuse_devicehub.resources.lot.models import Lot from ereuse_devicehub.resources.lot.models import Lot
from ereuse_devicehub.resources.tag.model import Tag from ereuse_devicehub.resources.tag.model import Tag
@ -38,7 +53,7 @@ class DeviceListMix(View):
lot = None lot = None
tags = ( tags = (
Tag.query.filter(Tag.owner_id == current_user.id) Tag.query.filter(Tag.owner_id == current_user.id)
.filter_by(device_id=None) .filter(Tag.device_id.is_(None))
.order_by(Tag.created.desc()) .order_by(Tag.created.desc())
) )
@ -155,9 +170,8 @@ class LotCreateView(View):
return flask.redirect(next_url) return flask.redirect(next_url)
lots = Lot.query.filter(Lot.owner_id == current_user.id) lots = Lot.query.filter(Lot.owner_id == current_user.id)
return flask.render_template( context = {'form': form, 'title': self.title, 'lots': lots}
self.template_name, form=form, title=self.title, lots=lots return flask.render_template(self.template_name, **context)
)
class LotUpdateView(View): class LotUpdateView(View):
@ -174,9 +188,8 @@ class LotUpdateView(View):
return flask.redirect(next_url) return flask.redirect(next_url)
lots = Lot.query.filter(Lot.owner_id == current_user.id) lots = Lot.query.filter(Lot.owner_id == current_user.id)
return flask.render_template( context = {'form': form, 'title': self.title, 'lots': lots}
self.template_name, form=form, title=self.title, lots=lots return flask.render_template(self.template_name, **context)
)
class LotDeleteView(View): class LotDeleteView(View):
@ -197,15 +210,13 @@ class UploadSnapshotView(View):
template_name = 'inventory/upload_snapshot.html' template_name = 'inventory/upload_snapshot.html'
def dispatch_request(self): def dispatch_request(self):
context = {'page_title': 'Upload Snapshot'}
lots = Lot.query.filter(Lot.owner_id == current_user.id).all() lots = Lot.query.filter(Lot.owner_id == current_user.id).all()
form = UploadSnapshotForm() form = UploadSnapshotForm()
context = {'page_title': 'Upload Snapshot', 'lots': lots, 'form': form}
if form.validate_on_submit(): if form.validate_on_submit():
form.save() form.save()
return flask.render_template( return flask.render_template(self.template_name, **context)
self.template_name, form=form, lots=lots, **context
)
class DeviceCreateView(View): class DeviceCreateView(View):
@ -214,17 +225,15 @@ class DeviceCreateView(View):
template_name = 'inventory/device_create.html' template_name = 'inventory/device_create.html'
def dispatch_request(self): def dispatch_request(self):
context = {'page_title': 'New Device'}
lots = Lot.query.filter(Lot.owner_id == current_user.id).all() lots = Lot.query.filter(Lot.owner_id == current_user.id).all()
form = NewDeviceForm() form = NewDeviceForm()
context = {'page_title': 'New Device', 'lots': lots, 'form': form}
if form.validate_on_submit(): if form.validate_on_submit():
form.save() form.save()
next_url = url_for('inventory.devices.devicelist') next_url = url_for('inventory.devices.devicelist')
return flask.redirect(next_url) return flask.redirect(next_url)
return flask.render_template( return flask.render_template(self.template_name, **context)
self.template_name, form=form, lots=lots, **context
)
class TagListView(View): class TagListView(View):
@ -233,9 +242,10 @@ class TagListView(View):
template_name = 'inventory/tag_list.html' template_name = 'inventory/tag_list.html'
def dispatch_request(self): def dispatch_request(self):
lots = Lot.query.filter(Lot.owner_id == current_user.id)
tags = Tag.query.filter(Tag.owner_id == current_user.id) tags = Tag.query.filter(Tag.owner_id == current_user.id)
context = { context = {
'lots': [], 'lots': lots,
'tags': tags, 'tags': tags,
'page_title': 'Tags Management', 'page_title': 'Tags Management',
} }
@ -248,7 +258,8 @@ class TagAddView(View):
template_name = 'inventory/tag_create.html' template_name = 'inventory/tag_create.html'
def dispatch_request(self): def dispatch_request(self):
context = {'page_title': 'New Tag'} lots = Lot.query.filter(Lot.owner_id == current_user.id)
context = {'page_title': 'New Tag', 'lots': lots}
form = TagForm() form = TagForm()
if form.validate_on_submit(): if form.validate_on_submit():
form.save() form.save()
@ -264,7 +275,8 @@ class TagAddUnnamedView(View):
template_name = 'inventory/tag_create_unnamed.html' template_name = 'inventory/tag_create_unnamed.html'
def dispatch_request(self): def dispatch_request(self):
context = {'page_title': 'New Unnamed Tag'} lots = Lot.query.filter(Lot.owner_id == current_user.id)
context = {'page_title': 'New Unnamed Tag', 'lots': lots}
form = TagUnnamedForm() form = TagUnnamedForm()
if form.validate_on_submit(): if form.validate_on_submit():
form.save() form.save()
@ -311,6 +323,7 @@ class TagUnlinkDeviceView(View):
template_name = 'inventory/tag_unlink_device.html' template_name = 'inventory/tag_unlink_device.html'
def dispatch_request(self, id): def dispatch_request(self, id):
lots = Lot.query.filter(Lot.owner_id == current_user.id)
form = TagDeviceForm(delete=True, device=id) form = TagDeviceForm(delete=True, device=id)
if form.validate_on_submit(): if form.validate_on_submit():
form.remove() form.remove()
@ -319,7 +332,7 @@ class TagUnlinkDeviceView(View):
return flask.redirect(next_url) return flask.redirect(next_url)
return flask.render_template( return flask.render_template(
self.template_name, form=form, referrer=request.referrer self.template_name, form=form, lots=lots, referrer=request.referrer
) )

View File

@ -5,7 +5,7 @@
<header id="header" class="header fixed-top d-flex align-items-center"> <header id="header" class="header fixed-top d-flex align-items-center">
<div class="d-flex align-items-center justify-content-between"> <div class="d-flex align-items-center justify-content-between">
<a href="index.html" class="logo d-flex align-items-center"> <a href="{{ url_for('inventory.devices.devicelist')}}" class="logo d-flex align-items-center">
<img src="{{ url_for('static', filename='img/usody-logo-black.svg') }}" alt=""> <img src="{{ url_for('static', filename='img/usody-logo-black.svg') }}" alt="">
</a> </a>
<i class="bi bi-list toggle-sidebar-btn"></i> <i class="bi bi-list toggle-sidebar-btn"></i>
@ -81,7 +81,7 @@
<aside id="sidebar" class="sidebar"> <aside id="sidebar" class="sidebar">
<ul class="sidebar-nav" id="sidebar-nav"> <ul class="sidebar-nav" id="sidebar-nav">
<!-- We need defined before the Dashboard
<li class="nav-item"> <li class="nav-item">
<a class="nav-link collapsed" href="index.html"> <a class="nav-link collapsed" href="index.html">
<i class="bi bi-grid"></i> <i class="bi bi-grid"></i>
@ -99,10 +99,18 @@
<li class="nav-heading">Lots</li> <li class="nav-heading">Lots</li>
<li class="nav-item"> <li class="nav-item">
{% if lot and lot.is_incoming %}
<a class="nav-link" data-bs-target="#incoming-lots-nav" data-bs-toggle="collapse" href="#">
{% else %}
<a class="nav-link collapsed" data-bs-target="#incoming-lots-nav" data-bs-toggle="collapse" href="#"> <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 Lots</span><i class="bi bi-chevron-down ms-auto"></i>
</a> </a>
{% if lot and lot.is_incoming %}
<ul id="incoming-lots-nav" class="nav-content collapse show" data-bs-parent="#sidebar-nav">
{% else %}
<ul id="incoming-lots-nav" class="nav-content collapse" data-bs-parent="#sidebar-nav"> <ul id="incoming-lots-nav" class="nav-content collapse" data-bs-parent="#sidebar-nav">
{% endif %}
{% for lot in lots %} {% for lot in lots %}
{% if lot.is_incoming %} {% if lot.is_incoming %}
<li> <li>
@ -116,10 +124,18 @@
</li><!-- End Incoming Lots Nav --> </li><!-- End Incoming Lots Nav -->
<li class="nav-item"> <li class="nav-item">
{% if lot and lot.is_outgoing %}
<a class="nav-link" data-bs-target="#outgoing-lots-nav" data-bs-toggle="collapse" href="#">
{% else %}
<a class="nav-link collapsed" data-bs-target="#outgoing-lots-nav" data-bs-toggle="collapse" href="#"> <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 Lots</span><i class="bi bi-chevron-down ms-auto"></i>
</a> </a>
{% if lot and lot.is_outgoing %}
<ul id="outgoing-lots-nav" class="nav-content collapse show" data-bs-parent="#sidebar-nav">
{% else %}
<ul id="outgoing-lots-nav" class="nav-content collapse " data-bs-parent="#sidebar-nav"> <ul id="outgoing-lots-nav" class="nav-content collapse " data-bs-parent="#sidebar-nav">
{% endif %}
{% for lot in lots %} {% for lot in lots %}
{% if lot.is_outgoing %} {% if lot.is_outgoing %}
<li> <li>
@ -133,10 +149,18 @@
</li><!-- End Outgoing Lots Nav --> </li><!-- End Outgoing Lots Nav -->
<li class="nav-item"> <li class="nav-item">
<a class="nav-link collapsed" data-bs-target="#temporal-lots-nav" data-bs-toggle="collapse" href="#"> {% if lot and lot.is_temporary %}
<a class="nav-link" data-bs-target="#temporal-lots-nav" data-bs-toggle="collapse" href="#">
{% 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 class="bi bi-chevron-down ms-auto"></i> <i class="bi bi-layout-text-window-reverse"></i><span>Temporary Lots</span><i class="bi bi-chevron-down ms-auto"></i>
</a> </a>
{% if lot and lot.is_temporary %}
<ul id="temporal-lots-nav" class="nav-content collapse show" data-bs-parent="#sidebar-nav">
{% else %}
<ul id="temporal-lots-nav" class="nav-content collapse " data-bs-parent="#sidebar-nav"> <ul id="temporal-lots-nav" class="nav-content collapse " data-bs-parent="#sidebar-nav">
{% endif %}
<li> <li>
<a href="{{ url_for('inventory.devices.lot_add')}}"> <a href="{{ url_for('inventory.devices.lot_add')}}">
<i class="bi bi-plus" style="font-size: larger;"></i><span>New temporary lot</span> <i class="bi bi-plus" style="font-size: larger;"></i><span>New temporary lot</span>
@ -163,13 +187,6 @@
</a> </a>
</li><!-- End Tags Page Nav --> </li><!-- End Tags Page Nav -->
<li class="nav-item">
<a class="nav-link collapsed" href="{{ url_for('Document.StampsView') }}">
<i class="bi bi-pin-map-fill"></i>
<span>Stamp</span>
</a>
</li><!-- End Stamp Page Nav -->
</ul> </ul>
</aside><!-- End Sidebar--> </aside><!-- End Sidebar-->

View File

@ -28,7 +28,9 @@ class LoginView(View):
if not is_safe_url(flask.request, next_url): if not is_safe_url(flask.request, next_url):
return flask.abort(400) return flask.abort(400)
return flask.redirect(next_url or flask.url_for('core.user-profile')) return flask.redirect(
next_url or flask.url_for('inventory.devices.devicelist')
)
return flask.render_template('ereuse_devicehub/user_login.html', form=form) return flask.render_template('ereuse_devicehub/user_login.html', form=form)