handlers.sync_tag_and_field

class SyncTagAndField(handlers.eventhandler.EventHandler):

Whenever a tag is updated, the corresponding field value is updated as well, and vice versa.

Example: Synchronize the field Confidentiality and the tag group Vertraulichkeit by mapping the values as follows:

"Confidentiality/Vertraulichkeit": {
    "public": "0 - Öffentlich",
    "internal": "1 - Intern",
    "confidential": "2 - Vertraulich",
    "strictly_confidential": "3 - Streng Vertraulich"
},
name = 'Sync Tag And Field'
description = 'Whenever a tag is updated, the corresponding field value is updated as well, and vice versa.'
conditions = {'event_types': ['FactSheetTagAddedEvent', 'FactSheetFieldUpdatedEvent']}
supports_initial_sync = True
config_template = {'mapping': {'Confidentiality/Vertraulichkeit': {'public': '0 - Öffentlich', 'internal': '1 - Intern', 'confidential': '2 - Vertraulich', 'strictly_confidential': '3 - Streng Vertraulich'}, 'Availibility/Verfügbarkeit': {'downtime1': '0 - Ausfall bis 1 Woche', 'downtime2': '1 - Ausfall bis 2/3 Tage', 'downtime3': '2 - Ausfall bis 8 Stunden', 'downtime4': '3 - Ausfall bis 4 Stunden'}, 'Integrity/Integrität': {'no': '0 - Keine', 'small': '1 - Gering', 'high': '2 - Hoch', 'very_high': '3 - Sehr Hoch'}}, 'leading_for_initial_sync': 'tag'}
def data_requirements(self):

Declare the exact fact-sheet data this handler needs, so the webhook event loop (process_event in workspace/views_module.py) can load a single lean FastFactSheet per event instead of the full fact sheet.

Return a dict: { "fields": [], "relations": [], "subscriptions": bool, # True if handle() reads fs["subscriptions"] "tags": bool, # True if handle() reads tags / has_tag() "documents": bool, "acls": bool, "completion": bool, # True if handle() reads fs["completion"] "base_fields": [], # optional; omit/None = full # default base field set. A list restricts the # base scalars to just those (id and type are # always loaded). Advanced opt-in for max speed. } Fields referenced by this handler's trigger are folded in automatically by the event loop (into "fields"), so only declare what handle() itself needs on top of them.

Return None (the default) to signal "requirements cannot be declared statically" - e.g. handlers that exec/eval config-supplied code. The event loop then loads the full fact sheet for that event, so correctness is always preserved. This is a standalone hook (deliberately not tied to the initial_sync_* hooks, which are slated to migrate onto it later).

def handle(self, event, fs, **kwargs):

Called automatically whenever a matching event comes in via webhook.

def initial_sync_event(self, fs):