view for data wipe
This commit is contained in:
parent
8b467b95c3
commit
94604dd029
|
@ -9,7 +9,7 @@ from ereuse_devicehub.inventory.forms import (AllocateForm, LotDeviceForm,
|
||||||
LotForm, NewActionForm,
|
LotForm, NewActionForm,
|
||||||
NewDeviceForm, TagDeviceForm,
|
NewDeviceForm, TagDeviceForm,
|
||||||
TagForm, TagUnnamedForm,
|
TagForm, TagUnnamedForm,
|
||||||
UploadSnapshotForm)
|
UploadSnapshotForm, DataWipeForm)
|
||||||
from ereuse_devicehub.resources.device.models import Device
|
from ereuse_devicehub.resources.device.models import Device
|
||||||
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
|
||||||
|
@ -37,6 +37,7 @@ class DeviceListMix(View):
|
||||||
devices = sorted(devices, key=lambda x: x.updated, reverse=True)
|
devices = sorted(devices, key=lambda x: x.updated, reverse=True)
|
||||||
form_new_action = NewActionForm(lot=lot.id)
|
form_new_action = NewActionForm(lot=lot.id)
|
||||||
form_new_allocate = AllocateForm(lot=lot.id)
|
form_new_allocate = AllocateForm(lot=lot.id)
|
||||||
|
form_new_datawipe = DataWipeForm(lot=lot.id)
|
||||||
else:
|
else:
|
||||||
devices = Device.query.filter(
|
devices = Device.query.filter(
|
||||||
Device.owner_id == current_user.id).filter(
|
Device.owner_id == current_user.id).filter(
|
||||||
|
@ -44,6 +45,7 @@ class DeviceListMix(View):
|
||||||
Device.updated.desc())
|
Device.updated.desc())
|
||||||
form_new_action = NewActionForm()
|
form_new_action = NewActionForm()
|
||||||
form_new_allocate = AllocateForm()
|
form_new_allocate = AllocateForm()
|
||||||
|
form_new_datawipe = DataWipeForm()
|
||||||
|
|
||||||
action_devices = form_new_action.devices.data
|
action_devices = form_new_action.devices.data
|
||||||
list_devices = []
|
list_devices = []
|
||||||
|
@ -57,6 +59,7 @@ class DeviceListMix(View):
|
||||||
'form_tag_device': TagDeviceForm(),
|
'form_tag_device': TagDeviceForm(),
|
||||||
'form_new_action': form_new_action,
|
'form_new_action': form_new_action,
|
||||||
'form_new_allocate': form_new_allocate,
|
'form_new_allocate': form_new_allocate,
|
||||||
|
'form_new_datawipe': form_new_datawipe,
|
||||||
'lot': lot,
|
'lot': lot,
|
||||||
'tags': tags,
|
'tags': tags,
|
||||||
'list_devices': list_devices
|
'list_devices': list_devices
|
||||||
|
@ -310,25 +313,35 @@ class NewAllocateView(NewActionView, DeviceListMix):
|
||||||
methods = ['POST']
|
methods = ['POST']
|
||||||
_form = AllocateForm
|
_form = AllocateForm
|
||||||
|
|
||||||
def dispatch_request(self, lot_id=None):
|
def dispatch_request(self):
|
||||||
self.form = self._form()
|
|
||||||
|
|
||||||
next_url = url_for('inventory.devices.devicelist')
|
|
||||||
lot_id = self.form.lot.data
|
lot_id = self.form.lot.data
|
||||||
if lot_id:
|
dispatch = super().dispatch_request()
|
||||||
next_url = url_for('inventory.devices.lotdevicelist', lot_id=lot_id)
|
if dispatch:
|
||||||
|
return dispatch
|
||||||
if self.form.validate_on_submit():
|
|
||||||
self.form.save()
|
|
||||||
return flask.redirect(next_url)
|
|
||||||
|
|
||||||
self.get_context(lot_id)
|
self.get_context(lot_id)
|
||||||
self.context['form_new_allocate'] = self.form
|
self.context['form_new_allocate'] = self.form
|
||||||
return flask.render_template(self.template_name, **self.context)
|
return flask.render_template(self.template_name, **self.context)
|
||||||
|
|
||||||
|
|
||||||
|
class NewDataWipeView(NewActionView, DeviceListMix):
|
||||||
|
methods = ['POST']
|
||||||
|
_form = DataWipeForm
|
||||||
|
|
||||||
|
def dispatch_request(self):
|
||||||
|
dispatch = super().dispatch_request()
|
||||||
|
if dispatch:
|
||||||
|
return dispatch
|
||||||
|
|
||||||
|
lot_id = self.form.lot.data
|
||||||
|
self.get_context(lot_id)
|
||||||
|
self.context['form_new_datawipe'] = self.form
|
||||||
|
return flask.render_template(self.template_name, **self.context)
|
||||||
|
|
||||||
|
|
||||||
devices.add_url_rule('/action/add/', view_func=NewActionView.as_view('action_add'))
|
devices.add_url_rule('/action/add/', view_func=NewActionView.as_view('action_add'))
|
||||||
devices.add_url_rule('/action/allocate/add/', view_func=NewAllocateView.as_view('allocate_add'))
|
devices.add_url_rule('/action/allocate/add/', view_func=NewAllocateView.as_view('allocate_add'))
|
||||||
|
devices.add_url_rule('/action/datawipe/add/', view_func=NewDataWipeView.as_view('datawipe_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('/device/<string:id>/', view_func=DeviceDetailView.as_view('device_details'))
|
devices.add_url_rule('/device/<string:id>/', view_func=DeviceDetailView.as_view('device_details'))
|
||||||
devices.add_url_rule('/lot/<string:lot_id>/device/', view_func=DeviceListView.as_view('lotdevicelist'))
|
devices.add_url_rule('/lot/<string:lot_id>/device/', view_func=DeviceListView.as_view('lotdevicelist'))
|
||||||
|
|
Reference in New Issue