adminlte2_pdq package

Subpackages

Submodules

adminlte2_pdq.admin_menu module

Django AdminLTE2 Admin Menu

adminlte2_pdq.decorators module

Django AdminLte2Pdq package decorators.

adminlte2_pdq.decorators.allow_anonymous_access(function=None)

Decorator for strict mode, that defines a view can be accessed without login.

Also adds the required logic to render the view on the sidebar template.

adminlte2_pdq.decorators.allow_without_permissions(function=None, redirect_field_name='next', login_url=None)

Decorator for strict mode, that defines a view which requires login, but no permissions.

Also adds the required logic to render the view on the sidebar template. TODO: Consider changing how the “allow_without_permission” decorator works so that it also looks at the whitelists to know if it should actually use the “login_required decorator”.

adminlte2_pdq.decorators.login_required(function=None, redirect_field_name='next', login_url=None)

Decorator for views that defines login is required.

Also adds the login required as a property to that view function. The property added to the view function can then be used by the sidebar template to know whether to render the sidebar menu item that links to that view function.

Does NOT do anything if project is in “strict” mode. For strict mode, see one of the following decorators: * allow_anonymous_access * allow_without_permissions

adminlte2_pdq.decorators.permission_required(permission, login_url=None, raise_exception=False)

Decorator for views that defines a full set of permissions that are required.

Also adds the required permissions as a property to that view function. The permissions added to the view function can then be used by the sidebar template to know whether to render the sidebar menu item that links to that view function.

adminlte2_pdq.decorators.permission_required_one(permission, login_url=None, raise_exception=False)

Decorator for views that defines that only one of the indicated permissions are required.

Also adds the required permissions as a property to that view function. The permissions added to the view function can then be used by the sidebar template to know whether to render the sidebar menu item that links to that view function.

adminlte2_pdq.forms module

Django AdminLTE2 Sample Forms

class adminlte2_pdq.forms.SampleForm(*args, **kwargs)

Bases: Form

Sample Form with all field types

base_fields = {'sample_bool': <django.forms.fields.BooleanField object>, 'sample_char': <django.forms.fields.CharField object>, 'sample_char_opt': <django.forms.fields.CharField object>, 'sample_choice': <django.forms.fields.ChoiceField object>, 'sample_choice_radio': <django.forms.fields.ChoiceField object>, 'sample_color': <django.forms.fields.CharField object>, 'sample_datalist': <django.forms.fields.CharField object>, 'sample_date': <django.forms.fields.DateField object>, 'sample_date_time': <django.forms.fields.DateTimeField object>, 'sample_decimal': <django.forms.fields.DecimalField object>, 'sample_duration': <django.forms.fields.DurationField object>, 'sample_email': <django.forms.fields.EmailField object>, 'sample_file': <django.forms.fields.FileField object>, 'sample_file_path': <django.forms.fields.FilePathField object>, 'sample_float': <django.forms.fields.FloatField object>, 'sample_generic_ip': <django.forms.fields.GenericIPAddressField object>, 'sample_integer': <django.forms.fields.IntegerField object>, 'sample_json': <django.forms.fields.JSONField object>, 'sample_multi_choice': <django.forms.fields.MultipleChoiceField object>, 'sample_multi_choice_checkbox': <django.forms.fields.MultipleChoiceField object>, 'sample_null_bool': <django.forms.fields.NullBooleanField object>, 'sample_phone': <django.forms.fields.CharField object>, 'sample_range': <django.forms.fields.CharField object>, 'sample_range_datalist': <django.forms.fields.CharField object>, 'sample_regex': <django.forms.fields.RegexField object>, 'sample_slug': <django.forms.fields.SlugField object>, 'sample_time': <django.forms.fields.TimeField object>, 'sample_typed_choice': <django.forms.fields.TypedChoiceField object>, 'sample_typed_multi_choice': <django.forms.fields.TypedMultipleChoiceField object>, 'sample_url': <django.forms.fields.URLField object>, 'sample_uuid': <django.forms.fields.UUIDField object>}
declared_fields = {'sample_bool': <django.forms.fields.BooleanField object>, 'sample_char': <django.forms.fields.CharField object>, 'sample_char_opt': <django.forms.fields.CharField object>, 'sample_choice': <django.forms.fields.ChoiceField object>, 'sample_choice_radio': <django.forms.fields.ChoiceField object>, 'sample_color': <django.forms.fields.CharField object>, 'sample_datalist': <django.forms.fields.CharField object>, 'sample_date': <django.forms.fields.DateField object>, 'sample_date_time': <django.forms.fields.DateTimeField object>, 'sample_decimal': <django.forms.fields.DecimalField object>, 'sample_duration': <django.forms.fields.DurationField object>, 'sample_email': <django.forms.fields.EmailField object>, 'sample_file': <django.forms.fields.FileField object>, 'sample_file_path': <django.forms.fields.FilePathField object>, 'sample_float': <django.forms.fields.FloatField object>, 'sample_generic_ip': <django.forms.fields.GenericIPAddressField object>, 'sample_integer': <django.forms.fields.IntegerField object>, 'sample_json': <django.forms.fields.JSONField object>, 'sample_multi_choice': <django.forms.fields.MultipleChoiceField object>, 'sample_multi_choice_checkbox': <django.forms.fields.MultipleChoiceField object>, 'sample_null_bool': <django.forms.fields.NullBooleanField object>, 'sample_phone': <django.forms.fields.CharField object>, 'sample_range': <django.forms.fields.CharField object>, 'sample_range_datalist': <django.forms.fields.CharField object>, 'sample_regex': <django.forms.fields.RegexField object>, 'sample_slug': <django.forms.fields.SlugField object>, 'sample_time': <django.forms.fields.TimeField object>, 'sample_typed_choice': <django.forms.fields.TypedChoiceField object>, 'sample_typed_multi_choice': <django.forms.fields.TypedMultipleChoiceField object>, 'sample_url': <django.forms.fields.URLField object>, 'sample_uuid': <django.forms.fields.UUIDField object>}
property media

Return all media required to render the widgets on this form.

class adminlte2_pdq.forms.SampleFormsetForm(*args, **kwargs)

Bases: Form

Sample Form for Formset

base_fields = {'sample_bool': <django.forms.fields.BooleanField object>, 'sample_char': <django.forms.fields.CharField object>, 'sample_char_opt': <django.forms.fields.CharField object>, 'sample_file': <django.forms.fields.FileField object>, 'sample_multi_choice_checkbox': <django.forms.fields.MultipleChoiceField object>, 'sample_phone': <django.forms.fields.CharField object>}
declared_fields = {'sample_bool': <django.forms.fields.BooleanField object>, 'sample_char': <django.forms.fields.CharField object>, 'sample_char_opt': <django.forms.fields.CharField object>, 'sample_file': <django.forms.fields.FileField object>, 'sample_multi_choice_checkbox': <django.forms.fields.MultipleChoiceField object>, 'sample_phone': <django.forms.fields.CharField object>}
property media

Return all media required to render the widgets on this form.

adminlte2_pdq.menu module

Django AdminLTE2 default Sidebar menu.

adminlte2_pdq.middleware module

Django-AdminLTE2-PDQ Middleware

class adminlte2_pdq.middleware.AuthMiddleware(get_response)

Bases: object

Middleware that requires a user to be authenticated to view any page other than ones defined in LOGIN_EXEMPT_ENDPOINTS. Exemptions to this requirement can optionally be specified with the ADMINLTE2_LOGIN_EXEMPT_WHITELIST setting in your settings.py file. (which you can copy from your urls.py). If a user tries to access one of these routes, they will be redirected to the LOGIN_URL defined in settings.

Additionally, if the ADMINLTE2_USE_STRICT_POLICY setting is enabled, users will be prevented from accessing a route if the view for that route does not have permissions or login_required defined on that view. If a user tries to access one of these routes, they will be redirected to the ADMINLTE2_HOME_ROUTE defined in settings which is the only non-login required route that is exempt by default. If you would like to add additional exempt routes, you can add them to the ADMINLTE2_STRICT_POLICY_WHITELIST setting in your settings.py file.

Requires authentication middleware and template context processors to be loaded. You’ll get an error if they aren’t.

check_main_error_states(request, view_data)

Check for various conflicting decorator/mixin states, raise error upon finding any.

check_post_login_check_error_states(request, view_data)

Check for various permission required errors TODO: See if there is a way to combine this with the other error states above Though it might be hard because this check currently needs to happen after we handle redirecting for login required checks.

get_full_path_with_slash(request)

Return the full path of the request with a trailing slash appended.

Raise a RuntimeError if settings.DEBUG is True and request.method is DELETE, POST, PUT, or PATCH.

is_login_whitelisted(view_data)

Determines if view is login-whitelisted. Used for login_required mode or strict mode.

is_permission_whitelisted(view_data)

Determines if view is permission-whitelisted. Used for strict mode.

is_special_route(view_data)

Check if the path is a special route that should forego checks

login_required_hook(request)

Hook that can be overridden in subclasses to add additional ways to pass the login required criteria. Should return either True or False.

parse_request_data(request)

Parses request data and generates dict of calculated values.

permission_required_hook(request)

Hook that can be overridden in subclasses to add additional ways to pass the login required criteria. Should return either True or False.

run_auth_checks(request)

Various AdminLTE authentication checks upon User trying to access a view.

Upon failure, user will be redirected accordingly. Redirects are determined by the LOGIN_REDIRECT_URL setting, and the ADMINLTE2_HOME_ROUTE setting.

should_redirect_with_slash(request)

Return True if settings.APPEND_SLASH is True and appending a slash to the request path turns an invalid path into a valid one.

user_passes_perms(request, view_data)

Checks to verify User has required permissions, for views that require it.

verify_favicon_route(path)

Verify that the path of the request is not a favicon request.

verify_logged_in(request, view_data)

Checks to verify User is logged in, for views that require it.

verify_media_route(path)

Verify that the path of the request is not a MEDIA URL

verify_permissions(request, view_data)

Checks to verify User passes the permission checks, for views that require it.

verify_redirect_route(view_class)

Verify that the view class is a RedirectView

verify_static_route(path)

Verify that the path of the request is not a STATIC URL

verify_websocket_route(path)

Verify that the path of the request is not a WEBSOCKET URL

view_is_permission_exempt(request, view_data)

Return whether the view is exempt from requiring permissions in strict mode.

adminlte2_pdq.mixins module

Django AdminLte2Pdq package mixins.

class adminlte2_pdq.mixins.AllowAnonymousAccessMixin

Bases: object

Mixin for strict mode, that defines a view can be accessed without login.

General logic comes from the login_required project decorator.

admin_pdq_data = {'allow_anonymous_access': True, 'allow_without_permissions': False, 'decorator_name': 'allow_anonymous_access', 'login_required': False}
subclasses = []
class adminlte2_pdq.mixins.AllowWithoutPermissionsMixin

Bases: LoginRequiredMixin

Mixin for strict mode, that defines a view which requires login, but no permissions.

General logic comes from the login_required project decorator.

admin_pdq_data = {'allow_anonymous_access': False, 'allow_without_permissions': True, 'decorator_name': 'allow_without_permissions', 'login_required': True}
subclasses = []
class adminlte2_pdq.mixins.LoginRequiredMixin

Bases: LoginRequiredMixin

Mixin for views that defines login is required.

admin_pdq_data = {'allow_anonymous_access': False, 'allow_without_permissions': False, 'decorator_name': 'login_required', 'login_required': True}
subclasses = []
class adminlte2_pdq.mixins.PermissionRequiredMixin

Bases: PermissionRequiredMixin

Mixin for views that defines permissions are required.

admin_pdq_data = {'allow_anonymous_access': False, 'allow_without_permissions': False, 'decorator_name': 'permission_required', 'login_required': True}
dispatch(request, *args, **kwargs)
get_permission_required()

Override this method to override permission attributes. Must return a tuple of two iterables: (perms_all, perms_one)

has_permission()

Check request user matches permission criteria.

permission_required = None
permission_required_one = None
subclasses = []

adminlte2_pdq.urls module

Django AdminLTE2 Default URL Configuration

adminlte2_pdq.views module

Django AdminLTE2 Views

adminlte2_pdq.views.demo_css(request)

Show examples of extra-features.css

adminlte2_pdq.views.home(request)

Show default home page

adminlte2_pdq.views.register(request)

Show default register page

adminlte2_pdq.views.sample1(request)

Show default sample1 page

adminlte2_pdq.views.sample2(request)

Show default sample2 page

adminlte2_pdq.views.sample_form(request)

Show sample form page

Module contents

Version declaration

adminlte2_pdq.parse_version(version)

‘0.1.2.dev1’ -> (0, 1, 2, ‘dev1’) ‘0.1.2’ -> (0, 1, 2)