wbintegrator_office365 2.2.1__py2.py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. wbintegrator_office365/__init__.py +1 -0
  2. wbintegrator_office365/admin.py +209 -0
  3. wbintegrator_office365/apps.py +5 -0
  4. wbintegrator_office365/configurations/__init__.py +0 -0
  5. wbintegrator_office365/configurations/configurations/__init__.py +23 -0
  6. wbintegrator_office365/dynamic_preferences_registry.py +15 -0
  7. wbintegrator_office365/factories.py +102 -0
  8. wbintegrator_office365/filters.py +237 -0
  9. wbintegrator_office365/importer/__init__.py +3 -0
  10. wbintegrator_office365/importer/api.py +403 -0
  11. wbintegrator_office365/importer/disable_signals.py +43 -0
  12. wbintegrator_office365/importer/parser.py +135 -0
  13. wbintegrator_office365/kpi_handlers/__init__.py +1 -0
  14. wbintegrator_office365/kpi_handlers/calls.py +114 -0
  15. wbintegrator_office365/migrations/0001_initial_squashed_squashed_0003_alter_calendar_owner_alter_calendarevent_organizer_and_more.py +677 -0
  16. wbintegrator_office365/migrations/0002_remove_calendar_owner_remove_calendarevent_activity_and_more.py +85 -0
  17. wbintegrator_office365/migrations/0003_alter_event_options.py +20 -0
  18. wbintegrator_office365/migrations/__init__.py +0 -0
  19. wbintegrator_office365/models/__init__.py +3 -0
  20. wbintegrator_office365/models/event.py +623 -0
  21. wbintegrator_office365/models/subscription.py +144 -0
  22. wbintegrator_office365/models/tenant.py +62 -0
  23. wbintegrator_office365/serializers.py +266 -0
  24. wbintegrator_office365/tasks.py +108 -0
  25. wbintegrator_office365/tests/__init__.py +0 -0
  26. wbintegrator_office365/tests/conftest.py +28 -0
  27. wbintegrator_office365/tests/test_admin.py +86 -0
  28. wbintegrator_office365/tests/test_models.py +65 -0
  29. wbintegrator_office365/tests/test_tasks.py +318 -0
  30. wbintegrator_office365/tests/test_views.py +128 -0
  31. wbintegrator_office365/tests/tests.py +12 -0
  32. wbintegrator_office365/urls.py +46 -0
  33. wbintegrator_office365/viewsets/__init__.py +31 -0
  34. wbintegrator_office365/viewsets/display.py +306 -0
  35. wbintegrator_office365/viewsets/endpoints.py +52 -0
  36. wbintegrator_office365/viewsets/menu.py +65 -0
  37. wbintegrator_office365/viewsets/titles.py +49 -0
  38. wbintegrator_office365/viewsets/viewsets.py +745 -0
  39. wbintegrator_office365-2.2.1.dist-info/METADATA +10 -0
  40. wbintegrator_office365-2.2.1.dist-info/RECORD +41 -0
  41. wbintegrator_office365-2.2.1.dist-info/WHEEL +5 -0
@@ -0,0 +1,31 @@
1
+ from wbintegrator_office365.viewsets.display import (
2
+ CallEventDisplayConfig,
3
+ EventLogDisplayConfig,
4
+ EventLogEventDisplayConfig,
5
+ SubscriptionDisplayConfig,
6
+ TenantUserDisplayConfig,
7
+ )
8
+ from wbintegrator_office365.viewsets.endpoints import (
9
+ CallEventEndpointConfig,
10
+ EventLogEndpointConfig,
11
+ EventLogEventEndpointConfig,
12
+ SubscriptionEndpointConfig,
13
+ TenantUserEndpointConfig,
14
+ )
15
+ from wbintegrator_office365.viewsets.menu import (
16
+ CALLEVENT_MENUITEM,
17
+ CALLEVENTCHART_MENUITEM,
18
+ CALLEVENTSUMMARYGRAPH_MENUITEM,
19
+ CALLUSER_MENUITEM,
20
+ EVENT_MENUITEM,
21
+ SUBSCRIPTION_MENUITEM,
22
+ TENANTUSER_MENUITEM,
23
+ )
24
+ from wbintegrator_office365.viewsets.titles import (
25
+ CallEventReceptionTimeTitleConfig,
26
+ CallEventSummaryGraphTitleConfig,
27
+ CallEventTitleConfig,
28
+ CallUserTitleConfig,
29
+ SubscriptionTitleConfig,
30
+ TenantUserTitleConfig,
31
+ )
@@ -0,0 +1,306 @@
1
+ from typing import Optional
2
+
3
+ from wbcore.contrib.color.enums import WBColor
4
+ from wbcore.enums import Operator
5
+ from wbcore.metadata.configs import display as dp
6
+ from wbcore.metadata.configs.display.instance_display.shortcuts import (
7
+ Display,
8
+ create_simple_display,
9
+ create_simple_section,
10
+ )
11
+ from wbcore.metadata.configs.display.instance_display.utils import repeat_field
12
+ from wbcore.metadata.configs.display.view_config import DisplayViewConfig
13
+ from wbintegrator_office365.models import Event
14
+
15
+
16
+ class TenantUserDisplayConfig(DisplayViewConfig):
17
+ def get_list_display(self) -> Optional[dp.ListDisplay]:
18
+ fields = [
19
+ dp.Field(key="tenant_id", label="Tenant Id"),
20
+ dp.Field(key="profile", label="Profile"),
21
+ dp.Field(key="display_name", label="Display name"),
22
+ dp.Field(key="mail", label="Mail"),
23
+ dp.Field(key="phone", label="Phone"),
24
+ dp.Field(key="tenant_organization_id", label="Tenant Organisation"),
25
+ dp.Field(key="is_internal_organization", label="Is internal organization"),
26
+ ]
27
+ return dp.ListDisplay(
28
+ fields=fields,
29
+ )
30
+
31
+ def get_instance_display(self) -> Display:
32
+ return create_simple_display(
33
+ [
34
+ [repeat_field(2, "profile")],
35
+ [repeat_field(2, "display_name")],
36
+ ["mail", "phone"],
37
+ ["tenant_id", "tenant_organization_id"],
38
+ ]
39
+ )
40
+
41
+
42
+ class CallUserDisplayConfig(DisplayViewConfig):
43
+ def get_list_display(self) -> Optional[dp.ListDisplay]:
44
+ fields = [
45
+ dp.Field(key="tenant_user", label="Tenant User"),
46
+ dp.Field(key="is_guest", label="Is guest"),
47
+ dp.Field(key="is_phone", label="Is phone"),
48
+ dp.Field(key="name_user", label="Display Name"),
49
+ dp.Field(key="phone", label="Phone"),
50
+ dp.Field(key="mail", label="Mail"),
51
+ ]
52
+ return dp.ListDisplay(
53
+ fields=fields,
54
+ )
55
+
56
+ def get_instance_display(self) -> Display:
57
+ return create_simple_display(
58
+ [
59
+ [repeat_field(2, "tenant_user")],
60
+ ["is_guest", "is_phone"],
61
+ [repeat_field(2, "name_user")],
62
+ ["phone", "mail"],
63
+ ["acs_user", "splool_user"],
64
+ ["encrypted", "on_premises"],
65
+ ["acs_application_instance", "spool_application_instance"],
66
+ ["application_instance", "application"],
67
+ [repeat_field(2, "device")],
68
+ ]
69
+ )
70
+
71
+
72
+ class SubscriptionDisplayConfig(DisplayViewConfig):
73
+ def get_list_display(self) -> Optional[dp.ListDisplay]:
74
+ fields = [
75
+ dp.Field(key="subscription_id", label="Subscription Id"),
76
+ dp.Field(key="change_type", label="Change Type"),
77
+ dp.Field(key="expiration_date", label="Expiration"),
78
+ dp.Field(key="type_resource", label="Resource"),
79
+ dp.Field(key="tenant_user", label="Tenant User"),
80
+ dp.Field(key="is_enable", label="Is enable"),
81
+ dp.Field(key="created", label="Created"),
82
+ ]
83
+ return dp.ListDisplay(
84
+ fields=fields,
85
+ formatting=[
86
+ dp.Formatting(
87
+ column="type_resource",
88
+ formatting_rules=[
89
+ dp.FormattingRule(
90
+ style={"backgroundColor": WBColor.GREEN_LIGHT.value},
91
+ condition=dp.Condition(operator=Operator.EQUAL, value=Event.Type.CALENDAR),
92
+ ),
93
+ dp.FormattingRule(
94
+ style={"backgroundColor": WBColor.BLUE_LIGHT.value},
95
+ condition=dp.Condition(operator=Operator.EQUAL, value=Event.Type.CALLRECORD),
96
+ ),
97
+ ],
98
+ )
99
+ ],
100
+ legends=[
101
+ dp.Legend(
102
+ key="type_resource",
103
+ items=[
104
+ dp.LegendItem(
105
+ icon=WBColor.GREEN_LIGHT.value, label=Event.Type.CALENDAR.label, value=Event.Type.CALENDAR
106
+ ),
107
+ dp.LegendItem(
108
+ icon=WBColor.BLUE_LIGHT.value,
109
+ label=Event.Type.CALLRECORD.label,
110
+ value=Event.Type.CALLRECORD,
111
+ ),
112
+ ],
113
+ ),
114
+ ],
115
+ )
116
+
117
+ def get_instance_display(self) -> Display:
118
+ return create_simple_display(
119
+ [
120
+ [repeat_field(2, "id_str")],
121
+ [repeat_field(2, "subscription_id")],
122
+ [repeat_field(2, "is_enable")],
123
+ ["type_resource", "tenant_user"],
124
+ ["change_type", "change_type"],
125
+ ["created", "expiration_date"],
126
+ [repeat_field(2, "resource")],
127
+ [repeat_field(2, "notification_url")],
128
+ [repeat_field(2, "odata_context")],
129
+ ["application_id", "creator_id"],
130
+ ["client_state", "latest_supported_tls_version"],
131
+ ["notification_content_type", "include_resource_data"],
132
+ ["encryption_certificate_id", "encryption_certificate"],
133
+ [repeat_field(2, "notification_query_options")],
134
+ ]
135
+ )
136
+
137
+
138
+ class EventDisplayConfig(DisplayViewConfig):
139
+ def get_list_display(self) -> Optional[dp.ListDisplay]:
140
+ fields = [
141
+ dp.Field(key="id", label="Id"),
142
+ dp.Field(key="nb_received", label="Nb received"),
143
+ dp.Field(key="type", label="Type"),
144
+ dp.Field(key="change_type", label="Change Type"),
145
+ dp.Field(key="created", label="Created"),
146
+ dp.Field(key="changed", label="Changed"),
147
+ dp.Field(key="tenant_user", label="Tenant User"),
148
+ dp.Field(key="is_handled", label="Is Handled"),
149
+ dp.Field(key="uuid_event", label="Event UId"),
150
+ dp.Field(key="id_event", label="Event Id"),
151
+ dp.Field(key="subscription_id", label="Subscription id"),
152
+ ]
153
+ return dp.ListDisplay(
154
+ fields=fields,
155
+ formatting=[
156
+ dp.Formatting(
157
+ column="type",
158
+ formatting_rules=[
159
+ dp.FormattingRule(
160
+ style={"backgroundColor": WBColor.GREEN_LIGHT.value},
161
+ condition=dp.Condition(operator=Operator.EQUAL, value=Event.Type.CALENDAR),
162
+ ),
163
+ dp.FormattingRule(
164
+ style={"backgroundColor": WBColor.BLUE_LIGHT.value},
165
+ condition=dp.Condition(operator=Operator.EQUAL, value=Event.Type.CALLRECORD),
166
+ ),
167
+ ],
168
+ )
169
+ ],
170
+ legends=[
171
+ dp.Legend(
172
+ key="type",
173
+ items=[
174
+ dp.LegendItem(
175
+ icon=WBColor.GREEN_LIGHT.value, label=Event.Type.CALENDAR.label, value=Event.Type.CALENDAR
176
+ ),
177
+ dp.LegendItem(
178
+ icon=WBColor.BLUE_LIGHT.value,
179
+ label=Event.Type.CALLRECORD.label,
180
+ value=Event.Type.CALLRECORD,
181
+ ),
182
+ ],
183
+ ),
184
+ ],
185
+ )
186
+
187
+ def get_instance_display(self) -> Display:
188
+ return create_simple_display(
189
+ [
190
+ [repeat_field(2, "id_str")],
191
+ [repeat_field(2, "uuid_event")],
192
+ [repeat_field(2, "id_event")],
193
+ [repeat_field(2, "is_handled")],
194
+ ["auto_inc_id", "nb_received"],
195
+ ["type", "change_type"],
196
+ ["created", "changed"],
197
+ ["tenant_user", "subscription_id"],
198
+ [repeat_field(2, "resource")],
199
+ [repeat_field(2, "eventlog_section")],
200
+ ],
201
+ [create_simple_section("eventlog_section", "Event Logs", [["eventlog"]], "eventlog", collapsed=True)],
202
+ )
203
+
204
+
205
+ class EventLogDisplayConfig(DisplayViewConfig):
206
+ def get_list_display(self) -> Optional[dp.ListDisplay]:
207
+ fields = [
208
+ dp.Field(key="id", label="Id"),
209
+ dp.Field(key="order_received", label="Order received"),
210
+ dp.Field(key="change_type", label="Change Type"),
211
+ dp.Field(key="created", label="Created"),
212
+ dp.Field(key="changed", label="Changed"),
213
+ dp.Field(key="last_event", label="Last Event"),
214
+ dp.Field(key="is_handled", label="Is handled"),
215
+ dp.Field(key="id_event", label="Event Id"),
216
+ ]
217
+ return dp.ListDisplay(
218
+ fields=fields,
219
+ )
220
+
221
+ def get_instance_display(self) -> Display:
222
+ return create_simple_display(
223
+ [
224
+ [repeat_field(2, "last_event")],
225
+ [repeat_field(2, "id_event")],
226
+ [repeat_field(2, "is_handled")],
227
+ ["order_received", "change_type"],
228
+ ["created", "changed"],
229
+ [repeat_field(2, "resource")],
230
+ ]
231
+ )
232
+
233
+
234
+ class EventLogEventDisplayConfig(EventLogDisplayConfig):
235
+ def get_list_display(self) -> Optional[dp.ListDisplay]:
236
+ fields = [
237
+ dp.Field(key="order_received", label="Order received"),
238
+ dp.Field(key="change_type", label="Change Type"),
239
+ dp.Field(key="is_handled", label="Is handled"),
240
+ dp.Field(key="id_event", label="Event Id"),
241
+ dp.Field(key="resource", label="Resource"),
242
+ dp.Field(key="created", label="Created"),
243
+ dp.Field(key="changed", label="Changed"),
244
+ ]
245
+ return dp.ListDisplay(
246
+ fields=fields,
247
+ formatting=[
248
+ dp.Formatting(
249
+ column="is_handled",
250
+ formatting_rules=[
251
+ dp.FormattingRule(
252
+ style={"backgroundColor": WBColor.GREEN_LIGHT.value},
253
+ condition=dp.Condition(operator=Operator.EQUAL, value=True),
254
+ ),
255
+ dp.FormattingRule(
256
+ style={"backgroundColor": WBColor.GREY.value},
257
+ condition=dp.Condition(operator=Operator.EQUAL, value=False),
258
+ ),
259
+ ],
260
+ )
261
+ ],
262
+ legends=[
263
+ dp.Legend(
264
+ key="is_handled",
265
+ items=[
266
+ dp.LegendItem(icon=WBColor.GREEN_LIGHT.value, label="Present in Outlook", value=True),
267
+ dp.LegendItem(
268
+ icon=WBColor.GREY.value,
269
+ label="Deleted in Outlook",
270
+ value=False,
271
+ ),
272
+ ],
273
+ ),
274
+ ],
275
+ )
276
+
277
+
278
+ class CallEventDisplayConfig(DisplayViewConfig):
279
+ def get_list_display(self) -> Optional[dp.ListDisplay]:
280
+ fields = [
281
+ dp.Field(key="event", label="Event"),
282
+ dp.Field(key="organizer", label="Organizer"),
283
+ dp.Field(key="change_type", label="Type"),
284
+ dp.Field(key="start", label="Start"),
285
+ dp.Field(key="end", label="End"),
286
+ dp.Field(key="created", label="Created"),
287
+ dp.Field(key="last_modified", label="Last modified"),
288
+ dp.Field(key="is_internal_call", label="Is Internal Call"),
289
+ dp.Field(key="participants", label="Participants"),
290
+ ]
291
+ return dp.ListDisplay(
292
+ fields=fields,
293
+ )
294
+
295
+ def get_instance_display(self) -> Display:
296
+ return create_simple_display(
297
+ [
298
+ [repeat_field(2, "organizer")],
299
+ ["change_type", "type"],
300
+ ["version", "is_internal_call"],
301
+ ["start", "end"],
302
+ ["last_modified", "created"],
303
+ [repeat_field(2, "participants")],
304
+ [repeat_field(2, "join_web_url")],
305
+ ]
306
+ )
@@ -0,0 +1,52 @@
1
+ from rest_framework.reverse import reverse
2
+ from wbcore.metadata.configs.endpoints import EndpointViewConfig
3
+
4
+
5
+ class MixinEndpointConfig(EndpointViewConfig):
6
+ def get_endpoint(self):
7
+ return super().get_endpoint()
8
+
9
+ def get_list_endpoint(self):
10
+ return reverse(f"{self.view.get_model().get_endpoint_basename()}-list", request=self.request)
11
+
12
+ def get_instance_endpoint(self):
13
+ if self.instance:
14
+ return None
15
+ return super().get_instance_endpoint()
16
+
17
+ def get_create_endpoint(self):
18
+ return None
19
+
20
+ def get_delete_endpoint(self):
21
+ return None
22
+
23
+
24
+ class TenantUserEndpointConfig(MixinEndpointConfig):
25
+ pass
26
+
27
+
28
+ class EventEndpointConfig(MixinEndpointConfig):
29
+ pass
30
+
31
+
32
+ class CallUserEndpointConfig(MixinEndpointConfig):
33
+ pass
34
+
35
+
36
+ class CallEventEndpointConfig(MixinEndpointConfig):
37
+ pass
38
+
39
+
40
+ class SubscriptionEndpointConfig(MixinEndpointConfig):
41
+ pass
42
+
43
+
44
+ class EventLogEndpointConfig(MixinEndpointConfig):
45
+ pass
46
+
47
+
48
+ class EventLogEventEndpointConfig(MixinEndpointConfig):
49
+ def get_endpoint(self, **kwargs):
50
+ if event_id := self.view.kwargs.get("last_event_id", None):
51
+ return reverse("wbintegrator_office365:event-eventlog-list", args=[event_id], request=self.request)
52
+ return None
@@ -0,0 +1,65 @@
1
+ from wbcore.menus import ItemPermission, MenuItem
2
+ from wbcore.permissions.shortcuts import is_internal_user
3
+
4
+ TENANTUSER_MENUITEM = MenuItem(
5
+ label="Tenant Users",
6
+ endpoint="wbintegrator_office365:tenantuser-list",
7
+ permission=ItemPermission(
8
+ method=lambda request: is_internal_user(request.user),
9
+ permissions=["wbintegrator_office365.view_tenantuser", "wbintegrator_office365.administrate_event"],
10
+ ),
11
+ )
12
+
13
+ CALLUSER_MENUITEM = MenuItem(
14
+ label="Call Users",
15
+ endpoint="wbintegrator_office365:calluser-list",
16
+ permission=ItemPermission(
17
+ method=lambda request: is_internal_user(request.user),
18
+ permissions=["wbintegrator_office365.view_calluser", "wbintegrator_office365.administrate_event"],
19
+ ),
20
+ )
21
+
22
+ SUBSCRIPTION_MENUITEM = MenuItem(
23
+ label="Subscriptions",
24
+ endpoint="wbintegrator_office365:subscription-list",
25
+ permission=ItemPermission(
26
+ method=lambda request: is_internal_user(request.user),
27
+ permissions=["wbintegrator_office365.view_subscription", "wbintegrator_office365.administrate_event"],
28
+ ),
29
+ )
30
+
31
+ EVENT_MENUITEM = MenuItem(
32
+ label="Events",
33
+ endpoint="wbintegrator_office365:event-list",
34
+ permission=ItemPermission(
35
+ method=lambda request: is_internal_user(request.user),
36
+ permissions=["wbintegrator_office365.view_event", "wbintegrator_office365.administrate_event"],
37
+ ),
38
+ )
39
+
40
+ CALLEVENT_MENUITEM = MenuItem(
41
+ label="Call Events",
42
+ endpoint="wbintegrator_office365:callevent-list",
43
+ permission=ItemPermission(
44
+ method=lambda request: is_internal_user(request.user),
45
+ permissions=["wbintegrator_office365.view_callevent", "wbintegrator_office365.administrate_event"],
46
+ ),
47
+ )
48
+
49
+ CALLEVENTCHART_MENUITEM = MenuItem(
50
+ label="Call Reception Delay",
51
+ endpoint="wbintegrator_office365:calleventchart-list",
52
+ permission=ItemPermission(
53
+ method=lambda request: is_internal_user(request.user),
54
+ permissions=["wbintegrator_office365.view_callevent", "wbintegrator_office365.administrate_event"],
55
+ ),
56
+ )
57
+
58
+ CALLEVENTSUMMARYGRAPH_MENUITEM = MenuItem(
59
+ label="Call Summary Graph",
60
+ endpoint="wbintegrator_office365:calleventsummarygraph-list",
61
+ permission=ItemPermission(
62
+ method=lambda request: is_internal_user(request.user),
63
+ permissions=["wbintegrator_office365.view_callevent", "wbintegrator_office365.administrate_event"],
64
+ ),
65
+ )
@@ -0,0 +1,49 @@
1
+ from wbcore.metadata.configs.titles import TitleViewConfig
2
+
3
+
4
+ class TenantUserTitleConfig(TitleViewConfig):
5
+ def get_instance_title(self):
6
+ return "Tenant User: {{tenant_id}}"
7
+
8
+ def get_list_title(self):
9
+ return "Tenant Users"
10
+
11
+ def get_create_title(self):
12
+ return "New Tenant User"
13
+
14
+
15
+ class CallUserTitleConfig(TitleViewConfig):
16
+ def get_instance_title(self):
17
+ return "Call User: {{_tenant_user.profile_str}}"
18
+
19
+ def get_list_title(self):
20
+ return "Call Users"
21
+
22
+ def get_create_title(self):
23
+ return "New Call User"
24
+
25
+
26
+ class CallEventTitleConfig(TitleViewConfig):
27
+ def get_instance_title(self):
28
+ return "Call Event: {{_event.id}}"
29
+
30
+ def get_list_title(self):
31
+ return "Call Events"
32
+
33
+ def get_create_title(self):
34
+ return "New Call Event"
35
+
36
+
37
+ class CallEventReceptionTimeTitleConfig(TitleViewConfig):
38
+ def get_list_title(self):
39
+ return "Call Events Reception Delay"
40
+
41
+
42
+ class CallEventSummaryGraphTitleConfig(TitleViewConfig):
43
+ def get_list_title(self):
44
+ return "Call Events Summary Graph"
45
+
46
+
47
+ class SubscriptionTitleConfig(TitleViewConfig):
48
+ def get_instance_title(self):
49
+ return "Subscription: {{id_str}}"