fixing ereuse pdf

This commit is contained in:
Cayo Puigdefabregas 2021-12-21 09:55:06 +01:00
parent ba7136dc60
commit 4acd03e714
1 changed files with 24 additions and 17 deletions

View File

@ -61,23 +61,29 @@ class DocumentView(DeviceView):
args = self.QUERY_PARSER.parse(self.find_args, args = self.QUERY_PARSER.parse(self.find_args,
flask.request, flask.request,
locations=('querystring',)) locations=('querystring',))
if id: ids = []
# todo we assume we can pass both device id and action id if 'filter' in request.args:
# for certificates... how is it going to end up being? filters = json.loads(request.args.get('filter', {}))
try: ids = filters.get('ids', [])
id = uuid.UUID(id) query = devs.Device.query.filter(Device.id.in_(ids))
except ValueError:
try: # if id:
id = int(id) # # todo we assume we can pass both device id and action id
except ValueError: # # for certificates... how is it going to end up being?
raise teal.marshmallow.ValidationError('Document must be an ID or UUID.') # try:
else: # id = uuid.UUID(id)
query = devs.Device.query.filter_by(id=id) # except ValueError:
else: # try:
query = evs.Action.query.filter_by(id=id) # id = int(id)
else: # except ValueError:
flask.current_app.auth.requires_auth(lambda: None)() # todo not nice # raise teal.marshmallow.ValidationError('Document must be an ID or UUID.')
query = self.query(args) # else:
# query = devs.Device.query.filter_by(id=id)
# else:
# query = evs.Action.query.filter_by(id=id)
# else:
# flask.current_app.auth.requires_auth(lambda: None)() # todo not nice
# query = self.query(args)
type = urlutils.URL(flask.request.url).path_parts[-2] type = urlutils.URL(flask.request.url).path_parts[-2]
if type == 'erasures': if type == 'erasures':
@ -93,6 +99,7 @@ class DocumentView(DeviceView):
@staticmethod @staticmethod
def erasure(query: db.Query): def erasure(query: db.Query):
# import pdb; pdb.set_trace()
def erasures(): def erasures():
for model in query: for model in query:
if isinstance(model, devs.Computer): if isinstance(model, devs.Computer):