calingen.views.profile

Views related to the calingen.models.profile.Profile model.

Module Contents

Classes

ProfileCreateView

Generic class-based view implementation to add calingen.models.profile.Profile objects.

ProfileDeleteView

Generic class-based view implementation to delete calingen.models.profile.Profile objects.

ProfileDetailView

Provide details of a calingen.models.profile.Profile instance.

ProfileUpdateView

Generic class-based view implementation to add calingen.models.profile.Profile objects.

class calingen.views.profile.ProfileCreateView(**kwargs)

Bases: django.contrib.auth.mixins.LoginRequiredMixin, django.views.generic.CreateView

Generic class-based view implementation to add calingen.models.profile.Profile objects.

Notes

This implementation uses Django’s generic class-based view django.views.generic.CreateView.

fields = []

The fields to include into the form.

This list is left empty, as the creation of the Profile instance is a one-off operation, simply tying the instance to an existing User of the Django project.

model

Required attribute to tie this view to the model.

template_name_suffix = _create

Make the view use the template calingen/profile_create.html.

form_valid(form)

Handle database integrity errors.

Notes

The view relies on an automatically generated instance of Django’s ModelForm without any fields. Thus, validation of the form is a given, as the request.user is injected after form validation.

However, the Profile has a 1:1 relation with the project’s AUTH_USER_MODEL, so trying to create multiple instances of Profile for the same user will raise an IntegrityError.

If the IntegrityError is catched, the user will be redirected to his profile page.

class calingen.views.profile.ProfileDeleteView(*args, **kwargs)

Bases: django.contrib.auth.mixins.LoginRequiredMixin, calingen.views.mixins.RestrictToUserMixin, calingen.views.mixins.ProfileIDMixin, django.views.generic.DeleteView

Generic class-based view implementation to delete calingen.models.profile.Profile objects.

Notes

This implementation uses Django’s generic class-based view django.views.generic.DeleteView.

context_object_name = profile_item

Provide a semantic name for the built-in context.

model

Required attribute to tie this view to the model.

pk_url_kwarg = profile_id

The name of the keyword argument as provided in the app’s url configuration.

By default, this is simply "pk", but for clarity, the app’s url configuration (calingen.urls) uses the more explicit "profile_id".

success_url

The URL to redirect to after successfully deleting the instance.

Warning

As of now, this redirect to the page to create a profile. This must be adjusted, once the real estimated flows are implemented with all required views.

class calingen.views.profile.ProfileDetailView(**kwargs)

Bases: django.contrib.auth.mixins.LoginRequiredMixin, calingen.views.mixins.RestrictToUserMixin, calingen.views.mixins.ProfileIDMixin, django.views.generic.DetailView

Provide details of a calingen.models.profile.Profile instance.

Notes

This implementation uses Django’s generic class-based view django.views.generic.DetailView.

context_object_name = profile

Provide a semantic name for the built-in context.

model

Required attribute to tie this view to the model.

pk_url_kwarg = profile_id

The name of the keyword argument as provided in the app’s url configuration.

By default, this is simply "pk", but for clarity, the app’s url configuration (calingen.urls) uses the more explicit "event_id".

get_context_data(**kwargs)

Just for linting.

class calingen.views.profile.ProfileUpdateView(**kwargs)

Bases: calingen.views.mixins.RestrictToUserMixin, django.contrib.auth.mixins.LoginRequiredMixin, calingen.views.mixins.ProfileIDMixin, django.views.generic.UpdateView

Generic class-based view implementation to add calingen.models.profile.Profile objects.

Notes

This implementation uses Django’s generic class-based view django.views.generic.CreateView.

form_class

Specify which form to use.

model

Required attribute to tie this view to the model.

pk_url_kwarg = profile_id

The name of the keyword argument as provided in the app’s url configuration.

By default, this is simply "pk", but for clarity, the app’s url configuration (calingen.urls) uses the more explicit "profile_id".

template_name_suffix = _update

Make the view use the template calingen/profile_update.html.

get_context_data(**kwargs)

Provide additional context for this view, depending on app-specific settings.

While accessing the users Profile, its list of event_provider is updated. If there are providers, that are moved from active to unavailable, the user is informed using Django’s messages framework.

This is dependent on the setting CALINGEN_MISSING_EVENT_PROVIDER_NOTIFICATION.