basxbread.views package

Submodules

basxbread.views.add module

class basxbread.views.add.AddView(*args, **kwargs)

Bases: CustomFormMixin, BaseView, SuccessMessageMixin, PermissionRequiredMixin, CreateView

TODO: documentation

accept_global_perms = True
default_success_page = 'read'
get_context_data(*args, **kwargs)

Insert the form into the context dict.

get_permission_object()
get_required_permissions(request)

Returns list of permissions in format <app_label>.<codename> that should be checked against request.user and object. By default, it returns list from permission_required attribute.

Parameters:

request – Original request.

get_success_message(cleaned_data)

basxbread.views.administration module

class basxbread.views.administration.TaskResultBrowseView(*args, **kwargs)

Bases: BrowseView

columns: Iterable[str | layout.datatable.DataTableColumn] = ['task_id', 'task_name', 'date_created', 'date_done', 'status', 'task_args', 'task_kwargs', 'meta']
rowactions: Iterable[Link] | None = ()
rowclickaction: Link | None = (<basxbread.utils.links.ModelHref object>, '', None, [], {}, False, {}, 'Are you sure?')
title: hg.BaseElement | str = 'Background Jobs'
basxbread.views.administration.maintainance_package_layout(request)
basxbread.views.administration.maintenance_database_optimization(request)
basxbread.views.administration.maintenance_search_reindex(request)
basxbread.views.administration.maintenancesettings(request)
basxbread.views.administration.restart_app_server(request)
basxbread.views.administration.systeminformation(request)

basxbread.views.auth module

class basxbread.views.auth.LoginView(*args, **kwargs)

Bases: BaseView, LoginView

get(*args, **kwargs)

Handle GET requests: instantiate a blank version of the form.

get_context_data(*args, **kwargs)

Insert the form into the context dict.

get_form(*args, **kwargs)

Return an instance of the form to be used in this view.

get_layout()

Returns the layout for this view, returns the layout attribute by default. Either set the layout attribute or override this method.

class basxbread.views.auth.LogoutView(*args, **kwargs)

Bases: BaseView, LogoutView

get(*args, **kwargs)

Logout may be done via POST.

get_context_data(*args, **kwargs)
get_layout()

Returns the layout for this view, returns the layout attribute by default. Either set the layout attribute or override this method.

class basxbread.views.auth.PasswordResetCompleteView(*args, **kwargs)

Bases: BaseView, PasswordResetCompleteView

get_context_data(*args, **kwargs)
get_layout()

Returns the layout for this view, returns the layout attribute by default. Either set the layout attribute or override this method.

class basxbread.views.auth.PasswordResetConfirmView(*args, **kwargs)

Bases: BaseView, PasswordResetConfirmView

get_context_data(*args, **kwargs)

Insert the form into the context dict.

get_layout()

Returns the layout for this view, returns the layout attribute by default. Either set the layout attribute or override this method.

class basxbread.views.auth.PasswordResetDoneView(*args, **kwargs)

Bases: BaseView, PasswordResetView

get_context_data(*args, **kwargs)

Insert the form into the context dict.

get_layout()

Returns the layout for this view, returns the layout attribute by default. Either set the layout attribute or override this method.

class basxbread.views.auth.PasswordResetView(*args, **kwargs)

Bases: BaseView, PasswordResetView

get_context_data(*args, **kwargs)

Insert the form into the context dict.

get_layout()

Returns the layout for this view, returns the layout attribute by default. Either set the layout attribute or override this method.

basxbread.views.auth.auth_page(content, submitname, show_cancelbutton=False)

basxbread.views.browse module

class basxbread.views.browse.AndGroup(*args, **kwargs)

Bases: FilterSet

base_filters = {}
declared_filters = {}
property errors

Return an ErrorDict for the data provided for the underlying form.

filter_queryset(queryset)

Filter the queryset with the underlying form’s cleaned_data. You must call is_valid() or errors before calling this method.

This method should be overridden if additional filtering needs to be applied to the queryset before it is cached.

prefix = None
class basxbread.views.browse.BrowseView(*args, **kwargs)

Bases: BaseView, LoginRequiredMixin, PermissionListMixin, ListView

TODO: documentation

backurl = None
bulkaction_urlparameter: str = '_bulkaction'
bulkactions: Iterable[Link | Callable[[HttpRequest, QuerySet], HttpResponse | None]] = ()
columns: Iterable[str | DataTableColumn] = ('__all__',)
filter_queryset_by_formfilter(qs)
filter_queryset_by_selection(qs)
filterconfig: tuple | None = None
filterset_class: FilterSet | None = None
static gen_rowclickaction(modelaction, **kwargs)

Shortcut to get a Link to a model view. The default models views in basxbread are “read”, “edit”, “delete”. :param modelaction: A model view whose name has been generated

with basxbread.utils.urls.model_urlname

get(*args, **kwargs)
get_context_data(*args, **kwargs)

Get the context for this view.

get_filtered_queryset(qs)

Prefetch related tables to speed up queries. Also order result by get-parameters.

get_final_queryset()
get_layout(**datatable_kwargs)

Returns the layout for this view, returns the layout attribute by default. Either set the layout attribute or override this method.

get_ordred_queryset(qs)
get_paginate_by(queryset)

Get the number of items to paginate by, or None for no pagination.

get_required_permissions(request)

Returns list of permissions in format <app_label>.<codename> that should be checked against request.user and object. By default, it returns list from permission_required attribute.

Parameters:

request – Original request.

get_settingspanel()
items_per_page_options: Iterable[int] | None = None
itemsperpage_urlparameter: str = 'itemsperpage'
objectids_urlparameter: str = '_selected'
orderingurlparameter: str = 'ordering'
primary_button = None
rowactions: Iterable[Link] | None = None
rowclickaction: Link | None = None
search_urlparameter: str = 'q'
title: BaseElement | str = ''
viewstate_sessionkey: str | None = None
class basxbread.views.browse.BulkAction(name, label, action, iconname, permissions)

Bases: NamedTuple

action: Callable[[HttpRequest, QuerySet], HttpResponse | None]

Alias for field number 2

has_permission(request, obj=None)
iconname: str

Alias for field number 3

label: str

Alias for field number 1

name: str

Alias for field number 0

permissions: List[str]

Alias for field number 4

class basxbread.views.browse.OrGroup(*args, **kwargs)

Bases: FilterSet

base_filters = {}
declared_filters = {}
property errors

Return an ErrorDict for the data provided for the underlying form.

filter_queryset(queryset)

Filter the queryset with the underlying form’s cleaned_data. You must call is_valid() or errors before calling this method.

This method should be overridden if additional filtering needs to be applied to the queryset before it is cached.

prefix = None
basxbread.views.browse.build_filterpanel(filterset, hiddenparams_form)
basxbread.views.browse.default_bulkactions(model, columns=['__all__'])
basxbread.views.browse.delete(request, queryset, softdeletefield=None, required_permissions=None)
basxbread.views.browse.export(queryset, columns, request=None)
basxbread.views.browse.get_field(basemodel, fieldname)
basxbread.views.browse.get_filtername(column)
basxbread.views.browse.order_queryset_by_urlparameter(qs, order)

Can used to order a queryset by a user-provided string, e.g. through a GET query parameter

basxbread.views.browse.parse_filterconfig(basemodel, filterconfig, prefix)
filterconfig: Tree in the form of
(“and”

(“or”, fieldname1, fieldname2), (“or”, fieldname3, fieldname4),

)

basxbread.views.browse.restore(request, queryset, softdeletefield, required_permissions=None)

basxbread.views.delete module

class basxbread.views.delete.DeleteView(*args, **kwargs)

Bases: BaseView, PermissionRequiredMixin, RedirectView

TODO: documentation

accept_global_perms = True
get_redirect_url(*args, **kwargs)

Return the URL redirect to. Keyword arguments from the URL pattern match generating the redirect request are provided as kwargs to this method.

get_required_permissions(request)

Returns list of permissions in format <app_label>.<codename> that should be checked against request.user and object. By default, it returns list from permission_required attribute.

Parameters:

request – Original request.

model = None
post(*args, **kwargs)
softdeletefield = None
urlparams: Iterable[Tuple[str, Type]] = (('pk', <class 'int'>),)

basxbread.views.edit module

class basxbread.views.edit.EditView(*args, **kwargs)

Bases: CustomFormMixin, BaseView, SuccessMessageMixin, PermissionRequiredMixin, UpdateView

TODO: documentation

accept_global_perms = True
default_success_page = 'read'
dispatch(*args, **kwargs)
fields: List[BaseElement | str] | None = None
get_context_data(*args, **kwargs)

Insert the form into the context dict.

get_required_permissions(request)

Returns list of permissions in format <app_label>.<codename> that should be checked against request.user and object. By default, it returns list from permission_required attribute.

Parameters:

request – Original request.

get_success_message(cleaned_data)
urlparams: Iterable[Tuple[str, Type]] = (('pk', <class 'int'>),)
basxbread.views.edit.bulkcopy(request, queryset, attrs=None, labelfield=None, copy_related_fields=())

creates a copy all instances of a queryset attrs: custom field values for the new instance labelfield: name of a model field which will be used to create copy-labels

(Example, Example (Copy 2), Example (Copy 3), etc)

copy_related_fields: related fields which should also be (deep) copied

basxbread.views.edit.copylabel(original_name)

create names/labels with the sequence (Copy), (Copy 2), (Copy 3), etc.

basxbread.views.edit.deepcopy_object(instance, attrs=None, copy_related_fields=())

Creates a ‘deep’ coyp of the model instance Related fields are only copied if they are listed in copy_related_fields ManyToMany relationships are copied automatically if they have no key in ‘attrs’ attrs defineds default values for fields

basxbread.views.edit.generate_copyview(model, attrs=None, labelfield=None, copy_related_fields=())

creates a copy of a model instance and redirects to the edit view of the newly created instance attrs: custom field values for the new instance labelfield: name of a model field which will be used to create copy-labels

(Example, Example (Copy 2), Example (Copy 3), etc)

basxbread.views.error module

basxbread.views.error.error_layout(request, status_code: int, status_title: str, description: str | BaseElement, exception_detail: str | None = None)
basxbread.views.error.handler400(request, exception)
basxbread.views.error.handler403(request, exception)
basxbread.views.error.handler404(request, exception)
basxbread.views.error.handler500(request)

basxbread.views.globalpreferences module

class basxbread.views.globalpreferences.PreferencesView(*args, **kwargs)

Bases: BaseView, SuccessMessageMixin, PermissionRequiredMixin, PreferenceFormView

form_class

alias of GlobalPreferenceForm

get_layout()

Returns the layout for this view, returns the layout attribute by default. Either set the layout attribute or override this method.

permission_required = ['dynamic_preferences.change_globalpreferencemodel', 'dynamic_preferences.view_globalpreferencemodel']
registry = {'general': {'logo': <basxbread.dynamic_preferences_registry.Logo object>, 'organizationname': <basxbread.dynamic_preferences_registry.OrganizationName object>}}

the registry for preference lookups

success_message = 'Preferences updated'

basxbread.views.read module

class basxbread.views.read.ReadView(*args, **kwargs)

Bases: BaseView, PermissionRequiredMixin, DetailView

accept_global_perms = True
fields = ['__all__']
get_context_data(*args, **kwargs)

Insert the single object into the context dict.

get_layout()

Returns the layout for this view, returns the layout attribute by default. Either set the layout attribute or override this method.

get_required_permissions(request)

Returns list of permissions in format <app_label>.<codename> that should be checked against request.user and object. By default, it returns list from permission_required attribute.

Parameters:

request – Original request.

urlparams: Iterable[Tuple[str, Type]] = (('pk', <class 'int'>),)

basxbread.views.userprofile module

class basxbread.views.userprofile.EditLoginView(*args, **kwargs)

Bases: EditView

fields: List[hg.BaseElement | str] | None = ['username', 'email']
get_form_class(*args, **kwargs)

Return the form class to use in this view.

get_layout()

Returns the layout for this view, returns the layout attribute by default. Either set the layout attribute or override this method.

get_object()

Return the object the view is displaying.

Require self.queryset and a pk or slug argument in the URLconf. Subclasses can override this to return any object.

get_required_permissions(request)

Returns list of permissions in format <app_label>.<codename> that should be checked against request.user and object. By default, it returns list from permission_required attribute.

Parameters:

request – Original request.

model

alias of User

urlparams: Iterable[Tuple[str, Type]] = ()
class basxbread.views.userprofile.EditPermissionsView(*args, **kwargs)

Bases: EditView

check_permissions(request)

Checks if request.user has all permissions returned by get_required_permissions method.

Parameters:

request – Original request.

fields: List[hg.BaseElement | str] | None = ['is_active', 'is_superuser', 'is_staff']
get_object()

Return the object the view is displaying.

Require self.queryset and a pk or slug argument in the URLconf. Subclasses can override this to return any object.

get_required_permissions(request)

Returns list of permissions in format <app_label>.<codename> that should be checked against request.user and object. By default, it returns list from permission_required attribute.

Parameters:

request – Original request.

model

alias of User

urlparams: Iterable[Tuple[str, Type]] = ()
class basxbread.views.userprofile.EditPersonalDataView(*args, **kwargs)

Bases: EditView

fields: List[hg.BaseElement | str] | None = ['first_name', 'last_name']
form_valid(form)

If the form is valid, save the associated model.

get_form_class(*args, **kwargs)

Return the form class to use in this view.

get_layout()

Returns the layout for this view, returns the layout attribute by default. Either set the layout attribute or override this method.

get_object()

Return the object the view is displaying.

Require self.queryset and a pk or slug argument in the URLconf. Subclasses can override this to return any object.

get_required_permissions(request)

Returns list of permissions in format <app_label>.<codename> that should be checked against request.user and object. By default, it returns list from permission_required attribute.

Parameters:

request – Original request.

model

alias of User

urlparams: Iterable[Tuple[str, Type]] = ()
class basxbread.views.userprofile.UserProfileView(*args, **kwargs)

Bases: ReadView

get_layout()

Returns the layout for this view, returns the layout attribute by default. Either set the layout attribute or override this method.

get_object()

Return the object the view is displaying.

Require self.queryset and a pk or slug argument in the URLconf. Subclasses can override this to return any object.

get_required_permissions(request)

This method overrides the old one from ReadView because this view should be accessible to all users.

model

alias of User

basxbread.views.userprofile.password_reset(request)

Automatically sends a password-reset email to the currently logged in user

basxbread.views.userprofile.profile_field(fieldname)
basxbread.views.userprofile.profile_field_checkbox(fieldname)
basxbread.views.userprofile.profile_field_password(fieldname)
basxbread.views.userprofile.set_devmode(request, enable: str)

basxbread.views.util module

class basxbread.views.util.BaseView(*args, **kwargs)

Bases: object

Shortcut to create a subclass with the given attributes

ajax_urlparameter = 'asajax'
get_layout()

Returns the layout for this view, returns the layout attribute by default. Either set the layout attribute or override this method.

hidemenus_urlparameter = 'hidemenus'
layout: BaseElement | None = None
page_layout: Callable[[Menu, BaseElement, bool], BaseElement] | None = None
render_to_response(context, **response_kwargs)
urlparams: Iterable[Tuple[str, Type]] = ()
class basxbread.views.util.CustomFormMixin

Bases: object

This mixin takes care of the following things: - Allows to pass initial values for form fields via the GET query - Converts n-to-many fields into inline forms - Set GenericForeignKey fields before saving (not supported by default in django) - If “next” is in the GET query redirect to that location on success - If default_success_page

form_valid(*args, **kwargs)
get_form(form_class=None)
get_form_class(form=<class 'django.forms.models.ModelForm'>)
get_initial(*args, **kwargs)
get_layout()
get_success_url()
basxbread.views.util.header()

basxbread.views.wizard module

basxbread.views.wizard.generate_wizard_form(wizardview, wizardtitle, steptitle, formlayout)

title: Title of the current page steps: list of 2-tuples with (step_title, status) where status must be one of [“incomplete”, “complete”, “current”]