udata 9.1.5.dev31446__py2.py3-none-any.whl → 9.1.5.dev31465__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.
- tasks/__init__.py +1 -1
- udata/api_fields.py +5 -1
- udata/core/owned.py +16 -0
- udata/core/reuse/api.py +3 -2
- udata/core/reuse/models.py +1 -1
- udata/static/chunks/{5.ab857e015f0a36d37d24.js → 5.3aa55302c802f48db900.js} +3 -3
- udata/static/chunks/{5.ab857e015f0a36d37d24.js.map → 5.3aa55302c802f48db900.js.map} +1 -1
- udata/static/chunks/{6.8b8ce53453404ffcb7ab.js → 6.0db5d3ff22944de7edd5.js} +3 -3
- udata/static/chunks/{6.8b8ce53453404ffcb7ab.js.map → 6.0db5d3ff22944de7edd5.js.map} +1 -1
- udata/static/common.js +1 -1
- udata/static/common.js.map +1 -1
- udata/tests/api/test_reuses_api.py +105 -0
- udata/tests/test_owned.py +100 -1
- {udata-9.1.5.dev31446.dist-info → udata-9.1.5.dev31465.dist-info}/METADATA +3 -1
- {udata-9.1.5.dev31446.dist-info → udata-9.1.5.dev31465.dist-info}/RECORD +19 -19
- {udata-9.1.5.dev31446.dist-info → udata-9.1.5.dev31465.dist-info}/LICENSE +0 -0
- {udata-9.1.5.dev31446.dist-info → udata-9.1.5.dev31465.dist-info}/WHEEL +0 -0
- {udata-9.1.5.dev31446.dist-info → udata-9.1.5.dev31465.dist-info}/entry_points.txt +0 -0
- {udata-9.1.5.dev31446.dist-info → udata-9.1.5.dev31465.dist-info}/top_level.txt +0 -0
tasks/__init__.py
CHANGED
|
@@ -197,7 +197,7 @@ def qa(ctx):
|
|
|
197
197
|
def serve(ctx, host="localhost", port="7000"):
|
|
198
198
|
"""Run a development server"""
|
|
199
199
|
with ctx.cd(ROOT):
|
|
200
|
-
ctx.run(f"python manage.py serve -d -r -h {host} -p {port}")
|
|
200
|
+
ctx.run(f"python manage.py serve -d -r -h {host} -p {port}", pty=True)
|
|
201
201
|
|
|
202
202
|
|
|
203
203
|
@task
|
udata/api_fields.py
CHANGED
|
@@ -302,7 +302,11 @@ def generate_fields(**kwargs):
|
|
|
302
302
|
parser.add_argument("q", type=str, location="args")
|
|
303
303
|
|
|
304
304
|
for filterable in filterables:
|
|
305
|
-
parser.add_argument(
|
|
305
|
+
parser.add_argument(
|
|
306
|
+
filterable["key"],
|
|
307
|
+
type=filterable["type"],
|
|
308
|
+
location="args",
|
|
309
|
+
)
|
|
306
310
|
|
|
307
311
|
cls.__index_parser__ = parser
|
|
308
312
|
|
udata/core/owned.py
CHANGED
|
@@ -24,6 +24,22 @@ class OwnedQuerySet(UDataQuerySet):
|
|
|
24
24
|
qs |= Q(owner=owner) | Q(organization=owner)
|
|
25
25
|
return self(qs)
|
|
26
26
|
|
|
27
|
+
def visible_by_user(self, user: User, visible_query: Q):
|
|
28
|
+
"""Return EVERYTHING visible to the user."""
|
|
29
|
+
if user.is_anonymous:
|
|
30
|
+
return self(visible_query)
|
|
31
|
+
|
|
32
|
+
if user.sysadmin:
|
|
33
|
+
return self()
|
|
34
|
+
|
|
35
|
+
owners: list[User | Organization] = list(user.organizations) + [user.id]
|
|
36
|
+
# We create a new queryset because we want a pristine self._query_obj.
|
|
37
|
+
owned_qs: OwnedQuerySet = self.__class__(self._document, self._collection_obj).owned_by(
|
|
38
|
+
*owners
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
return self(visible_query | owned_qs._query_obj)
|
|
42
|
+
|
|
27
43
|
|
|
28
44
|
def check_owner_is_current_user(owner):
|
|
29
45
|
from udata.auth import admin_permission, current_user
|
udata/core/reuse/api.py
CHANGED
|
@@ -99,8 +99,9 @@ class ReuseListAPI(API):
|
|
|
99
99
|
@api.expect(Reuse.__index_parser__)
|
|
100
100
|
@api.marshal_with(Reuse.__page_fields__)
|
|
101
101
|
def get(self):
|
|
102
|
-
query = Reuse.objects(
|
|
103
|
-
|
|
102
|
+
query = Reuse.objects.visible_by_user(
|
|
103
|
+
current_user, mongoengine.Q(private__ne=True, deleted=None)
|
|
104
|
+
)
|
|
104
105
|
return Reuse.apply_sort_filters_and_pagination(query)
|
|
105
106
|
|
|
106
107
|
@api.secure
|
udata/core/reuse/models.py
CHANGED
|
@@ -104,7 +104,7 @@ class Reuse(db.Datetimed, WithMetrics, BadgeMixin, Owned, db.Document):
|
|
|
104
104
|
)
|
|
105
105
|
# badges = db.ListField(db.EmbeddedDocumentField(ReuseBadge))
|
|
106
106
|
|
|
107
|
-
private = field(db.BooleanField(default=False))
|
|
107
|
+
private = field(db.BooleanField(default=False), filterable={})
|
|
108
108
|
|
|
109
109
|
ext = db.MapField(db.GenericEmbeddedDocumentField())
|
|
110
110
|
extras = field(db.ExtrasField())
|