Fixing test_documents.py::test_export_basic_snapshot and test_documents.py::test_export_full_snapshot

This commit is contained in:
nad 2020-08-17 15:57:27 +02:00
parent b6138f9108
commit 65ba42ada8
1 changed files with 4 additions and 4 deletions

View File

@ -22,6 +22,7 @@ from ereuse_devicehub.resources.documents.device_row import DeviceRow, StockRow
from flask import g, request from flask import g, request
class Format(enum.Enum): class Format(enum.Enum):
HTML = 'HTML' HTML = 'HTML'
PDF = 'PDF' PDF = 'PDF'
@ -107,7 +108,7 @@ class DocumentView(DeviceView):
class DevicesDocumentView(DeviceView): class DevicesDocumentView(DeviceView):
@cache(datetime.timedelta(minutes=1)) @cache(datetime.timedelta(minutes=1))
def find(self, args: dict): def find(self, args: dict):
query = self.query(args) query = (x for x in self.query(args) if x.owner_id == g.user.id)
return self.generate_post_csv(query) return self.generate_post_csv(query)
def generate_post_csv(self, query): def generate_post_csv(self, query):
@ -155,6 +156,7 @@ class DocumentDef(Resource):
SCHEMA = None SCHEMA = None
VIEW = None # We do not want to create default / documents endpoint VIEW = None # We do not want to create default / documents endpoint
AUTH = False AUTH = False
def __init__(self, app, def __init__(self, app,
import_name=__name__, import_name=__name__,
static_folder='static', static_folder='static',
@ -183,13 +185,11 @@ class DocumentDef(Resource):
devices_view = DevicesDocumentView.as_view('devicesDocumentView', devices_view = DevicesDocumentView.as_view('devicesDocumentView',
definition=self, definition=self,
auth=app.auth) auth=app.auth)
devices_view = app.auth.requires_auth(devices_view)
stock_view = StockDocumentView.as_view('stockDocumentView', definition=self) stock_view = StockDocumentView.as_view('stockDocumentView', definition=self)
stock_view = app.auth.requires_auth(stock_view) stock_view = app.auth.requires_auth(stock_view)
if self.AUTH:
devices_view = app.auth.requires_auth(devices_view)
self.add_url_rule('/devices/', defaults=d, view_func=devices_view, methods=get) self.add_url_rule('/devices/', defaults=d, view_func=devices_view, methods=get)
stock_view = StockDocumentView.as_view('stockDocumentView', definition=self, auth=app.auth) stock_view = StockDocumentView.as_view('stockDocumentView', definition=self, auth=app.auth)