-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathplugin.py
More file actions
76 lines (67 loc) · 2.47 KB
/
Copy pathplugin.py
File metadata and controls
76 lines (67 loc) · 2.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
from django.apps import apps
from baseapp_core.plugins.base import BaseAppPlugin, PackageSettings
class NotificationsPlugin(BaseAppPlugin):
"""
The Notifications plugin is used to send notifications to users.
It depends on the django-notifications-community package. But it must not activate the "notifications" app.
"""
@property
def name(self) -> str:
return "baseapp_notifications"
@property
def package_name(self) -> str:
return "baseapp_notifications"
def get_settings(self) -> PackageSettings:
return PackageSettings(
django_extra_settings={
"DJANGO_NOTIFICATIONS_CONFIG": {"USE_JSONFIELD": True},
},
# GraphQL
graphql_mutations=[
"baseapp_notifications.graphql.mutations.NotificationsMutations",
],
graphql_subscriptions=[
"baseapp_notifications.graphql.subscriptions.NotificationsSubscription",
],
# Plugin deps
required_packages=[],
optional_packages=[
{
"push_notifications": "Used for push notifications. See baseapp_notifications/README.md for more details.",
},
],
# URLs
v1_urlpatterns=self.v1_urlpatterns,
)
@staticmethod
def v1_urlpatterns(include, path, re_path):
if not apps.is_installed("push_notifications"):
return []
from push_notifications.api.rest_framework import (
APNSDeviceAuthorizedViewSet,
GCMDeviceAuthorizedViewSet,
WebPushDeviceAuthorizedViewSet,
WNSDeviceAuthorizedViewSet,
)
return [
path(
"push-notifications/apns",
APNSDeviceAuthorizedViewSet.as_view({"post": "create"}),
name="create_apns_device",
),
path(
"push-notifications/gcm",
GCMDeviceAuthorizedViewSet.as_view({"post": "create"}),
name="create_gcm_device",
),
path(
"push-notifications/wns",
WNSDeviceAuthorizedViewSet.as_view({"post": "create"}),
name="create_wns_device",
),
path(
"push-notifications/web",
WebPushDeviceAuthorizedViewSet.as_view({"post": "create"}),
name="create_web_device",
),
]