udata 10.0.9.dev33959__py2.py3-none-any.whl → 10.0.9.dev33978__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.

@@ -242,7 +242,10 @@ class OrgContactAPI(API):
242
242
 
243
243
  requests_parser = api.parser()
244
244
  requests_parser.add_argument(
245
- "status", type=str, help="If provided, only return requests ith a given status", location="args"
245
+ "status", type=str, help="If provided, only return requests in a given status", location="args"
246
+ )
247
+ requests_parser.add_argument(
248
+ "user", type=str, help="If provided, only return requests for this user", location="args"
246
249
  )
247
250
 
248
251
 
@@ -255,8 +258,24 @@ class MembershipRequestAPI(API):
255
258
  @api.marshal_list_with(request_fields)
256
259
  def get(self, org):
257
260
  """List membership requests for a given organization"""
258
- OrganizationPrivatePermission(org).test()
259
261
  args = requests_parser.parse_args()
262
+ if args["user"]:
263
+ if not current_user.is_authenticated or (
264
+ str(current_user.id) != args["user"]
265
+ and not OrganizationPrivatePermission(org).can()
266
+ ):
267
+ api.abort(
268
+ 403,
269
+ "You can only access your own membership requests or the one of your organizations.",
270
+ )
271
+ if args["status"]:
272
+ return [
273
+ r
274
+ for r in org.requests
275
+ if (r.status == args["status"] and str(r.user.id) == args["user"])
276
+ ]
277
+ return [r for r in org.requests if str(r.user.id) == args["user"]]
278
+ OrganizationPrivatePermission(org).test()
260
279
  if args["status"]:
261
280
  return [r for r in org.requests if r.status == args["status"]]
262
281
  else:
@@ -276,6 +276,42 @@ class MembershipAPITest:
276
276
  response = api.get(url_for("api.request_membership", org=organization))
277
277
  assert403(response)
278
278
 
279
+ def test_applicant_can_get_their_membership_requests(self, api):
280
+ applicant = api.login()
281
+ membership_request = MembershipRequest(user=applicant, comment="test")
282
+ organization = OrganizationFactory(members=[], requests=[membership_request])
283
+
284
+ response = api.get(
285
+ url_for("api.request_membership", org=organization),
286
+ query_string={"user": str(applicant.id)},
287
+ )
288
+ assert200(response)
289
+
290
+ @pytest.mark.parametrize(
291
+ "searched_status",
292
+ [
293
+ "pending",
294
+ "accepted",
295
+ "refused",
296
+ ],
297
+ )
298
+ def test_applicant_can_get_their_membership_requests_with_status(
299
+ self, api, searched_status: str
300
+ ):
301
+ applicant = api.login()
302
+ membership_request = MembershipRequest(user=applicant, comment="test")
303
+ organization = OrganizationFactory(members=[], requests=[membership_request])
304
+ response = api.get(
305
+ url_for("api.request_membership", org=organization),
306
+ query_string={"user": str(applicant.id), "status": searched_status},
307
+ )
308
+ assert200(response)
309
+ requests = response.json
310
+ if searched_status == "pending":
311
+ assert len(requests) == 1
312
+ else:
313
+ assert len(requests) == 0
314
+
279
315
  def test_get_members_with_or_without_email(self, api):
280
316
  admin = Member(
281
317
  user=UserFactory(email="admin@example.org"), role="admin", since="2024-04-14"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: udata
3
- Version: 10.0.9.dev33959
3
+ Version: 10.0.9.dev33978
4
4
  Summary: Open data portal
5
5
  Home-page: https://github.com/opendatateam/udata
6
6
  Author: Opendata Team
@@ -147,6 +147,7 @@ It is collectively taken care of by members of the
147
147
  - Return harvesters's errors details only for super-admins [#3264](https://github.com/opendatateam/udata/pull/3264)
148
148
  - feat: topics list filtered by visible_by_user [#3265](https://github.com/opendatateam/udata/pull/3265)
149
149
  - Allow geozone suggest to check the id field [#3267](https://github.com/opendatateam/udata/pull/3267)
150
+ - Allow a user to check its own membership requests [#3269](https://github.com/opendatateam/udata/pull/3269)
150
151
 
151
152
  ## 10.0.8 (2025-01-31)
152
153
 
@@ -141,7 +141,7 @@ udata/core/metrics/signals.py,sha256=9mdJW__gR2GJT3huBr6HN2SDhKYJRgNbW9dnh48cAnU
141
141
  udata/core/metrics/tasks.py,sha256=_3L2g3blndBID66s_CauXEW2bDYathjd4HAAhYNVaOs,827
142
142
  udata/core/organization/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
143
143
  udata/core/organization/activities.py,sha256=NY9pDzOVcdo2HZ-ax77lioiDGUZ8jpUguSLt_824saQ,1133
144
- udata/core/organization/api.py,sha256=Z8QHV8KE53nNv56qJhUq5OLo_F6dFyzxrTT9wJ3VAPo,17927
144
+ udata/core/organization/api.py,sha256=ECHxNjsx6p1znSPrpdY_GEI0Oj4GvOZWKjT6NPwsnQs,18744
145
145
  udata/core/organization/api_fields.py,sha256=TCYTZkHme86KG2zZUyIEGr55W5PG-P9jLtph4jwxO8Y,7970
146
146
  udata/core/organization/apiv2.py,sha256=1HQRQNu8r5dKPOGdkQyYfn7romhOoZydd4ZVUA0tQIk,3169
147
147
  udata/core/organization/commands.py,sha256=DsRAtFDZvTciYNsUWumQWdn0jnNmKW-PwfIHUUZoBb8,1591
@@ -618,7 +618,7 @@ udata/tests/api/test_datasets_api.py,sha256=03bSBiw70js6qZ43kihDLTkD7ha3i50z5YED
618
618
  udata/tests/api/test_fields.py,sha256=OW85Z5MES5HeWOpapeem8OvR1cIcrqW-xMWpdZO4LZ8,1033
619
619
  udata/tests/api/test_follow_api.py,sha256=fccgVNfcqET221PPS3p7qzb9hpvbBBUGhV-l4UeOpyk,3352
620
620
  udata/tests/api/test_me_api.py,sha256=ZJKGH9fFv-4cSGcYAGd6IJA_PwPjVGIqWNy_DhFA8ms,13827
621
- udata/tests/api/test_organizations_api.py,sha256=-oSfxy3Wk0yi5cGKQfr-ctESFFsZXvb9Fh8S9Lt1dNU,36229
621
+ udata/tests/api/test_organizations_api.py,sha256=jDCGw5BZ2Ps6S1xxp5hRi8XsrmR8DE22tflRPGtUYcc,37527
622
622
  udata/tests/api/test_reports_api.py,sha256=fCSz9NwMXBs6cxdXBVVI6y564AtovmZYw3xkgxQ9KE8,6217
623
623
  udata/tests/api/test_reuses_api.py,sha256=d8mtUrDURIfnUK-sLogvAP-rOID2FDJ0UVTM0ravQ-Q,24642
624
624
  udata/tests/api/test_swagger.py,sha256=eE6La9qdTYTIUFevRVPJgtj17Jq_8uOlsDwzCNR0LL8,760
@@ -712,9 +712,9 @@ udata/translations/pt/LC_MESSAGES/udata.mo,sha256=M42S33mIOlRa2Z-np3xY_KVC5K8Hrq
712
712
  udata/translations/pt/LC_MESSAGES/udata.po,sha256=Ywuy-wSaui9a5EYH2nB3_JWmR3UGXCR2KwOdX61g0BA,45082
713
713
  udata/translations/sr/LC_MESSAGES/udata.mo,sha256=n-a4aF62_JmXOj52_X-_zPbnNcDso_b7W3mKOOCrANw,29169
714
714
  udata/translations/sr/LC_MESSAGES/udata.po,sha256=ijd7U_rvSctNKejNOUR6hW5oWtX4ndlThHwtqfbYK1A,52057
715
- udata-10.0.9.dev33959.dist-info/LICENSE,sha256=V8j_M8nAz8PvAOZQocyRDX7keai8UJ9skgmnwqETmdY,34520
716
- udata-10.0.9.dev33959.dist-info/METADATA,sha256=MRXz94X29MxRwNTlvw9COpDhp0YKLX1NdZ1QMvlMFnU,140524
717
- udata-10.0.9.dev33959.dist-info/WHEEL,sha256=DZajD4pwLWue70CAfc7YaxT1wLUciNBvN_TTcvXpltE,110
718
- udata-10.0.9.dev33959.dist-info/entry_points.txt,sha256=3SKiqVy4HUqxf6iWspgMqH8d88Htk6KoLbG1BU-UddQ,451
719
- udata-10.0.9.dev33959.dist-info/top_level.txt,sha256=39OCg-VWFWOq4gCKnjKNu-s3OwFlZIu_dVH8Gl6ndHw,12
720
- udata-10.0.9.dev33959.dist-info/RECORD,,
715
+ udata-10.0.9.dev33978.dist-info/LICENSE,sha256=V8j_M8nAz8PvAOZQocyRDX7keai8UJ9skgmnwqETmdY,34520
716
+ udata-10.0.9.dev33978.dist-info/METADATA,sha256=QMaDuuBMgTAeaiImaPWFuTJ5XZcAyXQOadY2WzseAG4,140633
717
+ udata-10.0.9.dev33978.dist-info/WHEEL,sha256=DZajD4pwLWue70CAfc7YaxT1wLUciNBvN_TTcvXpltE,110
718
+ udata-10.0.9.dev33978.dist-info/entry_points.txt,sha256=3SKiqVy4HUqxf6iWspgMqH8d88Htk6KoLbG1BU-UddQ,451
719
+ udata-10.0.9.dev33978.dist-info/top_level.txt,sha256=39OCg-VWFWOq4gCKnjKNu-s3OwFlZIu_dVH8Gl6ndHw,12
720
+ udata-10.0.9.dev33978.dist-info/RECORD,,