Exemple #1
0
    def post(self, request, repo_id):
        repo = get_repo(repo_id)
        resp = check_repo_access_permission(request, repo)
        if resp:
            return resp

        path = request.GET.get('p', None)
        if not path:
            return api_error(request, '413', 'Path needed')

        op = request.GET.get('op', 'sendsharelink')
        if op == 'sendsharelink':
            emails = request.POST.get('email', None)
            if not emails:
                return api_error(request, '400', "Email required")
            return send_share_link(request, path, emails)
        elif op == 'star':
            org_id = int(request.GET.get('org', '-1'))
            star_file(request.user.username, repo_id, path, False, org_id=org_id)
            return HttpResponse(json.dumps('success'), status=200,
                                content_type=json_content_type)
        elif op == 'unstar':
            unstar_file(request.user.username, repo_id, path)
            return HttpResponse(json.dumps('success'), status=200,
                                content_type=json_content_type)
        return api_error(request, '415')
Exemple #2
0
    def delete(self, request, format=None):
        # remove starred file
        repo_id = request.GET.get('repo_id', '')
        path = request.GET.get('p', '')
        if not (repo_id and path):
            return api_error(status.HTTP_400_BAD_REQUEST,
                             'Repo_id or path is missing.')

        if path[-1] == '/':  # Should not contain '/' at the end of path.
            return api_error(status.HTTP_400_BAD_REQUEST, 'Invalid file path.')

        unstar_file(request.user.username, repo_id, path)
        return Response('success', status=status.HTTP_200_OK)
Exemple #3
0
    def delete(self, request, format=None):
        # remove starred file
        repo_id = request.GET.get('repo_id', '')
        path = request.GET.get('p', '')
        if not (repo_id and path):
            return api_error(status.HTTP_400_BAD_REQUEST,
                             'Repo_id or path is missing.')

        if path[-1] == '/':     # Should not contain '/' at the end of path.
            return api_error(status.HTTP_400_BAD_REQUEST, 'Invalid file path.')
        
        unstar_file(request.user.username, repo_id, path)
        return Response('success', status=status.HTTP_200_OK)