change views

This commit is contained in:
Cayo Puigdefabregas 2022-05-18 11:01:58 +02:00
parent 99309162e3
commit d9e94e66d3
2 changed files with 10 additions and 29 deletions

View File

@ -25,8 +25,8 @@ from ereuse_devicehub.inventory.forms import (
UploadSnapshotForm, UploadSnapshotForm,
) )
from ereuse_devicehub.labels.forms import PrintLabelsForm from ereuse_devicehub.labels.forms import PrintLabelsForm
from ereuse_devicehub.parser.models import SnapshotErrors from ereuse_devicehub.parser.models import SnapshotsLog
from ereuse_devicehub.resources.action.models import Snapshot, Trade from ereuse_devicehub.resources.action.models import Trade
from ereuse_devicehub.resources.device.models import Computer, DataStorage, Device from ereuse_devicehub.resources.device.models import Computer, DataStorage, Device
from ereuse_devicehub.resources.documents.device_row import ActionRow, DeviceRow from ereuse_devicehub.resources.documents.device_row import ActionRow, DeviceRow
from ereuse_devicehub.resources.hash_reports import insert_hash from ereuse_devicehub.resources.hash_reports import insert_hash
@ -513,33 +513,17 @@ class ExportsView(View):
return flask.render_template('inventory/erasure.html', **params) return flask.render_template('inventory/erasure.html', **params)
class SnapshotErrorsListView(GenericMixView): class SnapshotListView(GenericMixin):
methods = ['GET']
decorators = [login_required]
template_name = 'inventory/snapshot_errors_list.html'
def dispatch_request(self):
self.get_context()
self.context['page_title'] = "Snapshot Errors"
snapshot_errors = SnapshotErrors.query.filter(
SnapshotErrors.owner == current_user
).order_by(SnapshotErrors.created.desc())
self.context['snapshot_errors'] = snapshot_errors
return flask.render_template(self.template_name, **self.context)
class SnapshotListView(GenericMixView):
decorators = [login_required]
template_name = 'inventory/snapshots_list.html' template_name = 'inventory/snapshots_list.html'
def dispatch_request(self): def dispatch_request(self):
self.get_context() self.get_context()
snapshots = Snapshot.query.filter(Snapshot.author == current_user).order_by( self.context['page_title'] = "Snapshots Logs"
Snapshot.created.desc() snapshots_log = SnapshotsLog.query.filter(
) SnapshotsLog.owner == current_user
self.context['page_title'] = "Snapshots" ).order_by(SnapshotsLog.created.desc())
self.context['snapshots'] = snapshots self.context['snapshots_log'] = snapshots_log
return flask.render_template(self.template_name, **self.context) return flask.render_template(self.template_name, **self.context)
@ -556,10 +540,6 @@ devices.add_url_rule(
view_func=NewTradeDocumentView.as_view('trade_document_add'), view_func=NewTradeDocumentView.as_view('trade_document_add'),
) )
devices.add_url_rule('/device/', view_func=DeviceListView.as_view('devicelist')) devices.add_url_rule('/device/', view_func=DeviceListView.as_view('devicelist'))
devices.add_url_rule(
'/snapshot/errors/',
view_func=SnapshotErrorsListView.as_view('snapshot_errors_list'),
)
devices.add_url_rule( devices.add_url_rule(
'/device/<string:id>/', view_func=DeviceDetailView.as_view('device_details') '/device/<string:id>/', view_func=DeviceDetailView.as_view('device_details')
) )

View File

@ -50,6 +50,7 @@ class LogoutView(View):
class GenericMixin(View): class GenericMixin(View):
methods = ['GET']
decorators = [login_required] decorators = [login_required]
def get_lots(self): def get_lots(self):