django-content-studio 1.0.0b2.post5__tar.gz → 1.0.0b10.post1__tar.gz

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.
Files changed (53) hide show
  1. {django_content_studio-1.0.0b2.post5 → django_content_studio-1.0.0b10.post1}/PKG-INFO +1 -1
  2. {django_content_studio-1.0.0b2.post5 → django_content_studio-1.0.0b10.post1}/content_studio/__init__.py +1 -1
  3. {django_content_studio-1.0.0b2.post5 → django_content_studio-1.0.0b10.post1}/content_studio/admin.py +51 -14
  4. {django_content_studio-1.0.0b2.post5 → django_content_studio-1.0.0b10.post1}/content_studio/apps.py +12 -2
  5. {django_content_studio-1.0.0b2.post5 → django_content_studio-1.0.0b10.post1}/content_studio/dashboard/__init__.py +34 -5
  6. {django_content_studio-1.0.0b2.post5 → django_content_studio-1.0.0b10.post1}/content_studio/dashboard/activity_log.py +7 -2
  7. django_content_studio-1.0.0b10.post1/content_studio/dashboard/statistic.py +27 -0
  8. {django_content_studio-1.0.0b2.post5 → django_content_studio-1.0.0b10.post1}/content_studio/form.py +95 -1
  9. {django_content_studio-1.0.0b2.post5 → django_content_studio-1.0.0b10.post1}/content_studio/models.py +4 -1
  10. {django_content_studio-1.0.0b2.post5 → django_content_studio-1.0.0b10.post1}/content_studio/serializers.py +9 -0
  11. {django_content_studio-1.0.0b2.post5 → django_content_studio-1.0.0b10.post1}/content_studio/settings.py +4 -0
  12. django_content_studio-1.0.0b10.post1/content_studio/static/content_studio/assets/browser-ponyfill-TyWUZ1Oq.js +2 -0
  13. django_content_studio-1.0.0b10.post1/content_studio/static/content_studio/assets/index.css +1 -0
  14. django_content_studio-1.0.0b10.post1/content_studio/static/content_studio/assets/index.js +249 -0
  15. {django_content_studio-1.0.0b2.post5 → django_content_studio-1.0.0b10.post1}/content_studio/static/content_studio/index.html +6 -3
  16. {django_content_studio-1.0.0b2.post5 → django_content_studio-1.0.0b10.post1}/content_studio/static/content_studio/locales/en/translation.json +7 -1
  17. {django_content_studio-1.0.0b2.post5 → django_content_studio-1.0.0b10.post1}/content_studio/static/content_studio/locales/nl/translation.json +17 -1
  18. {django_content_studio-1.0.0b2.post5 → django_content_studio-1.0.0b10.post1}/content_studio/templates/content_studio/index.html +5 -0
  19. {django_content_studio-1.0.0b2.post5 → django_content_studio-1.0.0b10.post1}/content_studio/utils.py +27 -0
  20. {django_content_studio-1.0.0b2.post5 → django_content_studio-1.0.0b10.post1}/content_studio/views.py +43 -11
  21. {django_content_studio-1.0.0b2.post5 → django_content_studio-1.0.0b10.post1}/content_studio/viewsets.py +75 -2
  22. {django_content_studio-1.0.0b2.post5 → django_content_studio-1.0.0b10.post1}/content_studio/widgets.py +4 -0
  23. {django_content_studio-1.0.0b2.post5 → django_content_studio-1.0.0b10.post1}/pyproject.toml +5 -5
  24. django_content_studio-1.0.0b2.post5/content_studio/static/content_studio/assets/browser-ponyfill-Ct7s-5jI.js +0 -2
  25. django_content_studio-1.0.0b2.post5/content_studio/static/content_studio/assets/index.css +0 -1
  26. django_content_studio-1.0.0b2.post5/content_studio/static/content_studio/assets/index.js +0 -228
  27. django_content_studio-1.0.0b2.post5/content_studio/static/content_studio/assets/inter-cyrillic-ext-wght-normal.woff2 +0 -0
  28. django_content_studio-1.0.0b2.post5/content_studio/static/content_studio/assets/inter-cyrillic-wght-normal.woff2 +0 -0
  29. django_content_studio-1.0.0b2.post5/content_studio/static/content_studio/assets/inter-greek-ext-wght-normal.woff2 +0 -0
  30. django_content_studio-1.0.0b2.post5/content_studio/static/content_studio/assets/inter-greek-wght-normal.woff2 +0 -0
  31. django_content_studio-1.0.0b2.post5/content_studio/static/content_studio/assets/inter-latin-ext-wght-normal.woff2 +0 -0
  32. django_content_studio-1.0.0b2.post5/content_studio/static/content_studio/assets/inter-latin-wght-normal.woff2 +0 -0
  33. django_content_studio-1.0.0b2.post5/content_studio/static/content_studio/assets/inter-vietnamese-wght-normal.woff2 +0 -0
  34. {django_content_studio-1.0.0b2.post5 → django_content_studio-1.0.0b10.post1}/LICENSE +0 -0
  35. {django_content_studio-1.0.0b2.post5 → django_content_studio-1.0.0b10.post1}/README.md +0 -0
  36. {django_content_studio-1.0.0b2.post5 → django_content_studio-1.0.0b10.post1}/content_studio/filters.py +0 -0
  37. {django_content_studio-1.0.0b2.post5 → django_content_studio-1.0.0b10.post1}/content_studio/formats.py +0 -0
  38. {django_content_studio-1.0.0b2.post5 → django_content_studio-1.0.0b10.post1}/content_studio/login_backends/__init__.py +0 -0
  39. {django_content_studio-1.0.0b2.post5 → django_content_studio-1.0.0b10.post1}/content_studio/login_backends/username_password.py +0 -0
  40. {django_content_studio-1.0.0b2.post5 → django_content_studio-1.0.0b10.post1}/content_studio/media_library/serializers.py +0 -0
  41. {django_content_studio-1.0.0b2.post5 → django_content_studio-1.0.0b10.post1}/content_studio/media_library/viewsets.py +0 -0
  42. {django_content_studio-1.0.0b2.post5 → django_content_studio-1.0.0b10.post1}/content_studio/paginators.py +0 -0
  43. {django_content_studio-1.0.0b2.post5 → django_content_studio-1.0.0b10.post1}/content_studio/router.py +0 -0
  44. {django_content_studio-1.0.0b2.post5 → django_content_studio-1.0.0b10.post1}/content_studio/static/content_studio/icons/pi/Phosphor-Bold.svg +0 -0
  45. {django_content_studio-1.0.0b2.post5 → django_content_studio-1.0.0b10.post1}/content_studio/static/content_studio/icons/pi/Phosphor-Bold.ttf +0 -0
  46. {django_content_studio-1.0.0b2.post5 → django_content_studio-1.0.0b10.post1}/content_studio/static/content_studio/icons/pi/Phosphor-Bold.woff +0 -0
  47. {django_content_studio-1.0.0b2.post5 → django_content_studio-1.0.0b10.post1}/content_studio/static/content_studio/icons/pi/Phosphor-Bold.woff2 +0 -0
  48. {django_content_studio-1.0.0b2.post5 → django_content_studio-1.0.0b10.post1}/content_studio/static/content_studio/icons/pi/style.css +0 -0
  49. {django_content_studio-1.0.0b2.post5 → django_content_studio-1.0.0b10.post1}/content_studio/static/content_studio/img/media_placeholder.svg +0 -0
  50. {django_content_studio-1.0.0b2.post5 → django_content_studio-1.0.0b10.post1}/content_studio/static/content_studio/vite.svg +0 -0
  51. {django_content_studio-1.0.0b2.post5 → django_content_studio-1.0.0b10.post1}/content_studio/token_backends/__init__.py +0 -0
  52. {django_content_studio-1.0.0b2.post5 → django_content_studio-1.0.0b10.post1}/content_studio/token_backends/jwt.py +0 -0
  53. {django_content_studio-1.0.0b2.post5 → django_content_studio-1.0.0b10.post1}/content_studio/urls.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: django-content-studio
3
- Version: 1.0.0b2.post5
3
+ Version: 1.0.0b10.post1
4
4
  Summary: Modern & flexible Django admin
5
5
  License: MIT
6
6
  Author: Leon van der Grient
@@ -1,5 +1,5 @@
1
1
  __title__ = "Django Content Studio"
2
- __version__ = "1.0.0-beta.2"
2
+ __version__ = "1.0.0-beta.10"
3
3
  __author__ = "Leon van der Grient"
4
4
  __license__ = "MIT"
5
5
 
@@ -1,3 +1,4 @@
1
+ import uuid
1
2
  from typing import Type
2
3
 
3
4
  from django.contrib import admin
@@ -6,12 +7,13 @@ from django.db.models import Model
6
7
  from rest_framework.request import HttpRequest
7
8
 
8
9
  from . import widgets, formats
9
- from .form import FormSet, FormSetGroup
10
+ from .form import FormSet, FormSetGroup, Field, Component
10
11
  from .login_backends import LoginBackendManager
11
12
  from .token_backends import TokenBackendManager
12
- from .utils import get_related_field_name
13
+ from .utils import get_related_field_name, flatten
13
14
 
14
15
  register = admin.register
16
+ display = admin.display
15
17
 
16
18
 
17
19
  class StackedInline(admin.StackedInline):
@@ -101,6 +103,12 @@ class AdminSite(admin.AdminSite):
101
103
  """
102
104
  return obj.file.url
103
105
 
106
+ def get_tenants(self, tenant_model: Type[models.Model], **kwargs):
107
+ """
108
+ Method for getting the list of available tenants.
109
+ """
110
+ return tenant_model.objects.all()
111
+
104
112
 
105
113
  admin_site = AdminSite()
106
114
 
@@ -139,18 +147,13 @@ class ModelAdmin(admin.ModelAdmin):
139
147
  list_description = ""
140
148
 
141
149
  # Configure the main section in the edit-view.
142
- edit_main: list[type[FormSetGroup | FormSet | str]] = []
150
+ edit_main: list[type[FormSetGroup | FormSet | Field | str]] = []
143
151
 
144
152
  # Configure the sidebar in the edit-view.
145
- edit_sidebar: list[type[FormSet | str]] = []
153
+ edit_sidebar: list[type[FormSet | Field | str]] = []
146
154
 
147
155
  icon = None
148
156
 
149
- def save_model(self, request, obj, form, change):
150
- if hasattr(obj, "edited_by"):
151
- obj.edited_by = request.user
152
- super().save_model(request, obj, form, change)
153
-
154
157
  def has_add_permission(self, request):
155
158
  is_singleton = getattr(self.model, "is_singleton", False)
156
159
 
@@ -168,12 +171,25 @@ class ModelAdmin(admin.ModelAdmin):
168
171
 
169
172
  return super().has_delete_permission(request, obj)
170
173
 
171
- def render_change_form(self, request, context, *args, **kwargs):
172
- is_singleton = getattr(self.model, "is_singleton", False)
174
+ def get_component(self, component_id: uuid.UUID):
175
+ """
176
+ Retrieves a component from the edit_main or edit_sidebar attributes by ID.
177
+ :param component_id:
178
+ :return:
179
+ """
180
+ all_fields = getattr(self, "edit_main", []) + getattr(self, "edit_sidebar", [])
173
181
 
174
- context["show_save_and_add_another"] = not is_singleton
182
+ flat_fields = flatten(
183
+ [f.get_fields() if hasattr(f, "get_fields") else [f] for f in all_fields]
184
+ )
175
185
 
176
- return super().render_change_form(request, context, *args, **kwargs)
186
+ components = [c for c in flat_fields if issubclass(c.__class__, Component)]
187
+
188
+ for component in components:
189
+ if component.component_id == component_id:
190
+ return component
191
+
192
+ return None
177
193
 
178
194
 
179
195
  class AdminSerializer:
@@ -208,7 +224,7 @@ class AdminSerializer:
208
224
  "list": {
209
225
  "per_page": admin_class.list_per_page,
210
226
  "description": getattr(admin_class, "list_description", ""),
211
- "display": admin_class.list_display,
227
+ "display": self.get_list_display(),
212
228
  "search": len(admin_class.search_fields) > 0,
213
229
  "filter": admin_class.list_filter,
214
230
  "sortable_by": admin_class.sortable_by,
@@ -245,6 +261,27 @@ class AdminSerializer:
245
261
  for i in self.get_edit_sidebar(getattr(admin_class, "edit_sidebar", None))
246
262
  ]
247
263
 
264
+ def get_list_display(self):
265
+ admin_class = self.admin_class
266
+ fields = []
267
+
268
+ for field in admin_class.list_display:
269
+ if hasattr(admin_class, field):
270
+ method = getattr(admin_class, field)
271
+ description = getattr(method, "short_description", None)
272
+ empty_value = getattr(method, "empty_value", None)
273
+ fields.append(
274
+ {
275
+ "name": field,
276
+ "description": description,
277
+ "empty_value": empty_value,
278
+ }
279
+ )
280
+ else:
281
+ fields.append({"name": field})
282
+
283
+ return fields
284
+
248
285
  def get_edit_main(self, edit_main):
249
286
  """
250
287
  Returns a normalized list of form set groups.
@@ -4,7 +4,7 @@ from django.contrib import admin
4
4
  from . import VERSION
5
5
  from .paginators import ContentPagination
6
6
  from .settings import cs_settings
7
- from .utils import is_runserver
7
+ from .utils import is_runserver, get_tenant_field_name
8
8
 
9
9
 
10
10
  class DjangoContentStudioConfig(AppConfig):
@@ -68,7 +68,7 @@ class DjangoContentStudioConfig(AppConfig):
68
68
  _admin_model = admin_model
69
69
  is_singleton = getattr(admin_model, "is_singleton", False)
70
70
  pagination_class = Pagination
71
- queryset = _model.objects.all()
71
+ queryset = _model.objects.none()
72
72
  search_fields = list(getattr(_admin_model, "search_fields", []))
73
73
 
74
74
  def get_serializer_class(self):
@@ -90,6 +90,16 @@ class DjangoContentStudioConfig(AppConfig):
90
90
 
91
91
  return Serializer
92
92
 
93
+ def get_queryset(self):
94
+ tenant_model = cs_settings.TENANT_MODEL
95
+ tenant_id = self.request.headers.get("x-dcs-tenant", None)
96
+ field_name = get_tenant_field_name(self._model)
97
+
98
+ if tenant_model and tenant_id and field_name:
99
+ return self._model.objects.filter(**{f"{field_name}_id": tenant_id})
100
+
101
+ return self._model.objects.all()
102
+
93
103
  if parent:
94
104
  prefix = f"api/inlines/{parent._meta.label_lower}/{model._meta.label_lower}"
95
105
  basename = f"content_studio_api-{parent._meta.label_lower}-{model._meta.label_lower}"
@@ -1,3 +1,6 @@
1
+ import uuid
2
+
3
+ from rest_framework import serializers
1
4
  from rest_framework.decorators import action
2
5
  from rest_framework.exceptions import NotFound
3
6
  from rest_framework.parsers import JSONParser
@@ -31,7 +34,11 @@ class Dashboard:
31
34
  def serialize(self):
32
35
  return {
33
36
  "widgets": [
34
- {"name": w.__class__.__name__, "col_span": getattr(w, "col_span", 1)}
37
+ {
38
+ "name": w.name,
39
+ "widget_id": w.widget_id,
40
+ "col_span": w.col_span,
41
+ }
35
42
  for w in self.widgets
36
43
  ]
37
44
  }
@@ -50,15 +57,37 @@ class DashboardViewSet(ViewSet):
50
57
  admin_site.token_backend.active_backend.authentication_class
51
58
  ]
52
59
 
53
- @action(detail=False, url_path="(?P<name>[^/.]+)")
54
- def get(self, request, name=None):
60
+ @action(detail=False, url_path="widgets/(?P<widget_id>[^/.]+)")
61
+ def get(self, request, widget_id=None):
55
62
  widget = None
56
63
 
57
64
  for w in self.dashboard.widgets:
58
- if name == w.__class__.__name__.lower():
65
+ if widget_id == str(w.widget_id):
59
66
  widget = w
60
67
 
61
68
  if not widget:
62
69
  raise NotFound()
63
70
 
64
- return Response(data=widget.get_data(request))
71
+ data = widget.get_data(request)
72
+
73
+ if isinstance(data, serializers.Serializer):
74
+ data.is_valid(raise_exception=True)
75
+ data = data.data
76
+
77
+ return Response(data=data)
78
+
79
+
80
+ class BaseWidget:
81
+ col_span = 1
82
+ widget_id = None
83
+
84
+ def __init__(self):
85
+ self.widget_id = self.widget_id or uuid.uuid4()
86
+
87
+
88
+ class SpacingWidget(BaseWidget):
89
+ name = "SpacingWidget"
90
+
91
+ def __init__(self, col_span=1):
92
+ self.col_span = col_span
93
+ super().__init__()
@@ -2,6 +2,7 @@ from django.contrib.admin.models import LogEntry
2
2
  from rest_framework import serializers
3
3
 
4
4
  from content_studio.serializers import ContentSerializer
5
+ from ..dashboard import BaseWidget
5
6
 
6
7
 
7
8
  class LogEntrySerializer(ContentSerializer):
@@ -23,12 +24,16 @@ class LogEntrySerializer(ContentSerializer):
23
24
  return f"{obj.content_type.app_label}.{obj.content_type.model}"
24
25
 
25
26
 
26
- class ActivityLogWidget:
27
+ class ActivityLogWidget(BaseWidget):
27
28
  """
28
29
  Widget for showing activity logs.
29
30
  """
30
31
 
32
+ name = "ActivityLogWidget"
33
+
31
34
  col_span = 2
32
35
 
33
36
  def get_data(self, request):
34
- return LogEntrySerializer(LogEntry.objects.all()[0:5], many=True).data
37
+ return LogEntrySerializer(
38
+ LogEntry.objects.all().order_by("-action_time")[0:5], many=True
39
+ ).data
@@ -0,0 +1,27 @@
1
+ from rest_framework import serializers
2
+
3
+ from ..dashboard import BaseWidget
4
+
5
+
6
+ class StatisticWidgetSerializer(serializers.Serializer):
7
+ value = serializers.IntegerField()
8
+ prefix = serializers.CharField(default="", allow_blank=True, required=False)
9
+ suffix = serializers.CharField(default="", allow_blank=True, required=False)
10
+ title = serializers.CharField(default="", allow_blank=True, required=False)
11
+ trend = serializers.DecimalField(
12
+ max_digits=5, decimal_places=1, allow_null=True, required=False
13
+ )
14
+ trend_sentiment = serializers.ChoiceField(
15
+ default="default", required=False, choices=["default", "positive", "negative"]
16
+ )
17
+
18
+
19
+ class StatisticWidget(BaseWidget):
20
+ """
21
+ Widget for showing some statistic.
22
+ """
23
+
24
+ name = "StatisticWidget"
25
+
26
+ def get_data(self, request):
27
+ raise NotImplementedError("You need to implement get_data for your widget.")
@@ -1,6 +1,11 @@
1
1
  ###
2
2
  # Form field classes are used for grouping, ordering and laying out fields.
3
3
  ###
4
+ import uuid
5
+ from typing import Type
6
+
7
+ from django.db.models import Model
8
+ from rest_framework.response import Response
4
9
 
5
10
 
6
11
  class Field:
@@ -15,6 +20,7 @@ class Field:
15
20
 
16
21
  def serialize(self):
17
22
  return {
23
+ "type": "field",
18
24
  "name": self.name,
19
25
  "col_span": self.col_span,
20
26
  "label": self.label,
@@ -32,11 +38,18 @@ class FieldLayout:
32
38
 
33
39
  def serialize(self):
34
40
  return {
41
+ "type": "field-layout",
35
42
  "fields": [field.serialize() for field in self.fields],
36
43
  "columns": self.columns,
37
44
  }
38
45
 
46
+ def get_fields(self) -> list[Field]:
47
+ return self.fields
48
+
39
49
  def _normalize_field(self, field):
50
+ """
51
+ Checks if a field is of an allowed type and wraps string fields in a Field object.
52
+ """
40
53
  if isinstance(field, str):
41
54
  return Field(field)
42
55
  elif isinstance(field, Field):
@@ -63,21 +76,41 @@ class FormSet:
63
76
 
64
77
  def serialize(self):
65
78
  return {
79
+ "type": "form-set",
66
80
  "title": self.title,
67
81
  "description": self.description,
68
82
  "fields": [field.serialize() for field in self.fields],
69
83
  }
70
84
 
85
+ def get_fields(self) -> list[Field]:
86
+ """
87
+ Returns a list of all Field and Component objects.
88
+ """
89
+ fields = []
90
+
91
+ for field in self.fields:
92
+ if isinstance(field, FieldLayout):
93
+ fields = fields + field.get_fields()
94
+ else:
95
+ fields.append(field)
96
+
97
+ return fields
98
+
71
99
  def _normalize_field(self, field):
100
+ """
101
+ Checks if a field is of an allowed type and wraps string fields in a Field object.
102
+ """
72
103
  if isinstance(field, str):
73
104
  return Field(field)
74
105
  elif isinstance(field, Field):
75
106
  return field
76
107
  elif isinstance(field, FieldLayout):
77
108
  return field
109
+ elif issubclass(field.__class__, Component):
110
+ return field
78
111
  else:
79
112
  raise ValueError(
80
- f"Invalid field: {field}. Must be a string, Field or FieldLayout."
113
+ f"Invalid field: {field}. Must be a string, Field, FieldLayout or a Component (subclass)."
81
114
  )
82
115
 
83
116
 
@@ -92,6 +125,67 @@ class FormSetGroup:
92
125
 
93
126
  def serialize(self):
94
127
  return {
128
+ "type": "form-set-group",
95
129
  "label": self.label,
96
130
  "formsets": [formset.serialize() for formset in self.formsets],
97
131
  }
132
+
133
+ def get_fields(self) -> list[Field]:
134
+ """
135
+ Returns a list of all Field and Component objects.
136
+ """
137
+ fields = []
138
+
139
+ for form_set in self.formsets:
140
+ fields = fields + form_set.get_fields()
141
+
142
+ return fields
143
+
144
+
145
+ class Component:
146
+ component_id: uuid.UUID
147
+ component_type: str
148
+
149
+ def __init__(self):
150
+ self.component_id = uuid.uuid4()
151
+
152
+ def serialize(self):
153
+ return {
154
+ "type": "component",
155
+ "component_type": str(self.component_type),
156
+ "component_id": str(self.component_id),
157
+ }
158
+
159
+
160
+ class Link(Component):
161
+ component_type = "Link"
162
+ label: str
163
+
164
+ def get_url(self, obj: Type[Model], request):
165
+ raise NotImplementedError
166
+
167
+ def serialize(self):
168
+ return {
169
+ **super().serialize(),
170
+ "label": self.label,
171
+ }
172
+
173
+ def handle_request(self, obj: Type[Model], request):
174
+ return Response(data={"url": self.get_url(obj, request)})
175
+
176
+
177
+ class ButtonLink(Link):
178
+ component_type = "LinkButton"
179
+
180
+ # Add icon before label
181
+ icon = None
182
+
183
+ # Add copy to clipboard button
184
+ copy = False
185
+
186
+ def serialize(self):
187
+ return {
188
+ **super().serialize(),
189
+ "icon": self.icon,
190
+ "copy": self.copy,
191
+ }
@@ -1,6 +1,6 @@
1
1
  from django.db import models
2
2
 
3
- from .utils import is_jsonable
3
+ from .utils import is_jsonable, get_tenant_field_name
4
4
 
5
5
 
6
6
  class ModelSerializer:
@@ -10,11 +10,14 @@ class ModelSerializer:
10
10
  def serialize(self):
11
11
  model = self.model
12
12
 
13
+ tenant_field = get_tenant_field_name(self.model)
14
+
13
15
  return {
14
16
  "label": model._meta.label_lower,
15
17
  "verbose_name": model._meta.verbose_name,
16
18
  "verbose_name_plural": model._meta.verbose_name_plural,
17
19
  "fields": self.get_fields(),
20
+ "tenant_field": tenant_field,
18
21
  }
19
22
 
20
23
  def get_fields(self):
@@ -94,6 +94,15 @@ class ContentSerializer(serializers.ModelSerializer):
94
94
  return super().build_field(field_name, info, model_class, nested_depth)
95
95
 
96
96
 
97
+ class RelatedItemSerializer(serializers.Serializer):
98
+ """
99
+ Serializer for use in the relations endpoint.
100
+ """
101
+
102
+ id = serializers.UUIDField()
103
+ __str__ = serializers.CharField()
104
+
105
+
97
106
  class SessionUserSerializer(serializers.ModelSerializer):
98
107
  username = serializers.CharField(source=user_model.USERNAME_FIELD)
99
108
 
@@ -31,6 +31,7 @@ DEFAULTS = {
31
31
  "CREATED_AT_ATTR": "created_at",
32
32
  "MEDIA_LIBRARY_MODEL": None,
33
33
  "MEDIA_LIBRARY_FOLDER_MODEL": None,
34
+ "TENANT_MODEL": None,
34
35
  }
35
36
 
36
37
 
@@ -40,6 +41,7 @@ IMPORT_STRINGS = [
40
41
  "LOGIN_BACKENDS",
41
42
  "MEDIA_LIBRARY_MODEL",
42
43
  "MEDIA_LIBRARY_FOLDER_MODEL",
44
+ "TENANT_MODEL",
43
45
  ]
44
46
 
45
47
 
@@ -150,3 +152,5 @@ def reload_settings(*args, **kwargs):
150
152
 
151
153
 
152
154
  setting_changed.connect(reload_settings)
155
+
156
+ allowed_cors_headers = ("x-dcs-tenant",)
@@ -0,0 +1,2 @@
1
+ import{c as R,g as z}from"./index.js";function $(w,d){for(var b=0;b<d.length;b++){const y=d[b];if(typeof y!="string"&&!Array.isArray(y)){for(const h in y)if(h!=="default"&&!(h in w)){const p=Object.getOwnPropertyDescriptor(y,h);p&&Object.defineProperty(w,h,p.get?p:{enumerable:!0,get:()=>y[h]})}}}return Object.freeze(Object.defineProperty(w,Symbol.toStringTag,{value:"Module"}))}var A={exports:{}},U;function X(){return U||(U=1,(function(w,d){var b=typeof globalThis<"u"&&globalThis||typeof self<"u"&&self||typeof R<"u"&&R,y=(function(){function p(){this.fetch=!1,this.DOMException=b.DOMException}return p.prototype=b,new p})();(function(p){(function(u){var a=typeof p<"u"&&p||typeof self<"u"&&self||typeof a<"u"&&a,f={searchParams:"URLSearchParams"in a,iterable:"Symbol"in a&&"iterator"in Symbol,blob:"FileReader"in a&&"Blob"in a&&(function(){try{return new Blob,!0}catch{return!1}})(),formData:"FormData"in a,arrayBuffer:"ArrayBuffer"in a};function S(e){return e&&DataView.prototype.isPrototypeOf(e)}if(f.arrayBuffer)var F=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],I=ArrayBuffer.isView||function(e){return e&&F.indexOf(Object.prototype.toString.call(e))>-1};function v(e){if(typeof e!="string"&&(e=String(e)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(e)||e==="")throw new TypeError('Invalid character in header field name: "'+e+'"');return e.toLowerCase()}function E(e){return typeof e!="string"&&(e=String(e)),e}function T(e){var t={next:function(){var r=e.shift();return{done:r===void 0,value:r}}};return f.iterable&&(t[Symbol.iterator]=function(){return t}),t}function s(e){this.map={},e instanceof s?e.forEach(function(t,r){this.append(r,t)},this):Array.isArray(e)?e.forEach(function(t){this.append(t[0],t[1])},this):e&&Object.getOwnPropertyNames(e).forEach(function(t){this.append(t,e[t])},this)}s.prototype.append=function(e,t){e=v(e),t=E(t);var r=this.map[e];this.map[e]=r?r+", "+t:t},s.prototype.delete=function(e){delete this.map[v(e)]},s.prototype.get=function(e){return e=v(e),this.has(e)?this.map[e]:null},s.prototype.has=function(e){return this.map.hasOwnProperty(v(e))},s.prototype.set=function(e,t){this.map[v(e)]=E(t)},s.prototype.forEach=function(e,t){for(var r in this.map)this.map.hasOwnProperty(r)&&e.call(t,this.map[r],r,this)},s.prototype.keys=function(){var e=[];return this.forEach(function(t,r){e.push(r)}),T(e)},s.prototype.values=function(){var e=[];return this.forEach(function(t){e.push(t)}),T(e)},s.prototype.entries=function(){var e=[];return this.forEach(function(t,r){e.push([r,t])}),T(e)},f.iterable&&(s.prototype[Symbol.iterator]=s.prototype.entries);function B(e){if(e.bodyUsed)return Promise.reject(new TypeError("Already read"));e.bodyUsed=!0}function P(e){return new Promise(function(t,r){e.onload=function(){t(e.result)},e.onerror=function(){r(e.error)}})}function M(e){var t=new FileReader,r=P(t);return t.readAsArrayBuffer(e),r}function q(e){var t=new FileReader,r=P(t);return t.readAsText(e),r}function H(e){for(var t=new Uint8Array(e),r=new Array(t.length),n=0;n<t.length;n++)r[n]=String.fromCharCode(t[n]);return r.join("")}function D(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function x(){return this.bodyUsed=!1,this._initBody=function(e){this.bodyUsed=this.bodyUsed,this._bodyInit=e,e?typeof e=="string"?this._bodyText=e:f.blob&&Blob.prototype.isPrototypeOf(e)?this._bodyBlob=e:f.formData&&FormData.prototype.isPrototypeOf(e)?this._bodyFormData=e:f.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)?this._bodyText=e.toString():f.arrayBuffer&&f.blob&&S(e)?(this._bodyArrayBuffer=D(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):f.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(e)||I(e))?this._bodyArrayBuffer=D(e):this._bodyText=e=Object.prototype.toString.call(e):this._bodyText="",this.headers.get("content-type")||(typeof e=="string"?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):f.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},f.blob&&(this.blob=function(){var e=B(this);if(e)return e;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){if(this._bodyArrayBuffer){var e=B(this);return e||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer))}else return this.blob().then(M)}),this.text=function(){var e=B(this);if(e)return e;if(this._bodyBlob)return q(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(H(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},f.formData&&(this.formData=function(){return this.text().then(k)}),this.json=function(){return this.text().then(JSON.parse)},this}var L=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function C(e){var t=e.toUpperCase();return L.indexOf(t)>-1?t:e}function m(e,t){if(!(this instanceof m))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');t=t||{};var r=t.body;if(e instanceof m){if(e.bodyUsed)throw new TypeError("Already read");this.url=e.url,this.credentials=e.credentials,t.headers||(this.headers=new s(e.headers)),this.method=e.method,this.mode=e.mode,this.signal=e.signal,!r&&e._bodyInit!=null&&(r=e._bodyInit,e.bodyUsed=!0)}else this.url=String(e);if(this.credentials=t.credentials||this.credentials||"same-origin",(t.headers||!this.headers)&&(this.headers=new s(t.headers)),this.method=C(t.method||this.method||"GET"),this.mode=t.mode||this.mode||null,this.signal=t.signal||this.signal,this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&r)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(r),(this.method==="GET"||this.method==="HEAD")&&(t.cache==="no-store"||t.cache==="no-cache")){var n=/([?&])_=[^&]*/;if(n.test(this.url))this.url=this.url.replace(n,"$1_="+new Date().getTime());else{var i=/\?/;this.url+=(i.test(this.url)?"&":"?")+"_="+new Date().getTime()}}}m.prototype.clone=function(){return new m(this,{body:this._bodyInit})};function k(e){var t=new FormData;return e.trim().split("&").forEach(function(r){if(r){var n=r.split("="),i=n.shift().replace(/\+/g," "),o=n.join("=").replace(/\+/g," ");t.append(decodeURIComponent(i),decodeURIComponent(o))}}),t}function N(e){var t=new s,r=e.replace(/\r?\n[\t ]+/g," ");return r.split("\r").map(function(n){return n.indexOf(`
2
+ `)===0?n.substr(1,n.length):n}).forEach(function(n){var i=n.split(":"),o=i.shift().trim();if(o){var _=i.join(":").trim();t.append(o,_)}}),t}x.call(m.prototype);function c(e,t){if(!(this instanceof c))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');t||(t={}),this.type="default",this.status=t.status===void 0?200:t.status,this.ok=this.status>=200&&this.status<300,this.statusText=t.statusText===void 0?"":""+t.statusText,this.headers=new s(t.headers),this.url=t.url||"",this._initBody(e)}x.call(c.prototype),c.prototype.clone=function(){return new c(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new s(this.headers),url:this.url})},c.error=function(){var e=new c(null,{status:0,statusText:""});return e.type="error",e};var G=[301,302,303,307,308];c.redirect=function(e,t){if(G.indexOf(t)===-1)throw new RangeError("Invalid status code");return new c(null,{status:t,headers:{location:e}})},u.DOMException=a.DOMException;try{new u.DOMException}catch{u.DOMException=function(t,r){this.message=t,this.name=r;var n=Error(t);this.stack=n.stack},u.DOMException.prototype=Object.create(Error.prototype),u.DOMException.prototype.constructor=u.DOMException}function O(e,t){return new Promise(function(r,n){var i=new m(e,t);if(i.signal&&i.signal.aborted)return n(new u.DOMException("Aborted","AbortError"));var o=new XMLHttpRequest;function _(){o.abort()}o.onload=function(){var l={status:o.status,statusText:o.statusText,headers:N(o.getAllResponseHeaders()||"")};l.url="responseURL"in o?o.responseURL:l.headers.get("X-Request-URL");var g="response"in o?o.response:o.responseText;setTimeout(function(){r(new c(g,l))},0)},o.onerror=function(){setTimeout(function(){n(new TypeError("Network request failed"))},0)},o.ontimeout=function(){setTimeout(function(){n(new TypeError("Network request failed"))},0)},o.onabort=function(){setTimeout(function(){n(new u.DOMException("Aborted","AbortError"))},0)};function V(l){try{return l===""&&a.location.href?a.location.href:l}catch{return l}}o.open(i.method,V(i.url),!0),i.credentials==="include"?o.withCredentials=!0:i.credentials==="omit"&&(o.withCredentials=!1),"responseType"in o&&(f.blob?o.responseType="blob":f.arrayBuffer&&i.headers.get("Content-Type")&&i.headers.get("Content-Type").indexOf("application/octet-stream")!==-1&&(o.responseType="arraybuffer")),t&&typeof t.headers=="object"&&!(t.headers instanceof s)?Object.getOwnPropertyNames(t.headers).forEach(function(l){o.setRequestHeader(l,E(t.headers[l]))}):i.headers.forEach(function(l,g){o.setRequestHeader(g,l)}),i.signal&&(i.signal.addEventListener("abort",_),o.onreadystatechange=function(){o.readyState===4&&i.signal.removeEventListener("abort",_)}),o.send(typeof i._bodyInit>"u"?null:i._bodyInit)})}return O.polyfill=!0,a.fetch||(a.fetch=O,a.Headers=s,a.Request=m,a.Response=c),u.Headers=s,u.Request=m,u.Response=c,u.fetch=O,u})({})})(y),y.fetch.ponyfill=!0,delete y.fetch.polyfill;var h=b.fetch?b:y;d=h.fetch,d.default=h.fetch,d.fetch=h.fetch,d.Headers=h.Headers,d.Request=h.Request,d.Response=h.Response,w.exports=d})(A,A.exports)),A.exports}var j=X();const J=z(j),Q=$({__proto__:null,default:J},[j]);export{Q as b};