Exemple #1
0
 def __init__(self, request, *args, **kwargs):
     super(WorkshopEditForm, self).__init__(*args, **kwargs)
     self.fields['expected_date'] = forms.DateField(
         widget=CalendarWidget, input_formats=settings.ALLOWED_DATE_FORMAT)
     self.fields['requester'].widget = forms.TextInput()
     self.fields['requester'].widget.attrs['readonly'] = True
     if RegionalLead.is_regional_lead(request.user, self.instance.location):
         self.fields['presenter'].queryset = User.objects.filter(
             profile__usertype__slug="tutor")
     else:
         del self.fields['presenter']
Exemple #2
0
 def dispatch(self, request, *args, **kwargs):
     user = request.user
     pk = self.kwargs.get(self.pk_url_kwarg, None)
     workshop = Workshop.objects.get(id=pk)
     is_admin = Profile.is_admin(user)
     is_lead = (Profile.is_regional_lead(user) and
                RegionalLead.is_regional_lead(user, workshop.location))
     is_presenter = (Profile.is_organiser(user) and
                     user in workshop.requester.user.all())
     if not (is_admin or is_lead or is_presenter):
         return HttpResponseForbidden("Not sufficent permission")
     return super(WorkshopAccessMixin, self).dispatch(request, *args, **kwargs)
Exemple #3
0
 def dispatch(self, request, *args, **kwargs):
     user = request.user
     pk = self.kwargs.get(self.pk_url_kwarg, None)
     workshop = Workshop.objects.get(id=pk)
     is_admin = Profile.is_admin(user)
     is_lead = (Profile.is_regional_lead(user)
                and RegionalLead.is_regional_lead(user, workshop.location))
     is_presenter = (Profile.is_organiser(user)
                     and user in workshop.requester.user.all())
     if not (is_admin or is_lead or is_presenter):
         return HttpResponseForbidden("Not sufficent permission")
     return super(WorkshopAccessMixin,
                  self).dispatch(request, *args, **kwargs)
Exemple #4
0
 def __init__(self, request, *args, **kwargs):
     super(WorkshopEditForm, self).__init__(*args, **kwargs)
     self.fields['expected_date'] = forms.DateField(
         widget=CalendarWidget,
         input_formats=settings.ALLOWED_DATE_FORMAT)
     self.fields['requester'].widget = forms.TextInput()
     self.fields['requester'].widget.attrs['readonly'] = True
     if RegionalLead.is_regional_lead(
             request.user, self.instance.location):
         self.fields['presenter'].queryset = User.objects.filter(
             profile__usertype__slug="tutor"
         )
     else:
         del self.fields['presenter']