calingen.views.generation

Views in the context of rendering and compilation of layouts.

Module Contents

Classes

CompilerView

Render the selected layout and pass the result to a compiler.

LayoutConfigurationView

Show the (optional) configuration form for the selected layout.

LayoutSelectionView

Provide a list of availabe layouts.

Attributes

logger

class calingen.views.generation.CompilerView(**kwargs)

Bases: django.contrib.auth.mixins.LoginRequiredMixin, calingen.views.mixins.RestrictToUserMixin, calingen.views.mixins.AllCalendarEntriesMixin, django.views.generic.base.ContextMixin, django.views.generic.base.View

Render the selected layout and pass the result to a compiler.

_get_layout()

Return the LayoutProvider implementation.

Notes

If there is no selected layout in the user’s Session, a custom exception will cause a redirect to the user’s profile overview.

_prepare_context(*args, **kwargs)

Prepare the context passed to the layout’s rendering method.

Notes

The context that is passed to the layout’s render() method contains the following keys:

get(*args, **kwargs)

Render the selected layout and call the compiler on the result.

The actual response to the GET request is provided by the implementation of calingen.interfaces.plugin_api.CompilerProvider.get_response().

Notes

If there is no selected layout in the user’s Session, a redirect to calingen.views.generation.LayoutSelectionView is performed.

The method retrieves the compiler instance from the project’s settings module (CALINGEN_COMPILER). It will resort to the configured "default" compiler, if no specific compiler for the selected layout_type (as defined by the implementation of LayoutProvider) is set or if the specified compiler can not be imported. In that case a log message (of level warn) is emitted.

class calingen.views.generation.LayoutConfigurationView(**kwargs)

Bases: django.contrib.auth.mixins.LoginRequiredMixin, calingen.views.generic.RequestEnabledFormView

Show the (optional) configuration form for the selected layout.

Warning

This view is not restricted to users with a Calingen Profile and can be accessed by any user of the project.

However, on actual generation and compilation of the output, a Profile is required.

Notes

This is just the view to show and process the layout’s implementation of calingen.forms.generation.LayoutConfigurationForm.

success_url
template_name = calingen/layout_configuration.html
form_valid(form)

Trigger saving of the configuration values in the user’s Session.

get(request, *args, **kwargs)

Handle a GET request to the view.

While processing the request, it is determined if the selected implementation of calingen.interfaces.plugin_api.LayoutProvider uses a custon configuration_form.

If no custom configuration is implemented by the layout, the request is redirected to the generator.

Notes

Determining the configuration_form is done implicitly while traversing the view’s hierarchy during processing the request. Several methods are involved, but at some point get_form_class() is called, which will raise an exceptions that is handled here.

If there is no selected layout in the user’s Session, a redirect to calingen.views.generation.LayoutSelectionView is performed.

get_form_class()

Retrieve the layout’s configuration form.

Notes

Implementations of calingen.interfaces.plugin_api.LayoutProvider may provide a class attribute configuration_form with a subclass of calingen.forms.generation.LayoutConfigurationForm.

If configuration_form is omitted, a custom exception is raised, that will be handled in get().

If there is no selected layout in the user’s Session, a different custom exception will cause a redirect to the user’s profile overview.

class calingen.views.generation.LayoutSelectionView(**kwargs)

Bases: django.contrib.auth.mixins.LoginRequiredMixin, calingen.views.generic.RequestEnabledFormView

Provide a list of availabe layouts.

Warning

This view is not restricted to users with a Calingen Profile and can be accessed by any user of the project.

However, on actual generation and compilation of the output, a Profile is required.

Notes

This is just the view to show and process the calingen.forms.generation.LayoutSelectionForm.

Relevant logic, that affects the actual creation, rendering and compilation of layouts is provided in the corresponding Form instance.

form_class
success_url
template_name = calingen/layout_selection.html
form_valid(form)

Trigger saving of the selected value in the user’s Session.

calingen.views.generation.logger