openedx-webhooks 22.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- openedx_webhooks/__init__.py +7 -0
- openedx_webhooks/admin.py +40 -0
- openedx_webhooks/apps.py +130 -0
- openedx_webhooks/filters.py +2276 -0
- openedx_webhooks/migrations/0001_initial.py +30 -0
- openedx_webhooks/migrations/0002_webfilter.py +37 -0
- openedx_webhooks/migrations/0003_auto_20230607_1246.py +23 -0
- openedx_webhooks/migrations/0004_auto_20230613_1033.py +28 -0
- openedx_webhooks/migrations/0005_alter_webfilter_event.py +18 -0
- openedx_webhooks/migrations/0006_alter_webfilter_event.py +18 -0
- openedx_webhooks/migrations/0007_alter_webfilter_event.py +18 -0
- openedx_webhooks/migrations/0008_verawood.py +51 -0
- openedx_webhooks/migrations/__init__.py +0 -0
- openedx_webhooks/models.py +185 -0
- openedx_webhooks/receivers.py +434 -0
- openedx_webhooks/settings/__init__.py +0 -0
- openedx_webhooks/settings/cms.py +21 -0
- openedx_webhooks/settings/common.py +191 -0
- openedx_webhooks/settings/test.py +10 -0
- openedx_webhooks/urls.py +10 -0
- openedx_webhooks/utils.py +124 -0
- openedx_webhooks-22.0.0.dist-info/METADATA +415 -0
- openedx_webhooks-22.0.0.dist-info/RECORD +27 -0
- openedx_webhooks-22.0.0.dist-info/WHEEL +5 -0
- openedx_webhooks-22.0.0.dist-info/entry_points.txt +5 -0
- openedx_webhooks-22.0.0.dist-info/licenses/LICENSE.txt +674 -0
- openedx_webhooks-22.0.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# coding=utf-8
|
|
2
|
+
"""
|
|
3
|
+
Admin settings for webhooks.
|
|
4
|
+
|
|
5
|
+
written by: Andrés González
|
|
6
|
+
https://aulasneo.com
|
|
7
|
+
|
|
8
|
+
date: May 2023
|
|
9
|
+
|
|
10
|
+
usage: register the custom Django models in LMS Django Admin
|
|
11
|
+
"""
|
|
12
|
+
import logging
|
|
13
|
+
|
|
14
|
+
from django.contrib import admin
|
|
15
|
+
|
|
16
|
+
from .models import Webfilter, Webhook
|
|
17
|
+
|
|
18
|
+
logger = logging.getLogger(__name__)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class WebhooksAdmin(admin.ModelAdmin):
|
|
22
|
+
list_display = [f.name for f in Webhook._meta.get_fields()]
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class WebfilterAdmin(admin.ModelAdmin):
|
|
26
|
+
list_display = [
|
|
27
|
+
'event',
|
|
28
|
+
'webhook_url',
|
|
29
|
+
'enabled',
|
|
30
|
+
'disable_halt',
|
|
31
|
+
'disable_filtering',
|
|
32
|
+
'halt_on_4xx',
|
|
33
|
+
'halt_on_5xx',
|
|
34
|
+
'halt_on_request_exception',
|
|
35
|
+
]
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
logger.debug("Registering Webhook")
|
|
39
|
+
admin.site.register(Webhook, WebhooksAdmin)
|
|
40
|
+
admin.site.register(Webfilter, WebfilterAdmin)
|
openedx_webhooks/apps.py
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
"""
|
|
2
|
+
openedx_webhooks Django application initialization.
|
|
3
|
+
"""
|
|
4
|
+
import logging
|
|
5
|
+
|
|
6
|
+
from django.apps import AppConfig
|
|
7
|
+
|
|
8
|
+
# Declare all signals
|
|
9
|
+
signals = {
|
|
10
|
+
"authz": [
|
|
11
|
+
"ROLE_ASSIGNMENT_CREATED",
|
|
12
|
+
"ROLE_ASSIGNMENT_DELETED",
|
|
13
|
+
],
|
|
14
|
+
"content_authoring": [
|
|
15
|
+
"COURSE_CATALOG_INFO_CHANGED",
|
|
16
|
+
"XBLOCK_CREATED",
|
|
17
|
+
"XBLOCK_UPDATED",
|
|
18
|
+
"XBLOCK_PUBLISHED",
|
|
19
|
+
"XBLOCK_DELETED",
|
|
20
|
+
"XBLOCK_DUPLICATED",
|
|
21
|
+
"COURSE_CERTIFICATE_CONFIG_CHANGED",
|
|
22
|
+
"COURSE_CERTIFICATE_CONFIG_DELETED",
|
|
23
|
+
"COURSE_CREATED",
|
|
24
|
+
"CONTENT_LIBRARY_CREATED",
|
|
25
|
+
"CONTENT_LIBRARY_UPDATED",
|
|
26
|
+
"CONTENT_LIBRARY_DELETED",
|
|
27
|
+
"LIBRARY_BLOCK_CREATED",
|
|
28
|
+
"LIBRARY_BLOCK_UPDATED",
|
|
29
|
+
"LIBRARY_BLOCK_DELETED",
|
|
30
|
+
"LIBRARY_BLOCK_PUBLISHED",
|
|
31
|
+
"CONTENT_OBJECT_TAGS_CHANGED",
|
|
32
|
+
"CONTENT_OBJECT_ASSOCIATIONS_CHANGED",
|
|
33
|
+
"LIBRARY_COLLECTION_CREATED",
|
|
34
|
+
"LIBRARY_COLLECTION_UPDATED",
|
|
35
|
+
"LIBRARY_COLLECTION_DELETED",
|
|
36
|
+
"LIBRARY_CONTAINER_CREATED",
|
|
37
|
+
"LIBRARY_CONTAINER_UPDATED",
|
|
38
|
+
"LIBRARY_CONTAINER_DELETED",
|
|
39
|
+
"LIBRARY_CONTAINER_PUBLISHED",
|
|
40
|
+
"COURSE_IMPORT_COMPLETED",
|
|
41
|
+
"COURSE_RERUN_COMPLETED",
|
|
42
|
+
],
|
|
43
|
+
"learning": [
|
|
44
|
+
"STUDENT_REGISTRATION_COMPLETED",
|
|
45
|
+
"SESSION_LOGIN_COMPLETED",
|
|
46
|
+
"COURSE_ENROLLMENT_CREATED",
|
|
47
|
+
"COURSE_ENROLLMENT_CHANGED",
|
|
48
|
+
"COURSE_UNENROLLMENT_COMPLETED",
|
|
49
|
+
"CERTIFICATE_CREATED",
|
|
50
|
+
"CERTIFICATE_CHANGED",
|
|
51
|
+
"CERTIFICATE_REVOKED",
|
|
52
|
+
"COHORT_MEMBERSHIP_CHANGED",
|
|
53
|
+
"COURSE_DISCUSSIONS_CHANGED",
|
|
54
|
+
"PROGRAM_CERTIFICATE_REVOKED",
|
|
55
|
+
"PROGRAM_CERTIFICATE_AWARDED",
|
|
56
|
+
"PERSISTENT_GRADE_SUMMARY_CHANGED",
|
|
57
|
+
"XBLOCK_SKILL_VERIFIED",
|
|
58
|
+
"USER_NOTIFICATION_REQUESTED",
|
|
59
|
+
"EXAM_ATTEMPT_SUBMITTED",
|
|
60
|
+
"EXAM_ATTEMPT_REJECTED",
|
|
61
|
+
"EXAM_ATTEMPT_VERIFIED",
|
|
62
|
+
"EXAM_ATTEMPT_ERRORED",
|
|
63
|
+
"EXAM_ATTEMPT_RESET",
|
|
64
|
+
"COURSE_ACCESS_ROLE_ADDED",
|
|
65
|
+
"COURSE_ACCESS_ROLE_REMOVED",
|
|
66
|
+
"FORUM_THREAD_CREATED",
|
|
67
|
+
"FORUM_THREAD_RESPONSE_CREATED",
|
|
68
|
+
"FORUM_RESPONSE_COMMENT_CREATED",
|
|
69
|
+
"COURSE_NOTIFICATION_REQUESTED",
|
|
70
|
+
"ORA_SUBMISSION_CREATED",
|
|
71
|
+
"COURSE_PASSING_STATUS_UPDATED",
|
|
72
|
+
"CCX_COURSE_PASSING_STATUS_UPDATED",
|
|
73
|
+
"BADGE_AWARDED",
|
|
74
|
+
"BADGE_REVOKED",
|
|
75
|
+
"IDV_ATTEMPT_CREATED",
|
|
76
|
+
"IDV_ATTEMPT_PENDING",
|
|
77
|
+
"IDV_ATTEMPT_APPROVED",
|
|
78
|
+
"IDV_ATTEMPT_DENIED",
|
|
79
|
+
"EXTERNAL_GRADER_SCORE_SUBMITTED",
|
|
80
|
+
"LTI_PROVIDER_LAUNCH_SUCCESS",
|
|
81
|
+
]
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
logger = logging.getLogger(__name__)
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
class WebhooksConfig(AppConfig):
|
|
88
|
+
"""
|
|
89
|
+
Configuration for the webhooks Django application.
|
|
90
|
+
"""
|
|
91
|
+
|
|
92
|
+
name = 'openedx_webhooks'
|
|
93
|
+
|
|
94
|
+
receivers = []
|
|
95
|
+
for signal_app, signal_list in signals.items():
|
|
96
|
+
for signal in signal_list:
|
|
97
|
+
receivers.append({
|
|
98
|
+
"receiver_func_name": signal.lower() + "_receiver",
|
|
99
|
+
"signal_path": f"openedx_events.{signal_app}.signals.{signal}",
|
|
100
|
+
})
|
|
101
|
+
|
|
102
|
+
plugin_app = {
|
|
103
|
+
"settings_config": {
|
|
104
|
+
"lms.djangoapp": {
|
|
105
|
+
"common": {"relative_path": "settings.common"},
|
|
106
|
+
"test": {"relative_path": "settings.test"},
|
|
107
|
+
},
|
|
108
|
+
"cms.djangoapp": {
|
|
109
|
+
"common": {"relative_path": "settings.cms"},
|
|
110
|
+
"test": {"relative_path": "settings.cms"},
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
"signals_config": {
|
|
114
|
+
"lms.djangoapp": {
|
|
115
|
+
"relative_path": "receivers",
|
|
116
|
+
"receivers": receivers,
|
|
117
|
+
},
|
|
118
|
+
"cms.djangoapp": {
|
|
119
|
+
"relative_path": "receivers",
|
|
120
|
+
"receivers": [
|
|
121
|
+
receiver for receiver in receivers
|
|
122
|
+
if receiver["signal_path"].startswith((
|
|
123
|
+
"openedx_events.content_authoring.", "openedx_events.authz.",
|
|
124
|
+
))
|
|
125
|
+
],
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
logger.info("Open edX Webhooks: signals registered")
|