diff --git a/smash/web/views/language.py b/smash/web/views/language.py index d024f10ae3f9171d752b8dcbedde4c9ac1877bb0..e971d7ed224af7b8dab6ca092631688088a9d4a6 100644 --- a/smash/web/views/language.py +++ b/smash/web/views/language.py @@ -15,7 +15,10 @@ class LanguageListView(ListView, WrappedView): context_object_name = "languages" template_name = 'languages/list.html' -@PermissionDecorator('change_language', 'configuration') + @PermissionDecorator('change_language', 'configuration') + def dispatch(self, *args, **kwargs): + return super(LanguageListView, self).dispatch(*args, **kwargs) + class LanguageCreateView(CreateView, WrappedView): model = Language template_name = "languages/add.html" @@ -23,7 +26,10 @@ class LanguageCreateView(CreateView, WrappedView): success_url = reverse_lazy('web.views.languages') success_message = "Language created" -@PermissionDecorator('change_language', 'configuration') + @PermissionDecorator('change_language', 'configuration') + def dispatch(self, *args, **kwargs): + return super(LanguageCreateView, self).dispatch(*args, **kwargs) + class LanguageDeleteView(DeleteView, WrappedView): model = Language success_url = reverse_lazy('web.views.languages') @@ -33,7 +39,10 @@ class LanguageDeleteView(DeleteView, WrappedView): messages.success(request, "Language deleted") return super(LanguageDeleteView, self).delete(request, *args, **kwargs) -@PermissionDecorator('change_language', 'configuration') + @PermissionDecorator('change_language', 'configuration') + def dispatch(self, *args, **kwargs): + return super(LanguageDeleteView, self).dispatch(*args, **kwargs) + class LanguageEditView(UpdateView, WrappedView): model = Language success_url = reverse_lazy('web.views.languages') @@ -41,3 +50,7 @@ class LanguageEditView(UpdateView, WrappedView): success_message = "Language edited" template_name = "languages/edit.html" context_object_name = "language" + + @PermissionDecorator('change_language', 'configuration') + def dispatch(self, *args, **kwargs): + return super(LanguageEditView, self).dispatch(*args, **kwargs) \ No newline at end of file diff --git a/smash/web/views/study.py b/smash/web/views/study.py index 82756ed8cfde79b17254538e5e23fdceb6ee65e9..e2a37152a639437963f9cb561132d2d861befae7 100644 --- a/smash/web/views/study.py +++ b/smash/web/views/study.py @@ -11,7 +11,7 @@ from web.decorators import PermissionDecorator logger = logging.getLogger(__name__) -PermissionDecorator('change_study', 'configuration') +@PermissionDecorator('change_study', 'configuration') def study_edit(request, study_id): study = get_object_or_404(Study, id=study_id) if request.method == 'POST': diff --git a/smash/web/views/voucher.py b/smash/web/views/voucher.py index e08023d7d0331b2fd61a315ac386a550c3d4c55f..e68918f6178ba28b78ee2a998dfd644b0060ab95 100644 --- a/smash/web/views/voucher.py +++ b/smash/web/views/voucher.py @@ -24,11 +24,14 @@ class VoucherListView(ListView, WrappedView): context_object_name = "vouchers" template_name = 'vouchers/list.html' + @PermissionDecorator('change_voucher', 'configuration') + def dispatch(self, *args, **kwargs): + return super(VoucherListView, self).dispatch(*args, **kwargs) + def voucher_types_for_study_subject(study_subject_id): return StudySubject.objects.get(id=study_subject_id).voucher_types.all() -PermissionDecorator('change_voucher', 'configuration') class VoucherCreateView(CreateView, WrappedView): form_class = VoucherForm model = Voucher @@ -61,7 +64,10 @@ class VoucherCreateView(CreateView, WrappedView): kwargs['voucher_types'] = voucher_types_for_study_subject(self.request.GET.get("study_subject_id", -1)) return kwargs -PermissionDecorator('change_voucher', 'configuration') + @PermissionDecorator('change_voucher', 'configuration') + def dispatch(self, *args, **kwargs): + return super(VoucherCreateView, self).dispatch(*args, **kwargs) + class VoucherEditView(SuccessMessageMixin, UpdateView, WrappedView): form_class = VoucherForm model = Voucher @@ -83,6 +89,10 @@ class VoucherEditView(SuccessMessageMixin, UpdateView, WrappedView): context['mail_templates'] = MailTemplate.get_voucher_mail_templates([]) return context + @PermissionDecorator('change_voucher', 'configuration') + def dispatch(self, *args, **kwargs): + return super(VoucherEditView, self).dispatch(*args, **kwargs) + class ExpireVouchersJob(CronJobBase): RUN_EVERY_MINUTES = 120 diff --git a/smash/web/views/voucher_type.py b/smash/web/views/voucher_type.py index 82df7343f45e44c6f316bbd410fb4f8336afa58b..1c47a8e618540971f32ae12a817e9c639511d560 100644 --- a/smash/web/views/voucher_type.py +++ b/smash/web/views/voucher_type.py @@ -15,7 +15,10 @@ class VoucherTypeListView(ListView, WrappedView): context_object_name = "voucher_types" template_name = 'voucher_types/list.html' -PermissionDecorator('change_vouchertype', 'configuration') + @PermissionDecorator('change_vouchertype', 'configuration') + def dispatch(self, *args, **kwargs): + return super(VoucherTypeListView, self).dispatch(*args, **kwargs) + class VoucherTypeCreateView(CreateView, WrappedView): form_class = VoucherTypeForm model = VoucherType @@ -28,7 +31,11 @@ class VoucherTypeCreateView(CreateView, WrappedView): form.instance.study_id = GLOBAL_STUDY_ID return super(VoucherTypeCreateView, self).form_valid(form) -PermissionDecorator('change_vouchertype', 'configuration') + @PermissionDecorator('change_vouchertype', 'configuration') + def dispatch(self, *args, **kwargs): + return super(VoucherTypeCreateView, self).dispatch(*args, **kwargs) + +#@PermissionDecorator('change_vouchertype', 'configuration') class VoucherTypeEditView(UpdateView, WrappedView): form_class = VoucherTypeForm model = VoucherType @@ -37,3 +44,7 @@ class VoucherTypeEditView(UpdateView, WrappedView): success_message = "Voucher type edited" template_name = "voucher_types/edit.html" context_object_name = "voucher_type" + + @PermissionDecorator('change_vouchertype', 'configuration') + def dispatch(self, *args, **kwargs): + return super(VoucherTypeEditView, self).dispatch(*args, **kwargs)