mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-19 10:26:17 +00:00
Fix code styles
This commit is contained in:
@@ -116,7 +116,7 @@ class Ping(APIView):
|
|||||||
"""
|
"""
|
||||||
Returns a simple `pong` message when client calls `api2/ping/`.
|
Returns a simple `pong` message when client calls `api2/ping/`.
|
||||||
For example:
|
For example:
|
||||||
curl http://127.0.0.1:8000/api2/ping/
|
curl http://127.0.0.1:8000/api2/ping/
|
||||||
"""
|
"""
|
||||||
def get(self, request, format=None):
|
def get(self, request, format=None):
|
||||||
return Response('pong')
|
return Response('pong')
|
||||||
@@ -128,7 +128,7 @@ class AuthPing(APIView):
|
|||||||
"""
|
"""
|
||||||
Returns a simple `pong` message when client provided an auth token.
|
Returns a simple `pong` message when client provided an auth token.
|
||||||
For example:
|
For example:
|
||||||
curl -H "Authorization: Token 9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b" http://127.0.0.1:8000/api2/auth/ping/
|
curl -H "Authorization: Token 9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b" http://127.0.0.1:8000/api2/auth/ping/
|
||||||
"""
|
"""
|
||||||
authentication_classes = (TokenAuthentication, )
|
authentication_classes = (TokenAuthentication, )
|
||||||
permission_classes = (IsAuthenticated,)
|
permission_classes = (IsAuthenticated,)
|
||||||
@@ -141,7 +141,7 @@ class ObtainAuthToken(APIView):
|
|||||||
"""
|
"""
|
||||||
Returns auth token if username and password are valid.
|
Returns auth token if username and password are valid.
|
||||||
For example:
|
For example:
|
||||||
curl -d "username=foo@example.com&password=123456" http://127.0.0.1:8000/api2/auth-token/
|
curl -d "username=foo@example.com&password=123456" http://127.0.0.1:8000/api2/auth-token/
|
||||||
"""
|
"""
|
||||||
throttle_classes = (AnonRateThrottle, )
|
throttle_classes = (AnonRateThrottle, )
|
||||||
permission_classes = ()
|
permission_classes = ()
|
||||||
@@ -699,8 +699,8 @@ class Repo(APIView):
|
|||||||
username = request.user.username
|
username = request.user.username
|
||||||
repo = seafile_api.get_repo(repo_id)
|
repo = seafile_api.get_repo(repo_id)
|
||||||
if not repo:
|
if not repo:
|
||||||
return api_error(status.HTTP_400_BAD_REQUEST, \
|
return api_error(status.HTTP_400_BAD_REQUEST,
|
||||||
'Library does not exist.')
|
'Library does not exist.')
|
||||||
|
|
||||||
# check permission
|
# check permission
|
||||||
if is_org_context(request):
|
if is_org_context(request):
|
||||||
@@ -1919,13 +1919,13 @@ class BeShared(APIView):
|
|||||||
|
|
||||||
joined_groups = get_personal_groups_by_user(username)
|
joined_groups = get_personal_groups_by_user(username)
|
||||||
for grp in joined_groups:
|
for grp in joined_groups:
|
||||||
# Get group repos, and for each group repos...
|
# Get group repos, and for each group repos...
|
||||||
for r_id in get_group_repoids(grp.id):
|
for r_id in get_group_repoids(grp.id):
|
||||||
# No need to list my own repo
|
# No need to list my own repo
|
||||||
if seafile_api.is_repo_owner(username, r_id):
|
if seafile_api.is_repo_owner(username, r_id):
|
||||||
continue
|
continue
|
||||||
# Convert repo properties due to the different collumns in Repo
|
# Convert repo properties due to the different collumns in Repo
|
||||||
# and SharedRepo
|
# and SharedRepo
|
||||||
r = get_repo(r_id)
|
r = get_repo(r_id)
|
||||||
if not r:
|
if not r:
|
||||||
continue
|
continue
|
||||||
@@ -2055,9 +2055,7 @@ class PrivateSharedFileView(APIView):
|
|||||||
return get_repo_file(request, repo_id, file_id, file_name, op)
|
return get_repo_file(request, repo_id, file_id, file_name, op)
|
||||||
|
|
||||||
class SharedFileView(APIView):
|
class SharedFileView(APIView):
|
||||||
# Anyone should be able to access a Shared File assuming they have the token
|
# Anyone should be able to access a Shared File assuming they have the token
|
||||||
# authentication_classes = (TokenAuthentication, )
|
|
||||||
# permission_classes = (IsAuthenticated,)
|
|
||||||
throttle_classes = (UserRateThrottle, )
|
throttle_classes = (UserRateThrottle, )
|
||||||
|
|
||||||
def get(self, request, token, format=None):
|
def get(self, request, token, format=None):
|
||||||
|
@@ -648,7 +648,7 @@ def copy_move_common(func):
|
|||||||
dst_repo_id = request.POST.get('dst_repo')
|
dst_repo_id = request.POST.get('dst_repo')
|
||||||
dst_path = request.POST.get('dst_path')
|
dst_path = request.POST.get('dst_path')
|
||||||
|
|
||||||
if not (path and obj_name and dst_repo_id and dst_path):
|
if not (path and obj_name and dst_repo_id and dst_path):
|
||||||
result['error'] = _('Argument missing')
|
result['error'] = _('Argument missing')
|
||||||
return HttpResponse(json.dumps(result), status=400,
|
return HttpResponse(json.dumps(result), status=400,
|
||||||
content_type=content_type)
|
content_type=content_type)
|
||||||
@@ -1040,7 +1040,7 @@ def get_contacts(request):
|
|||||||
from seahub.avatar.templatetags.avatar_tags import avatar
|
from seahub.avatar.templatetags.avatar_tags import avatar
|
||||||
for c in contacts:
|
for c in contacts:
|
||||||
try:
|
try:
|
||||||
user = User.objects.get(email = c.contact_email)
|
user = User.objects.get(email=c.contact_email)
|
||||||
if user.is_active:
|
if user.is_active:
|
||||||
contact_list.append({"email": c.contact_email, "avatar": avatar(c.contact_email, 16)})
|
contact_list.append({"email": c.contact_email, "avatar": avatar(c.contact_email, 16)})
|
||||||
except User.DoesNotExist:
|
except User.DoesNotExist:
|
||||||
@@ -1319,7 +1319,7 @@ def set_notice_seen_by_id(request):
|
|||||||
notice_id = request.GET.get('notice_id')
|
notice_id = request.GET.get('notice_id')
|
||||||
|
|
||||||
notice = UserNotification.objects.get(id=notice_id)
|
notice = UserNotification.objects.get(id=notice_id)
|
||||||
if notice.seen == False:
|
if not notice.seen:
|
||||||
notice.seen = True
|
notice.seen = True
|
||||||
notice.save()
|
notice.save()
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user