udata 10.0.9.dev33939__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.

Files changed (26) hide show
  1. udata/core/organization/api.py +21 -2
  2. udata/core/spatial/api.py +3 -1
  3. udata/core/spatial/tests/test_api.py +11 -0
  4. udata/static/chunks/{10.471164b2a9fe15614797.js → 10.8ca60413647062717b1e.js} +3 -3
  5. udata/static/chunks/{10.471164b2a9fe15614797.js.map → 10.8ca60413647062717b1e.js.map} +1 -1
  6. udata/static/chunks/{11.55ab79044cda0271b595.js → 11.b6f741fcc366abfad9c4.js} +3 -3
  7. udata/static/chunks/{11.55ab79044cda0271b595.js.map → 11.b6f741fcc366abfad9c4.js.map} +1 -1
  8. udata/static/chunks/{13.f29411b06be1883356a3.js → 13.2d06442dd9a05d9777b5.js} +2 -2
  9. udata/static/chunks/{13.f29411b06be1883356a3.js.map → 13.2d06442dd9a05d9777b5.js.map} +1 -1
  10. udata/static/chunks/{17.3bd0340930d4a314ce9c.js → 17.e8e4caaad5cb0cc0bacc.js} +2 -2
  11. udata/static/chunks/{17.3bd0340930d4a314ce9c.js.map → 17.e8e4caaad5cb0cc0bacc.js.map} +1 -1
  12. udata/static/chunks/{19.3e0e8651d948e04b8cf2.js → 19.f03a102365af4315f9db.js} +3 -3
  13. udata/static/chunks/{19.3e0e8651d948e04b8cf2.js.map → 19.f03a102365af4315f9db.js.map} +1 -1
  14. udata/static/chunks/{8.494b003a94383b142c18.js → 8.778091d55cd8ea39af6b.js} +2 -2
  15. udata/static/chunks/{8.494b003a94383b142c18.js.map → 8.778091d55cd8ea39af6b.js.map} +1 -1
  16. udata/static/chunks/{9.07515e5187f475bce828.js → 9.033d7e190ca9e226a5d0.js} +3 -3
  17. udata/static/chunks/{9.07515e5187f475bce828.js.map → 9.033d7e190ca9e226a5d0.js.map} +1 -1
  18. udata/static/common.js +1 -1
  19. udata/static/common.js.map +1 -1
  20. udata/tests/api/test_organizations_api.py +36 -0
  21. {udata-10.0.9.dev33939.dist-info → udata-10.0.9.dev33978.dist-info}/METADATA +3 -1
  22. {udata-10.0.9.dev33939.dist-info → udata-10.0.9.dev33978.dist-info}/RECORD +26 -26
  23. {udata-10.0.9.dev33939.dist-info → udata-10.0.9.dev33978.dist-info}/LICENSE +0 -0
  24. {udata-10.0.9.dev33939.dist-info → udata-10.0.9.dev33978.dist-info}/WHEEL +0 -0
  25. {udata-10.0.9.dev33939.dist-info → udata-10.0.9.dev33978.dist-info}/entry_points.txt +0 -0
  26. {udata-10.0.9.dev33939.dist-info → udata-10.0.9.dev33978.dist-info}/top_level.txt +0 -0
@@ -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:
udata/core/spatial/api.py CHANGED
@@ -54,7 +54,9 @@ class SuggestZonesAPI(API):
54
54
  def get(self):
55
55
  """Geospatial zones suggest endpoint using mongoDB contains"""
56
56
  args = suggest_parser.parse_args()
57
- geozones = GeoZone.objects(Q(name__icontains=args["q"]) | Q(code__icontains=args["q"]))
57
+ geozones = GeoZone.objects(
58
+ Q(name__icontains=args["q"]) | Q(code__icontains=args["q"]) | Q(id__icontains=args["q"])
59
+ )
58
60
 
59
61
  # We're manually sorting based on zone level int (cause we don't have the int value directly in mongo document)
60
62
  level_id_to_int_level = {level.id: level.admin_level for level in GeoLevel.objects()}
@@ -75,6 +75,17 @@ class SpatialApiTest(APITestCase):
75
75
  self.assertIn("level", suggestion)
76
76
  self.assertIn("name-test", suggestion["name"])
77
77
 
78
+ def test_suggest_zones_on_id(self):
79
+ """It should suggest zones based on its id"""
80
+ zone = GeoZoneFactory()
81
+ for _ in range(2):
82
+ GeoZoneFactory()
83
+
84
+ response = self.get(url_for("api.suggest_zones"), qs={"q": zone.id})
85
+ self.assert200(response)
86
+
87
+ self.assertEqual(response.json[0]["id"], zone["id"])
88
+
78
89
  def test_suggest_zones_sorted(self):
79
90
  """It should suggest zones based on its name"""
80
91
  country_level = GeoLevelFactory(id="country", name="country", admin_level=10)