def method(self, request, *args, **kwargs): view_func = view.as_view(page=self) for perm in perms: view_func = permission_required(perm)(view_func) return view_func(request, *args, **kwargs)
@profile_required @method_restriction('POST') def toggle_email_subscription(req): profile = req.user.profile profile.email_subscribed = not profile.email_subscribed profile.save() print(profile.email_subscribed) return HttpResponse('ok') @profile_required @method_restriction('POST') def change_password(req): profile = req.user.profile old_password = req.POST.get('old_password', '') new_password = req.POST.get('new_password', '') if len(new_password) < 8: return HttpResponse('fail', status=400) if profile.user.check_password(old_password): profile.user.set_password(new_password) profile.user.save() return HttpResponse('ok') return HttpResponse('fail', status=400) change_name = ( permission_required('change_name')( profile_required( method_restriction('POST')( ProfileSetting('name').as_view()))))
def method(self, request, *args, **kwargs): view_func = lambda request: view(request, self, *args, **kwargs) for perm in perms: view_func = permission_required(perm)(view_func) return view_func(request)
path("oauth/applications/", views.OAuth2List.as_view(), name="oauth_list"), path("oauth/applications/<int:pk>/detail", views.OAuth2Detail.as_view(), name="oauth_detail"), path("oauth/applications/<int:pk>/delete", views.OAuth2Delete.as_view(), name="oauth_delete"), path("oauth/applications/<int:pk>/update", views.OAuth2Update.as_view(), name="oauth_update"), path("oauth/", include("oauth2_provider.urls", namespace="oauth2_provider")), path("__i18n__/", include("django.conf.urls.i18n")), path( "ckeditor/upload/", permission_required("core.ckeditor_upload_files_rule")( ckeditor_uploader_views.upload), name="ckeditor_upload", ), path( "ckeditor/browse/", permission_required("core.ckeditor_upload_files_rule")( ckeditor_uploader_views.browse), name="ckeditor_browse", ), path("select2/", include("django_select2.urls")), path("jsreverse.js", urls_js, name="js_reverse"), path("calendarweek_i18n.js", calendarweek.django.i18n_js, name="calendarweek_i18n_js"), path("gettext.js", JavaScriptCatalog.as_view(), name="javascript-catalog"), path("preferences/site/",