udata 10.0.6.dev32994__py2.py3-none-any.whl → 10.0.6.dev33070__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.
Potentially problematic release.
This version of udata might be problematic. Click here for more details.
- udata/core/dataset/tasks.py +5 -1
- udata/core/post/api.py +15 -5
- udata/core/post/tests/test_api.py +16 -2
- udata/static/chunks/{10.471164b2a9fe15614797.js → 10.8ca60413647062717b1e.js} +3 -3
- udata/static/chunks/{10.471164b2a9fe15614797.js.map → 10.8ca60413647062717b1e.js.map} +1 -1
- udata/static/chunks/{11.51d706fb9521c16976bc.js → 11.b6f741fcc366abfad9c4.js} +3 -3
- udata/static/chunks/{11.51d706fb9521c16976bc.js.map → 11.b6f741fcc366abfad9c4.js.map} +1 -1
- udata/static/chunks/{13.f29411b06be1883356a3.js → 13.2d06442dd9a05d9777b5.js} +2 -2
- udata/static/chunks/{13.f29411b06be1883356a3.js.map → 13.2d06442dd9a05d9777b5.js.map} +1 -1
- udata/static/chunks/{17.3bd0340930d4a314ce9c.js → 17.e8e4caaad5cb0cc0bacc.js} +2 -2
- udata/static/chunks/{17.3bd0340930d4a314ce9c.js.map → 17.e8e4caaad5cb0cc0bacc.js.map} +1 -1
- udata/static/chunks/{19.8da42e8359d72afc2618.js → 19.f03a102365af4315f9db.js} +3 -3
- udata/static/chunks/{19.8da42e8359d72afc2618.js.map → 19.f03a102365af4315f9db.js.map} +1 -1
- udata/static/chunks/{8.54e44b102164ae5e7a67.js → 8.778091d55cd8ea39af6b.js} +2 -2
- udata/static/chunks/{8.54e44b102164ae5e7a67.js.map → 8.778091d55cd8ea39af6b.js.map} +1 -1
- udata/static/chunks/{9.07515e5187f475bce828.js → 9.033d7e190ca9e226a5d0.js} +3 -3
- udata/static/chunks/{9.07515e5187f475bce828.js.map → 9.033d7e190ca9e226a5d0.js.map} +1 -1
- udata/static/common.js +1 -1
- udata/static/common.js.map +1 -1
- {udata-10.0.6.dev32994.dist-info → udata-10.0.6.dev33070.dist-info}/METADATA +3 -1
- {udata-10.0.6.dev32994.dist-info → udata-10.0.6.dev33070.dist-info}/RECORD +25 -25
- {udata-10.0.6.dev32994.dist-info → udata-10.0.6.dev33070.dist-info}/LICENSE +0 -0
- {udata-10.0.6.dev32994.dist-info → udata-10.0.6.dev33070.dist-info}/WHEEL +0 -0
- {udata-10.0.6.dev32994.dist-info → udata-10.0.6.dev33070.dist-info}/entry_points.txt +0 -0
- {udata-10.0.6.dev32994.dist-info → udata-10.0.6.dev33070.dist-info}/top_level.txt +0 -0
udata/core/dataset/tasks.py
CHANGED
|
@@ -123,7 +123,11 @@ def send_frequency_reminder(self):
|
|
|
123
123
|
def update_datasets_reuses_metrics(self):
|
|
124
124
|
all_datasets = Dataset.objects.visible().timeout(False)
|
|
125
125
|
for dataset in all_datasets:
|
|
126
|
-
|
|
126
|
+
try:
|
|
127
|
+
dataset.count_reuses()
|
|
128
|
+
except Exception as e:
|
|
129
|
+
log.error(f"Error for dataset {dataset} during reuses metrics update: {e}")
|
|
130
|
+
continue
|
|
127
131
|
|
|
128
132
|
|
|
129
133
|
def get_queryset(model_cls):
|
udata/core/post/api.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
from datetime import datetime
|
|
2
2
|
|
|
3
3
|
from udata.api import API, api, fields
|
|
4
|
+
from udata.auth import Permission as AdminPermission
|
|
4
5
|
from udata.auth import admin_permission
|
|
5
6
|
from udata.core.dataset.api_fields import dataset_fields
|
|
6
7
|
from udata.core.reuse.models import Reuse
|
|
@@ -60,6 +61,13 @@ parser = api.page_parser()
|
|
|
60
61
|
parser.add_argument(
|
|
61
62
|
"sort", type=str, default="-created_at", location="args", help="The sorting attribute"
|
|
62
63
|
)
|
|
64
|
+
parser.add_argument(
|
|
65
|
+
"with_drafts",
|
|
66
|
+
type=bool,
|
|
67
|
+
default=False,
|
|
68
|
+
location="args",
|
|
69
|
+
help="`True` also returns the unpublished posts (only for super-admins)",
|
|
70
|
+
)
|
|
63
71
|
|
|
64
72
|
|
|
65
73
|
@ns.route("/", endpoint="posts")
|
|
@@ -70,11 +78,13 @@ class PostsAPI(API):
|
|
|
70
78
|
def get(self):
|
|
71
79
|
"""List all posts"""
|
|
72
80
|
args = parser.parse_args()
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
81
|
+
|
|
82
|
+
posts = Post.objects()
|
|
83
|
+
|
|
84
|
+
if not (AdminPermission().can() and args["with_drafts"]):
|
|
85
|
+
posts = posts.published()
|
|
86
|
+
|
|
87
|
+
return posts.order_by(args["sort"]).paginate(args["page"], args["page_size"])
|
|
78
88
|
|
|
79
89
|
@api.doc("create_post")
|
|
80
90
|
@api.secure(admin_permission)
|
|
@@ -15,14 +15,28 @@ class PostsAPITest:
|
|
|
15
15
|
|
|
16
16
|
def test_post_api_list(self, api):
|
|
17
17
|
"""It should fetch a post list from the API"""
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
PostFactory.create_batch(3)
|
|
19
|
+
draft = PostFactory(published=None)
|
|
20
20
|
|
|
21
21
|
response = api.get(url_for("api.posts"))
|
|
22
22
|
assert200(response)
|
|
23
23
|
# Response should not contain the unpublished post
|
|
24
24
|
assert len(response.json["data"]) == 3
|
|
25
25
|
|
|
26
|
+
api.login(AdminFactory())
|
|
27
|
+
|
|
28
|
+
response = api.get(url_for("api.posts"))
|
|
29
|
+
assert200(response)
|
|
30
|
+
|
|
31
|
+
assert len(response.json["data"]) == 3
|
|
32
|
+
assert str(draft.id) not in [post["id"] for post in response.json["data"]]
|
|
33
|
+
|
|
34
|
+
response = api.get(url_for("api.posts", with_drafts=True))
|
|
35
|
+
assert200(response)
|
|
36
|
+
|
|
37
|
+
assert len(response.json["data"]) == 4
|
|
38
|
+
assert str(draft.id) in [post["id"] for post in response.json["data"]]
|
|
39
|
+
|
|
26
40
|
def test_post_api_get(self, api):
|
|
27
41
|
"""It should fetch a post from the API"""
|
|
28
42
|
post = PostFactory()
|