Views

class cards.views.card_views.CardDeleteView(**kwargs)[source]

Bases: View

The CardDeleteView class is a view class that deletes a card from a collection.

The class has the following attributes:

  • template_name: a string that represents the name of the template file

post(request, *args, **kwargs)
template_name = 'cards/edit_collection.html'
class cards.views.card_views.CardsListView(**kwargs)[source]

Bases: ListView

The CardsListView class is a class-based view that displays all the cards in a collection.

The class has the following attributes:

  • model: a model class that represents the collection

  • template_name: a string that represents the name of the template file

  • paginate_by: an integer that represents the number of cards to display

get_context_data(*args, object_list=None, **kwargs)[source]

Get the context data for the template and add the collection_id to the context.

Parameters:
  • args – Pass a list of arguments to the function

  • object_list – Pass the list of objects to the template, default is None

  • kwargs – Pass keyworded, variable-length argument list

Returns:

A dictionary of data that will be used to render the template

get_queryset()[source]

Get all cards from the collection. The collection_id is passed as a keyword argument. The collection is retrieved from the database using the get_collection_by_id method from the CollectionServices class. The cards are then retrieved from the collection using the get_all_cards method from the CollectionServices class. The cards are ordered based on the order_list of the collection.

Returns:

A list of cards that belong to a certain collection

model

alias of Collections

paginate_by = 1
template_name = 'cards/open_collection.html'
class cards.views.card_views.CreateCardView(**kwargs)[source]

Bases: View, MessageMixin

The CreateCardView class is a class-based view that allows users to create a new card.

The class has the following attributes:

  • template_name: a string that represents the name of the template file

  • confirm_create_template: a string that represents the name of the template file that confirms the creation of a card

confirm_create_template = 'cards/confirm_card_create.html'
get(request, *args, **kwargs)
post(request, *args, **kwargs)
template_name = 'cards/create_card.html'
class cards.views.collection_views.CardPositionView(**kwargs)[source]

Bases: View

The CardPositionView class is a view class that changes the position of a card in a collection.

The class has the following attributes:

  • template_name: a string that represents the name of the template file

post(request, *args, **kwargs)
template_name = 'cards:open_collection'
class cards.views.collection_views.CollectionCreateView(**kwargs)[source]

Bases: View, MessageMixin

The CollectionCreateView class is a view class that creates a new collection.

The class has the following attributes:

  • template_name: a string that represents the name of the template file

get(request, *args, **kwargs)
post(request, *args, **kwargs)
template_name = 'cards/create_collection.html'
class cards.views.collection_views.CollectionDeleteView(**kwargs)[source]

Bases: View

The CollectionDeleteView class is a view class that deletes a collection.

The class has the following attributes:

  • template_name: a string that represents the name of the template file

get(request, *args, **kwargs)
post(request, *args, **kwargs)
template_name = 'cards/deleting_warning.html'
class cards.views.collection_views.CollectionEditView(**kwargs)[source]

Bases: View

The CollectionEditView class is a view class that edits a collection.

The class has the following attributes:

  • template_name: a string that represents the name of the template file

get(request, *args, **kwargs)
post(request, *args, **kwargs)
template_name = 'cards/edit_collection.html'
class cards.views.collection_views.CollectionListView(**kwargs)[source]

Bases: ListView

The CollectionListView class is a view class that displays a list of collections created by the user. The class inherits from the ListView class, which is a generic view that displays a list of objects.

The class has the following attributes:

  • model: a model class that represents the collection

  • template_name: a string that represents the name of the template file

get_queryset()[source]

The get_queryset function is a built-in function that returns a list of objects that match the given query parameters.

Returns:

A list of objects that match the given query parameters

model

alias of Collections

template_name = 'cards/study_cards.html'