Database Models¶
-
db.
db
¶ Instance of
flask_sqlalchemy.SQLAlchemy
that the models are registered to.
Processing Operations¶
-
class
db.
Operation
(**kwargs)¶ flask_sqlalchemy.Model
representing a processing operation-
id
¶ Database id (int)
List of
Tag
objects associated with the operation
-
versions
¶ List of
OpVersion
objects representing versions of the operation. Does not include drafts. Ordered byOpVersion.date_introduced
.
-
-
class
db.
Tag
(**kwargs)¶ flask_sqlalchemy.Model
representing a tag forOperation
objects-
id
¶ Database id (int)
-
label
¶ Tag label displayed to the user
-
-
class
db.
Contact
(**kwargs)¶ flask_sqlalchemy.Model
representing a contact forOperation
objects-
id
¶ Database id (int)
-
name
¶ Display name of the contact. Could be a real name consisting of given and surname or a generic role name, must not be empty.
-
role
¶ Display name of the contact’s role in the organisation. May be empty if no role is specified.
-
email
¶ Contact’s email address. May be empty or a arbitrary string.
-
phone
¶ Contact’s phone number. May be empty or a arbitrary string.
-
address
¶ Contact’s office address. May be empty or a multi-line string.
-
-
class
db.
OpVersion
(**kwargs)¶ flask_sqlalchemy.Model
that represents versions of andb.Operation
-
id
¶ Database id (int)
-
operation
¶ Corresponding
db.Operation
-
data_categories
¶ List of
OpVerCategory
objects representing the proccessed data categories and affected subjects
-
date_introduced
¶ datetime
object representing the time when the version was activated orNone
if it is a draft
-
date_redeemed
¶ datetime
object representing the time when the version was redeemed orNone
if it is either active or a draft
-
title
¶ Operation display name. Must not be empty.
-
description
¶ Human-readable and short description. Must be a string but may be empty.
-
toms
¶ Technical and organisational measures applied to ensure the protection of the subject’s data protection rights
-
reasons
¶ Set of
db.LegalReason
enum members (seeEncodedEnumSet
)
-
external_controllers
¶ Set of strings representing the names of external entities that are jointly responsible for the processing operation
The names must not contain commas (“,”), see
EncodedTokenSet
.
-
property
subjects
¶ Read-only view summarizing the
subject
of alldata_categories
as aset
ofstr
objects.Cannot be used in queries.
-
property
categories
¶ Read-only view summarizing the
name
of alldata_categories
as aset
ofstr
objects.Cannot be used in queries.
-
property
accessors
¶ Read-only view summarizing the
accessors
of alldata_categories
as aset
ofstr
objects.Cannot be used in queries.
-
property
recipients
¶ Read-only view summarizing the
recipients
of alldata_categories
as aset
ofstr
objects.Cannot be used in queries.
-
-
class
db.
OpVerCategory
(**kwargs)¶ flask_sqlalchemy.Model
that represents a data category of adb.OpVersion
object-
id
¶ Database id (int)
-
name
¶ Data category name. Must not be empty. Should only name a single category.
-
subject
¶
-
limit
¶
-
is_special
¶
-
accessors
¶
-
recipients
¶
-
Custom Column Types¶
-
class
db.
EncodedEnumSet
(base_enum)¶ TypeDecorator
to storeset
ofEnum
members in a singleString
column- Parameters
base_enum (Enum) – The enum whose members shall be stored
To work properly, columns must be defined using a
MutableSet
:mycol = Column(MutableSet.as_mutable(EncodedEnumSet(MyEnum))
Values are encoded as a comma-separeted list of enum member values.
Assinging sets containing non-member items or adding such items will raise a
ValueError
exception. Equally, unknown values in the database will raise aValueError
exception upon accesss.Note
When members of
base_enum
are added or removed, database migrations must be performed carefully to avoid incompatabilities. It is not recommended to remove members of thebase_enum
.
-
class
db.
EncodedTokenSet
(*args, **kwargs)¶ TypeDecorator
to storeset
ofstr
objects in a singleText
columnTo work properly, columns must be defined using a
MutableSet
:Column(MutableSet.as_mutable(EncodedTokenSet)
Values are encoded as a comma-separeted list of the set items. Therefore items must not include commas (“,”)!
Assinging sets containing invalid strings or adding such strings will raise a
ValueError
exception.