calingen.views.generation¶
Views in the context of rendering and compilation of layouts.
Module Contents¶
Classes¶
Render the selected layout and pass the result to a compiler. |
|
Show the (optional) configuration form for the selected layout. |
|
Provide a list of availabe layouts. |
Attributes¶
- 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.ViewRender the selected layout and pass the result to a compiler.
- _get_layout()¶
Return the
LayoutProviderimplementation.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
contextthat is passed to the layout’srender()method contains the followingkeys:target_year: The year to create the layout for.layout_configuration: If the layout provides a custom implementation ofcalingen.forms.generation.LayoutConfigurationForm, the fetched values will be provided here.entries: All calendar entries of the user’s profile, resolved to thetarget_year, provided as acalingen.interfaces.data_exchange.CalendarEntryListobject.
- 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 tocalingen.views.generation.LayoutSelectionViewis performed.The method retrieves the
compiler instancefrom the project’s settings module (CALINGEN_COMPILER). It will resort to the configured"default"compiler, if no specific compiler for the selectedlayout_type(as defined by the implementation ofLayoutProvider) 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.RequestEnabledFormViewShow the (optional) configuration form for the selected layout.
Warning
This view is not restricted to users with a
Calingen Profileand can be accessed by any user of the project.However, on actual generation and compilation of the output, a
Profileis 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.LayoutProvideruses a custonconfiguration_form.If no custom configuration is implemented by the layout, the request is redirected to the generator.
Notes
Determining the
configuration_formis done implicitly while traversing the view’s hierarchy during processing the request. Several methods are involved, but at some pointget_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 tocalingen.views.generation.LayoutSelectionViewis performed.
- get_form_class()¶
Retrieve the layout’s configuration form.
Notes
Implementations of
calingen.interfaces.plugin_api.LayoutProvidermay provide a class attributeconfiguration_formwith a subclass ofcalingen.forms.generation.LayoutConfigurationForm.If
configuration_formis omitted, a custom exception is raised, that will be handled inget().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.RequestEnabledFormViewProvide a list of availabe layouts.
Warning
This view is not restricted to users with a
Calingen Profileand can be accessed by any user of the project.However, on actual generation and compilation of the output, a
Profileis 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
Forminstance.- 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¶