예제 #1
0
 def queryset(self, request):
     #from dbgp.client import brk
     #brk(host="localhost", port=9000)            
     qs = super(OrganisationAdmin, self).queryset(request)
     opts = self.opts
     if request.user.has_perm(opts.app_label + '.' + opts.get_change_permission()):
         return qs
     elif request.user.has_perm(opts.app_label + '.' + get_rsr_limited_change_permission(opts)):
         organisation = request.user.get_profile().organisation
         return qs.filter(pk=organisation.id)
     else:
         raise PermissionDenied
예제 #2
0
 def queryset(self, request):
     """
     Return a queryset possibly filtered depending on current user's group(s)
     """
     qs = super(UserProfileAdmin, self).queryset(request)
     opts = self.opts
     if request.user.has_perm(opts.app_label + '.' + opts.get_change_permission()):
         return qs
     elif request.user.has_perm(opts.app_label + '.' + get_rsr_limited_change_permission(opts)):
         organisation = request.user.get_profile().organisation
         return qs.filter(organisation=organisation)
     else:
         raise PermissionDenied
예제 #3
0
 def queryset(self, request):
     #from dbgp.client import brk
     #brk(host="localhost", port=9000)
     qs = super(OrganisationAdmin, self).queryset(request)
     opts = self.opts
     if request.user.has_perm(opts.app_label + '.' +
                              opts.get_change_permission()):
         return qs
     elif request.user.has_perm(opts.app_label + '.' +
                                get_rsr_limited_change_permission(opts)):
         organisation = request.user.get_profile().organisation
         return qs.filter(pk=organisation.id)
     else:
         raise PermissionDenied
예제 #4
0
 def queryset(self, request):
     """
     Return a queryset possibly filtered depending on current user's group(s)
     """
     qs = super(ProjectAdmin, self).queryset(request)
     opts = self.opts
     if request.user.has_perm(opts.app_label + '.' + opts.get_change_permission()):
         return qs
     elif request.user.has_perm(opts.app_label + '.' + get_rsr_limited_change_permission(opts)):
         projects = request.user.get_profile().organisation.all_projects()
         #projects = get_model('rsr', 'organisation').projects.filter(pk__in=[request.user.get_profile().organisation.pk])
         return qs.filter(pk__in=projects)
     else:
         raise PermissionDenied
예제 #5
0
 def queryset(self, request):
     """
     Return a queryset possibly filtered depending on current user's group(s)
     """
     qs = super(UserProfileAdmin, self).queryset(request)
     opts = self.opts
     if request.user.has_perm(opts.app_label + '.' +
                              opts.get_change_permission()):
         return qs
     elif request.user.has_perm(opts.app_label + '.' +
                                get_rsr_limited_change_permission(opts)):
         organisation = request.user.get_profile().organisation
         return qs.filter(organisation=organisation)
     else:
         raise PermissionDenied
예제 #6
0
 def queryset(self, request):
     """
     Return a queryset possibly filtered depending on current user's group(s)
     """
     qs = super(ProjectAdmin, self).queryset(request)
     opts = self.opts
     if request.user.has_perm(opts.app_label + '.' +
                              opts.get_change_permission()):
         return qs
     elif request.user.has_perm(opts.app_label + '.' +
                                get_rsr_limited_change_permission(opts)):
         projects = request.user.get_profile().organisation.all_projects()
         #projects = get_model('rsr', 'organisation').projects.filter(pk__in=[request.user.get_profile().organisation.pk])
         return qs.filter(pk__in=projects)
     else:
         raise PermissionDenied
예제 #7
0
    def has_change_permission(self, request, obj=None):
        """
        Returns True if the given request has permission to change the given
        Django model instance.
        
        If `obj` is None, this should return True if the given request has
        permission to change *any* object of the given type.

        get_rsr_limited_change_permission is used for  partner orgs to limit their listing and editing to
        "own" projects, organisation and user profiles
        """
        opts = self.opts
        if request.user.has_perm(opts.app_label + '.' + opts.get_change_permission()):
            return True
        if request.user.has_perm(opts.app_label + '.' + get_rsr_limited_change_permission(opts)):
            if obj:
                return obj == request.user.get_profile().organisation
            else:
                return True
        return False
예제 #8
0
    def has_change_permission(self, request, obj=None):
        """
        Returns True if the given request has permission to change the given
        Django model instance.
        
        If `obj` is None, this should return True if the given request has
        permission to change *any* object of the given type.

        get_rsr_limited_change_permission is used for  partner orgs to limit their listing and editing to
        "own" projects, organisation and user profiles
        """
        opts = self.opts
        if request.user.has_perm(opts.app_label + '.' +
                                 opts.get_change_permission()):
            return True
        if request.user.has_perm(opts.app_label + '.' +
                                 get_rsr_limited_change_permission(opts)):
            if obj:
                return obj == request.user.get_profile().organisation
            else:
                return True
        return False