Views

class cruditor.views.Cruditor404View(**kwargs)[source]

Bases: CruditorMixin, TemplateView

Customized not found page. Needed to add the required cruditor context for properly rendered templates.

template_name = 'cruditor/404.html'[source]

Template used to render the 404 page.

dispatch(request, *args, **kwargs)[source]

Ensure the user is logged in (by calling ensure_logged_in` method). If the user is logged in, permissions are checked by calling ensure_required_permission.

class cruditor.views.Cruditor403View(**kwargs)[source]

Bases: CruditorMixin, TemplateView

Customized permission denied page. Needed to add the required cruditor context for properly rendered templates.

template_name = 'cruditor/403.html'[source]

Template used to render the 403 page.

dispatch(request, *args, **kwargs)[source]

Ensure the user is logged in (by calling ensure_logged_in` method). If the user is logged in, permissions are checked by calling ensure_required_permission.

class cruditor.views.CruditorListView(**kwargs)[source]

Bases: CruditorMixin, TemplateView

Enhanced list view backed by django-tables2 and django-filters.

You want to set at least the model property. The remaining default property values are just fine for a working output.

By providing a alternative table_class and/or filter_class you can improve the usability of the view even further.

model = None[source]

Model to work on in this view.

queryset = None[source]

Queryset to use for looking up objects.

filter_class = None[source]

Optional django_filters.FilterSet class to provide filtering capabilities.

table_class = None[source]

Required django_tables2.Table class to change the rendered table.

template_name = 'cruditor/list.html'[source]

Template to use when rendering the list view.

get_context_data(**kwargs)[source]

Prepares the context by adding the table context variable. If you have configured filter_class, the filter_form context variable will be provided too.

get_queryset()[source]

Provide a queryset to fetch data with. If queryset is set on the class, the value will be used, if not but model is set, the default manager is used.

If both queryset and model is not set, you have to override this method to provide data to display.

get_table_class()[source]

Method to override the used table class. By default, returns table_class property if set.

If no table_class``is provided, an ``ImproperlyConfigured exception is raised.

get_table_kwargs()[source]

Override to provide additional kwargs when initializing the table object.

get_filter_class()[source]

Method to override the used filter class from django_filters. By default, returns filter_class property if set.

get_filter_kwargs()[source]

Override to provide additional kwargs when initializing the filterset object.

get_filtered_queryset()[source]

Filter the base queryset using the django-filters FilterSet if available. QuerySet is passed if no filter_class is defined.

get_table(filtered_qs)[source]

Prepare the table object using the provided QuerySet/Iterable.

class cruditor.views.CruditorAddView(**kwargs)[source]

Bases: CruditorMixin, FormViewMixin, CreateView

Enhanced view to add new items using a form view.

success_message = 'The {model} "{object}" was successfully added.'[source]

Message used when a new item was added successfully.

template_name = 'cruditor/form.html'[source]

Template used to render the add form view.

get_object()[source]

As we are in a add view, no object will be available ever.

get_title()[source]

Generate a sane title when adding new items using the get_model_verbose_name.

class cruditor.views.CruditorChangeView(**kwargs)[source]

Bases: CruditorMixin, FormViewMixin, UpdateView

Enhanced view to edit existing items using a form view.

success_message = 'The {model} "{object}" was successfully changed.'[source]

Message used when a item was changed successfully.

template_name = 'cruditor/form.html'[source]

Template used to render the change form view.

get_title()[source]

Generate a sane title when editing an item using the __str__ representation of a object.

get_delete_url()[source]

Override to provide a link for the delete button in the change view. By default no delete button is visible.

get_context_data(**kwargs)[source]

Add the object_delete_url context variable using get_delete_url. Feel free to extend the context further.

class cruditor.views.CruditorDeleteView(*args, **kwargs)[source]

Bases: CruditorMixin, DeleteView

Enhanced view to delete existing items after a confirmation.

success_message = 'The {model} "{object}" was successfully deleted.'[source]

Message used when a item was deleted.

template_name = 'cruditor/delete.html'[source]

Template used to render the confirmation form view.

delete(*args, **kwargs)[source]

Call the delete() method on the fetched object and then redirect to the success URL.

form_valid(request, *args, **kwargs)[source]

Call perform_delete method and redirect to the success URL with a nice success message. If there are protected related objects, an error message is shown instead with the output of format_linked_objects.

get_title()[source]

Generate a sane title when requesting a confirmation to delete an item using the __str__ representation of a object.

perform_delete()[source]

Actual delete a object/model/item after confirmation.

format_linked_objects(objects)[source]

Generate a list of strings describing the objects which have a protected relation to the item to delete.

class cruditor.views.CruditorChangePasswordView(**kwargs)[source]

Bases: CruditorMixin, FormView

Enhanced view to perform password changes in the Cruditor context.

template_name = 'cruditor/form.html'[source]

Template used when rendering the change password form.

title = 'Change password'[source]

Title for breadcrumb and page.

form_class[source]

Form used to change the password.

alias of ChangePasswordForm

get_form_kwargs()[source]

The current user is passed to the provided form_class when initializing the change password form.

form_valid(form)[source]

Save the new password (by calling form.save) and rotate the session authorization hash.

get_context_data(**kwargs)[source]

Set form_save_button_label context variable to change the button label for the change password form.

class cruditor.views.CruditorLogoutView(**kwargs)[source]

Bases: CruditorMixin, LogoutView

View to log out the current user. After logging out, a info is displayed.

template_name = 'cruditor/logout.html'[source]

Template used to display the info that the user was logged out.

ensure_logged_in(*args, **kwargs)[source]

This method checks if the request user is logged in and has the right flags set (e.g. is_staff if staff_required is set in view).

If user is logged in, True is returned. If not, handle_not_logged_in is called.

get_context_data(**kwargs)[source]

Adds the cruditor context variable to the template context. Uses data from get_cruditor_context method.