handlers.quality_check_handler

class QualityCheckHandler(handlers.eventhandler.EventHandler):

Whenever somebody updates an Application, we run a quality check and create a to-do if there are quality gaps.
Default rules: Description needs to be filled, Lifecycle must be defined for current day.

Configuration:
todo_roles: List of roles that will receive the to-do. Can be any of the following:

  • __FIRST_MATCHING__: Assign the to-do only to the first subscription that matches the roles below.
  • name of a specific subscription role: matches any subscription with that role, e.g. "Application Owner".
  • __CREATOR__: the creator of the fact sheet.
  • __EDITOR__: the person that just modified the fact sheet.
  • __ANY_RESPONSIBLE__: any subscription with type "RESPONSIBLE"
  • __ANY_ACCOUNTABLE__: any subscription with type "ACCOUNTABLE"
  • __ANY_RESPONSIBLE_OR_ACCOUNTABLE__: any subscription with type either "RESPONSIBLE" or "ACCOUNTABLE"
  • __ANY__: any subscription.

todo_title: Title of the to-do.
todo_category: Category of the to-do, should be ACTION_ITEM.
todo_due_in_days: Due date of the to-do items.
rules: The default configuration contains an example.

Optional configuration for editorial management:
editorial_status_field: Optional: Field name where the editorial status (e.g. "Draft") is stored.
editorial_status_initial: Optional: Initial value for the editorial status field, e.g. "Draft"
editorial_status_prefix_field: Optional: Field name where the prefix for the editorial status (e.g. [DRAFT Expires 2025-01-31]) is stored.
editorial_details: Optional: Field where the editorial details are stored, e.g. the instructions for the end user.
deletion_days_field: Optional: Field that stores the expiration date of a draft fact sheet.

name = 'Quality Check'
description = 'Whenever somebody updates an Application, we run a quality check and create a to-do (if failed) or set the status to published.'
conditions = {'event_types': ['FactSheetUpdatedEvent', 'RelationCreatedEvent', 'RelationUpdatedEvent', 'RelationSwitchEvent', 'RelationArchivedEvent', 'RelationDeletedEvent'], 'fs_types': ['Application']}
supports_initial_sync = True
config_template = {'user_ids': [], 'todo_roles': ['__CREATOR__', 'Steward'], 'todo_title': 'Please fix quality gaps', 'todo_fs_type': 'Application', 'todo_description': '', 'todo_category': 'ACTION_ITEM', 'todo_due_in_days': 30, 'rules': {'Application': [{'name': 'Description', 'rule': "len(fs.get('description', '')) > 10", 'error': 'Description must be longer than 10 characters.'}, {'name': 'Lifecycle', 'rule': "len(fs.get('lifecycle_status', '')) > 1", 'error': 'Lifecycle for today must be defined: At least one date must be in the past.'}], 'relApplicationToUserGroup': [{'name': 'Description of relation', 'rule': "rel['description]", 'error': 'Description on User Group relation must be set.'}]}, 'editorial_status_field': 'editorialStatus', 'editorial_status_initial': 'Draft', 'editorial_status_prefix_field': 'editorialStatusPostfix', 'editorial_details': 'editorialDetails', 'deletion_days_field': 'editorialDraftExpiryDate'}
def handle(self, event, fs, **kwargs):

Called automatically whenever a FactSheetUpdated event comes in via webhook.

def quality_check(self, event, fs, rules, rel=None, **kwargs):

Called automatically whenever a FactSheetUpdated event comes in via webhook.

def load_rules(self, fs_type=None, rel_type=None):
def initial_sync_event(self, fs):