web.views.mailbox_views package

web.views.mailbox_views package containing views for the core.models.Mailbox data.

class web.views.mailbox_views.MailboxCreateDaemonView(**kwargs)[source]

Bases: LoginRequiredMixin, DetailView, BaseFormView

View for creating a single core.models.Daemon instance.

URL_NAME = 'mailbox-create-daemon'
model

alias of Mailbox

form_class

alias of CreateMailboxDaemonForm

template_name = 'web/mailbox/mailbox_daemon_create.html'
get_queryset()[source]

Restricts the queryset to objects owned by the requesting user.

Return type:

QuerySet

get_context_data(**kwargs)[source]

Insert the single object into the context dict.

Return type:

dict[str, Any]

Parameters:

kwargs (Any)

get_form_kwargs()[source]

Extended to add the user to the form kwargs.

Return type:

dict[str, Any]

get_form(form_class=None)[source]

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

Return type:

Any

Parameters:

form_class (type[CreateMailboxDaemonForm] | None)

get_success_url()[source]

Return the URL to redirect to after processing a valid form.

Return type:

str

form_valid(form)[source]

If the form is valid, save the associated model.

Return type:

HttpResponse

Parameters:

form (CreateMailboxDaemonForm)

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

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

Return type:

HttpResponse

Parameters:
  • request (HttpRequest)

  • args (Any)

  • kwargs (Any)

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

Handle POST requests: instantiate a form instance with the passed POST variables and then check if it’s valid.

Return type:

HttpResponse

Parameters:
  • request (HttpRequest)

  • args (Any)

  • kwargs (Any)

class web.views.mailbox_views.MailboxDetailWithDeleteView(**kwargs)[source]

Bases: LoginRequiredMixin, DetailWithDeleteView, CustomActionMixin, TestActionMixin

View for a single core.models.Mailbox instance.

URL_NAME = 'mailbox-detail'
model

alias of Mailbox

template_name = 'web/mailbox/mailbox_detail.html'
success_url = '/mailboxes/'
get_queryset()[source]

Restricts the queryset to objects owned by the requesting user.

Return type:

QuerySet

get_context_data(**kwargs)[source]

Extended to add the mailboxes latest emails to the context.

Return type:

dict[str, Any]

Parameters:

kwargs (Any)

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

Creates response to a post request.

If no action matches the existing handlers, responds with Http204. Should be executed last in a custom view post method.

Parameters:
Return type:

HttpResponse

Returns:

The handlers response to the request. If no matching handler is found Http204.

Raises:

ImproperlyConfigured – If the called handler method does not return a django.http.HttpResponse.>

handle_fetch(request)[source]

Handler function for the fetch action.

Parameters:

request (HttpRequest) – The action request to handle.

Return type:

HttpResponse

Returns:

A template response with the updated view after the action.

class web.views.mailbox_views.MailboxEmailsFilterView(**kwargs)[source]

Bases: EmailFilterView, SingleObjectMixin

View for filtering listed core.models.Email instances belonging to a certain mailbox.

URL_NAME = 'mailbox-emails'
template_name = 'web/mailbox/mailbox_email_filter_list.html'
get_queryset()[source]

Restricts the queryset to objects owned by the requesting user.

Return type:

QuerySet

get_context_data(**kwargs)[source]

Extended method to pass the query parameters to the context.

References

https://jeffpohlmeyer.com/django-filters-with-pagination

Return type:

dict[str, Any]

Returns:

The view’s context with added query parameters.

Parameters:

kwargs (Any)

class web.views.mailbox_views.MailboxEmailsTableView(**kwargs)[source]

Bases: SingleTableMixin, MailboxEmailsFilterView

View for tabling core.models.Email instances belonging to a certain mailbox.

URL_NAME = 'mailbox-emails-table'
template_name = 'web/mailbox/mailbox_email_table.html'
table_class

alias of BaseEmailTable

get_paginate_by(table_data)[source]

Overridden to reconcile mixin and view.

Return type:

int

Parameters:

table_data (QuerySet)

class web.views.mailbox_views.MailboxFilterView(**kwargs)[source]

Bases: LoginRequiredMixin, FilterPageView

View for filtering listed core.models.Mailbox instances.

URL_NAME = 'mailbox-filter-list'
model

alias of Mailbox

template_name = 'web/mailbox/mailbox_filter_list.html'
context_object_name = 'mailboxes'
filterset_class

alias of MailboxFilterSet

ordering = ['-is_favorite', 'account__mail_address', 'name']
get_queryset()[source]

Restricts the queryset to objects owned by the requesting user.

Return type:

QuerySet

class web.views.mailbox_views.MailboxTableView(**kwargs)[source]

Bases: SingleTableMixin, MailboxFilterView

View for filtering a table of core.models.Mailbox instances.

URL_NAME = 'mailbox-table'
template_name = 'web/mailbox/mailbox_table.html'
table_class

alias of BaseMailboxTable

get_paginate_by(table_data)[source]

Overridden to reconcile mixin and view.

Return type:

int

Parameters:

table_data (QuerySet)

class web.views.mailbox_views.MailboxUpdateOrDeleteView(**kwargs)[source]

Bases: LoginRequiredMixin, UpdateOrDeleteView

View for updating or deleting a single core.models.Mailbox instance.

URL_NAME = 'mailbox-edit'
model

alias of Mailbox

form_class

alias of BaseMailboxForm

template_name = 'web/mailbox/mailbox_edit.html'
delete_success_url = '/mailboxes/'

The URL to redirect to after deletion. Must be set.

get_queryset()[source]

Restricts the queryset to objects owned by the requesting user.

Return type:

QuerySet

class web.views.mailbox_views.UploadEmailView(**kwargs)[source]

Bases: LoginRequiredMixin, DetailView, FormView

View for uploading email and mailbox files to a mailbox.

URL_NAME = 'mailbox-upload'
model

alias of Mailbox

context_object_name = 'mailbox'
form_class

alias of UploadEmailForm

template_name = 'web/mailbox/upload_email.html'
get_success_url()[source]

Gets the success_url of the upload.

Return type:

str

Returns:

The detail url of the mailbox.

get_queryset()[source]

Restricts the queryset to objects owned by the requesting user.

Return type:

QuerySet

form_valid(form)[source]

Runs when the request form data is valid.

Parameters:

form (UploadEmailForm) – The form of the request data.

Return type:

HttpResponse

Returns:

A django.http.HttpResponse redirecting to success_url.

form_invalid(form)[source]

Runs when the request form data is invalid.

Note

This override is required to reconcile FormView and DetailView.

Parameters:

form (UploadEmailForm) – The form of the request data.

Return type:

HttpResponse

Returns:

A django.http.HttpResponse redirecting to success_url.

Submodules