Decorator for views that checks whether an user has a particular permission enabled for an object or a general permission from the django permission system, redirecting to the log-in page if necessary.
Example:
# Permissions required for setting stats
pr_set_stats = (
('granular', 'project_permission.maintain'),
('general', 'projects.refresh_stats'),
#(<perm_type>, <perm_name>),
)
@one_perm_required_or_403(pr_set_stats,
(Project, 'slug__contains', 'project_slug'))
def component_set_stats(request, project_slug, component_slug):
bla bla bla
In the example above the decorator checks for the maintain permission for a Project object, taking the project_slug from the view component_set_stats. If the user IS NOT a maintainer of that project, the second and general permission is checked.
If at least one of the permissions checks in the list returns True, the access for the user is guarantee.
The permissions are checked in the same order as they are put in the tuple and it is allowed to add how many permissions checks as wanted.
Decorator for views that checks that the user passes the given test.
Users that fail the test will be given a 403 error.
A small wrapper that adds a convenient resolve method.
Return a value as a restructured text header.
border - Character to be used in the header bottom-border
Return a number increasing its counting each time it’s called. An initial value can be passed to identify from which number it should start counting.
Syntax:
{% counter %}
{% counter 20 %}
Return a dictionary with the top translators of the system or for a object, when it’s passed by parameter.
Usage:: get_top_translators <number_of_top_translators> get_top_translators 10
or
get_top_translators <number_of_top_translators> <obj> get_top_translators 10 project_foo
Filter a NoticeType list passed by parameter using the NOTICE_TYPES dictionary that says which notice types must be shown to the user.
It is necessary by now until the upstream project have a model change to be able to do this filtering from the database.
Return meta-style link rendered as superscript to count something.
For example, with list=[‘a’, ‘b’] and countable=’boxes’ return the HTML for “2 boxes”.
Mar 02, 2010