Class decorator¶
API¶
-
class
rules_light.class_decorator.
class_decorator
[source]¶ Can be used to secure class based views.
If the view has
model=YourModel
, it will support:CreateView
, it will decorateget_form()
, to runrules_light.require('yourapp.yourmodel.create')
,UpdateView
, it will decorateget_object()
, to runrules_light.require('yourapp.yourmodel.update', obj)
,DeleteView
, it will decorateget_object()
, to runrules_light.require('yourapp.yourmodel.delete', obj)
,DetailView
, it will decorateget_object()
, to runrules_light.require('yourapp.yourmodel.read', obj)
,- others views, if the rule name is specified in the decorator for example
@class_decorator('some_rule')
, then it will decoratedispatch()
, - Else it raises an exception.