Exemple #1
0
 def has_permission(self, request, view):
     if super(IsAuthenticatedOrInternal,
              self).has_permission(request=request, view=view):
         return True
     if request.user and not request.user.is_anonymous and is_internal_user(
             request.user):
         return True
     return False
Exemple #2
0
 def get_object(self):
     project = get_permissible_project(view=self)
     repo = get_object_or_404(Repo, project=project)
     if not is_internal_user(self.request.user):
         auditor.record(event_type=REPO_DOWNLOADED,
                        instance=repo,
                        actor_id=self.request.user.id)
     return repo
Exemple #3
0
 def get_object(self):
     project = get_permissible_project(view=self)
     try:
         repo = Repo.objects.get(project=project)
     except Repo.DoesNotExist:
         raise Http404('Repo does not exist.')
     if not is_internal_user(self.request.user):
         auditor.record(event_type=REPO_DOWNLOADED, instance=repo, actor_id=self.request.user.id)
     return repo
Exemple #4
0
def check_access_project_item(view, request, project):
    internal_condition = ((IsAuthenticatedOrInternal in view.permission_classes
                           or IsInternal in view.permission_classes)
                          and is_internal_user(request.user))
    if internal_condition:
        return
    permission = IsProjectOwnerOrPublicReadOnly()
    if not permission.has_object_permission(request, view, project):
        view.permission_denied(request,
                               message=getattr(permission, 'message', None))
Exemple #5
0
 def get_object(self):
     project = get_permissible_project(view=self)
     try:
         repo = Repo.objects.get(project=project)
     except Repo.DoesNotExist:
         raise Http404('Repo does not exist.')
     if not is_internal_user(self.request.user):
         auditor.record(event_type=REPO_DOWNLOADED,
                        instance=repo,
                        actor_id=self.request.user.id)
     return repo
Exemple #6
0
def check_access_project_item(view, request, project):
    internal_condition = (
        (IsAuthenticatedOrInternal in view.permission_classes or
         IsInternal in view.permission_classes) and
        is_internal_user(request.user)
    )
    if internal_condition:
        return
    permission = IsProjectOwnerOrPublicReadOnly()
    if not permission.has_object_permission(request, view, project):
        view.permission_denied(
            request, message=getattr(permission, 'message', None)
        )
Exemple #7
0
 def has_permission(self, request, view):
     if request.user and not request.user.is_anonymous and is_internal_user(
             request.user):
         return True
     return False
Exemple #8
0
 def has_permission(self, request, view):
     if request.user and not request.user.is_anonymous and is_internal_user(request.user):
         return True
     return False
Exemple #9
0
 def has_permission(self, request, view):
     if super(IsAuthenticatedOrInternal, self).has_permission(request=request, view=view):
         return True
     if request.user and not request.user.is_anonymous and is_internal_user(request.user):
         return True
     return False