wbnews 2.2.4__py2.py3-none-any.whl → 2.2.5__py2.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.
Files changed (44) hide show
  1. {wbnews-2.2.4.dist-info → wbnews-2.2.5.dist-info}/METADATA +1 -1
  2. wbnews-2.2.5.dist-info/RECORD +3 -0
  3. wbnews/.coveragerc +0 -23
  4. wbnews/__init__.py +0 -1
  5. wbnews/admin.py +0 -27
  6. wbnews/apps.py +0 -9
  7. wbnews/factories.py +0 -33
  8. wbnews/import_export/__init__.py +0 -0
  9. wbnews/import_export/backends/__init__.py +0 -1
  10. wbnews/import_export/backends/news.py +0 -35
  11. wbnews/import_export/handlers/__init__.py +0 -1
  12. wbnews/import_export/handlers/news.py +0 -25
  13. wbnews/import_export/parsers/__init__.py +0 -0
  14. wbnews/import_export/parsers/emails/__init__.py +0 -0
  15. wbnews/import_export/parsers/emails/news.py +0 -48
  16. wbnews/import_export/parsers/emails/utils.py +0 -61
  17. wbnews/import_export/parsers/rss/__init__.py +0 -0
  18. wbnews/import_export/parsers/rss/news.py +0 -63
  19. wbnews/migrations/0001_initial_squashed_0005_alter_news_import_source.py +0 -349
  20. wbnews/migrations/0006_alter_news_language.py +0 -122
  21. wbnews/migrations/0007_auto_20240103_0955.py +0 -43
  22. wbnews/migrations/0008_alter_news_language.py +0 -123
  23. wbnews/migrations/0009_newsrelationship_analysis_newsrelationship_sentiment.py +0 -94
  24. wbnews/migrations/__init__.py +0 -0
  25. wbnews/models/__init__.py +0 -3
  26. wbnews/models/news.py +0 -116
  27. wbnews/models/relationships.py +0 -20
  28. wbnews/models/sources.py +0 -43
  29. wbnews/serializers.py +0 -83
  30. wbnews/signals.py +0 -4
  31. wbnews/tests/__init__.py +0 -0
  32. wbnews/tests/conftest.py +0 -6
  33. wbnews/tests/test_models.py +0 -15
  34. wbnews/tests/tests.py +0 -12
  35. wbnews/urls.py +0 -29
  36. wbnews/viewsets/__init__.py +0 -12
  37. wbnews/viewsets/buttons.py +0 -23
  38. wbnews/viewsets/display.py +0 -133
  39. wbnews/viewsets/endpoints.py +0 -18
  40. wbnews/viewsets/menu.py +0 -23
  41. wbnews/viewsets/titles.py +0 -39
  42. wbnews/viewsets/views.py +0 -140
  43. wbnews-2.2.4.dist-info/RECORD +0 -43
  44. {wbnews-2.2.4.dist-info → wbnews-2.2.5.dist-info}/WHEEL +0 -0
wbnews/viewsets/titles.py DELETED
@@ -1,39 +0,0 @@
1
- from django.utils.translation import gettext as _
2
- from wbcore.metadata.configs.titles import TitleViewConfig
3
- from wbnews.models import NewsSource
4
-
5
-
6
- class SourceModelTitleConfig(TitleViewConfig):
7
- def get_list_title(self):
8
- return _("Sources")
9
-
10
- def get_instance_title(self):
11
- if "pk" in self.view.kwargs:
12
- return _("Source: {source}").format(source=str(self.view.get_object()))
13
- return _("News Source")
14
-
15
-
16
- class NewsTitleConfig(TitleViewConfig):
17
- def get_list_title(self):
18
- return _("News Flow")
19
-
20
- def get_instance_title(self):
21
- if "pk" in self.view.kwargs:
22
- return str(self.view.get_object())
23
- return _("News")
24
-
25
-
26
- class NewsSourceModelTitleConfig(TitleViewConfig):
27
- def get_list_title(self):
28
- source = NewsSource.objects.get(id=self.view.kwargs["source_id"])
29
- return _("News from {source}").format(source=source.title)
30
-
31
-
32
- class NewsRelationshipTitleConfig(TitleViewConfig):
33
- def get_list_title(self):
34
- if self.view and (content_object := self.view.content_object):
35
- return _("News Article for {}").format(str(content_object))
36
- return _("News Article")
37
-
38
- def get_instance_title(self):
39
- return self.get_list_title()
wbnews/viewsets/views.py DELETED
@@ -1,140 +0,0 @@
1
- from functools import reduce
2
- from operator import or_
3
-
4
- from django.contrib.contenttypes.models import ContentType
5
- from django.db.models import OuterRef, Q, Subquery
6
- from django.utils.functional import cached_property
7
- from wbcore import viewsets
8
- from wbcore.content_type.utils import get_ancestors_content_type
9
- from wbnews.models import News, NewsRelationship, NewsSource
10
- from wbnews.serializers import (
11
- NewsModelSerializer,
12
- NewsRelationshipModelSerializer,
13
- NewsRepresentationSerializer,
14
- SourceModelSerializer,
15
- SourceRepresentationSerializer,
16
- )
17
-
18
- from .buttons import NewsButtonConfig
19
- from .display import (
20
- NewsDisplayConfig,
21
- NewsRelationshipDisplayConfig,
22
- NewsSourceDisplayConfig,
23
- SourceDisplayConfig,
24
- )
25
- from .endpoints import NewsEndpointConfig, NewsSourceEndpointConfig
26
- from .titles import (
27
- NewsRelationshipTitleConfig,
28
- NewsSourceModelTitleConfig,
29
- NewsTitleConfig,
30
- SourceModelTitleConfig,
31
- )
32
-
33
-
34
- class NewsRepresentationViewSet(viewsets.RepresentationViewSet):
35
- queryset = News.objects.all()
36
- serializer_class = NewsRepresentationSerializer
37
- filterset_fields = {"title": ["icontains"]}
38
- ordering_fields = ["datetime"]
39
- ordering = ["-datetime"]
40
- search_fields = ["title", "description"]
41
-
42
-
43
- class SourceRepresentationViewSet(viewsets.RepresentationViewSet):
44
- queryset = NewsSource.objects.all()
45
- serializer_class = SourceRepresentationSerializer
46
- filterset_fields = {"title": ["icontains"]}
47
- ordering_fields = ordering = ["title"]
48
- search_fields = ["title"]
49
-
50
-
51
- class SourceModelViewSet(viewsets.ReadOnlyModelViewSet):
52
- serializer_class = SourceModelSerializer
53
- queryset = NewsSource.objects.all()
54
- filterset_fields = {"title": ["icontains"]}
55
- ordering_fields = ordering = ["title"]
56
- search_fields = ["title"]
57
-
58
- display_config_class = SourceDisplayConfig
59
- title_config_class = SourceModelTitleConfig
60
-
61
-
62
- class NewsModelViewSet(viewsets.ReadOnlyModelViewSet):
63
- serializer_class = NewsModelSerializer
64
- filterset_fields = {"title": ["icontains"], "datetime": ["lte", "gte"], "source": ["exact"], "language": ["exact"]}
65
- ordering_fields = ["datetime"]
66
- ordering = ["-datetime"]
67
- search_fields = ["title", "description"]
68
-
69
- queryset = News.objects.select_related("source")
70
-
71
- button_config_class = NewsButtonConfig
72
- display_config_class = NewsDisplayConfig
73
- title_config_class = NewsTitleConfig
74
- endpoint_config_class = NewsEndpointConfig
75
-
76
- def get_queryset(self):
77
- qs = super().get_queryset()
78
- if (content_type_id := self.kwargs.get("content_type")) and (object_id := self.kwargs.get("content_id")):
79
- content_type = ContentType.objects.get_for_id(content_type_id)
80
- content_object = content_type.get_object_for_this_type(id=object_id)
81
- content_types = list(get_ancestors_content_type(content_type))
82
- # we ensure that for MPTT model, all descendants news are included as well
83
- if hasattr(content_object, "get_family"):
84
- conditions = []
85
- for descendant in content_object.get_family():
86
- for ct in content_types:
87
- conditions.append(Q(content_type=ct, object_id=descendant.id))
88
- else:
89
- conditions = [Q(content_type=ct, object_id=object_id) for ct in content_types]
90
- relationships = NewsRelationship.objects.filter(reduce(or_, conditions))
91
- qs = qs.filter(relationships__in=relationships)
92
- return qs.distinct()
93
-
94
-
95
- class NewsRelationshipModelViewSet(viewsets.ReadOnlyModelViewSet):
96
- serializer_class = NewsRelationshipModelSerializer
97
- queryset = News.objects.all()
98
- display_config_class = NewsRelationshipDisplayConfig
99
- title_config_class = NewsRelationshipTitleConfig
100
- ordering = ["-datetime"]
101
-
102
- @cached_property
103
- def content_type(self) -> ContentType:
104
- if content_type_id := self.kwargs.get("content_type"):
105
- return ContentType.objects.get_for_id(content_type_id)
106
-
107
- @cached_property
108
- def content_object(self):
109
- if (object_id := self.kwargs.get("content_id")) and self.content_type:
110
- return self.content_type.get_object_for_this_type(id=object_id)
111
-
112
- def get_queryset(self):
113
- queryset = super().get_queryset()
114
-
115
- if self.content_type and self.content_object:
116
- content_types = list(get_ancestors_content_type(self.content_type))
117
- # we ensure that for MPTT model, all descendants news are included as well
118
- if hasattr(self.content_object, "get_family"):
119
- conditions = []
120
- for descendant in self.content_object.get_family():
121
- for ct in content_types:
122
- conditions.append(Q(content_type=ct, object_id=descendant.id))
123
- else:
124
- conditions = [Q(content_type=ct, object_id=self.content_object.id) for ct in content_types]
125
- relationships = NewsRelationship.objects.filter(reduce(or_, conditions))
126
-
127
- return queryset.filter(id__in=relationships.values("news")).annotate(
128
- analysis=Subquery(relationships.filter(news=OuterRef("id")).values("analysis")[:1]),
129
- sentiment=Subquery(relationships.filter(news=OuterRef("id")).values("sentiment")[:1]),
130
- )
131
- return News.objects.none()
132
-
133
-
134
- class NewsSourceModelViewSet(NewsModelViewSet):
135
- def get_queryset(self):
136
- return super().get_queryset().filter(source_id=self.kwargs["source_id"])
137
-
138
- display_config_class = NewsSourceDisplayConfig
139
- title_config_class = NewsSourceModelTitleConfig
140
- endpoint_config_class = NewsSourceEndpointConfig
@@ -1,43 +0,0 @@
1
- wbnews/.coveragerc,sha256=OOkT651L0NuoSVSXKZiLAbnQmHe9DRoLOzo1_S_buQc,383
2
- wbnews/__init__.py,sha256=J-j-u0itpEFT6irdmWmixQqYMadNl1X91TxUmoiLHMI,22
3
- wbnews/admin.py,sha256=-FksVPcu1L6PttiHJP9gIGguEd_G4wXNpM31bkkV0ik,732
4
- wbnews/apps.py,sha256=l4kfE3Pux84Fb34xNgKDxcxRHuPCp6odCGFE9Sa3Wzw,212
5
- wbnews/factories.py,sha256=h7pxotk_SXx4wTRAImqzeQLdsQdZc-6zkWdpHLIPxGQ,1016
6
- wbnews/serializers.py,sha256=sY24i1eoB0BA5Dw9XQaGxle2Oihr3zBQQ3KbOPo8EjU,2670
7
- wbnews/signals.py,sha256=eqipwffwJnDQWUZ9VTKr5Jp-OMXLmVSNwoIsawnCKvM,192
8
- wbnews/urls.py,sha256=urea02HNKMeulLgWVi2FpBSJFM41kpRHjiQSB2qBVnE,1214
9
- wbnews/import_export/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
- wbnews/import_export/backends/__init__.py,sha256=_2HnB9uCuGhQDNg-Z0V2uIvKn26LtRBXAxUBoNetBIo,30
11
- wbnews/import_export/backends/news.py,sha256=eY-uuQwzOVQC8IuFbWiJYQuOE_goUbsionlqz3HKVoY,1445
12
- wbnews/import_export/handlers/__init__.py,sha256=zOeENt9cpEcSLG9ZaVb4otmbTnLAa0XdTPsUjD11dXs,36
13
- wbnews/import_export/handlers/news.py,sha256=FqxS7oKVGYYzKbgNxnHZa4FTvGEXBfm6XcIx70BfFOY,1091
14
- wbnews/import_export/parsers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
15
- wbnews/import_export/parsers/emails/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
- wbnews/import_export/parsers/emails/news.py,sha256=YbInbXJ5pk1IS7fEOutuW9LIU4KzZXBx0HZHZrKmeIc,1507
17
- wbnews/import_export/parsers/emails/utils.py,sha256=zvLBr1EvwBd2tBKgc7H7ZI-ifHYg1NvluOZlwvPI1v8,1946
18
- wbnews/import_export/parsers/rss/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
19
- wbnews/import_export/parsers/rss/news.py,sha256=7qk-Xm5ziWlzlSJ1adwbzvokJY5ucf5s5p3Yzr7mjmE,2249
20
- wbnews/migrations/0001_initial_squashed_0005_alter_news_import_source.py,sha256=4qxqfpAYVeU16GsWaj7kUbtOk0ZLzuECTfzhUfmni2A,14596
21
- wbnews/migrations/0006_alter_news_language.py,sha256=necqSWKi20sHLok-RO9He3vnmMlmmdx07AiN3lnZPBM,4638
22
- wbnews/migrations/0007_auto_20240103_0955.py,sha256=YzkH_LSWH_8qdw_BrKaTN5vqLNCPnjMlJZxs03Xbbvw,1478
23
- wbnews/migrations/0008_alter_news_language.py,sha256=4tbpcVSey9PJOdf8xWndl1R8GmhmflpVQtI8YTwcevw,4648
24
- wbnews/migrations/0009_newsrelationship_analysis_newsrelationship_sentiment.py,sha256=ud_yO6skjVx2s32snxzai6Z4Uao1s-40v6UZaq4k64I,3432
25
- wbnews/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
26
- wbnews/models/__init__.py,sha256=KKIcQbpCPCVNJUPJs2MtpN9Q2Wb34Qdk-C7w6AAOy7w,99
27
- wbnews/models/news.py,sha256=hGKbXFmUt06t4q7Pfn4zUuF41FVe7lfICk-G8gyjUQo,4568
28
- wbnews/models/relationships.py,sha256=zrbv2uF2JziZy3BlCY0CIW403GojGTPFcr2mz3gziFA,832
29
- wbnews/models/sources.py,sha256=ekMBGzA12nqUD9yvLQeZgnXncsJP-OuOGJzpE1Hrz9w,1350
30
- wbnews/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
31
- wbnews/tests/conftest.py,sha256=UEZOYH5Av-Cqqq5t8WQCR7QJdNnajhthBPpF8AnwQjY,186
32
- wbnews/tests/test_models.py,sha256=S1FElzu4MMMOHM_vZ39GZeOV3O0Z9Sx0b-8U2ffxaf4,407
33
- wbnews/tests/tests.py,sha256=OADY-vbKZBe0bjjVEO1KNzRYAP2JA9mWkO9pZuh1TSs,280
34
- wbnews/viewsets/__init__.py,sha256=SY6hiVZtArCvU5LpWn9U0J5DAQwv8wtlE7OTIJYcLvI,499
35
- wbnews/viewsets/buttons.py,sha256=K1_2K7B1Bn9bHhrss1WslECQ7BBusA56xnDNINfPeq4,1038
36
- wbnews/viewsets/display.py,sha256=FTi3Jz6rY0d-g7S7Y8xk42wm-JHU6thayIEiTQEubKY,5145
37
- wbnews/viewsets/endpoints.py,sha256=QX4iMqU6XtRmGDkr5EQ5i_QwCkQvYDH_XBgoJkTgKp4,618
38
- wbnews/viewsets/menu.py,sha256=tdU6NUX7WXR4lRf3T1chp8tHbAubAk7EBhMDoa-IlHc,793
39
- wbnews/viewsets/titles.py,sha256=nmSi0TPMQfJoh66KBUJI-5gmc-zXygAlAqZG7PyvSl4,1243
40
- wbnews/viewsets/views.py,sha256=Cpjl7l6UFW_4bpXpdqImkj9drE3XR3IygJybRFrZuws,5673
41
- wbnews-2.2.4.dist-info/METADATA,sha256=MBC7ewc9VfVfx1O_7xHlNSpSMwY4Xfqs4KmoVPV8Ai4,245
42
- wbnews-2.2.4.dist-info/WHEEL,sha256=aO3RJuuiFXItVSnAUEmQ0yRBvv9e1sbJh68PtuQkyAE,105
43
- wbnews-2.2.4.dist-info/RECORD,,
File without changes