add filter as user owner

This commit is contained in:
Cayo Puigdefabregas 2020-08-06 16:51:49 +02:00
parent b90047bc4a
commit 801a8a6c4a
1 changed files with 3 additions and 2 deletions

View File

@ -10,7 +10,7 @@ import flask
import flask_weasyprint import flask_weasyprint
import teal.marshmallow import teal.marshmallow
from boltons import urlutils from boltons import urlutils
from flask import make_response from flask import make_response, g
from teal.cache import cache from teal.cache import cache
from teal.resource import Resource from teal.resource import Resource
@ -130,7 +130,7 @@ class DevicesDocumentView(DeviceView):
class StockDocumentView(DeviceView): class StockDocumentView(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):
@ -182,6 +182,7 @@ class DocumentDef(Resource):
auth=app.auth) auth=app.auth)
stock_view = StockDocumentView.as_view('stockDocumentView', definition=self) stock_view = StockDocumentView.as_view('stockDocumentView', definition=self)
stock_view = app.auth.requires_auth(stock_view)
if self.AUTH: if self.AUTH:
devices_view = app.auth.requires_auth(devices_view) devices_view = app.auth.requires_auth(devices_view)