Les tutoriels v2 (ZEP12) (tutorialv2/
)¶
Module situé dans zds/tutorialv2/
.
Fichiers documentés :
Modèles (models/
)¶
Modèles de la base de donnée (models_database.py
)¶
-
class
zds.tutorialv2.models.models_database.
ContentReaction
(*args, **kwargs)¶ A comment written by any user about a PublishableContent they just read.
-
class
zds.tutorialv2.models.models_database.
ContentRead
(*args, **kwargs)¶ Small model which keeps track of the user viewing tutorials.
It remembers the PublishableContent they read and what was the last Note at that time.
-
save
(force_insert=False, force_update=False, using=None, update_fields=None)¶ Save this model but check that if we have not a related note it is because the user is content author.
-
-
class
zds.tutorialv2.models.models_database.
FakeChapter
(chapter, main_container, parent_id)¶ A simple class that is used by ES to index chapters, constructed from the containers.
In mapping, this class defines PublishedContent as its parent. Also, indexing is done by the parent.
Note that this class is only indexable, not updatable, since it does not maintain value of
es_already_indexed
-
get_es_document_as_bulk_action
(index, action=u'index')¶ Overridden to handle parenting between chapter and PublishedContent
-
classmethod
get_es_mapping
()¶ Define mapping and parenting
-
parent_model
¶ alias de
PublishedContent
-
-
class
zds.tutorialv2.models.models_database.
PickListOperation
(id, content, operation, operation_date, version, staff_user, canceler_user, is_effective)¶ -
cancel
(canceler, autosave=True)¶ Cancel a decision :param canceler: staff user :param autosave: if
True
saves the modification
-
-
class
zds.tutorialv2.models.models_database.
PublishableContent
(*args, **kwargs)¶ A publishable content.
A PublishableContent retains metadata about a content in database, such as
- authors, description, source (if the content comes from another website), subcategory, tags and licence ;
- Thumbnail and gallery ;
- Creation, publication and update date ;
- Public, beta, validation and draft sha, for versioning ;
- Comment support ;
- Type, which is either “ARTICLE” “TUTORIAL” or “OPINION”
Add all tags contained in tag_collection to this content. If a tag is unknown, it is added to the system. :param tag_collection: A collection of tags. :type tag_collection: list
-
antispam
(user=None)¶ Check if the user is allowed to post in an tutorial according to the SPAM_LIMIT_SECONDS value.
Paramètres: user – the user to check antispam. If None
, current user is used.Retourne: True
if the user is not able to note (the elapsed time is not enough),False
otherwise.Type retourné: bool
ensure all authors subscribe to gallery
-
first_note
()¶ Retourne: the first post of a topic, written by topic’s author, if any. Type retourné: ContentReaction
-
first_unread_note
(user=None)¶ Retourne: Return the first note the user has unread. Type retourné: ContentReaction
-
get_absolute_contact_url
(title=u'Collaboration')¶ Get url to send a new PM for collaboration
Paramètres: title (str) – what is going to be in the title of the PM before the name of the content Retourne: url to the PM creation form Type retourné: str
-
get_absolute_url_beta
()¶ NOTE: it’s better to use the version contained in VersionedContent, if possible !
Retourne: absolute URL to the beta version the content Type retourné: str
-
get_absolute_url_online
()¶ NOTE: it’s better to use the version contained in VersionedContent, if possible !
Retourne: absolute URL to the public version the content, if self.public_version is defined Type retourné: str
-
get_last_note
()¶ Retourne: the last answer in the thread, if any. Type retourné: ContentReaction|None
-
get_note_count
()¶ Count all the reactions to this content. Warning, if you did not pre process this number, a query will be sent
Retourne: number of notes in the tutorial. Type retourné: int
-
get_repo_path
(relative=False)¶ Get the path to the tutorial repository
Paramètres: relative – if True
, the path will be relative, absolute otherwise.Retourne: physical path Type retourné: str
-
in_beta
()¶ A tutorial is not in beta if sha_beta is
None
or emptyRetourne: True
if the tutorial is in beta,False
otherwiseType retourné: bool
-
in_drafting
()¶ A tutorial is not in draft if sha_draft is
None
or emptyRetourne: True
if the tutorial is in draft,False
otherwiseType retourné: bool
-
in_public
()¶ A tutorial is not in on line if sha_public is
None
or emptyRetourne: True
if the tutorial is on line,False
otherwiseType retourné: bool
-
in_validation
()¶ A tutorial is not in validation if sha_validation is
None
or emptyRetourne: True
if the tutorial is in validation,False
otherwiseType retourné: bool
-
insert_data_in_versioned
(versioned)¶ Insert some additional data from database in a VersionedContent
Paramètres: versioned – the VersionedContent to fill
-
is_beta
(sha)¶ Is this version of the content the beta version ?
Paramètres: sha – version Retourne: True
if the tutorial is in beta,False
otherwiseType retourné: bool
-
is_permanently_unpublished
()¶ Is this content permanently unpublished by a moderator ?
-
is_public
(sha)¶ Is this version of the content the published version ?
Paramètres: sha – version Retourne: True
if the tutorial is in public,False
otherwiseType retourné: bool
-
is_validation
(sha)¶ Is this version of the content the validation version ?
Paramètres: sha – version Retourne: True
if the tutorial is in validation,False
otherwiseType retourné: bool
-
last_read_note
()¶ Retourne: the last post the user has read. Type retourné: ContentReaction
-
load_version
(sha=None, public=None)¶ Using git, load a specific version of the content. if
sha
isNone
, the draft/public version is used (ifpublic
isTrue
).Attention
for practical reason, the returned object is filled with information from DB.
Paramètres: - sha – version
- public (PublishedContent) – if set with the right object, return the public version
Lève: - BadObject – if sha is not None and related version could not be found
- IOError – if the path to the repository is wrong
- NotAPublicVersion – if the sha does not correspond to a public version
Retourne: the versioned content
Type retourné:
-
load_version_or_404
(sha=None, public=None)¶ Using git, load a specific version of the content. if sha is None, the draft/public version is used (if public is True).
Paramètres: - sha – version
- public (PublishedContent) – if set with the right object, return the public version
Lève: Http404 – if sha is not None and related version could not be found
Retourne: the versioned content
Type retourné: zds.tutorialv2.models.models_versioned.ViersionedContent
-
repo_delete
()¶ Delete the entities and their filesystem counterparts
-
requires_validation_before
()¶ Check if content required a validation before publication. Used to check if JsFiddle is available too.
Retourne: Whether validation is required before publication. Type retourné: bool
-
save
(*args, **kwargs)¶ Rewrite the save() function to handle slug uniqueness
-
update
(**fields)¶ wrapper arround
self.objects.update
Paramètres: fields – Fields to update Retourne: modified self
-
class
zds.tutorialv2.models.models_database.
PublishedContent
(*args, **kwargs)¶ A class that contains information on the published version of a content.
Used for quick url resolution, quick listing, and to know where the public version of the files are.
Linked to a
PublishableContent
for the rest. Don’t forget to add a.prefetch_related('content')
!!-
get_absolute_url_epub
()¶ wrapper around
self.get_absolute_url_to_extra_content('epub')
Retourne: URL to the epub version of the published content Type retourné: str
-
get_absolute_url_html
()¶ wrapper around
self.get_absolute_url_to_extra_content('html')
Retourne: URL to the HTML version of the published content Type retourné: str
-
get_absolute_url_md
()¶ wrapper around
self.get_absolute_url_to_extra_content('md')
Retourne: URL to the full markdown version of the published content Type retourné: str
-
get_absolute_url_pdf
()¶ wrapper around
self.get_absolute_url_to_extra_content('pdf')
Retourne: URL to the PDF version of the published content Type retourné: str
-
get_absolute_url_to_extra_content
(type_)¶ Get the url that point to the extra content the user may want to download
Paramètres: type (str) – the type inside allowed_type Retourne: URL to a given extra content (note that no check for existence is done) Type retourné: str
-
get_absolute_url_zip
()¶ wrapper around
self.get_absolute_url_to_extra_content('zip')
Retourne: URL to the zip archive of the published content Type retourné: str
-
get_char_count
(md_file_path=None)¶ Compute the number of letters for a given content
Paramètres: md_file_path (str) – use another file to compute the number of letter rather than the default one. Retourne: Number of letters in the md file Type retourné: int
-
classmethod
get_es_django_indexable
(force_reindexing=False)¶ Overridden to remove must_redirect=True (and prefetch stuffs).
-
get_es_document_source
(excluded_fields=None)¶ Overridden to handle the fact that most information are versioned
-
classmethod
get_es_indexable
(force_reindexing=False)¶ Overridden to also include chapters
-
get_size_file_type
(type_)¶ Get the size of a given extra content. Is the size is not in database we get it and store it for next time.
Retourne: size of file Type retourné: int
-
have_epub
()¶ Check if the standard epub version of the content is available
Retourne: True
if available,False
otherwiseType retourné: bool
-
have_html
()¶ Check if the html version of the content is available
Retourne: True
if available,False
otherwiseType retourné: bool
-
have_md
()¶ Check if the markdown version of the content is available
Retourne: True
if available,False
otherwiseType retourné: bool
-
have_pdf
()¶ Check if the pdf version of the content is available
Retourne: True
if available,False
otherwiseType retourné: bool
-
have_type
(type_)¶ check if a given extra content exists
Retourne: True
if the file exists,False
otherwhiseType retourné: bool
-
have_zip
()¶ Check if the standard zip version of the content is available
Retourne: True
if available,False
otherwiseType retourné: bool
-
load_public_version
()¶ Type retourné: zds.tutorialv2.models.models_database.PublicContent Retourne: the public content
-
load_public_version_or_404
()¶ Retourne: the public content Type retourné: zds.tutorialv2.models.models_database.PublicContent Lève: Http404 – if the version is not available
-
-
class
zds.tutorialv2.models.models_database.
Validation
(*args, **kwargs)¶ Content validation.
-
is_accept
()¶ Check if the content is accepted
Retourne: True
if status is accepted,False
otherwiseType retourné: bool
-
is_cancel
()¶ Check if the content is canceled
Retourne: True
if status is canceled,False
otherwiseType retourné: bool
-
is_pending
()¶ Check if the validation is pending
Retourne: True
if status is pending,False
otherwiseType retourné: bool
-
-
zds.tutorialv2.models.models_database.
delete_gallery
(sender, instance, **kwargs)¶ catch the post_delete signal to ensure the deletion of the gallery (otherwise, you generate a loop)
-
zds.tutorialv2.models.models_database.
delete_published_content_in_elasticsearch
(sender, instance, **kwargs)¶ Catch the pre_delete signal to ensure the deletion in ES. Also, handle the deletion of the corresponding chapters.
-
zds.tutorialv2.models.models_database.
delete_published_content_in_elasticsearch_if_set_to_redirect
(sender, instance, **kwargs)¶ If the slug of the content changes, the
must_redirect
field is set toTrue
and a new PublishedContnent is created. To avoid duplicates, the previous ones must be removed from ES.
-
zds.tutorialv2.models.models_database.
delete_repo
(sender, instance, **kwargs)¶ catch the pre_delete signal to ensure the deletion of the repository if a PublishableContent is deleted
-
zds.tutorialv2.models.models_database.
transfer_paternity_receiver
(sender, instance, **kwargs)¶ transfer paternity to external user on user deletion
Modèles “versionnés” (models_versioned.py
)¶
-
class
zds.tutorialv2.models.models_versioned.
Container
(title, slug='', parent=None, position_in_parent=1)¶ A container, which can have sub-Containers or Extracts.
A Container has a title, a introduction and a conclusion, a parent (which can be None) and a position into this parent (which is 1 by default).
It has also a tree depth.
A container could be either a tutorial/article/opinion, a part or a chapter.
-
add_container
(container, generate_slug=False)¶ Add a child Container, but only if no extract were previously added and tree depth is < 2.
Attention
this function will also raise an Exception if article, because it cannot contain child container
Paramètres: - container – the new container
- generate_slug – if
True
, ask the top container an unique slug for this object
Lève: InvalidOperationError – if cannot add container to this one. Please use
can_add_container
to check this before callingadd_container
.
-
add_extract
(extract, generate_slug=False)¶ Add a child container, but only if no container were previously added
Paramètres: - extract – the new extract
- generate_slug – if True, ask the top container an unique slug for this object
Lève: InvalidOperationError – if cannot add extract to this container.
-
add_slug_to_pool
(slug)¶ Add a slug to the slug pool to be taken into account when generate a unique slug
Paramètres: slug – the slug to add Lève: InvalidOperationErrpr – if the slug already exists
-
can_add_container
()¶ Retourne: True
if this container accept child container,False
otherwiseType retourné: bool
-
can_add_extract
()¶ check that this container can get extract, i.e has no container and is not too deep
Retourne: True
if this container accept child extract,False
otherwiseType retourné: bool
-
can_be_in_beta
()¶ Check if content can be in beta.
Retourne: Whether content is in beta. Type retourné: bool
-
compute_hash
()¶ Compute an MD5 hash from the introduction and conclusion, for comparison purpose
Retourne: MD5 hash Type retourné: str
-
get_conclusion_online
()¶ The conclusion content for online version.
Retourne: the full text if introduction exists None
otherwiseType retourné: str
-
get_introduction_online
()¶ The introduction content for online version.
Retourne: the full text if introduction exists None
otherwiseType retourné: str
-
get_last_child_position
()¶ Retourne: the position of the last child Type: int
-
get_level_as_string
()¶ Get a word (Part/Chapter/Section) for the container level
Attention
this deals with internationalized string
Retourne: The string representation of this level Type retourné: str
-
get_next_level_as_string
()¶ Same as
self.get_level_as_string()
but try to guess the level of this container’s childrenRetourne: The string representation of next level (upper) Type retourné: str
-
get_path
(relative=False)¶ Get the physical path to the draft version of the container. Note: this function rely on the fact that the top container is VersionedContainer.
Paramètres: relative (bool) – if True
, the path will be relative, absolute otherwise.Retourne: physical path Type retourné: str
-
get_prod_path
(relative=False)¶ Get the physical path to the public version of the container. If the container have extracts, then it returns the final HTML file.
Paramètres: relative (bool) – return a relative path instead of an absolute one Retourne: physical path Type retourné: str
-
get_tree_depth
()¶ Represent the depth where this container is found Tree depth is no more than 2, because there is 3 levels for Containers :
- PublishableContent (0),
- Part (1),
- Chapter (2)
Attention
that
max_tree_depth
is2
to ensure that there is no more than 3 levelsRetourne: Tree depth Type retourné: int
-
get_tree_level
()¶ Represent the level in the tree of this container, i.e the depth of its deepest child
Retourne: tree level Type retourné: int
-
get_unique_slug
(title)¶ Generate a slug from title, and check if it is already in slug pool. If it is the case, recursively add a “-x” to the end, where “x” is a number starting from 1. When generated, it is added to the slug pool.
Note that the slug cannot be larger than settings.ZDS_APP[‘content’][‘max_slug_size’], due to maximum file size limitation.
Paramètres: title – title from which the slug is generated (with slugify()
)Retourne: the unique slug Type retourné: str
-
has_child_with_path
(child_path)¶ Check that the given path represent the full path of a child of this container.
Paramètres: child_path – the full path (/maincontainer/subc1/subc2/childslug) we want to check Retourne: True
if child is found,False
otherwiseType retourné: bool
-
has_extracts
()¶ Note : this function rely on the fact that the children can only be of one type.
Retourne: True if the container has extract as children, False otherwise. Type retourné: bool
-
has_sub_containers
()¶ Note : this function rely on the fact that the children can only be of one type.
Retourne: True
if the container has containers as children,False
otherwise.Type retourné: bool
-
is_part
()¶ determin if this container is a part (i.e a first level container or container with extract when we are in midsize tutorial :return:
-
move_child_after
(child_slug, refer_slug)¶ Change the child’s ordering by moving the child to be below the reference child. This method does not automaticaly update the repo
Paramètres: - child_slug – the child’s slug
- refer_slug – the referent child’s slug.
Lève: ValueError – if one slug does not refer to an existing child
-
move_child_before
(child_slug, refer_slug)¶ Change the child’s ordering by moving the child to be just above the reference child. . This method does not automaticaly update the repo
Paramètres: - child_slug – the child’s slug
- refer_slug – the referent child’s slug.
Lève: ValueError – if one slug does not refer to an existing child
-
move_child_down
(child_slug)¶ Change the child’s ordering by moving down the child whose slug equals child_slug. This method does not automaticaly update the repo
Paramètres: child_slug – the child’s slug
Lève: - ValueError – if the slug does not refer to an existing child
- IndexError – if the extract is already the last child
-
move_child_up
(child_slug)¶ Change the child’s ordering by moving up the child whose slug equals child_slug. This method does not automaticaly update the repo
Paramètres: child_slug – the child’s slug
Lève: - ValueError – if the slug does not refer to an existing child
- IndexError – if the extract is already the first child
-
repo_add_container
(title, introduction, conclusion, commit_message='', do_commit=True, slug=None)¶ Paramètres: - title – title of the new container
- introduction – text of its introduction
- conclusion – text of its conclusion
- commit_message – commit message that will be used instead of the default one
- do_commit – perform the commit in repository if
True
Retourne: commit sha
Type retourné:
-
repo_add_extract
(title, text, commit_message='', do_commit=True, slug=None)¶ Paramètres: - title – title of the new extract
- text – text of the new extract
- commit_message – commit message that will be used instead of the default one
- do_commit – perform the commit in repository if
True
- generate_slug – indicates that is must generate slug
Retourne: commit sha
Type retourné:
-
repo_delete
(commit_message='', do_commit=True)¶ Paramètres: - commit_message – commit message used instead of default one if provided
- do_commit – tells if we have to commit the change now or let the outter program do it
Retourne: commit sha
Type retourné:
-
repo_update
(title, introduction, conclusion, commit_message='', do_commit=True, update_slug=True)¶ Update the container information and commit them into the repository
Paramètres: - title – the new title
- introduction – the new introduction text
- conclusion – the new conclusion text
- commit_message – commit message that will be used instead of the default one
- do_commit – perform the commit in repository if
True
Retourne: commit sha
Type retourné:
-
requires_validation_before
()¶ Check if content required a validation before publication. Used to check if JsFiddle is available too.
Retourne: Whether validation is required before publication. Type retourné: bool
-
top_container
()¶ Retourne: Top container (for which parent is None
)Type retourné: VersionedContent
-
traverse
(only_container=True)¶ Traverse the container
Paramètres: only_container – if we only want container’s paths, not extract Retourne: a generator that traverse all the container recursively (depth traversal) Type retourné: collections.Iterable[Container|Extract]
-
update_children
()¶ Update the path for introduction and conclusion for the container and all its children. If the children is an extract, update the path to the text instead. This function is useful when self.slug has changed. Note : this function does not account for a different arrangement of the files.
-
-
class
zds.tutorialv2.models.models_versioned.
Extract
(title, slug='', container=None, position_in_parent=1)¶ A content extract from a Container.
It has a title, a position in the parent container and a text.
-
compute_hash
()¶ Compute an MD5 hash from the text, for comparison purpose
Retourne: MD5 hash of the text Type retourné: str
-
get_absolute_url
()¶ Find the url that point to the offline version of this extract
Retourne: the url to access the tutorial offline Type retourné: str
-
get_first_level_slug
()¶ Retourne: the first_level_slug, if (and only) the parent container is a chapter Type retourné: str
-
get_full_slug
()¶ get the slug of curent extract with its full path (part1/chapter1/slug_of_extract) this method is an alias to extract.get_path(True)[:-3] (remove .md extension) :rtype: str
-
get_path
(relative=False)¶ Get the physical path to the draft version of the extract. :param relative: if
True
, the path will be relative, absolute otherwise. :return: physical path :rtype: str
-
get_tree_depth
()¶ Represent the depth where this exrtact is found Tree depth is no more than 3, because there is 3 levels for Containers +1 for extract :
- PublishableContent (0),
- Part (1),
- Chapter (2)
Note that ‘max_tree_depth is 2 to ensure that there is no more than 3 levels
Retourne: Tree depth Type retourné: int
-
repo_delete
(commit_message='', do_commit=True)¶ Paramètres: - commit_message – commit message used instead of default one if provided
- do_commit – tells if we have to commit the change now or let the outter program do it
Retourne: commit sha, None if no commit is done
Type retourné:
-
-
exception
zds.tutorialv2.models.models_versioned.
NotAPublicVersion
(*args, **kwargs)¶ Exception raised when a given version is not a public version as it should be
-
class
zds.tutorialv2.models.models_versioned.
PublicContent
(current_version, _type, title, slug)¶ This is the public version of a VersionedContent, created from public repository
-
class
zds.tutorialv2.models.models_versioned.
VersionedContent
(current_version, _type, title, slug, slug_repository='')¶ This class is used to handle a specific version of a tutorial.tutorial
It is created from the ‘manifest.json’ file, and could dump information in it.
For simplicity, it also contains DB information (but cannot modified them!), filled at the creation.
-
change_child_directory
(child, adoptive_parent)¶ Move an element of this content to a new location. This method changes the repository index and stage every change but does not commit.
Paramètres: - child – the child we want to move, can be either an Extract or a Container object
- adoptive_parent – the container where the child will be moved, must be a Container object
-
commit_changes
(commit_message)¶ Commit change made to the repository
Paramètres: commit_message – The message that will appear in content history Retourne: commit sha Type retourné: str
-
dump_json
(path=None)¶ Write the JSON into file
Paramètres: path – path to the file. If None, write in ‘manifest.json’
-
get_list_of_chapters
()¶ Retourne: a list of chapters (Container which contains Extracts) in the reading order Type retourné: list[Container]
-
get_path
(relative=False, use_current_slug=False)¶ Get the physical path to the draft version of the Content.
Paramètres: - relative – if True, the path will be relative, absolute otherwise.
- use_current_slug – if True, use self.slug instead of self.slug_last_draft
Retourne: physical path
Type retourné:
-
get_prod_path
(relative=False)¶ Get the physical path to the public version of the content. If it has extract (so, if its a mini-tutorial or an article), return the HTML file.
Paramètres: relative – return the relative path instead of the absolute one Retourne: physical path Type retourné: str
-
repo_update_top_container
(title, slug, introduction, conclusion, commit_message='', do_commit=True)¶ Update the top container information and commit them into the repository. Note that this is slightly different from the repo_update() function, because slug is generated using DB
Paramètres: - title – the new title
- slug – the new slug, according to title (choose using DB!!)
- introduction – the new introduction text
- conclusion – the new conclusion text
- commit_message – commit message that will be used instead of the default one
- do_commit – if True, also commit change
Retourne: commit sha
Type retourné:
-
Les managers (managers.py
)¶
-
class
zds.tutorialv2.managers.
PublishableContentManager
¶ ...
-
get_last_articles
(number=0)¶ - ..attention:
- this one uses a raw subquery for historical reasons. It will hopefully be replaced one day by an ORM primitive.
Retourne: list of last articles expanded with ‘count_note’ property that prefetches number of comments Type retourné: list
-
get_last_opinions
()¶ This depends on settings.ZDS_APP[‘opinions’][‘home_number’] parameter.
Retourne: list of last opinions Type retourné: list
-
get_last_tutorials
(number=0)¶ get list of last published tutorial
Paramètres: number – number of tutorial you want. By default it is interpreted as settings.ZDS_APP['tutorial']['home_number']
Retourne: list of last published content Type retourné: list
-
transfer_paternity
(unregistered_user, replacement_author, gallery_class)¶ Erases or transfers the paternity of all publishable content owned by a user. If a content has more than one author, the unregistering author simply leaves its author list, otherwise their published content are sent to
replacement_author
, unpublished content are deleted and their beta topics closed.Paramètres: - unregistered_user – the user to be unregistered
- replacement_author – the new author
- gallery_class – the class to link tutorial with gallery (perhaps overkill :p)
-
Vues (views/
)¶
Contenus (views/views_contents.py
)¶
-
class
zds.tutorialv2.views.views_contents.
ActivateJSFiddleInContent
(**kwargs)¶ Handles changes a validator or staff member can do on the js fiddle support of the provided content Only these users can do it
-
form_valid
(form)¶ Change the js fiddle support of content and redirect to the view page
-
-
class
zds.tutorialv2.views.views_contents.
ContentsWithHelps
(**kwargs)¶ List all tutorial that needs help, i.e registered as needing at least one HelpWriting or is in beta for more documentation, have a look to ZEP 03 specification (fr)
-
get_context_data
(**kwargs)¶ Add all HelpWriting objects registered to the context so that the template can use it
-
get_queryset
()¶ get only tutorial that need help and handle filtering if asked
-
-
class
zds.tutorialv2.views.views_contents.
CreateContent
(**kwargs)¶ Handle content creation. Since v22 a licence must be explicitly selected instead of defaulting to “All rights reserved”. Users can however set a default licence in their profile.
-
model
¶ alias de
PublishableContent
-
-
class
zds.tutorialv2.views.views_contents.
CreateContentFromArchive
(**kwargs)¶ Create a content using an archive
-
class
zds.tutorialv2.views.views_contents.
DisplayBetaContainer
(**kwargs)¶ View to get the beta version of a container
-
get_object
(queryset=None)¶ rewritten to ensure that the version is set to beta, raise Http404 if there is no such version
-
-
class
zds.tutorialv2.views.views_contents.
DisplayBetaContent
(**kwargs)¶ View to get the beta version of a content
-
get_object
(queryset=None)¶ rewritten to ensure that the version is set to beta, raise Http404 if there is no such version
-
-
class
zds.tutorialv2.views.views_contents.
DisplayContainer
(**kwargs)¶ Base class that can show any content in any state
-
get_context_data
(**kwargs)¶ Show the given tutorial if exists.
-
model
¶ alias de
PublishableContent
-
-
class
zds.tutorialv2.views.views_contents.
DisplayContent
(**kwargs)¶ Base class that can show any content in any state
-
get_forms
(context)¶ get all the auxiliary forms about validation, js fiddle...
-
model
¶ alias de
PublishableContent
-
-
class
zds.tutorialv2.views.views_contents.
DisplayDiff
(**kwargs)¶ Display the difference between two versions of a content. The left version is given in a GET query parameter named from, the right one with to. This class has no reason to be adapted to any content type.
-
model
¶ alias de
PublishableContent
-
-
class
zds.tutorialv2.views.views_contents.
DisplayHistory
(**kwargs)¶ Display the whole modification history. This class has no reason to be adapted to any content type.
-
model
¶ alias de
PublishableContent
-
-
class
zds.tutorialv2.views.views_contents.
DownloadContent
(**kwargs)¶ Download a zip archive with all the content of the repository directory
-
get_contents
()¶ get the zip file stream
Retourne: a zip file Type retourné: byte
-
static
insert_into_zip
(zip_file, git_tree)¶ Recursively add file into zip
Paramètres: - zip_file – a
zipfile
object (with writing permissions) - git_tree – Git tree (from
repository.commit(sha).tree
)
- zip_file – a
-
-
class
zds.tutorialv2.views.views_contents.
ManageBetaContent
(**kwargs)¶ Depending of the value of self.action, this class will behave differently; - if ‘set’, it will active (of update) the beta - if ‘inactive’, it will inactive the beta on the tutorial
-
model
¶ alias de
PublishableContent
-
-
class
zds.tutorialv2.views.views_contents.
RedirectOldBetaTuto
(**kwargs)¶ allows to redirect /tutoriels/beta/old_pk/slug to /contenus/beta/new_pk/slug
-
class
zds.tutorialv2.views.views_contents.
UpdateContentWithArchive
(**kwargs)¶ Update a content using an archive
-
static
extract_content_from_zip
(zip_archive)¶ Check if the data in the zip file are coherent
Paramètres: zip_archive (zipfile.ZipFile) – the zip archive to analyze Lève: BadArchiveError – if something is wrong in the archive Retourne: the content in the archive Type retourné: VersionedContent
-
static
update_from_new_version_in_zip
(copy_to, copy_from, zip_file)¶ Copy the information from
new_container
intocopy_to
. This function correct path for file if necessaryParamètres: - copy_to (Container) – container that to copy to
- copy_from (Container) – copy from container
- zip_file (zipfile.ZipFile) – zip file that contain the files
-
static
update_image_link
(group, translation_dic)¶ callback function for the transformation of
image:xxx
to the right path in galleryParamètres: - group (re.MatchObject) – matching object
- translation_dic (dict) – image to link into gallery dictionary
Retourne: updated link
Type retourné:
-
static
use_images_from_archive
(request, zip_file, versioned_content, gallery)¶ Extract image from a gallery and then translate the
![.+](prefix:filename)
into the final image we want. Theprefix
is defined into the settings. Note that this function does not perform any commit.Paramètres: - zip_file (zipfile.ZipFile) – ZIP archive
- versioned_content (VersionedContent) – content
- gallery (Gallery) – gallery of image
-
static
walk_container
(container)¶ Iterator that yield each file path in a Container
Paramètres: container (Container) – the container Type retourné: collections.Iterable[str]
-
static
walk_content
(versioned)¶ Iterator that yield each files in a VersionedContent
Paramètres: versioned (VersionedContent) – the content Type retourné: collections.Iterable[str]
-
static
Validations (views/views_validations.py
)¶
-
class
zds.tutorialv2.views.views_validations.
AcceptValidation
(**kwargs)¶ Publish the content
-
class
zds.tutorialv2.views.views_validations.
AskValidationForContent
(**kwargs)¶ User ask validation for his tutorial. Staff member can also to that
-
class
zds.tutorialv2.views.views_validations.
CancelValidation
(**kwargs)¶ The user or an admin cancel the validation process
-
class
zds.tutorialv2.views.views_validations.
DoNotPickOpinion
(**kwargs)¶ Remove
-
class
zds.tutorialv2.views.views_validations.
PickOpinion
(**kwargs)¶ Approve and Add the opinion in the picked list
-
class
zds.tutorialv2.views.views_validations.
PromoteOpinionToArticle
(**kwargs)¶ Promote an opinion to article. this duplicates the opinion and declares the clone as an article.
-
class
zds.tutorialv2.views.views_validations.
PublishOpinion
(**kwargs)¶ Publish the content (only content without preliminary validation)
-
form_class
¶ alias de
PublicationForm
-
-
class
zds.tutorialv2.views.views_validations.
RejectValidation
(**kwargs)¶ Reject the publication
-
class
zds.tutorialv2.views.views_validations.
ReserveValidation
(**kwargs)¶ Reserve or remove the reservation on a content
-
class
zds.tutorialv2.views.views_validations.
RevokePickOperation
(**kwargs)¶ Cancels a moderation operation. If operation was REMOVE_PUB, it just marks it as canceled, it does not republish the opinion.
-
class
zds.tutorialv2.views.views_validations.
RevokeValidation
(**kwargs)¶ Unpublish a content and reverse the situation back to a pending validation
-
class
zds.tutorialv2.views.views_validations.
UnpickOpinion
(**kwargs)¶ Remove opinion from the picked list
-
class
zds.tutorialv2.views.views_validations.
UnpublishOpinion
(**kwargs)¶ Unpublish an opinion
-
class
zds.tutorialv2.views.views_validations.
ValidationListView
(**kwargs)¶ List the validations, with possibilities of filters
-
class
zds.tutorialv2.views.views_validations.
ValidationOpinionListView
(**kwargs)¶ List the validations, with possibilities of filters
Contenus publiés (views/views_published.py
)¶
-
class
zds.tutorialv2.views.views_published.
DisplayOnlineArticle
(**kwargs)¶ Displays the list of published articles
-
class
zds.tutorialv2.views.views_published.
DisplayOnlineContainer
(**kwargs)¶ Base class that can show any content in any state
-
class
zds.tutorialv2.views.views_published.
DisplayOnlineContent
(**kwargs)¶ Base class that can show any online content
-
get_context_data
(**kwargs)¶ Show the given tutorial if exists.
-
model
¶ alias de
PublishedContent
-
-
class
zds.tutorialv2.views.views_published.
DisplayOnlineOpinion
(**kwargs)¶ Displays the list of published articles
-
class
zds.tutorialv2.views.views_published.
DisplayOnlineTutorial
(**kwargs)¶ Displays the list of published tutorials
-
class
zds.tutorialv2.views.views_published.
DownloadOnlineContent
(**kwargs)¶ Views that allow users to download ‘extra contents’ of the public version
-
class
zds.tutorialv2.views.views_published.
ListOnlineContents
(**kwargs)¶ Displays the list of published contents
-
get_queryset
()¶ Filter the contents to obtain the list of contents of given type. If category parameter is provided, only contents which have this category will be listed. :return: list of contents with the right type :rtype: list of zds.tutorialv2.models.models_database.PublishedContent
-
-
class
zds.tutorialv2.views.views_published.
ListOpinions
(**kwargs)¶ Displays the list of published opinions
Mixins (mixins.py
)¶
-
class
zds.tutorialv2.mixins.
ContentTypeMixin
¶ This class deals with the type of contents and fill context according to that
-
class
zds.tutorialv2.mixins.
DownloadViewMixin
(**kwargs)¶ Basic View to return a file to download
(inspired from https://djangosnippets.org/snippets/2549/ and http://stackoverflow.com/questions/16286666/send-a-file-through-django-class-based-views)
You just need to override get_contents() to make it works
-
get
(context, **response_kwargs)¶ Access to a file with only get method then write the file content in response stream. Properly sets Content-Type and Content-Disposition headers
-
-
class
zds.tutorialv2.mixins.
ModalFormView
(**kwargs)¶ If self.modal_form is set True, this class will ensure that the redirection is made to the previous page if an error appear
-
form_invalid
(form)¶ If self.modal_form is set True, this function is rewritten to send back to the previous page with an error message, instead of using the form template which is normally provided.
The redirection is made to form.previous_page_url, if exists, content:view otherwise.
-
-
exception
zds.tutorialv2.mixins.
MustRedirect
(*args, **kwargs)¶ Exception raised when this is not the last version of the content which is called
-
class
zds.tutorialv2.mixins.
NoValidationBeforeFormViewMixin
(**kwargs)¶ Ensure the content do not require validation before publication.
-
class
zds.tutorialv2.mixins.
SingleContentDetailViewMixin
(**kwargs)¶ This enhanced DetailView ensure,
- by rewriting get(), that:
- self.object contains the result of get_object() (as it must be if get() is not rewritten)
- self.sha is set according to self.request.GET[‘version’] (if any) and self.object.sha_draft otherwise
- self.versioned_object contains the results of get_versioned_object()
- by surcharging get_context_data(), that
- context[‘content’] contains self.versioned_object
- context[‘can_edit’] is set
- context[‘version’] is set (if different from self.object.sha_draft)
- context[‘beta_topic’] is set (if any)
-
class
zds.tutorialv2.mixins.
SingleContentDownloadViewMixin
(**kwargs)¶ Ensure, by rewritring
get()
, that - self.object contains the result of get_object() (as it must be if get() is not rewritten) - self.sha is set according to self.request.GET[‘version’] (if any) and self.object.sha_draft otherwise - self.versioned_object contains the results of get_versioned_object()
-
class
zds.tutorialv2.mixins.
SingleContentFormViewMixin
(**kwargs)¶ This enhanced FormView ensure,
- by surcharging dispatch(), that:
- self.object contains the result of get_object() (as for DetailView)
- self.versioned_object contains the results of get_versioned_object()
- by surcharging get_context_data(), that
- context[‘content’] contains self.versioned_object
-
class
zds.tutorialv2.mixins.
SingleContentPostMixin
¶ Base mixin used to get content from post query
-
class
zds.tutorialv2.mixins.
SingleContentViewMixin
¶ Base mixin to get only one content, and its corresponding versioned content
Deals with URL resolution in the following way:
- In
get_object()
: - Fetch the
PublishableContent
according toself.kwargs['pk']
,self.request.GET['pk']
orself.request.POST['pk']
(one of these have to be defined). Raise Http404 if any. - Then, check permissions with respect to
self.must_be_author
andself.authorized_for_staff
(and defineself.is_staff
andself.is_author
). RaisePermissionDenied
if any.
- Fetch the
- In
- In
get_versioned_object()
: - Deal with sha : assume
self.object.sha_draft
by default, but reset according toself.request.GET['version']
, if exists. Then, checkself.only_draft_version
and raisePermissionDenied
if any - Fetch the
VersionedContent
. Due to the use ofself.object.load_version_or_404(sha)
, raiseHttp404
. - Check if its the beta or public version, and allow access if it’s the case. Raise
PermissionDenied
. - Check slug if
self.kwargs['slug']
is defined. RaiseHttp404
if any.
- Deal with sha : assume
- In
- In
get_public_object()
, fetch the last published version, if any
Any redefinition of any of these two functions should take care of those points.
-
get_object
(queryset=None)¶ Get database representation of the content by its pk, then check permissions
-
get_public_object
()¶ Get the published version, if any
-
get_versioned_object
()¶ Gets the asked version of current content.
-
class
zds.tutorialv2.mixins.
SingleOnlineContentDetailViewMixin
(**kwargs)¶ This enhanced DetailView ensures,
- by rewriting get(), that:
- self.object contains the result of get_object() (as it must be if get() was not rewritten)
- Redirection is made if we catch MustRedirect
- self.versioned_object contains a PublicContent object
- self.public_content_object contains a PublishedContent object
- by surcharging get_context_data(), that
- context[‘content’] is set
- context[‘is_staff’] is set
- context[‘can_edit’] is set
- context[‘public_object’] is set
- context[‘isantispam’] is set
-
class
zds.tutorialv2.mixins.
SingleOnlineContentFormViewMixin
(**kwargs)¶ This enhanced FormView ensure,
- by surcharging dispatch(), that:
- self.public_content_object contains a PublishedContent object
- self.object contains the result of get_object() (as for DetailView)
- self.versioned_object contains the results of get_versioned_object()
- by surcharging get_context_data(), that
- context[‘content’] is set
- context[‘public_object’] is set
Note: does not catch MustRedirect, so you should not use a slug with POST request
-
class
zds.tutorialv2.mixins.
SingleOnlineContentViewMixin
¶ Base mixin to get only one content online content
Deals with URL resolution in the following way:
- In get_object():
- Fetch the
PublicContent
according toself.kwargs['pk']
,self.request.GET['pk']
orself.request.POST['pk']
0(one of these have to be defined). RaiseHttp404
if any. - Check if
self.current_content_type
if defined, and use it if it’s the case - Check if
slug
is defined, also check object it if it’s the case - Then, define
self.is_staff
andself.is_author
.
- Fetch the
- In
get_versioned_object()
: Fetch theVersionedContent
. Due to the use of self.public_content_object.load_public_version_or_404()
, raiseHttp404
if any.
- In
Any redefinition of any of these two functions should take care of those points.
-
get_redirect_url
(public_version)¶ Return the most recent url, based on the current public version
-
class
zds.tutorialv2.mixins.
ValidationBeforeViewMixin
(**kwargs)¶ Ensure the content require validation before publication.
Les forumulaires (forms.py
)¶
-
class
zds.tutorialv2.forms.
PublicationForm
(content, *args, **kwargs)¶ The publication form (used only for content without preliminary validation).
Les utilitaires (utils.py
)¶
-
exception
zds.tutorialv2.utils.
BadArchiveError
(reason)¶ The exception that is raised when a bad archive is sent
-
exception
zds.tutorialv2.utils.
BadManifestError
(*args, **kwargs)¶ The exception that is raised when the manifest.json contains errors
-
exception
zds.tutorialv2.utils.
InvalidSlugError
(*args, **kwargs)¶ Error raised when a slug is invalid. Argument is the slug that cause the error.
source
can also be provided, being the sentence from witch the slug was generated, if any.had_source
is set toTrue
if the source is provided.
-
exception
zds.tutorialv2.utils.
TooDeepContainerError
(*args, **kwargs)¶ Exception used to represent the fact you can’t add a container to a level greater than two
-
zds.tutorialv2.utils.
all_is_string_appart_from_children
(dict_representation)¶ check all keys are string appart from the children key :param dict_representation: the json decoded dictionary :type dict_representation: dict :return: :rtype: bool
-
zds.tutorialv2.utils.
check_slug
(slug)¶ If the title is incorrect (only special chars so slug is empty).
Paramètres: slug (str) – slug to test Retourne: True if slug is valid, false otherwise Type retourné: bool
-
zds.tutorialv2.utils.
clone_repo
(old_path, new_path)¶ Proxy to
git clone command
. Ensure directory are properly createdParamètres: - old_path – path of the repo to be cloned
- new_path – path of the target repo
Retourne: the target repository encapsulated in a
GitPython
object.Type retourné: Repo
-
zds.tutorialv2.utils.
default_slug_pool
()¶ initialize a slug pool with all forbidden name. basically
introduction
andconclusion
Retourne: the forbidden slugs in the edition system Type retourné: dict
-
zds.tutorialv2.utils.
export_container
(container)¶ Export a container to a dictionary
Paramètres: container – the container Retourne: dictionary containing the information Type retourné: dict
-
zds.tutorialv2.utils.
export_content
(content)¶ Export a content to dictionary in order to store them in a JSON file
Paramètres: content – content to be exported Retourne: dictionary containing the information Type retourné: dict
-
zds.tutorialv2.utils.
export_extract
(extract)¶ Export an extract to a dictionary
Paramètres: extract – extract to export Retourne: dictionary containing the information Type retourné: dict
-
zds.tutorialv2.utils.
fill_containers_from_json
(json_sub, parent)¶ Function which call itself to fill container
Paramètres: - json_sub – dictionary from ‘manifest.json’
- parent – the container to fill
Lève: - BadManifestError – if the manifest is not well formed or the content’s type is not correct
- KeyError – if one mandatory key is missing
-
zds.tutorialv2.utils.
get_blob
(tree, path)¶ Return the data contained into a given file
Paramètres: - tree (git.objects.tree.Tree) – Git Tree object
- path (str) – Path to file
Retourne: contains
Type retourné:
get a dictionary that represent the commit author with
author
andcomitter
key. If there is no users, bot account pk is used.Retourne: correctly formatted commit author for repo.index.commit()
Type retourné: dict
-
zds.tutorialv2.utils.
get_content_from_json
(json, sha, slug_last_draft, public=False, max_title_len=80)¶ Transform the JSON formated data into
VersionedContent
Paramètres: - json – JSON data from a manifest.json file
- sha – version
- slug_last_draft – the slug for draft marked version
- max_title_len – max str length for title
- public – the function will fill a PublicContent instead of a VersionedContent if True
Retourne: a Public/VersionedContent with all the information retrieved from JSON
Type retourné: models.models_versioned.VersionedContent|models.models_database.PublishedContent
-
zds.tutorialv2.utils.
get_target_tagged_tree
(movable_child, root)¶ Gets the tagged tree with deplacement availability
Paramètres: - movable_child – the extract we want to move
- root – the VersionnedContent we use as root
Type retourné: Retourne: an array of tuples that represent the capacity of movable_child to be moved near another child check get_target_tagged_tree_for_extract and get_target_tagged_tree_for_container for format
-
zds.tutorialv2.utils.
get_target_tagged_tree_for_container
(movable_child, root, bias=-1)¶ Gets the tagged tree with displacement availability when movable_child is an extract
Paramètres: - movable_child – the container we want to move
- root – the VersionnedContent we use as root
- bias – a negative or zero integer that represent the level bias. A value of -1 (default) represent the fact that we want to make the movable_child a sibling of the tagged child, a value of 0 that we want to make it a sub child.
Type retourné: Retourne: an array of tuples that represent the capacity of movable_child to be moved near another child extracts are not included
-
zds.tutorialv2.utils.
get_target_tagged_tree_for_extract
(movable_child, root)¶ Gets the tagged tree with displacement availability when movable_child is an extract
Paramètres: - movable_child – the extract we want to move
- root – the VersionnedContent we use as root
Type retourné: Retourne: an array of tuples that represent the capacity of movable_child to be moved near another child tuples are
(relative_path, title, level, can_be_a_target)
-
zds.tutorialv2.utils.
init_new_repo
(db_object, introduction_text, conclusion_text, commit_message='', do_commit=True)¶ Create a new repository in
settings.ZDS_APP['contents']['private_repo']
to store the files for a new content. Note thatdb_object.sha_draft
will be set to the good valueParamètres: - db_object – PublishableContent (WARNING: should have a valid
slug
, so previously saved) - introduction_text – introduction from form
- conclusion_text – conclusion from form
- commit_message – set a commit message instead of the default one
- do_commit – perform commit if
True
Retourne: VersionedContent
objectType retourné: - db_object – PublishableContent (WARNING: should have a valid
-
zds.tutorialv2.utils.
mark_read
(content, user=None)¶ Mark the last tutorial note as read for the user.
Paramètres: - content – the content to mark
- user – user that read the content, if
None
will use currrent user
-
zds.tutorialv2.utils.
never_read
(content, user=None)¶ Check if a content note feed has been read by an user since its last post was added.
Paramètres: - content (zds.tutorialv2.models.models_database.PublishableContent) – the content to check
- user (zds.member.models.User) – the user to test, if None, gets the current request user
Retourne: True
if the user never read this content’s reactions,False
otherwiseType retourné:
-
zds.tutorialv2.utils.
resize_svg
(source)¶ modify the SVG XML tree in order to resize the URL, to fit the maximum size allowed
Paramètres: source (str) – content (not parsed) of the SVG file
-
zds.tutorialv2.utils.
retrieve_and_update_images_links
(md_text, directory='.')¶ Find every image links and update them with update_image_link().
Paramètres: Retourne: the markdown with the good links
Type retourné:
-
zds.tutorialv2.utils.
retrieve_image
(url, directory)¶ For a given image, retrieve it, transform it into PNG (if needed) and store it
Paramètres: Retourne: the ‘transformed’ path to the image
Type retourné:
-
zds.tutorialv2.utils.
retrieve_image_and_update_link
(group, previous_urls, directory='.')¶ For each image link, update it (if possible)
Paramètres: - group (re.MatchObject) – matching object
- previous_urls (dict) – dictionary containing the previous urls and the transformed ones (in order to avoid treating the same image two times !)
- directory (str) – place where all image will be stored
Retourne: updated link
Type retourné:
-
zds.tutorialv2.utils.
search_container_or_404
(base_content, kwargs_array)¶ Paramètres: - base_content – the base Publishable content we will use to retrieve the container
- kwargs_array – an array that may contain parent_container_slug and container_slug keys or the string representation
Retourne: the Container object we were searching for
Type retourné: Lève: Http404 – if no suitable container is found
-
zds.tutorialv2.utils.
search_extract_or_404
(base_content, kwargs_array)¶ Paramètres: - base_content – the base Publishable content we will use to retrieve the container
- kwargs_array – an array that may contain parent_container_slug and container_slug and MUST contains
extract_slug
Retourne: the Extract object
Type retourné: Raise: Http404 if not found
-
zds.tutorialv2.utils.
slugify_raise_on_invalid
(title, use_old_slugify=False)¶ use uuslug to generate a slug but if the title is incorrect (only special chars or slug is empty), an exception is raised.
Paramètres: Lève: InvalidSlugError – on incorrect slug
Retourne: the slugified title
Type retourné:
-
zds.tutorialv2.utils.
try_adopt_new_child
(adoptive_parent, child)¶ Try the adoptive parent to take the responsability of the child :param adoptive_parent: the new parent for child if all check pass :param child: content child to be moved :raise Http404: if adoptive_parent_full_path is not found on root hierarchy :raise TypeError: if the adoptive parent is not allowed to adopt the child due to its type :raise TooDeepContainerError: if the child is a container that is too deep to be adopted by the proposed parent
Les utilitaires de publication (publication_utils.py
)¶
-
exception
zds.tutorialv2.publication_utils.
FailureDuringPublication
(*args, **kwargs)¶ Exception raised if something goes wrong during publication process
-
class
zds.tutorialv2.publication_utils.
PandocPublicator
(pandoc_loc, _format, pandoc_pdf_param=None)¶ Wrapper arround pandoc commands
-
publish
(md_file_path, base_name, change_dir='.', pandoc_debug_str='', **kwargs)¶ Paramètres: - md_file_path – base markdown file path
- base_name – file name without extension
- change_dir – directory in wich pandoc commands will be executed
- pandoc_debug_str – end of command to allow debugging
- kwargs – othe publicator dependant options ignored by this one
Retourne:
-
-
class
zds.tutorialv2.publication_utils.
Publicator
¶ Publicator base object, all methods must be overridden
-
publish
(md_file_path, base_name, **kwargs)¶ called function to generate a content export
Paramètres: - md_file_path – base markdown file path
- base_name – file name without extension
- kwargs – other publicator dependant options
-
-
class
zds.tutorialv2.publication_utils.
PublicatorRegistery
¶ Register all publicator as a ‘human-readable name/publicator’ instance key/value list
-
classmethod
get
(name)¶ get publicator with required name.
Paramètres: name – Retourne: the wanted publicator Type retourné: Publicator Lève: KeyError – if name is not registered
-
classmethod
get_all_registered
(exclude=None)¶ - Args:
- exclude: A list of excluded publicator
Returns:
-
classmethod
unregister
(name)¶ Remove Publicator registered at name if exists, run silently otherwise.
Paramètres: name – publicator name.
-
classmethod
-
class
zds.tutorialv2.publication_utils.
WatchdogFilePublicator
(watched_dir)¶ Just create a meta data file for watchdog
-
zds.tutorialv2.publication_utils.
generate_exernal_content
(base_name, extra_contents_path, md_file_path, pandoc_debug_str, overload_settings=False)¶ generate all static file that allow offline access to content
Paramètres: - base_name – base nae of file (without extension)
- extra_contents_path – internal directory where all files will be pushed
- md_file_path – bundled markdown file path
- pandoc_debug_str – specific to pandoc publication : avoid subprocess to be errored
- overload_settings – this option force the function to generate all registered formats even when settings ask for PDF not to be published
Retourne:
-
zds.tutorialv2.publication_utils.
make_zip_file
(published_content)¶ Create the zip archive extra content from the published content
Paramètres: published_content – a PublishedContent object Retourne:
-
zds.tutorialv2.publication_utils.
publish_container
(db_object, base_dir, container)¶ ‘Publish’ a given container, in a recursive way
Paramètres: - db_object (PublishableContent) – database representation of the content
- base_dir (str) – directory of the top container
- container (Container) – a given container
Lève: FailureDuringPublication – if anything goes wrong
-
zds.tutorialv2.publication_utils.
publish_content
(db_object, versioned, is_major_update=True)¶ Publish a given content.
Note
create a manifest.json without the introduction and conclusion if not needed. Also remove the ‘text’ field of extracts.
Paramètres: - db_object (PublishableContent) – Database representation of the content
- versioned (VersionedContent) – version of the content to publish
- is_major_update (bool) – if set to True, will update the publication date
Lève: FailureDuringPublication – if something goes wrong
Retourne: the published representation
Type retourné:
-
zds.tutorialv2.publication_utils.
unpublish_content
(db_object, moderator=None)¶ Remove the given content from the public view.
Note
This will send content_unpublished event.
Paramètres: db_object (PublishableContent) – Database representation of the content Retourne: True
if unpublished,False
otherwiseType retourné: bool
Les receveurs d’évènement bdd (receivers.py
)¶
-
zds.tutorialv2.receivers.
cleanup_validation_alerts
(sender, instance, **kwargs)¶ When opinions are unpublished (probably permanently), we must be sure all alerts are handled. For now we just resolve them.
Paramètres: - sender – sender class
- instance – object instance
- kwargs – possibily moderator