timApp.velp package#

Submodules#

timApp.velp.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.velp.annotation.add_annotation(velp_id: int, doc_id: int, coord: timApp.velp.annotation_model.AnnotationPosition, points: float | None, visible_to: timApp.velp.annotations.AnnotationVisibility = Field(name='visible_to', type=<enum 'AnnotationVisibility'>, default=<dataclasses._MISSING_TYPE object>, default_factory=<dataclasses._MISSING_TYPE object>, init=True, repr=True, hash=None, compare=True, metadata=mappingproxy({'by_value': True}), kw_only=False, _field_type=_FIELD), color: str | None = None, answer_id: int | None = None, draw_data: list[dict] | None = None, style: int | None = None) flask.wrappers.Response[source]#

Adds a new annotation.

timApp.velp.annotation.add_comment_route(id: int, content: str) flask.wrappers.Response[source]#

Adds a new comment to the annotation.

timApp.velp.annotation.anonymize_annotations(anns: list[timApp.velp.annotation_model.Annotation], current_user_id: int) None[source]#

Fully anonymizes annotation authors and comment authors unless they were created by same user

timApp.velp.annotation.check_annotation_edit_access_and_maybe_get_doc(user: timApp.user.user.User, ann: timApp.velp.annotation_model.Annotation) tuple[bool, timApp.document.docinfo.DocInfo | None][source]#
timApp.velp.annotation.check_visibility_and_maybe_get_doc(user: timApp.user.user.User, ann: timApp.velp.annotation_model.Annotation) tuple[bool, timApp.document.docinfo.DocInfo | None][source]#
timApp.velp.annotation.get_annotation_or_abort(ann_id: int) timApp.velp.annotation_model.Annotation[source]#
timApp.velp.annotation.get_annotations(doc_id: int, only_own: bool = False) flask.wrappers.Response[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

  • only_own – If True, only returns annotations of this user.

timApp.velp.annotation.invalidate_annotation(id: int) flask.wrappers.Response[source]#

Invalidates an annotation by setting its valid_until to current moment.

timApp.velp.annotation.is_color_hex_string(s: str) bool[source]#

Checks if string is valid HTML color hex string.

timApp.velp.annotation.should_anonymize_annotations(d: timApp.document.docinfo.DocInfo, u: timApp.user.user.User) bool[source]#

Determines whether annotation author and comment authors should be hidden from an user

timApp.velp.annotation.update_annotation(id: int, visible_to: timApp.velp.annotations.AnnotationVisibility = Field(name='visible_to', type=<enum 'AnnotationVisibility'>, default=<dataclasses._MISSING_TYPE object>, default_factory=<dataclasses._MISSING_TYPE object>, init=True, repr=True, hash=None, compare=True, metadata=mappingproxy({'by_value': True}), kw_only=False, _field_type=_FIELD), points: float | None = None, color: str | None = None, coord: timApp.velp.annotation_model.AnnotationPosition | None = None, draw_data: list[dict] | None = None, style: int | None = None) flask.wrappers.Response[source]#

Updates the information of an annotation.

timApp.velp.annotation.validate_color(color: str | None) None[source]#

timApp.velp.annotation_model module#

class timApp.velp.annotation_model.Annotation(**kwargs)[source]#

Bases: sqlalchemy.ext.declarative.api.Model

An annotation that can be associated with an Answer or with a DocParagraph in a Document.

The annotation can start and end in specific positions, in which case the annotation is supposed to be displayed as highlighted text in the corresponding location.

annotator#
annotator_id#

Id of the User who created the annotation.

answer#
answer_id#

Id of the Answer in case this is an answer annotation.

color#

Color for the annotation.

comments#
creation_time#

Creation time.

depth_end#

Positional information about the annotation.

depth_start#

Positional information about the annotation.

document_id#

Id of the document in case this is a paragraph annotation.

draw_data#

Drawing information about the annotation (for annotations on images).

element_path_end#

Positional information about the annotation.

element_path_start#

Positional information about the annotation.

hash_end#

Positional information about the annotation.

hash_start#

Positional information about the annotation.

id#

Annotation identifier.

node_end#

Positional information about the annotation.

node_start#

Positional information about the annotation.

offset_end#

Positional information about the annotation.

offset_start#

Positional information about the annotation.

paragraph_id_end#

The id of the paragraph where this annotation ends (in case this is a paragraph annotation).

paragraph_id_start#

The id of the paragraph where this annotation starts from (in case this is a paragraph annotation).

points#

Points associated with the annotation.

set_position_info(coordinates: timApp.velp.annotation_model.AnnotationPosition)[source]#
style#

Appearance of the annotation

to_json()[source]#
valid_from#

Since when should this annotation be valid.

valid_until#

Until when should this annotation be valid.

velp_content#
velp_version#
velp_version_id#

Id of the velp that has been used for this annotation.

visible_to#

Who should this annotation be visible to.

Possible values are denoted by AnnotationVisibility enum:

myself = 1 owner = 2 teacher = 3 everyone = 4

class timApp.velp.annotation_model.AnnotationCoordinate(par_id: str, offset: int | None = None, depth: int | None = None, node: int | None = None, el_path: list[int] | None = None, t: str | None = None)[source]#

Bases: object

depth: int | None = None#
el_path: list[int] | None = None#
node: int | None = None#
offset: int | None = None#
par_id: str#
t: str | None = None#
class timApp.velp.annotation_model.AnnotationPosition(start: timApp.velp.annotation_model.AnnotationCoordinate, end: timApp.velp.annotation_model.AnnotationCoordinate)[source]#

Bases: object

start.par_id: ID of paragraph where annotation starts. end.par_id: ID of paragraph where annotation ends. start.offset: Character location where annotation starts. start.node: start.depth: depth of the element path end.offset: Character location where annotation ends. end.node: end.depth: depth of the element path start.t: Hash code of paragraph where annotation starts. end.t: Hash code of paragraph where annotation ends. start.el_path: List of elements as text (parsed in interface) connected to annotation start. end.el_path: List of elements as text (parsed in interface) connected to annotation end.

end: timApp.velp.annotation_model.AnnotationCoordinate#
start: timApp.velp.annotation_model.AnnotationCoordinate#

timApp.velp.annotations module#

The module contains the database functions related to annotations. This includes adding, modifiying and deleting annotations as well as adding comments to the annotations. The module also retrieves the annotations from the database.

authors

Joonas Lattu, Petteri Palojärvi

copyright

2016 Timber project members

version

1.0.0

class timApp.velp.annotations.AnnotationVisibility(value)[source]#

Bases: enum.Enum

Enum for storing the visibility.

everyone = 4#
myself = 1#
owner = 2#
teacher = 3#
timApp.velp.annotations.get_annotations_with_comments_in_document(user: timApp.user.user.User, d: timApp.document.docinfo.DocInfo, only_own: bool = False) list[timApp.velp.annotation_model.Annotation][source]#

Gets all annotations with comments the user can see / has access to.

Parameters
  • user – The user who gets the answers.

  • d – The document the answers are searched from.

  • only_own – If True, only annotations for this user are searched even if the user has access to more answers.

Returns

List of annotations.

timApp.velp.annotations.set_annotation_query_opts(q: sqlalchemy.orm.query.Query) sqlalchemy.orm.query.Query[source]#

timApp.velp.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.velp.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.velp.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

  • comment: default comment

  • language_id: language ID

  • color: HEX color

  • valid_until: time stamp to until velp is still valid

  • labels: labels of the velp

  • visible_to: visibility group of the velp (1-4)

  • style: layout of the velp

Returns

ID of new velp

timApp.velp.velp.change_all_selections(doc_id: int)[source]#

Change selection for velp group in users 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

timApp.velp.velp.change_selection_route(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

timApp.velp.velp.create_default_velp_group_route(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.velp.velp.create_velp_group_route(doc_id: int) dict[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.velp.velp.get_default_personal_velp_group()[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.velp.velp.get_default_velp_group(doc_id: int)[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.velp.velp.get_folder_velp_groups(folder, u: timApp.user.user.User) list[timApp.document.docentry.DocEntry][source]#
timApp.velp.velp.get_velp_group_default_selections(doc_id: int) dict[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.velp.velp.get_velp_group_personal_selections(doc_id: int) dict[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.velp.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.velp.velp.get_velp_groups_from_tree(doc: timApp.document.docinfo.DocInfo)[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.

Returns

List of document / velp group information of found hits.

timApp.velp.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.velp.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.velp.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

timApp.velp.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

timApp.velp.velp.update_velp_label_route()[source]#

Updates velp label content.

Required key(s):
  • content: label content

  • id: label ID.

timApp.velp.velp.update_velp_route(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

  • default_comment: velp default comment

  • labels: velp labels

Parameters

doc_id – ID of document

timApp.velp.velp_folders module#

timApp.velp.velp_folders.check_personal_velp_folder(user: timApp.user.user.User)[source]#

Checks if personal velp group folder path exists and if not, creates it.

Parameters

user – Username of current user

Returns

timApp.velp.velp_folders.check_velp_group_folder_path(root_path: str, owner_group: timApp.user.usergroup.UserGroup, doc_name: str)[source]#

Checks if velp group folder path exists and if not, creates it.

Parameters
  • root_path – Root path where method was called from

  • owner_group – Owner group for the new folder if one is to be created

  • doc_name

Returns

Path for velp group folder

timApp.velp.velp_models module#

Defines all data models related to velps.

class timApp.velp.velp_models.AnnotationComment(**kwargs)[source]#

Bases: sqlalchemy.ext.declarative.api.Model

A comment in an Annotation.

annotation_id#

Annotation id.

comment_time#

Comment timestamp.

commenter#
commenter_id#

Commenter user id.

content#

Comment text.

id#

Comment identifier.

to_json()[source]#
class timApp.velp.velp_models.LabelInVelp(**kwargs)[source]#

Bases: sqlalchemy.ext.declarative.api.Model

Associates VelpLabels with Velps.

label_id#
velp_id#
class timApp.velp.velp_models.Velp(**kwargs)[source]#

Bases: sqlalchemy.ext.declarative.api.Model

A Velp is a kind of category for Annotations and is visually represented by a Post-it note.

color#
creation_time#
creator#
creator_id#
default_points#
groups#
id#
labels#
style#
to_json()[source]#
valid_from#
valid_until#
velp_versions: list['VelpVersion']#
visible_to#
class timApp.velp.velp_models.VelpContent(**kwargs)[source]#

Bases: sqlalchemy.ext.declarative.api.Model

The actual content of a Velp.

content#
default_comment#
language_id#
velp_version#
version_id#
class timApp.velp.velp_models.VelpGroup(**kwargs)[source]#

Bases: sqlalchemy.ext.declarative.api.Model

Represents a group of Velps.

block: timApp.item.block.Block#
creation_time#
default_group#
id#
name#
to_json()[source]#
valid_from#
valid_until#
velps#
class timApp.velp.velp_models.VelpGroupDefaults(**kwargs)[source]#

Bases: sqlalchemy.ext.declarative.api.Model

doc_id#
selected#
target_id#
target_type#
velp_group_id#
class timApp.velp.velp_models.VelpGroupLabel(**kwargs)[source]#

Bases: sqlalchemy.ext.declarative.api.Model

Currently not used (0 rows in production DB as of 5th July 2018).

content#
id#
class timApp.velp.velp_models.VelpGroupSelection(**kwargs)[source]#

Bases: sqlalchemy.ext.declarative.api.Model

doc_id#
selected#
target_id#
target_type#
user_id#
velp_group_id#
class timApp.velp.velp_models.VelpGroupsInDocument(**kwargs)[source]#

Bases: sqlalchemy.ext.declarative.api.Model

TODO: This table contains lots of rows in production DB (about 19000 as of 5th July 2018). TODO: Possibly needs some optimizations.

doc_id#
user_id#
velp_group_id#
class timApp.velp.velp_models.VelpInGroup(**kwargs)[source]#

Bases: sqlalchemy.ext.declarative.api.Model

velp_group_id#
velp_id#
class timApp.velp.velp_models.VelpLabel(**kwargs)[source]#

Bases: sqlalchemy.ext.declarative.api.Model

A label that can be assigned to a Velp.

creator#
creator_id#
id#
velps#
class timApp.velp.velp_models.VelpLabelContent(**kwargs)[source]#

Bases: sqlalchemy.ext.declarative.api.Model

content#
language_id#
to_json()[source]#
velplabel#
velplabel_id#
class timApp.velp.velp_models.VelpVersion(**kwargs)[source]#

Bases: sqlalchemy.ext.declarative.api.Model

content: list[timApp.velp.velp_models.VelpContent]#
id#
modify_time#
velp: timApp.velp.velp_models.Velp#
velp_id#

timApp.velp.velpgroups module#

The module contains the database functions related to velp groups and their default and show selections. This includes adding new velp groups and editing the information of their default and show selections in the document (and its paragraphs). The module also retrieves or creates the default and personal velp groups. Information about velp group selections are managed through this module. The module also retrieves the velp groups and their default and show selections from the database.

authors

Joonas Lattu, Petteri Palojärvi

copyright

2016 Timber project members

version

1.0.0

timApp.velp.velpgroups.add_groups_to_document(velp_groups: list[Union[timApp.velp.velp_models.VelpGroup, timApp.document.docinfo.DocInfo]], doc: timApp.document.docinfo.DocInfo, user: timApp.user.user.User)[source]#

Adds velp groups to VelpGroupsInDocument table.

timApp.velp.velpgroups.add_groups_to_selection_table(velp_group: timApp.velp.velp_models.VelpGroup, doc_id: int, user_id: int, target_type: int, target_id: str)[source]#

Adds velp groups to VelpGroupSelection table.

timApp.velp.velpgroups.change_all_target_area_default_selections(doc_id: int, target_type: int, target_id: str, user_id: int, selected: bool)[source]#

Change all default selections to True or False for currently chose area (document or paragraph)

Parameters
  • doc_id – ID of document

  • target_type – Currently 0 = document, 1 = paragraph

  • target_id – ID of target (‘0’ for documents)

  • user_id – ID of user (with manage access) to get all defaults from that user’s selection table

  • selected – True or False

timApp.velp.velpgroups.change_all_target_area_selections(doc_id: int, target_type: int, target_id: str, user_id: int, selected: bool)[source]#

Change all personal selections to True or False for currently chose area (document or paragraph)

Parameters
  • doc_id – ID of document

  • target_type – Currently 0 = document, 1 = paragraph

  • target_id – ID of target (‘0’ for documents)

  • user_id – ID of user

  • selected – True or False

timApp.velp.velpgroups.change_default_selection(doc_id: int, velp_group_id: int, target_type: int, target_id: str, selected: bool)[source]#

Changes selection for velp group’s default selection in target area.

Parameters
  • doc_id – ID of document

  • target_type – 0 document, 1 paragraph

  • target_id – ID of targeted area

  • velp_group_id – ID of velp group

  • selected – Boolean whether group is selected or not

timApp.velp.velpgroups.change_selection(doc_id: int, velp_group_id: int, target_type: int, target_id: str, user_id: int, selected: bool)[source]#

Changes selection for velp group in VelpGroupSelection for specific user / document / target combo.

Parameters
  • doc_id – ID of document

  • velp_group_id – ID of velp group

  • target_type – 0 document, 1 paragraph

  • target_id – ID of targeted area

  • user_id – ID of user

  • selected – Boolean whether group is selected or not

timApp.velp.velpgroups.create_default_velp_group(name: str, owner_group: timApp.user.usergroup.UserGroup, default_group_path: str) timApp.document.docinfo.DocInfo[source]#

Creates default velp group for document.

Parameters
  • name – Name of the new default velp group.

  • owner_group – The id of the owner group.

  • default_group_path – Path of new document / velp group

Returns

timApp.velp.velpgroups.create_velp_group(name: str, owner_group: timApp.user.usergroup.UserGroup, new_group_path: str, valid_until: Optional[str] = None) timApp.velp.velp_models.VelpGroup[source]#

Create a velp group.

Parameters
  • name – Name of the created group.

  • owner_group – The id of the owner group.

  • new_group_path – Path of new document / velp group

  • valid_until – How long velp group is valid (None is forever).

Returns

new velp group ID

timApp.velp.velpgroups.get_default_selections_for_velp_groups(doc_id: int)[source]#

Gets all velp group default selections for document.

Parameters

doc_id – ID of document

Returns

Dict with following info { target_id: [{velp_group_id, selected}, etc], etc }

timApp.velp.velpgroups.get_document_default_velp_group(doc_info: timApp.document.docinfo.DocInfo)[source]#

Returns document default velp group, default velp group path and default name for velp group

timApp.velp.velpgroups.get_document_default_velp_group_info(doc_info: timApp.document.docinfo.DocInfo)[source]#

Returns path and name for a document’s default group

timApp.velp.velpgroups.get_groups_from_document_table(doc_id: int, user_id: int) list[timApp.velp.velp_models.VelpGroup][source]#

Gets velp groups from VelpGroupsInDocument table of specific document / user combo.

Parameters
  • doc_id – ID of document

  • user_id – ID of user

Returns

velp groups in document that user has access to.

timApp.velp.velpgroups.get_personal_selections_for_velp_groups(doc_id: int, user_id: int)[source]#

Gets all velp group personal selections for document.

Parameters
  • doc_id – ID of document

  • user_id – ID of user

Returns

Dict with following info { target_id: [{velp_group_id, selected}, etc], etc }

timApp.velp.velpgroups.make_document_a_velp_group(name: str, velp_group_id: int, valid_until: Optional[str] = None, default_group: bool | None = False) timApp.velp.velp_models.VelpGroup[source]#

Adds document to VelpGroup table.

Parameters
  • name – Name of the created group.

  • velp_group_id – ID of new velp group (and existing document)

  • valid_until – How long velp group is valid (None is forever)

  • default_group – Boolean whether velp group should be default or not

Returns

velp group ID

timApp.velp.velpgroups.process_selection_info(vgss: list[timApp.velp.velp_models.VelpGroupSelection] | list[timApp.velp.velp_models.VelpGroupDefaults])[source]#
timApp.velp.velpgroups.set_default_velp_group_rights(doc_id: int, velp_group: timApp.document.docinfo.DocInfo)[source]#
timApp.velp.velpgroups.set_default_velp_group_selected_and_visible(doc_info: timApp.document.docinfo.DocInfo)[source]#

Makes document’s default velp group visible and selected for everyone

timApp.velp.velps module#

The module contains the database functions related to velps and velp labels. This includes adding and modifying velps and their labels. The module also retrieves the data related to velps and their labels from the database.

authors

Joonas Lattu, Petteri Palojärvi

copyright

2016 Timber project members

version

1.0.0

timApp.velp.velps.add_labels_to_velp(velp_id: int, labels: Iterable[int])[source]#

Associates a set of labels to a velp. (Appends to existing labels)

Do note that update_velp_labels depends on this method

Parameters
  • velp_id – id of the velp that

  • labels – list of label ids

timApp.velp.velps.add_velp_label_translation(label: timApp.velp.velp_models.VelpLabel, language_id: str, content: str)[source]#

Adds new translation to an existing label.

Parameters
  • label – Label

  • language_id – Language chosen

  • content – New translation

timApp.velp.velps.create_new_velp(creator_id: int, content: str, default_points: Optional[float] = None, default_comment: Optional[str] = None, valid_until: Optional[str] = None, language_id: str = 'FI', visible_to: Optional[int] = None, color: Optional[int] = None, style: Optional[int] = None) tuple[timApp.velp.velp_models.Velp, timApp.velp.velp_models.VelpVersion][source]#

Creates a new velp with all information.

Creates a new velp with all necessary information in one function using three others.

Parameters
  • default_comment – Default comment for velp

  • creator_id – User ID of creator.

  • content – Text for velp.

  • default_points – Default points for velp, None if not given.

  • valid_until – Time after velp becomes unusable.

  • language_id – Language ID of velp.

  • visible_to – Default visibility to annotation.

  • color – Velp color

Returns

A tuple of (velp id, velp version id).

timApp.velp.velps.create_velp_content(version: timApp.velp.velp_models.VelpVersion, language_id: str, content: str, default_comment: str)[source]#

Method to create content (text) for velp.

Parameters
  • version – The VelpVersion

  • language_id – Language id

  • content – Text of velp

  • default_comment – Default comment for velp

timApp.velp.velps.create_velp_version(velp: timApp.velp.velp_models.Velp) timApp.velp.velp_models.VelpVersion[source]#

Creates a new version for a velp to use.

Parameters

velp – The velp we’re adding version for

timApp.velp.velps.get_latest_velp_version(velp_id: int, language_id: str = 'FI') timApp.velp.velp_models.VelpContent | None[source]#

Method to fetch the latest version for velp in specific language.

Parameters
  • velp_id – ID of velp we’re checking

  • language_id – ID of language

Returns

Dictionary containing ID and content of velp version.

timApp.velp.velps.get_velp_content_for_document(doc_id: int, user_id: int, language_id: str = 'FI') list[timApp.velp.velp_models.Velp][source]#

Gets velps for document.

Uses VelpGroupsInDocument table data to determine which velp groups and via those which velps are usable for specific user in specific document.

Parameters
  • doc_id – ID of document in question

  • user_id – ID of current user

  • language_id – ID of language used

timApp.velp.velps.get_velp_label_content_for_document(doc_id: int, user_id: int, language_id: str = 'FI') dict[source]#

Gets velp label content for document.

Uses VelpGroupsInDocument table data to determine which velp groups and via those which velp labels are usable for specific user in specific document.

Parameters
  • doc_id – ID of document in question

  • user_id – ID of current user

  • language_id – ID of language used

Returns

List of dicts containing velp label ids and content

timApp.velp.velps.update_velp(velp_id: int, default_points: str, color: str, visible_to: int, style: int)[source]#

Changes the non-versioned properties of a velp. Does not update labels.

Parameters
  • velp_id – ID of velp that’s being updated

  • default_points – New default points

  • color – Velp color

  • visible_to – Velp visibility

  • style – Velp style

timApp.velp.velps.update_velp_labels(velp_id: int, labels: Iterable[int])[source]#

Replaces the labels of a velp with new ones.

Parameters
  • velp_id – velp ID

  • labels – list of label IDs.

Module contents#