def get_form(self, form_class=None): form = super(PositionCreateView, self).get_form(form_class=form_class) queryset = form.fields['role'].queryset queryset = queryset.filter(archived=False) if not is_admin(self.request.user): teams = official_of(self.request.user) queryset = queryset.filter(team__in=teams) form.fields['role'].queryset = queryset return form
def get_queryset(self, request): if is_admin(request.user): return super(RoleAdmin, self).get_queryset(request) else: teams = official_of(request.user) qs = Role.objects.filter(team__in=teams) ordering = self.get_ordering(request) if ordering: qs = qs.order_by(*ordering) return qs
def get_form(self, form_class=None): form = super(PositionEditView, self).get_form(form_class=form_class) queryset = form.fields['role'].queryset init = Role.objects.get(pk=form.initial['role']) if not init.archived: queryset = queryset.filter(archived=False) if not is_admin(self.request.user): teams = official_of(self.request.user) queryset = queryset.filter(team__in=teams) form.fields['role'].queryset = queryset return form
def get_queryset(self, request): if is_admin(request.user): return super(PositionAdmin, self).get_queryset(request) else: official_teams = official_of(request.user) teams = member_of(request.user) qs = Position.objects.filter( Q(role__team__in=official_teams) | Q(approval_committee__in=teams) ) ordering = self.get_ordering(request) if ordering: qs = qs.order_by(*ordering) return qs
def is_team_official(user, team): return team in official_of(user)
def is_official(user): return len(official_of(user)) > 0
def get_form(self, form_class=None): form = super(RoleEditView, self).get_form(form_class=form_class) if not is_admin(self.request.user): form.fields['team'].queryset = official_of(self.request.user) return form