calingen.views.mixins

App-specific mixins to be used with class-based views.

Module Contents

Classes

AllCalendarEntriesMixin

Add all CalendarEntry of the request.user.

ProfileIDMixin

Injects the Profile id of the request.user into the context.

RestrictToUserMixin

Limits the resulting queryset to objects, that belong to the current user.

class calingen.views.mixins.AllCalendarEntriesMixin

Add all CalendarEntry of the request.user.

This mixin uses get_context_data() to provide all of the user’s CalendarEntry instances for the context.

get_context_data(**kwargs)
class calingen.views.mixins.ProfileIDMixin

Injects the Profile id of the request.user into the context.

This mixin uses get_context_data() to inject the profile_id.

The mixin can safely be used on any View that also uses the django.contrib.auth.mixins.LoginRequiredMixin.

get_context_data(**kwargs)
class calingen.views.mixins.RestrictToUserMixin

Limits the resulting queryset to objects, that belong to the current user.

This mixin overwrites the view’s get_queryset() method and automatically uses the model’s app-specific calingen_manager with its filter_by_user() method.

The view, that uses this mixin, must provide the attribute model to actually make this mixin usable by any class-based view of the app.

get_queryset()

Return a queryset that only contains objects, that belong to the current user.

Internally, the returned queryset will use the app- and model-specific implementation of django.db.models.Manager as provided by calingen_manager on all of the app’s models. All of these managers rely on an app- and model-specific implementation of django.db.models.QuerySet that provide a model-specific method filter_by_user().

Returns:

The actual returned QuerySet is provided by the model’s app-specific manager calingen_manager.

Return type:

django.db.models.QuerySet

Raises:

django.core.exceptions.ImproperlyConfigured – The attribute model has to be defined on the view.