• Home
  • API Documentation
  • wte.views.part – Part Backend

wte.views.part – Part Backend¶

The part module provides the functionality for creating, viewing, editing, and deleting Part.

Routes are defined in init().

class wte.views.part.ChangeStatusSchema(*args, **kw)[source]¶
The ChangeStatusSchema handles the validation
for editing Part.

Messages

badDictType:
The input must be dict-like (not a %(type)s: %(value)r)
badType:
The input must be a string (not a %(type)s: %(value)r)
empty:
Please enter a value
missingValue:
Missing value
noneType:
The input must be a string (not None)
notExpected:
The input field %(name)s was not expected.
singleValueExpected:
Please provide only one value
return_to = None¶

Return to this URL

status = None¶

The part’s status

class wte.views.part.EditPartSchema(*args, **kw)[source]¶
The EditPartSchema handles the validation
for editing Part.

Messages

badDictType:
The input must be dict-like (not a %(type)s: %(value)r)
badType:
The input must be a string (not a %(type)s: %(value)r)
empty:
Please enter a value
missingValue:
Missing value
noneType:
The input must be a string (not None)
notExpected:
The input field %(name)s was not expected.
singleValueExpected:
Please provide only one value
child_part_id = None¶

The child Part ids for re-ordering

content = None¶

The ReST content

display_mode = None¶

The part’s display mode

email_notify = None¶

Whether to send out an automatic change notification e-mail

email_notify_text = None¶

The text of the automatic change notification e-mail

label = None¶

The part’s label

status = None¶

The part’s status

template_id = None¶

The Template ids for re-ordering

title = None¶

The part’s title

class wte.views.part.ImportPartConverter(*args, **kw)[source]¶
The ImportPartConverter converts a FieldStorage
into a (dict, ZipFile) tuple. Checks that the uploaded zip file is actually a valid file and that it can be imported with the given parent Part. The dict contains the Part data to import.

Messages

badType:
The input must be a string (not a %(type)s: %(value)r)
empty:
Please enter a value
invalidpart:
You cannot import a %(part_type)s here
invalidstructure:
The ZIP file does not have the correct internal structure
noneType:
The input must be a string (not None)
nopart:
The ZIP file does not contain any data to import
notzip:
Only ZIP files can be imported
class wte.views.part.ImportPartSchema(*args, **kw)[source]¶
The ImportPartSchema validates the request to import

a Part (and any children and Asset).

Uses the ImportPartConverter to actually check whether the uploaded file is a valid export generated from export().

Messages

badDictType:
The input must be dict-like (not a %(type)s: %(value)r)
badType:
The input must be a string (not a %(type)s: %(value)r)
empty:
Please enter a value
missingValue:
Missing value
noneType:
The input must be a string (not None)
notExpected:
The input field %(name)s was not expected.
singleValueExpected:
Please provide only one value
file = None¶

The file to import.

parent_id = None¶

The id of the parent Part to import into.

class wte.views.part.NewPartSchema(*args, **kw)[source]¶
The NewPartSchema handles the validation
of a new Part.

Messages

badDictType:
The input must be dict-like (not a %(type)s: %(value)r)
badType:
The input must be a string (not a %(type)s: %(value)r)
empty:
Please enter a value
missingValue:
Missing value
noneType:
The input must be a string (not None)
notExpected:
The input field %(name)s was not expected.
singleValueExpected:
Please provide only one value
display_mode = None¶

The part’s display mode

label = None¶

The part’s label

order = None¶

The optional order index to create the new Part at

parent_id = None¶

The parent Part

status = None¶

The part’s status

title = None¶

The part’s title

class wte.views.part.RegisterSettingsSchema(*args, **kw)[source]¶
The RegisterSettingsSchema handles the validation
for modifying the access_rights of a Part.

Messages

badDictType:
The input must be dict-like (not a %(type)s: %(value)r)
badType:
The input must be a string (not a %(type)s: %(value)r)
empty:
Please enter a value
missingValue:
Missing value
noneType:
The input must be a string (not None)
notExpected:
The input field %(name)s was not expected.
singleValueExpected:
Please provide only one value
email_domains = None¶

The email domains that the user must belong to

password = None¶

The password to use for access rights

require = None¶

Which access rights are required

class wte.views.part.ResetFilesSchema(*args, **kw)[source]¶
Validator for resetting all the files in the user’s UserPartProgress
to their initial values.

Messages

badDictType:
The input must be dict-like (not a %(type)s: %(value)r)
badType:
The input must be a string (not a %(type)s: %(value)r)
empty:
Please enter a value
missingValue:
Missing value
noneType:
The input must be a string (not None)
notExpected:
The input field %(name)s was not expected.
singleValueExpected:
Please provide only one value
filename = None¶

The optional filename to reset.

wte.views.part.change_status(request)[source]¶

Handles the /parts/{pid}/change_status URL, providing the UI and backend for changing the status of a Part.

Requires that the user has “edit” rights on the Part.

wte.views.part.create_part_crumbs(request, part, current=None)[source]¶

Creates the list of breadcrumbs for a given part. If the current is a list, then all will be added to the end of the crumbs.

Parameters:
  • part (Part) – The part to create the breadcrumbs to
  • current (dict or list) – The final, current breadcrumb
Returns:

A list of dict for use in the breadcrumbs

Return type:

list

wte.views.part.crossref_replace(match, id_mapping)[source]¶

The crossref_replace() function updates a single cross-reference ReST role identified by the match parameter with the correct new target part identifier from the id_mapping. If the identifier in the current cross-reference is not in the id_mapping, then it is replaced with the string ‘external’.

Parameters:
  • match (MatchObject) – The regexp match
  • id_mapping (dict) – The identifier change mappings
Returns:

The updated cross-reference

Return_type:

string

wte.views.part.delete(request)[source]¶

Handles the /modules/{mid}/parts/{pid}/delete URL, providing the UI and backend for deleting a Part.

Requires that the user has “delete” rights on the Part.

wte.views.part.deregister(request)[source]¶

Handles the /parts/{pid}/deregister URL, to allow users to de-register from a Part that is a “module”.

wte.views.part.download(request)[source]¶

Handles the /parts/{pid}/download URL, providing the UI and backend for downloading a Part.

The difference between exporting (export()) and downloading is that exporting creates an archive that can be imported into another WTE instance, while downloading creates an HTML version for offline viewing.

wte.views.part.download_part_progress(request)[source]¶

Handles the /users/{uid}/progress/{pid}/download URL, sending back the complete set of data associated with the UserPartProgress.

Requires that the user has “view” rights on the UserPartProgress.

wte.views.part.edit(request)[source]¶

Handles the /parts/{pid}/edit URL, providing the UI and backend for editing a Part.

Requires that the user has “edit” rights on the Part.

wte.views.part.edit_register_settings(request)[source]¶

Handles the /parts/{pid}/register/settings URL, providing the UI and backend for editing the settings for registering for a “module” type Part.

Requires that the user has “edit” rights on the Part.

wte.views.part.export(request)[source]¶

Handles the /parts/{pid}/export URL, providing the UI and backend for exporting a Part.

The difference between exporting and downloading (download()) is that exporting creates an archive that can be imported into another WTE instance, while downloading creates an HTML version for offline viewing.

Requires that the user has “edit” rights on the Part.

wte.views.part.get_all_parts(part)[source]¶

Recursively returns the Part and all its children.

Parameters:part (Part) – The Part for which to find it children
Returns:The part and all its children
Return type:list
wte.views.part.get_user_part_progress(dbsession, user, part)[source]¶

Returns the UserPartProgress for the given user and part. If none exists, then a new one is instantiated. If the :class:`~wte.models.UserPartProgress` points to a current page that is different to ``page, then the UserPartProgress is updated.

Parameters:
  • user (User) – The user to get the progress for
  • part (Part) – The part to get the progress for
Returns:

The UserPartProgress

Return type:

UserPartProgress

wte.views.part.import_file(request)[source]¶

Handles the /parts/import URL, providing the UI and backend for importing a Part.

The required permissions depend on the type of Part to create: * module – User permission “modules.create” * tutorial – “edit” permission on the parent Part * page – “edit” permission on the parent Part * exercise – “edit” permission on the parent Part * task – “edit” permission on the parent Part

wte.views.part.init(config)[source]¶

Adds the part-specific backend routes (route name, URL pattern handler):

  • part.list – /parts – list_parts()
  • part.new – /parts/new – new()
  • part.search – /parts/search – search()
  • part.import – /parts/import – import_file()
  • part.view – /parts/{pid} – view_part()
  • part.edit – /parts/{pid}/edit – edit()
  • part.delete – /parts/{pid}/delete – delete()
  • part.delete – /parts/{pid}/delete – delete()
  • part.preview – /parts/{pid}/rst_preview – preview()
  • part.register – /parts/{pid}/register – register()
  • part.register.settings – /parts/{pid}/register/settings – edit_register_settings()
  • part.deregister – /parts/{pid}/deregister – deregister()
  • part.change_status – /parts/{pid}/change_status – change_status()
  • part.export – /parts/{pid}/export – export()
  • part.download – /parts/{pid}/download – download()
  • part.reset-files – /parts/{pid}/reset_files – reset_files()
  • part.progress.download – /parts/{pid}/progress/download – download_part_progress()
  • part.progress.update – /parts/{pid}/progress/update – update_part_progress()
wte.views.part.list_parts(request)[source]¶

Handles the /parts URL, displaying modules. If no parameters are specified, lists all available modules. If a “user_id” parameter is specified, lists all modules for that user.

wte.views.part.new(request)[source]¶

Handles the /parts/new URL, providing the UI and backend for creating a new Part.

The required permissions depend on the type of Part to create: * module – User permission “modules.create” * tutorial – “edit” permission on the parent Part * page – “edit” permission on the parent Part * exercise – “edit” permission on the parent Part * task – “edit” permission on the parent Part

wte.views.part.preview(request)[source]¶

Handles the /parts/{pid}/rst_preview URL, generating an HTML preview of the submitted ReST. The ReST text to render has to be set as the content parameter.

In addition to rendering the ReST the in the same way that it is rendered when saving a Part, this will also insert a <span id=”focus”></span> at the current cursor position indicated by the string “§§§§§§§”.

Requires that the user has “edit” rights on the current Part.

wte.views.part.register(request)[source]¶

Handles the /parts/{pid}/register URL, to allow users to register for a Part that is a “module”.

wte.views.part.reset_files(request)[source]¶

Handles the /parts/{pid}/reset_files URL, providing the UI and backend for resetting all Assets of a Part to the default for the current user.

Requires that the user has “view” rights on the current Part.

wte.views.part.search(request)[source]¶

Handles the /parts/search URL, searching all Part for matches to the request parameter ‘q’. Returns all Part that the current user is allowed to view.

wte.views.part.update_part_progress(request)[source]¶

Handles the /users/{uid}/progress/{pid}/download URL, sending back the complete set of data associated with the UserPartProgress.

Requires that the user has “view” rights on the UserPartProgress.

wte.views.part.view_part(request)[source]¶

Handles the parts/{pid} URL, displaying the Part.

Requires that the user has “view” rights on the Part.

  • wte.views.asset – Assets
  • wte.views.timed_tasks – Timed Tasks Backend