django-content-studio 1.0.0b9__py3-none-any.whl → 1.0.0b10__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.
- content_studio/__init__.py +1 -1
- content_studio/dashboard/__init__.py +34 -5
- content_studio/dashboard/activity_log.py +6 -2
- content_studio/dashboard/statistic.py +27 -0
- content_studio/widgets.py +4 -0
- {django_content_studio-1.0.0b9.dist-info → django_content_studio-1.0.0b10.dist-info}/METADATA +1 -1
- {django_content_studio-1.0.0b9.dist-info → django_content_studio-1.0.0b10.dist-info}/RECORD +9 -8
- {django_content_studio-1.0.0b9.dist-info → django_content_studio-1.0.0b10.dist-info}/LICENSE +0 -0
- {django_content_studio-1.0.0b9.dist-info → django_content_studio-1.0.0b10.dist-info}/WHEEL +0 -0
content_studio/__init__.py
CHANGED
|
@@ -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
|
-
{
|
|
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<
|
|
54
|
-
def get(self, request,
|
|
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
|
|
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
|
-
|
|
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__()
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
from content_studio.serializers import ContentSerializer
|
|
2
1
|
from django.contrib.admin.models import LogEntry
|
|
3
2
|
from rest_framework import serializers
|
|
4
3
|
|
|
4
|
+
from content_studio.serializers import ContentSerializer
|
|
5
|
+
from ..dashboard import BaseWidget
|
|
6
|
+
|
|
5
7
|
|
|
6
8
|
class LogEntrySerializer(ContentSerializer):
|
|
7
9
|
object_model = serializers.SerializerMethodField()
|
|
@@ -22,11 +24,13 @@ class LogEntrySerializer(ContentSerializer):
|
|
|
22
24
|
return f"{obj.content_type.app_label}.{obj.content_type.model}"
|
|
23
25
|
|
|
24
26
|
|
|
25
|
-
class ActivityLogWidget:
|
|
27
|
+
class ActivityLogWidget(BaseWidget):
|
|
26
28
|
"""
|
|
27
29
|
Widget for showing activity logs.
|
|
28
30
|
"""
|
|
29
31
|
|
|
32
|
+
name = "ActivityLogWidget"
|
|
33
|
+
|
|
30
34
|
col_span = 2
|
|
31
35
|
|
|
32
36
|
def get_data(self, request):
|
|
@@ -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.")
|
content_studio/widgets.py
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
content_studio/__init__.py,sha256=
|
|
1
|
+
content_studio/__init__.py,sha256=EhSgseurRaoQIflicvxGVAbsaOcj-0ip6wNs6lTzi54,162
|
|
2
2
|
content_studio/admin.py,sha256=bsGQvHndTHmlFUgsBgWiDk9YOEz5i7duHwJk73CSdyk,11180
|
|
3
3
|
content_studio/apps.py,sha256=iGZYxsGerYYC8EmV9Wu9phuT9R8UHUkIQ6XAm94EUgA,3961
|
|
4
|
-
content_studio/dashboard/__init__.py,sha256=
|
|
5
|
-
content_studio/dashboard/activity_log.py,sha256=
|
|
4
|
+
content_studio/dashboard/__init__.py,sha256=G0fsYbegeZScWRb3vbCwd0sEm8fVc-tT_r-zCSPktgw,2377
|
|
5
|
+
content_studio/dashboard/activity_log.py,sha256=0hK96lXziD663a6YuKO7zRTVcVmbRitERqfNGc2NrtE,939
|
|
6
|
+
content_studio/dashboard/statistic.py,sha256=aoHJMM88zehapYWOmq_lqdSArkagYLCRWEAxXoNMcRg,912
|
|
6
7
|
content_studio/filters.py,sha256=GyglR2E_wswomW7EnfShEXr14zxuRlLAuxrHVO3QQYg,4335
|
|
7
8
|
content_studio/form.py,sha256=XvUbBVR3QlvyM1l73QWV5TnreQTM8cWNJqgxkACj9dQ,5041
|
|
8
9
|
content_studio/formats.py,sha256=JzOWrDRCVSnjJI0oX5fyFQU8LC634_jeAe84Widy43U,786
|
|
@@ -35,8 +36,8 @@ content_studio/urls.py,sha256=EY7lbzC0Q5vLfvqE3rK_4hmDrXhTuxKzYC55cc5tEEo,701
|
|
|
35
36
|
content_studio/utils.py,sha256=dGiYCixg-qcPGbF4hV6fts1Vv4ED8gRi8syLuSS4xzw,2123
|
|
36
37
|
content_studio/views.py,sha256=D5-o5pcj3RHuGyGB7S8fXAXoccRqdFpQEZZQ6sn7TvE,6361
|
|
37
38
|
content_studio/viewsets.py,sha256=iLhV6A_dl64-Ui4_DDT1Gje9ygvu0dYtF4OAO90MHSQ,5776
|
|
38
|
-
content_studio/widgets.py,sha256=
|
|
39
|
-
django_content_studio-1.0.
|
|
40
|
-
django_content_studio-1.0.
|
|
41
|
-
django_content_studio-1.0.
|
|
42
|
-
django_content_studio-1.0.
|
|
39
|
+
content_studio/widgets.py,sha256=kROwtBrM3s-NKSo9riVX_oDW5crlCx1TiPBt0HKX6Zc,1111
|
|
40
|
+
django_content_studio-1.0.0b10.dist-info/LICENSE,sha256=Wnx2EJhtSNnXE5Qs80i1HTBNFZTi8acEtC5TYqtFlnQ,1075
|
|
41
|
+
django_content_studio-1.0.0b10.dist-info/METADATA,sha256=ag5nbI1zmmBTVT-Dl2bzDCFJ3JG0Al7CBEqySVoxGkk,2513
|
|
42
|
+
django_content_studio-1.0.0b10.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
|
43
|
+
django_content_studio-1.0.0b10.dist-info/RECORD,,
|
{django_content_studio-1.0.0b9.dist-info → django_content_studio-1.0.0b10.dist-info}/LICENSE
RENAMED
|
File without changes
|
|
File without changes
|