Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

external_app thumbnail #18

Merged
merged 1 commit into from
Apr 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ RUN rm -f /usr/bin/python && \
ln -s /usr/local/bin/pip3.6 /usr/bin/pip && \
ln -s /usr/local/bin/pip3.6 /usr/bin/pip3

RUN pip3 install uvicorn pillow sqlalchemy==1.4.6 pymysql future requests redis django==3.2.* \
RUN pip3 install uvicorn==0.16.0 pillow sqlalchemy==1.4.6 pymysql future requests redis django==3.2.* \
-i https://mirrors.aliyun.com/pypi/simple && rm -r /root/.cache/pip


Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
uvicorn
uvicorn==0.16.0
pillow
sqlalchemy==1.4.6
pymysql
Expand Down
12 changes: 11 additions & 1 deletion seatable_thumbnail/permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,15 @@ def set_cache_permission(self):

def has_dtable_asset_read_permission(self):
# four ways to access asset
# 1. through external link to get image
# 1. through external link or external app to get image
# 2. through collection table to get image
# 3. through dtable perm, including dtable share, dtable custom share
# 4. through view share perm

if self.can_access_image_through_external_link():
return True
if self.can_access_image_through_external_app():
return True
if self.has_collection_table_permission():
return True
if self.check_dtable_permission():
Expand All @@ -62,6 +64,14 @@ def can_access_image_through_external_link(self):

return self.external_link['dtable_uuid'] == self.dtable_uuid

def can_access_image_through_external_app(self):
if not hasattr(self, 'external_app'):
return False
if not self.external_app.get('dtable_uuid'):
return False

return self.external_app['dtable_uuid'] == self.dtable_uuid

def has_collection_table_permission(self):
if not hasattr(self, 'collection_table'):
return False
Expand Down
3 changes: 2 additions & 1 deletion seatable_thumbnail/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,11 @@ def session_check(self):
username = self.session_data.get('_auth_user_name')
external_link = self.session_data.get('external_link')
collection_table = self.session_data.get('collection_table')
external_app = self.session_data.get('external_app')
if username:
self.session_data['username'] = username

if not username and not external_link and not collection_table:
if not username and not external_link and not collection_table and not external_app:
raise AssertionError(400, 'django session invalid.')

def get_enable_file_type(self):
Expand Down