Les outils de mises en avant (featured/
)
Module situé dans zds/featured/
.
Modèles (models.py
)
- class zds.featured.models.FeaturedMessage(*args, **kwargs)
The Featured Message is a simple one-line information on the home page. This message is divided in three parts:
The hook : displayed in bold, it shows the topic of the message (i.e.: « New », « Warning », « Info », …)
The message : the info message itself (i.e.: « The site will be down for maintenance tomorrow »)
The « tell me more » url : A tell me more button linking to a page giving more details
Only the message is mandatory.
- exception DoesNotExist
- exception MultipleObjectsReturned
- class zds.featured.models.FeaturedRequested(*args, **kwargs)
This class hold votes for a topic or content to be featured.
- exception DoesNotExist
- exception MultipleObjectsReturned
- toggle(user)
Toogle featured request for user. Do not reject the vote anymore.
- Paramètres:
user (User) – the user
- Renvoie:
tuple of the form (user has voted, number of votes)
- Type renvoyé:
(bool, int)
- class zds.featured.models.FeaturedResource(*args, **kwargs)
A FeaturedResource is a link to a resource that is featured by the Staff It displays 3 main informations:
A background picture
A title
The author(s) of the resource
Currently, the five newer FeaturedResource are displayed on the front page.
- exception DoesNotExist
- exception MultipleObjectsReturned
Vues (views.py
)
- class zds.featured.views.FeaturedMessageCreateUpdate(**kwargs)
Creates or updates the featured message.
- form_class
alias de
FeaturedMessageForm
- form_valid(form)
If the form is valid, redirect to the supplied URL.
- get_context_data(**kwargs)
Insert the form into the context dict.
- get_initial()
Return the initial data to use for forms on this view.
- class zds.featured.views.FeaturedMessageDelete(*args, **kwargs)
Delete the featured message.
- form_valid(form)
If the form is valid, redirect to the supplied URL.
- get_object(queryset=None)
Return the object the view is displaying.
Require self.queryset and a pk or slug argument in the URLconf. Subclasses can override this to return any object.
- model
alias de
FeaturedMessage
- class zds.featured.views.FeaturedRequestedList(**kwargs)
Displays the list of featured resources.
- get_queryset()
Return the list of items for this view.
The return value must be an iterable and may be an instance of QuerySet in which case QuerySet specific behavior will be enabled.
- class zds.featured.views.FeaturedRequestedUpdate(**kwargs)
- model
alias de
FeaturedRequested
- post(request, *args, **kwargs)
Handle POST requests: instantiate a form instance with the passed POST variables and then check if it’s valid.
- class zds.featured.views.FeaturedResourceCreate(**kwargs)
Creates a new featured resource.
- form_class
alias de
FeaturedResourceForm
- form_valid(form)
If the form is valid, save the associated model.
- get_form_kwargs()
Return the keyword arguments for instantiating the form.
- get_initial()
Return the initial data to use for forms on this view.
- class zds.featured.views.FeaturedResourceDeleteDetail(*args, **kwargs)
Deletes a featured resource.
- model
alias de
FeaturedResource
- class zds.featured.views.FeaturedResourceDeleteList(**kwargs)
Deletes a list of featured resources.
- get_queryset()
Return the list of items for this view.
The return value must be an iterable and may be an instance of QuerySet in which case QuerySet specific behavior will be enabled.
- class zds.featured.views.FeaturedResourceList(**kwargs)
Displays the list of featured resources.
- class zds.featured.views.FeaturedResourceUpdate(**kwargs)
Updates a featured resource.
- form_class
alias de
FeaturedResourceForm
- form_valid(form)
If the form is valid, save the associated model.
- get_form(form_class=None)
Return an instance of the form to be used in this view.
- get_initial()
Return the initial data to use for forms on this view.
- class zds.featured.views.FeaturedViewMixin