geo-activity-playground 0.33.1__py3-none-any.whl → 0.33.3__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.
@@ -13,7 +13,7 @@ from geo_activity_playground.core.config import import_old_strava_config
13
13
  from geo_activity_playground.explorer.tile_visits import TileVisitAccessor
14
14
  from geo_activity_playground.explorer.video import explorer_video_main
15
15
  from geo_activity_playground.webui.app import web_ui_main
16
- from geo_activity_playground.webui.upload.controller import scan_for_activities
16
+ from geo_activity_playground.webui.upload_blueprint import scan_for_activities
17
17
 
18
18
  logger = logging.getLogger(__name__)
19
19
 
@@ -22,7 +22,7 @@ from .search.blueprint import make_search_blueprint
22
22
  from .square_planner.blueprint import make_square_planner_blueprint
23
23
  from .summary.blueprint import make_summary_blueprint
24
24
  from .tile.blueprint import make_tile_blueprint
25
- from .upload.blueprint import make_upload_blueprint
25
+ from .upload_blueprint import make_upload_blueprint
26
26
  from geo_activity_playground.core.config import Config
27
27
  from geo_activity_playground.core.config import ConfigAccessor
28
28
  from geo_activity_playground.webui.auth.blueprint import make_auth_blueprint
@@ -16,10 +16,10 @@ class EntryController:
16
16
  self._config = config
17
17
 
18
18
  def render(self) -> dict:
19
- kind_scale = make_kind_scale(self._repository.meta, self._config)
20
19
  result = {"latest_activities": []}
21
20
 
22
21
  if len(self._repository):
22
+ kind_scale = make_kind_scale(self._repository.meta, self._config)
23
23
  result["distance_last_30_days_plot"] = distance_last_30_days_meta_plot(
24
24
  self._repository.meta, kind_scale
25
25
  )
@@ -91,7 +91,7 @@
91
91
  }
92
92
  },
93
93
  onEachFeature: onEachFeature
94
- }) let explorer_layer_last_age_color = L.geoJSON(explorer_geojson, {
94
+ }); let explorer_layer_last_age_color = L.geoJSON(explorer_geojson, {
95
95
  style:
96
96
  function (feature) {
97
97
  return {
@@ -99,12 +99,12 @@
99
99
  0.5
100
100
  }
101
101
  }, onEachFeature: onEachFeature
102
- }) let bbox = {{ center.bbox| safe }} if (bbox) {
102
+ }); let bbox = {{ center.bbox| safe }}; if (bbox) {
103
103
  map.fitBounds(L.geoJSON(bbox).getBounds())
104
- } let explorer_square_layer = L.geoJSON(square_geojson, {
104
+ }; let explorer_square_layer = L.geoJSON(square_geojson, {
105
105
  style: function (feature) { return { color: "blue", fill: false, weight: 2 } }
106
106
  }).addTo(map)
107
- active_layer = explorer_layer_cluster_color function changeColor(method) {
107
+ active_layer = explorer_layer_cluster_color; function changeColor(method) {
108
108
  map.removeLayer(active_layer)
109
109
  if (method == "cluster") { active_layer = explorer_layer_cluster_color } else if (method == "first") {
110
110
  active_layer = explorer_layer_first_age_color
@@ -112,7 +112,7 @@
112
112
  active_layer = explorer_layer_last_age_color
113
113
  } map.addLayer(active_layer)
114
114
  } function downloadAs(suffix) {
115
- bounds = map.getBounds() zoom = "{{ zoom }}"
115
+ bounds = map.getBounds(); zoom = "{{ zoom }}"
116
116
  window.location.href = `/explorer/${zoom}/${bounds.getNorth()}/${bounds.getEast()}/${bounds.getSouth()}/${bounds.getWest()}/${suffix}`
117
117
  } </script>
118
118
  </div>
@@ -58,8 +58,9 @@
58
58
  </div>
59
59
  {% endfor %}
60
60
  {% else %}
61
- <p>You don't have activities yet. Either put some files into a directory <tt>Activities</tt> or <a
62
- href="{{ url_for('settings.strava') }}">set up Strava API</a>.</p>
61
+ <p>You don't have activities yet. Either put some files into a directory <tt>Activities</tt>, <a
62
+ href="{{ url_for('upload.index') }}">upload activities</a> or <a href="{{ url_for('settings.strava') }}">set up
63
+ Strava API</a>.</p>
63
64
  {% endif %}
64
65
 
65
66
  {% endblock %}
@@ -1,53 +1,51 @@
1
- import logging
2
1
  import os
3
2
  import pathlib
4
3
 
4
+ from flask import Blueprint
5
5
  from flask import flash
6
6
  from flask import redirect
7
+ from flask import render_template
7
8
  from flask import request
8
- from flask import Response
9
9
  from flask import url_for
10
- from werkzeug.utils import secure_filename
11
10
 
12
- from geo_activity_playground.core.activities import ActivityRepository
13
- from geo_activity_playground.core.activities import build_activity_meta
11
+ from ..core.activities import ActivityRepository
12
+ from ..core.activities import build_activity_meta
13
+ from ..explorer.tile_visits import compute_tile_evolution
14
+ from ..explorer.tile_visits import compute_tile_visits_new
15
+ from ..explorer.tile_visits import TileVisitAccessor
14
16
  from geo_activity_playground.core.config import Config
15
17
  from geo_activity_playground.core.enrichment import enrich_activities
16
- from geo_activity_playground.explorer.tile_visits import compute_tile_evolution
17
- from geo_activity_playground.explorer.tile_visits import compute_tile_visits_new
18
- from geo_activity_playground.explorer.tile_visits import TileVisitAccessor
19
18
  from geo_activity_playground.importers.directory import get_file_hash
20
19
  from geo_activity_playground.importers.directory import import_from_directory
21
20
  from geo_activity_playground.importers.strava_api import import_from_strava_api
22
21
  from geo_activity_playground.importers.strava_checkout import (
23
22
  import_from_strava_checkout,
24
23
  )
24
+ from geo_activity_playground.webui.authenticator import Authenticator
25
+ from geo_activity_playground.webui.authenticator import needs_authentication
25
26
 
26
27
 
27
- logger = logging.getLogger(__name__)
28
-
29
-
30
- class UploadController:
31
- def __init__(
32
- self,
33
- repository: ActivityRepository,
34
- tile_visit_accessor: TileVisitAccessor,
35
- config: Config,
36
- ) -> None:
37
- self._repository = repository
38
- self._tile_visit_accessor = tile_visit_accessor
39
- self._config = config
28
+ def make_upload_blueprint(
29
+ repository: ActivityRepository,
30
+ tile_visit_accessor: TileVisitAccessor,
31
+ config: Config,
32
+ authenticator: Authenticator,
33
+ ) -> Blueprint:
34
+ blueprint = Blueprint("upload", __name__, template_folder="templates")
40
35
 
41
- def render_form(self) -> dict:
36
+ @blueprint.route("/")
37
+ @needs_authentication(authenticator)
38
+ def index():
39
+ pathlib.Path("Activities").mkdir(exist_ok=True, parents=True)
42
40
  directories = []
43
41
  for root, dirs, files in os.walk("Activities"):
44
42
  directories.append(root)
45
43
  directories.sort()
46
- return {
47
- "directories": directories,
48
- }
44
+ return render_template("upload/index.html.j2", directories=directories)
49
45
 
50
- def receive(self) -> Response:
46
+ @blueprint.route("/receive", methods=["POST"])
47
+ @needs_authentication(authenticator)
48
+ def receive():
51
49
  # check if the post request has the file part
52
50
  if "file" not in request.files:
53
51
  flash("No file could be found. Did you select a file?", "warning")
@@ -74,25 +72,34 @@ class UploadController:
74
72
  assert target_path.is_relative_to("Activities")
75
73
  file.save(target_path)
76
74
  scan_for_activities(
77
- self._repository,
78
- self._tile_visit_accessor,
79
- self._config,
75
+ repository,
76
+ tile_visit_accessor,
77
+ config,
80
78
  skip_strava=True,
81
79
  )
82
80
  activity_id = get_file_hash(target_path)
83
81
  flash(f"Activity was saved with ID {activity_id}.", "success")
84
82
  return redirect(f"/activity/{activity_id}")
85
83
 
86
- def execute_reload(self) -> None:
84
+ @blueprint.route("/refresh")
85
+ @needs_authentication(authenticator)
86
+ def reload():
87
+ return render_template("upload/reload.html.j2")
88
+
89
+ @blueprint.route("/execute-reload")
90
+ @needs_authentication(authenticator)
91
+ def execute_reload():
87
92
  scan_for_activities(
88
- self._repository,
89
- self._tile_visit_accessor,
90
- self._config,
93
+ repository,
94
+ tile_visit_accessor,
95
+ config,
91
96
  skip_strava=True,
92
97
  )
93
98
  flash("Scanned for new activities.", category="success")
94
99
  return redirect(url_for("index"))
95
100
 
101
+ return blueprint
102
+
96
103
 
97
104
  def scan_for_activities(
98
105
  repository: ActivityRepository,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: geo-activity-playground
3
- Version: 0.33.1
3
+ Version: 0.33.3
4
4
  Summary: Analysis of geo data activities like rides, runs or hikes.
5
5
  License: MIT
6
6
  Author: Martin Ueding
@@ -1,5 +1,5 @@
1
1
  geo_activity_playground/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- geo_activity_playground/__main__.py,sha256=MBZn9K1m3PofiPNTtpsSTVCyB_Gz95TjVP-nb9v_-JE,3989
2
+ geo_activity_playground/__main__.py,sha256=qbKjs7IsJwF2gB3b0lh7tGt6uraPqq5w-xGBIxrgoHI,3988
3
3
  geo_activity_playground/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
4
  geo_activity_playground/core/activities.py,sha256=MiQev1L7NnSVnxgbArlT-FpWTESTwnKh7pyT1tcEHqU,6926
5
5
  geo_activity_playground/core/config.py,sha256=uqiwk7CgcuGx8JemHSsRKjRwyNT1YTb7V0gX0OJhfaI,5109
@@ -37,7 +37,7 @@ geo_activity_playground/webui/activity/templates/activity/edit.html.j2,sha256=ck
37
37
  geo_activity_playground/webui/activity/templates/activity/lines.html.j2,sha256=_ZDg1ruW-9UMJfOudy1-uY_-IcSSaagq7tPCih5Bb8g,1079
38
38
  geo_activity_playground/webui/activity/templates/activity/name.html.j2,sha256=tKviMqMouHEGv3xBQVIsJgwj_hjwAsmGVefM3UMqlYg,2437
39
39
  geo_activity_playground/webui/activity/templates/activity/show.html.j2,sha256=bEx37UGSTeeJl7gN4fjyOpINFQwZ5Zm-HOKpLqcJGfs,6905
40
- geo_activity_playground/webui/app.py,sha256=nWbgxRHg0DThi44VFb04OIVwxnqIVmkr3cnO9ucE1Oo,5118
40
+ geo_activity_playground/webui/app.py,sha256=KghChBgJvRZ9Cx7Z5wmqx6X0Q6GH-2hi97eaKEE_Zvc,5118
41
41
  geo_activity_playground/webui/auth/blueprint.py,sha256=Lx-ZvMnfHLC1CMre1xPQI3k_pCtQoZvgRhtmafULzoE,812
42
42
  geo_activity_playground/webui/auth/templates/auth/index.html.j2,sha256=ILQ5HvTEYc3OrtOAIFt1VrqWorVD70V9DC342znmP70,579
43
43
  geo_activity_playground/webui/authenticator.py,sha256=k278OEVuOfAmTGT4F2X4pqSTwwkK_FA87EIhAeysEqc,1416
@@ -50,7 +50,7 @@ geo_activity_playground/webui/eddington/__init__.py,sha256=47DEQpj8HBSa-_TImW-5J
50
50
  geo_activity_playground/webui/eddington/blueprint.py,sha256=evIvueLfDWVTxJ9pRguqmZ9-Pybd2WmBRst_-7vX2QA,551
51
51
  geo_activity_playground/webui/eddington/controller.py,sha256=ly7JSkSS79kO4CL_xugB62uRuuWKVqOjbN-pheelv94,2910
52
52
  geo_activity_playground/webui/eddington/templates/eddington/index.html.j2,sha256=XHKeUymQMS5x00PLOVlg-nSRCz_jHB2pvD8QunULWJ4,1839
53
- geo_activity_playground/webui/entry_controller.py,sha256=kTEToBtR1T4l30cV3HkCK3KO2hVYfb22BSgcWLdLEXQ,2164
53
+ geo_activity_playground/webui/entry_controller.py,sha256=McxbyouKWHJ3a2R9agPazZoG7VHiFO1RvnkBr08dMH8,2168
54
54
  geo_activity_playground/webui/equipment/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
55
55
  geo_activity_playground/webui/equipment/blueprint.py,sha256=_NIhRJuJNbXpEd_nEPo01AqnUqPgo1vawFn7E3yoeng,636
56
56
  geo_activity_playground/webui/equipment/controller.py,sha256=Sx9i2RCK7m4W6FgpDfRMewcH64VBQfUhHJdTSCwMqOU,4079
@@ -58,7 +58,7 @@ geo_activity_playground/webui/equipment/templates/equipment/index.html.j2,sha256
58
58
  geo_activity_playground/webui/explorer/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
59
59
  geo_activity_playground/webui/explorer/blueprint.py,sha256=EKnBs8llqT6Wy1uac18dF2epp3TebF9p3iGlSbj6Vl0,2337
60
60
  geo_activity_playground/webui/explorer/controller.py,sha256=pIzWh0TpLJgKQZlS325-QT7nA1q9ms7fRqQIp24PNfo,11705
61
- geo_activity_playground/webui/explorer/templates/explorer/index.html.j2,sha256=PnAL0uDNjnziwbkCOpIWPb7KmS4c1dP-VLxjyXppUYc,6701
61
+ geo_activity_playground/webui/explorer/templates/explorer/index.html.j2,sha256=aGos75uUyjevDWKSyQwVyvuGHIY6qoGASMbgU6k71YU,6707
62
62
  geo_activity_playground/webui/heatmap/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
63
63
  geo_activity_playground/webui/heatmap/blueprint.py,sha256=ZEImDIwT3uiDIKapqCU49llvyqG79n7ZEu1GHgoLZqo,1558
64
64
  geo_activity_playground/webui/heatmap/heatmap_controller.py,sha256=Qw9MGW3TFWlG2JkA_r9RHgYq4hvPiJaZeAg5D9lIFC0,7821
@@ -102,18 +102,16 @@ geo_activity_playground/webui/summary/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCe
102
102
  geo_activity_playground/webui/summary/blueprint.py,sha256=tfA2aPF19yKwkQOb5lPQBySoQYYhTn49Iuh0SYvsGP8,593
103
103
  geo_activity_playground/webui/summary/controller.py,sha256=V3zBLNL_Yc_Ft-ZBaWnlLXhr8VsvTpipPUZ-G9sgUXs,9312
104
104
  geo_activity_playground/webui/summary/templates/summary/index.html.j2,sha256=ctOx3Qjx6nRDpUtFf1DlJhK_gtU77Vwx_S6euLz9-W4,5183
105
- geo_activity_playground/webui/templates/home.html.j2,sha256=JNQxpjDfXhLAJbZ7RaNBNe9u48nbvlEBrnU_Zizt544,2131
105
+ geo_activity_playground/webui/templates/home.html.j2,sha256=IdCqI_LLcYrpUjjCO-tbXR4s05XYrPOateiJ4idF3bo,2202
106
106
  geo_activity_playground/webui/templates/page.html.j2,sha256=znTbtD2NALrhmUN_Q-F1ElGlKtecoUv8vOCcUtojrdI,11134
107
+ geo_activity_playground/webui/templates/upload/index.html.j2,sha256=I1Ix8tDS3YBdi-HdaNfjkzYXVVCjfUTe5PFTnap1ydc,775
108
+ geo_activity_playground/webui/templates/upload/reload.html.j2,sha256=YZWX5eDeNyqKJdQAywDBcU8DZBm22rRBbZqFjrFrCvQ,556
107
109
  geo_activity_playground/webui/tile/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
108
110
  geo_activity_playground/webui/tile/blueprint.py,sha256=q0sw_F8L367Df01yjZijikEIglFBgg9lN61sbTAEOKQ,1018
109
111
  geo_activity_playground/webui/tile/controller.py,sha256=XjUTbyAMeQET1D3mFtT8r5-xMcMOaELPZWtQ1Xp7Cuw,1428
110
- geo_activity_playground/webui/upload/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
111
- geo_activity_playground/webui/upload/blueprint.py,sha256=xX9scEmleN_dL03jfhWRh5yI1WsFyhxUFiS_Ul2HWy4,1428
112
- geo_activity_playground/webui/upload/controller.py,sha256=EvoUnmKBo3QS2TLak7-yVZ16sEDyEB6Nf2MN_scHuhQ,4080
113
- geo_activity_playground/webui/upload/templates/upload/index.html.j2,sha256=I1Ix8tDS3YBdi-HdaNfjkzYXVVCjfUTe5PFTnap1ydc,775
114
- geo_activity_playground/webui/upload/templates/upload/reload.html.j2,sha256=YZWX5eDeNyqKJdQAywDBcU8DZBm22rRBbZqFjrFrCvQ,556
115
- geo_activity_playground-0.33.1.dist-info/LICENSE,sha256=4RpAwKO8bPkfXH2lnpeUW0eLkNWglyG4lbrLDU_MOwY,1070
116
- geo_activity_playground-0.33.1.dist-info/METADATA,sha256=FUqgwpebm9G0h5Uo8z2KDzxbQxGrzeG1lBd7JKhm_Rc,1612
117
- geo_activity_playground-0.33.1.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
118
- geo_activity_playground-0.33.1.dist-info/entry_points.txt,sha256=pbNlLI6IIZIp7nPYCfAtiSiz2oxJSCl7DODD6SPkLKk,81
119
- geo_activity_playground-0.33.1.dist-info/RECORD,,
112
+ geo_activity_playground/webui/upload_blueprint.py,sha256=topLI9ytDUFkqCc9AlOqDkjhABUwnPJ1tX_7XrBPbxc,4412
113
+ geo_activity_playground-0.33.3.dist-info/LICENSE,sha256=4RpAwKO8bPkfXH2lnpeUW0eLkNWglyG4lbrLDU_MOwY,1070
114
+ geo_activity_playground-0.33.3.dist-info/METADATA,sha256=eUVURIw-QgIO2bQUHVXXrPNf35-v_XEywE9iwQ6mfa8,1612
115
+ geo_activity_playground-0.33.3.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
116
+ geo_activity_playground-0.33.3.dist-info/entry_points.txt,sha256=pbNlLI6IIZIp7nPYCfAtiSiz2oxJSCl7DODD6SPkLKk,81
117
+ geo_activity_playground-0.33.3.dist-info/RECORD,,
File without changes
@@ -1,44 +0,0 @@
1
- from flask import Blueprint
2
- from flask import render_template
3
-
4
- from ...core.activities import ActivityRepository
5
- from ...explorer.tile_visits import TileVisitAccessor
6
- from .controller import UploadController
7
- from geo_activity_playground.core.config import Config
8
- from geo_activity_playground.webui.authenticator import Authenticator
9
- from geo_activity_playground.webui.authenticator import needs_authentication
10
-
11
-
12
- def make_upload_blueprint(
13
- repository: ActivityRepository,
14
- tile_visit_accessor: TileVisitAccessor,
15
- config: Config,
16
- authenticator: Authenticator,
17
- ) -> Blueprint:
18
- blueprint = Blueprint("upload", __name__, template_folder="templates")
19
-
20
- upload_controller = UploadController(repository, tile_visit_accessor, config)
21
-
22
- @blueprint.route("/")
23
- @needs_authentication(authenticator)
24
- def index():
25
- return render_template(
26
- "upload/index.html.j2", **upload_controller.render_form()
27
- )
28
-
29
- @blueprint.route("/receive", methods=["POST"])
30
- @needs_authentication(authenticator)
31
- def receive():
32
- return upload_controller.receive()
33
-
34
- @blueprint.route("/refresh")
35
- @needs_authentication(authenticator)
36
- def reload():
37
- return render_template("upload/reload.html.j2")
38
-
39
- @blueprint.route("/execute-reload")
40
- @needs_authentication(authenticator)
41
- def execute_reload():
42
- return upload_controller.execute_reload()
43
-
44
- return blueprint