1+ # Third Party (PyPI) Imports
2+ import rollbar
3+
14# Django Imports
25from django .apps import AppConfig
6+ from django .conf import settings
37from django .db .models import signals
48
59# HTK Imports
610from htk .app_config import HtkAppConfig
11+ from htk .decorators .classes import disable_for_loaddata
12+ from htk .utils import (
13+ htk_setting ,
14+ resolve_model_dynamically ,
15+ )
16+
17+
18+ # isort: off
19+
20+
21+ @disable_for_loaddata
22+ def organization_invitation_created (sender , instance , created , ** kwargs ):
23+ """Signal handler for when a new OrganizationInvitation object is created"""
24+ if created :
25+ invitation = instance
26+
27+ if not settings .TEST and htk_setting ('HTK_SLACK_NOTIFICATIONS_ENABLED' ):
28+ try :
29+ from htk .utils .notifications import slack_notify
30+
31+ msg = invitation .build_notification_message__created ()
32+ slack_notify (msg )
33+ except :
34+ rollbar .report_exc_info ()
735
836
937class HtkOrganizationAppConfig (HtkAppConfig ):
@@ -12,4 +40,12 @@ class HtkOrganizationAppConfig(HtkAppConfig):
1240 verbose_name = 'Organizations'
1341
1442 def ready (self ):
15- pass
43+ OrganizationInvitation = resolve_model_dynamically (
44+ htk_setting ('HTK_ORGANIZATION_INVITATION_MODEL' )
45+ )
46+
47+ signals .post_save .connect (
48+ organization_invitation_created ,
49+ sender = OrganizationInvitation ,
50+ dispatch_uid = 'htk_organization_invitation_created' ,
51+ )
0 commit comments