1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-18 16:36:15 +00:00

Added RESTful file/dir api

This commit is contained in:
zhengxie
2012-12-23 22:27:16 +08:00
parent 97af71f90f
commit 6c4cf35110
5 changed files with 508 additions and 134 deletions

View File

@@ -6,12 +6,17 @@ from rest_framework.permissions import BasePermission
from seaserv import check_permission
SAFE_METHODS = ['GET', 'HEAD', 'OPTIONS']
class IsRepoWritable(BasePermission):
"""
Allows access only for users who has write permission to the repo.
"""
def has_permission(self, request, view, obj=None):
if request.method in SAFE_METHODS:
return True
repo_id = view.kwargs.get('repo_id', '')
user = request.user.username if request.user else ''