def object_access_control(self, user=None, committee=None): if not user or not committee: raise ValueError('The object access control method requires ' 'both a user and a community object.') if hasattr(user, '_is_mock') and user._is_mock is True: return self.filter(is_confidential=False) elif user.is_superuser: return self.all() elif user.is_anonymous(): return self.filter(is_confidential=False) else: if 'view_confidential' in get_committee_perms(user, committee): return self.all() else: return self.filter(is_confidential=False)
def get_context_data(self, **kwargs): d = super(CommitteeProtectedMixin, self).get_context_data(**kwargs) d['cperms'] = get_committee_perms(self.request.user, self.committee) return d
def get_context_data(self, **kwargs): context = super(CommitteeMixin, self).get_context_data(**kwargs) context['committee'] = self.committee context['cperms'] = get_committee_perms(self.request.user, self.committee) return context