geovisio 2.6.0__py3-none-any.whl → 2.7.1__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 (62) hide show
  1. geovisio/__init__.py +36 -7
  2. geovisio/admin_cli/cleanup.py +2 -2
  3. geovisio/admin_cli/db.py +1 -4
  4. geovisio/config_app.py +40 -1
  5. geovisio/db_migrations.py +24 -3
  6. geovisio/templates/main.html +13 -13
  7. geovisio/templates/viewer.html +3 -3
  8. geovisio/translations/de/LC_MESSAGES/messages.mo +0 -0
  9. geovisio/translations/de/LC_MESSAGES/messages.po +804 -0
  10. geovisio/translations/el/LC_MESSAGES/messages.mo +0 -0
  11. geovisio/translations/el/LC_MESSAGES/messages.po +685 -0
  12. geovisio/translations/en/LC_MESSAGES/messages.mo +0 -0
  13. geovisio/translations/en/LC_MESSAGES/messages.po +738 -0
  14. geovisio/translations/es/LC_MESSAGES/messages.mo +0 -0
  15. geovisio/translations/es/LC_MESSAGES/messages.po +778 -0
  16. geovisio/translations/fi/LC_MESSAGES/messages.mo +0 -0
  17. geovisio/translations/fi/LC_MESSAGES/messages.po +589 -0
  18. geovisio/translations/fr/LC_MESSAGES/messages.mo +0 -0
  19. geovisio/translations/fr/LC_MESSAGES/messages.po +814 -0
  20. geovisio/translations/hu/LC_MESSAGES/messages.mo +0 -0
  21. geovisio/translations/hu/LC_MESSAGES/messages.po +773 -0
  22. geovisio/translations/ko/LC_MESSAGES/messages.mo +0 -0
  23. geovisio/translations/ko/LC_MESSAGES/messages.po +685 -0
  24. geovisio/translations/messages.pot +694 -0
  25. geovisio/translations/nl/LC_MESSAGES/messages.mo +0 -0
  26. geovisio/translations/nl/LC_MESSAGES/messages.po +602 -0
  27. geovisio/utils/__init__.py +1 -1
  28. geovisio/utils/auth.py +50 -11
  29. geovisio/utils/db.py +65 -0
  30. geovisio/utils/excluded_areas.py +83 -0
  31. geovisio/utils/extent.py +30 -0
  32. geovisio/utils/fields.py +1 -1
  33. geovisio/utils/filesystems.py +0 -1
  34. geovisio/utils/link.py +14 -0
  35. geovisio/utils/params.py +20 -0
  36. geovisio/utils/pictures.py +110 -88
  37. geovisio/utils/reports.py +171 -0
  38. geovisio/utils/sequences.py +262 -126
  39. geovisio/utils/tokens.py +37 -42
  40. geovisio/utils/upload_set.py +642 -0
  41. geovisio/web/auth.py +37 -37
  42. geovisio/web/collections.py +304 -304
  43. geovisio/web/configuration.py +14 -0
  44. geovisio/web/docs.py +276 -15
  45. geovisio/web/excluded_areas.py +377 -0
  46. geovisio/web/items.py +169 -112
  47. geovisio/web/map.py +104 -36
  48. geovisio/web/params.py +69 -26
  49. geovisio/web/pictures.py +14 -31
  50. geovisio/web/reports.py +399 -0
  51. geovisio/web/rss.py +13 -7
  52. geovisio/web/stac.py +129 -134
  53. geovisio/web/tokens.py +98 -109
  54. geovisio/web/upload_set.py +771 -0
  55. geovisio/web/users.py +100 -73
  56. geovisio/web/utils.py +28 -9
  57. geovisio/workers/runner_pictures.py +241 -207
  58. {geovisio-2.6.0.dist-info → geovisio-2.7.1.dist-info}/METADATA +17 -14
  59. geovisio-2.7.1.dist-info/RECORD +70 -0
  60. {geovisio-2.6.0.dist-info → geovisio-2.7.1.dist-info}/WHEEL +1 -1
  61. geovisio-2.6.0.dist-info/RECORD +0 -41
  62. {geovisio-2.6.0.dist-info → geovisio-2.7.1.dist-info}/LICENSE +0 -0
geovisio/web/auth.py CHANGED
@@ -1,9 +1,9 @@
1
1
  import flask
2
2
  from flask import current_app, url_for, session, redirect, request, jsonify
3
- import psycopg
4
- from typing import Any
3
+ from flask_babel import gettext as _
5
4
  from urllib.parse import quote
6
5
  from geovisio import utils, errors
6
+ from geovisio.utils import db
7
7
  from geovisio.utils.auth import Account, ACCOUNT_KEY
8
8
  from authlib.integrations.base_client.errors import MismatchingStateError
9
9
 
@@ -57,50 +57,50 @@ def auth():
57
57
  tokenResponse = utils.auth.oauth_provider.client.authorize_access_token()
58
58
  except MismatchingStateError as e:
59
59
  raise errors.InternalError(
60
- "Impossible to finish authentication flow",
60
+ _("Impossible to finish authentication flow"),
61
61
  payload={
62
62
  "details": {
63
63
  "error": str(e),
64
- "tips": "You can try to clear your cookies and retry. If the problem persists, contact your instance administrator.",
64
+ "tips": _("You can try to clear your cookies and retry. If the problem persists, contact your instance administrator."),
65
65
  }
66
66
  },
67
67
  status_code=403,
68
68
  )
69
69
 
70
70
  oauth_info = utils.auth.oauth_provider.get_user_oauth_info(tokenResponse)
71
- with psycopg.connect(current_app.config["DB_URL"]) as conn:
72
- with conn.cursor() as cursor:
73
- res = cursor.execute(
74
- "INSERT INTO accounts (name, oauth_provider, oauth_id) VALUES (%(name)s, %(provider)s, %(id)s) ON CONFLICT (oauth_provider, oauth_id) DO UPDATE SET name = %(name)s RETURNING id, name",
75
- {
76
- "provider": utils.auth.oauth_provider.name,
77
- "id": oauth_info.id,
78
- "name": oauth_info.name,
79
- },
80
- ).fetchone()
81
- if res is None:
82
- raise Exception("Impossible to insert user in database")
83
- id, name = res
84
- account = Account(
85
- id=str(id), # convert uuid to string for serialization
86
- name=name,
87
- oauth_provider=utils.auth.oauth_provider.name,
88
- oauth_id=oauth_info.id,
89
- )
90
- session[ACCOUNT_KEY] = account.__dict__
91
-
92
- next_url = session.pop(NEXT_URL_KEY, None)
93
- if next_url:
94
- response = flask.make_response(redirect(next_url))
95
- else:
96
- response = flask.make_response(redirect("/"))
97
-
98
- # also store id/name in cookies for the front end to use those
99
- max_age = current_app.config["PERMANENT_SESSION_LIFETIME"]
100
- _set_cookie(response, "user_id", str(id), max_age=max_age)
101
- _set_cookie(response, "user_name", quote(name), max_age=max_age)
102
-
103
- return response
71
+ with db.cursor(current_app) as cursor:
72
+ res = cursor.execute(
73
+ "INSERT INTO accounts (name, oauth_provider, oauth_id) VALUES (%(name)s, %(provider)s, %(id)s) ON CONFLICT (oauth_provider, oauth_id) DO UPDATE SET name = %(name)s RETURNING id, name",
74
+ {
75
+ "provider": utils.auth.oauth_provider.name,
76
+ "id": oauth_info.id,
77
+ "name": oauth_info.name,
78
+ },
79
+ ).fetchone()
80
+ if res is None:
81
+ raise Exception("Impossible to insert user in database")
82
+ id, name = res
83
+ account = Account(
84
+ id=str(id), # convert uuid to string for serialization
85
+ name=name,
86
+ oauth_provider=utils.auth.oauth_provider.name,
87
+ oauth_id=oauth_info.id,
88
+ )
89
+ session[ACCOUNT_KEY] = account.model_dump(exclude_none=True)
90
+ session.permanent = True
91
+
92
+ next_url = session.pop(NEXT_URL_KEY, None)
93
+ if next_url:
94
+ response = flask.make_response(redirect(next_url))
95
+ else:
96
+ response = flask.make_response(redirect("/"))
97
+
98
+ # also store id/name in cookies for the front end to use those
99
+ max_age = current_app.config["PERMANENT_SESSION_LIFETIME"]
100
+ _set_cookie(response, "user_id", str(id), max_age=max_age)
101
+ _set_cookie(response, "user_name", quote(name), max_age=max_age)
102
+
103
+ return response
104
104
 
105
105
 
106
106
  @bp.route("/logout")