mirror of
https://github.com/haiwen/seahub.git
synced 2025-08-31 22:54:11 +00:00
File shared link is viewd by people who generated.
This commit is contained in:
@@ -14,7 +14,7 @@ class FileShare(models.Model):
|
|||||||
"""
|
"""
|
||||||
Model used for file share link.
|
Model used for file share link.
|
||||||
"""
|
"""
|
||||||
username = models.EmailField(max_length=255)
|
username = models.EmailField(max_length=255, db_index=True)
|
||||||
repo_id = models.CharField(max_length=36, db_index=True)
|
repo_id = models.CharField(max_length=36, db_index=True)
|
||||||
path = models.TextField()
|
path = models.TextField()
|
||||||
token = models.CharField(max_length=10, unique=True)
|
token = models.CharField(max_length=10, unique=True)
|
||||||
|
16
views.py
16
views.py
@@ -796,9 +796,9 @@ def repo_view_file(request, repo_id):
|
|||||||
"""
|
"""
|
||||||
http_server_root = get_httpserver_root()
|
http_server_root = get_httpserver_root()
|
||||||
path = request.GET.get('p', '/')
|
path = request.GET.get('p', '/')
|
||||||
if path[-1] != '/':
|
if path[-1] == '/':
|
||||||
path = path + '/'
|
path = path[:-1]
|
||||||
filename = urllib2.quote(os.path.basename(path[:-1]).encode('utf-8'))
|
filename = urllib2.quote(os.path.basename(path).encode('utf-8'))
|
||||||
|
|
||||||
commit_id = request.GET.get('commit_id', '')
|
commit_id = request.GET.get('commit_id', '')
|
||||||
view_history = True if commit_id else False
|
view_history = True if commit_id else False
|
||||||
@@ -810,7 +810,7 @@ def repo_view_file(request, repo_id):
|
|||||||
obj_id = request.GET.get('obj_id', '')
|
obj_id = request.GET.get('obj_id', '')
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
obj_id = seafserv_rpc.get_file_by_path(repo_id, path[:-1])
|
obj_id = seafserv_rpc.get_file_by_path(repo_id, path)
|
||||||
except:
|
except:
|
||||||
obj_id = None
|
obj_id = None
|
||||||
|
|
||||||
@@ -854,7 +854,8 @@ def repo_view_file(request, repo_id):
|
|||||||
request.user.username)
|
request.user.username)
|
||||||
|
|
||||||
# file share link
|
# file share link
|
||||||
l = FileShare.objects.filter(repo_id=repo_id).filter(path=path[:-1])
|
l = FileShare.objects.filter(repo_id=repo_id).filter(\
|
||||||
|
username=request.user.username).filter(path=path)
|
||||||
fileshare = l[0] if len(l) > 0 else None
|
fileshare = l[0] if len(l) > 0 else None
|
||||||
|
|
||||||
http_or_https = request.is_secure() and 'https' or 'http'
|
http_or_https = request.is_secure() and 'https' or 'http'
|
||||||
@@ -940,7 +941,7 @@ def repo_file_get(request, repo_id):
|
|||||||
l, d = [], {}
|
l, d = [], {}
|
||||||
try:
|
try:
|
||||||
# XXX: file in windows is encoded in gbk
|
# XXX: file in windows is encoded in gbk
|
||||||
u_content = content.decode('gbk')
|
u_content = content.decode('gbk')
|
||||||
except:
|
except:
|
||||||
u_content = content.decode('utf-8')
|
u_content = content.decode('utf-8')
|
||||||
from django.utils.html import escape
|
from django.utils.html import escape
|
||||||
@@ -1833,7 +1834,8 @@ def get_shared_link(request):
|
|||||||
if path[-1] == '/':
|
if path[-1] == '/':
|
||||||
path = path[:-1]
|
path = path[:-1]
|
||||||
|
|
||||||
l = FileShare.objects.filter(repo_id=repo_id).filter(path=path)
|
l = FileShare.objects.filter(repo_id=repo_id).filter(\
|
||||||
|
username=request.user.username).filter(path=path)
|
||||||
if len(l) > 0:
|
if len(l) > 0:
|
||||||
fileshare = l[0]
|
fileshare = l[0]
|
||||||
token = fileshare.token
|
token = fileshare.token
|
||||||
|
Reference in New Issue
Block a user