timApp.routes package

Submodules

timApp.routes.annotation module

The module handles the main logic related to annotations. This includes adding, modifiying and deleting annotations as well as adding comments to the annotations. The module also retrieves the annotations to the document.

authors:Joonas Lattu, Petteri Palojärvi
copyright:2016 Timber project members
version:1.0.0
timApp.routes.annotation.add_annotation() → typing.Dict[KT, VT][source]

Creates a new annotation to the database.

Required key(s):
  • velp: velp ID
  • visible_to: visibility group number (1 = Myself, 2 = Teacher, 3 = Document owner, 4 = Everyone)
  • doc_id: document ID
  • coord: start and end coordinates of the annotation.
Returns:Dictionary oontaining annotation id and annotator name.
timApp.routes.annotation.add_comment() → typing.Dict[KT, VT][source]

Adds new comment to the annotation.

Required key(s):
  • annotation_id: annotation ID
  • content: content of the comment.
Returns:Dictionary of information about user who added the comment
timApp.routes.annotation.get_annotations(doc_id: int)[source]

Returns all annotations with comments user can see, e.g. has access to them in a document.

Parameters:doc_id – ID of the document
Returns:List of dictionaries containing annotations with comments
timApp.routes.annotation.invalidate_annotation()[source]

Invalidates annotation by setting its valid from to current moment.

Required key(s):
  • annotation_id: annotation ID
Returns:okJsonResponse()
timApp.routes.annotation.update_annotation()[source]

Updates the visibility and/or points of the annotation.

Required key(s):
  • annotation_id: annotation ID.
Optional key(s):
  • visible_to: visibility group number (1 = Myself, 2 = Teacher, 3 = Document owner, 4 = Everyone)
  • points: number of points
  • doc_id: document ID.
Returns:okJsonResponse()

timApp.routes.velp module

The module handles the main logic related to velps, velp groups and labels. This includes adding and modifiying velps and labels as well as adding new velp groups. The module also retrieves or creates the default velp group for the document and the personal default group for the user. Velp groups can be set to shown or shown as default in specific element (or in the whole document) through this module. The module also retrieves the velps, velp groups and labels to the document.

authors:Joonas Lattu, Petteri Palojärvi
copyright:2016 Timber project members
version:1.0.0
timApp.routes.velp.add_label() → int[source]

Creates new velp label.

Required key(s):
  • content: label content
Optional key(s):
  • language_id: language ID of the label.
Returns:ID of new velp label
timApp.routes.velp.add_velp() → int[source]

Creates a new velp and adds it to velp groups user chose.

Required key(s):
  • content: content of the new velp
  • velp_groups: list of velp group IDs of the new velp.
Optional key(s):
  • points: velp points
  • language_id: language ID
  • icon_id: icon ID
  • valid_until: time stamp to until velp is still valid
  • labels: labels of the velp
  • visible_to: visibility group number (1 = Myself, 2 = Teacher, 3 = Document owner, 4 = Everyone)
Returns:ID of new velp
timApp.routes.velp.change_all_selections(doc_id: int)[source]

Change selections for velp group in user’s VelpGroupSelection in current document.

Required key(s):
  • selection: 1 or 0 (true or false)
  • target_type: target type of the selection (document, paragraph)
  • target_id: target id of the selection (paragraph id or 0 for the whole document)
  • selection_type: ‘show’ or ‘default’.
Parameters:doc_id – ID of document
Returns:okJsonResponse
timApp.routes.velp.change_default_selection(doc_id: int)[source]

Change selection for velp group in users VelpGroupSelection in current document.

Required key(s):
  • id: velp group ID
  • target_type: target type of the selection (document, paragraph)
  • target_id: target id of the selection (paragraph id or 0 for the whole document)
  • default: current default value.
Parameters:doc_id – ID of document
Returns:okJsonResponse
timApp.routes.velp.change_selection(doc_id: int)[source]

Change selection for velp group in users VelpGroupSelection in current document.

Required key(s):
  • id: velp group iD
  • target_type: target type of the selection (document, paragraph)
  • target_id: target id of the selection (paragraph id or 0 for the whole document)
  • selection_type: ‘show’ or ‘default’.
Parameters:doc_id – ID of document
Returns:okJsonResponse
timApp.routes.velp.create_default_velp_group(doc_id: int)[source]

Creates a default velp group document or changes existing document to default velp group.

Parameters:doc_id – ID of document
Returns:Dictionary containing information of new default velp group.
timApp.routes.velp.create_velp_group(doc_id: int) → typing.Dict[KT, VT][source]

Creates a new velp group.

Required key(s):
  • name: velp group name
  • target_type: document, folder or personal group.
Parameters:doc_id – ID of the document
Returns:Dictionary containing information of new velp group.
timApp.routes.velp.get_default_personal_velp_group() → typing.Dict[KT, VT][source]

Get default personal velp group ID and if velp group doesn’t exist yet, create one.

Returns:Dictionary containing personal velp group data.
timApp.routes.velp.get_default_velp_group(doc_id: int) → typing.Dict[KT, VT][source]

Get default velp group ID and if velp group doesn’t exist yet, create one.

Parameters:doc_id – ID of document
Returns:Dictionary containing default velp group’s ID and name
timApp.routes.velp.get_velp_group_default_selections(doc_id: int) → typing.Dict[KT, VT][source]

Gets default velp group selections for velp groups user has access to in document.

Parameters:doc_id – ID of document
Returns:Dictionary containing list of default velp groups for each target area IDs
timApp.routes.velp.get_velp_group_personal_selections(doc_id: int) → typing.Dict[KT, VT][source]

Gets default velp group selections for velp groups user has access to in document.

Parameters:doc_id – ID of document
Returns:Dictionary containing list of selected velp groups for each target area IDs
timApp.routes.velp.get_velp_groups(doc_id: int)[source]

Gets all velp groups for document user has access to by using VelpGroupSelection table.

Parameters:doc_id – ID of document
Returns:List of dictionaries containing velp group information
timApp.routes.velp.get_velp_groups_from_tree(document_id: int)[source]

Returns all velp groups found from tree from document to root and from users own velp folder

Checks document’s own velp group folder first, then default velp group folders going up all the way to root. Doesn’t branch side ways or down, only checks parents. After root has been reached, finally checks users own velp group folder.

Checks that user has minimum of view right for velp groups.

Parameters:document_id – ID of document
Returns:List of document / velp group information of found hits.
timApp.routes.velp.get_velp_labels(doc_id: int) → str[source]

Gets all velp labels for document user has access to by using VelpGroupSelection table.

Parameters:doc_id – ID of document
Returns:List of dicts containing velp label IDs and content for the document
timApp.routes.velp.get_velps(doc_id: int)[source]

Get all velps for document user has access to.

Parameters:doc_id – ID of document
Returns:List of velps as dictionaries containing all needed information
timApp.routes.velp.reset_all_selections_to_defaults(doc_id: int)[source]

Changes user’s all personal velp group selections in document to defaults.

Parameters:doc_id – ID of document
Returns:okJsonResponse()
timApp.routes.velp.reset_target_area_selections_to_defaults(doc_id: int)[source]

Changes user’s personal velp group selections in target area to defaults.

Required key(s):
  • target_id: target id of the selection (paragraph id or 0 for the whole document)
Parameters:doc_id – ID of document
Returns:okJsonResponse()
timApp.routes.velp.update_velp(doc_id: int)[source]

Updates the velp’s data.

Required key(s):
  • id: velp ID
  • content: velp content
  • language_id: language ID
  • velp groups: list of velp group IDs.
Optional key(s):
  • points: velp points
  • icon_id: velp icon
  • labels: velp labels
Parameters:doc_id – ID of document
Returns:okJsonResponse
timApp.routes.velp.update_velp_label()[source]

Updates velp label content.

Required key(s):
  • content: label content
  • id: label ID.
Returns:okJsonResponse