pretix-map 0.0.7__tar.gz → 0.1.1__tar.gz
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.
- {pretix_map-0.0.7/pretix_map.egg-info → pretix_map-0.1.1}/PKG-INFO +3 -1
- {pretix_map-0.0.7 → pretix_map-0.1.1}/README.rst +2 -0
- {pretix_map-0.0.7 → pretix_map-0.1.1/pretix_map.egg-info}/PKG-INFO +3 -1
- pretix_map-0.1.1/pretix_mapplugin/__init__.py +1 -0
- pretix_map-0.1.1/pretix_mapplugin/tasks.py +90 -0
- pretix_map-0.0.7/pretix_mapplugin/__init__.py +0 -1
- pretix_map-0.0.7/pretix_mapplugin/tasks.py +0 -90
- {pretix_map-0.0.7 → pretix_map-0.1.1}/LICENSE +0 -0
- {pretix_map-0.0.7 → pretix_map-0.1.1}/MANIFEST.in +0 -0
- {pretix_map-0.0.7 → pretix_map-0.1.1}/pretix_map.egg-info/SOURCES.txt +0 -0
- {pretix_map-0.0.7 → pretix_map-0.1.1}/pretix_map.egg-info/dependency_links.txt +0 -0
- {pretix_map-0.0.7 → pretix_map-0.1.1}/pretix_map.egg-info/entry_points.txt +0 -0
- {pretix_map-0.0.7 → pretix_map-0.1.1}/pretix_map.egg-info/requires.txt +0 -0
- {pretix_map-0.0.7 → pretix_map-0.1.1}/pretix_map.egg-info/top_level.txt +0 -0
- {pretix_map-0.0.7 → pretix_map-0.1.1}/pretix_mapplugin/apps.py +0 -0
- {pretix_map-0.0.7 → pretix_map-0.1.1}/pretix_mapplugin/geocoding.py +0 -0
- {pretix_map-0.0.7 → pretix_map-0.1.1}/pretix_mapplugin/locale/de/LC_MESSAGES/django.mo +0 -0
- {pretix_map-0.0.7 → pretix_map-0.1.1}/pretix_mapplugin/locale/de/LC_MESSAGES/django.po +0 -0
- {pretix_map-0.0.7 → pretix_map-0.1.1}/pretix_mapplugin/locale/de_Informal/.gitkeep +0 -0
- {pretix_map-0.0.7 → pretix_map-0.1.1}/pretix_mapplugin/locale/de_Informal/LC_MESSAGES/django.mo +0 -0
- {pretix_map-0.0.7 → pretix_map-0.1.1}/pretix_mapplugin/locale/de_Informal/LC_MESSAGES/django.po +0 -0
- {pretix_map-0.0.7 → pretix_map-0.1.1}/pretix_mapplugin/management/__init__.py +0 -0
- {pretix_map-0.0.7 → pretix_map-0.1.1}/pretix_mapplugin/management/commands/__init__.py +0 -0
- {pretix_map-0.0.7 → pretix_map-0.1.1}/pretix_mapplugin/management/commands/geocode_existing_orders.py +0 -0
- {pretix_map-0.0.7 → pretix_map-0.1.1}/pretix_mapplugin/migrations/0001_initial.py +0 -0
- {pretix_map-0.0.7 → pretix_map-0.1.1}/pretix_mapplugin/migrations/__init__.py +0 -0
- {pretix_map-0.0.7 → pretix_map-0.1.1}/pretix_mapplugin/models.py +0 -0
- {pretix_map-0.0.7 → pretix_map-0.1.1}/pretix_mapplugin/signals.py +0 -0
- {pretix_map-0.0.7 → pretix_map-0.1.1}/pretix_mapplugin/static/pretix_mapplugin/.gitkeep +0 -0
- {pretix_map-0.0.7 → pretix_map-0.1.1}/pretix_mapplugin/static/pretix_mapplugin/css/salesmap.css +0 -0
- {pretix_map-0.0.7 → pretix_map-0.1.1}/pretix_mapplugin/static/pretix_mapplugin/js/salesmap.js +0 -0
- {pretix_map-0.0.7 → pretix_map-0.1.1}/pretix_mapplugin/static/pretix_mapplugin/libs/leaflet-sales-map/MarkerCluster.Default.css +0 -0
- {pretix_map-0.0.7 → pretix_map-0.1.1}/pretix_mapplugin/static/pretix_mapplugin/libs/leaflet-sales-map/MarkerCluster.css +0 -0
- {pretix_map-0.0.7 → pretix_map-0.1.1}/pretix_mapplugin/static/pretix_mapplugin/libs/leaflet-sales-map/images/layers-2x.png +0 -0
- {pretix_map-0.0.7 → pretix_map-0.1.1}/pretix_mapplugin/static/pretix_mapplugin/libs/leaflet-sales-map/images/layers.png +0 -0
- {pretix_map-0.0.7 → pretix_map-0.1.1}/pretix_mapplugin/static/pretix_mapplugin/libs/leaflet-sales-map/images/marker-icon-2x.png +0 -0
- {pretix_map-0.0.7 → pretix_map-0.1.1}/pretix_mapplugin/static/pretix_mapplugin/libs/leaflet-sales-map/images/marker-icon.png +0 -0
- {pretix_map-0.0.7 → pretix_map-0.1.1}/pretix_mapplugin/static/pretix_mapplugin/libs/leaflet-sales-map/images/marker-shadow.png +0 -0
- {pretix_map-0.0.7 → pretix_map-0.1.1}/pretix_mapplugin/static/pretix_mapplugin/libs/leaflet-sales-map/leaflet-heat.js +0 -0
- {pretix_map-0.0.7 → pretix_map-0.1.1}/pretix_mapplugin/static/pretix_mapplugin/libs/leaflet-sales-map/leaflet-src.esm.js +0 -0
- {pretix_map-0.0.7 → pretix_map-0.1.1}/pretix_mapplugin/static/pretix_mapplugin/libs/leaflet-sales-map/leaflet-src.esm.js.map +0 -0
- {pretix_map-0.0.7 → pretix_map-0.1.1}/pretix_mapplugin/static/pretix_mapplugin/libs/leaflet-sales-map/leaflet-src.js +0 -0
- {pretix_map-0.0.7 → pretix_map-0.1.1}/pretix_mapplugin/static/pretix_mapplugin/libs/leaflet-sales-map/leaflet-src.js.map +0 -0
- {pretix_map-0.0.7 → pretix_map-0.1.1}/pretix_mapplugin/static/pretix_mapplugin/libs/leaflet-sales-map/leaflet.css +0 -0
- {pretix_map-0.0.7 → pretix_map-0.1.1}/pretix_mapplugin/static/pretix_mapplugin/libs/leaflet-sales-map/leaflet.js +0 -0
- {pretix_map-0.0.7 → pretix_map-0.1.1}/pretix_mapplugin/static/pretix_mapplugin/libs/leaflet-sales-map/leaflet.js.map +0 -0
- {pretix_map-0.0.7 → pretix_map-0.1.1}/pretix_mapplugin/static/pretix_mapplugin/libs/leaflet-sales-map/leaflet.markercluster.js +0 -0
- {pretix_map-0.0.7 → pretix_map-0.1.1}/pretix_mapplugin/static/pretix_mapplugin/libs/leaflet-sales-map/leaflet.markercluster.js.map +0 -0
- {pretix_map-0.0.7 → pretix_map-0.1.1}/pretix_mapplugin/templates/pretix_mapplugin/.gitkeep +0 -0
- {pretix_map-0.0.7 → pretix_map-0.1.1}/pretix_mapplugin/templates/pretix_mapplugin/map_page.html +0 -0
- {pretix_map-0.0.7 → pretix_map-0.1.1}/pretix_mapplugin/urls.py +0 -0
- {pretix_map-0.0.7 → pretix_map-0.1.1}/pretix_mapplugin/views.py +0 -0
- {pretix_map-0.0.7 → pretix_map-0.1.1}/pyproject.toml +0 -0
- {pretix_map-0.0.7 → pretix_map-0.1.1}/setup.cfg +0 -0
- {pretix_map-0.0.7 → pretix_map-0.1.1}/setup.py +0 -0
- {pretix_map-0.0.7 → pretix_map-0.1.1}/tests/test_main.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: pretix-map
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.1.1
|
4
4
|
Summary: An overview map of the catchment area of previous orders. Measured by postcode
|
5
5
|
Author-email: MarkenJaden <jjsch1410@gmail.com>
|
6
6
|
Maintainer-email: MarkenJaden <jjsch1410@gmail.com>
|
@@ -140,10 +140,12 @@ This command is essential for processing orders that were placed *before* the ma
|
|
140
140
|
**Example Workflow:**
|
141
141
|
|
142
142
|
1. **Test with Dry Run (All Organizers):**
|
143
|
+
|
143
144
|
.. code-block:: bash
|
144
145
|
|
145
146
|
python manage.py geocode_existing_orders --dry-run
|
146
147
|
2. **(If satisfied) Run for Real (All Organizers):**
|
148
|
+
|
147
149
|
.. code-block:: bash
|
148
150
|
|
149
151
|
python manage.py geocode_existing_orders
|
@@ -125,10 +125,12 @@ This command is essential for processing orders that were placed *before* the ma
|
|
125
125
|
**Example Workflow:**
|
126
126
|
|
127
127
|
1. **Test with Dry Run (All Organizers):**
|
128
|
+
|
128
129
|
.. code-block:: bash
|
129
130
|
|
130
131
|
python manage.py geocode_existing_orders --dry-run
|
131
132
|
2. **(If satisfied) Run for Real (All Organizers):**
|
133
|
+
|
132
134
|
.. code-block:: bash
|
133
135
|
|
134
136
|
python manage.py geocode_existing_orders
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: pretix-map
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.1.1
|
4
4
|
Summary: An overview map of the catchment area of previous orders. Measured by postcode
|
5
5
|
Author-email: MarkenJaden <jjsch1410@gmail.com>
|
6
6
|
Maintainer-email: MarkenJaden <jjsch1410@gmail.com>
|
@@ -140,10 +140,12 @@ This command is essential for processing orders that were placed *before* the ma
|
|
140
140
|
**Example Workflow:**
|
141
141
|
|
142
142
|
1. **Test with Dry Run (All Organizers):**
|
143
|
+
|
143
144
|
.. code-block:: bash
|
144
145
|
|
145
146
|
python manage.py geocode_existing_orders --dry-run
|
146
147
|
2. **(If satisfied) Run for Real (All Organizers):**
|
148
|
+
|
147
149
|
.. code-block:: bash
|
148
150
|
|
149
151
|
python manage.py geocode_existing_orders
|
@@ -0,0 +1 @@
|
|
1
|
+
__version__ = "0.1.1"
|
@@ -0,0 +1,90 @@
|
|
1
|
+
import logging
|
2
|
+
from django.db import transaction
|
3
|
+
from django.core.exceptions import ObjectDoesNotExist
|
4
|
+
|
5
|
+
# --- Import django-scopes ---
|
6
|
+
from django_scopes import scope
|
7
|
+
|
8
|
+
# --- Use Pretix Celery app instance ---
|
9
|
+
from pretix.celery_app import app
|
10
|
+
# --- Import necessary Pretix models ---
|
11
|
+
from pretix.base.models import Order, Organizer # Import Organizer
|
12
|
+
|
13
|
+
# --- Import your Geocode model and geocoding functions ---
|
14
|
+
from .models import OrderGeocodeData
|
15
|
+
from .geocoding import (
|
16
|
+
get_formatted_address_from_order,
|
17
|
+
geocode_address,
|
18
|
+
DEFAULT_NOMINATIM_USER_AGENT
|
19
|
+
)
|
20
|
+
|
21
|
+
logger = logging.getLogger(__name__)
|
22
|
+
|
23
|
+
|
24
|
+
@app.task(bind=True, max_retries=3, default_retry_delay=60, ignore_result=True)
|
25
|
+
def geocode_order_task(self, order_pk: int, nominatim_user_agent: str | None = None):
|
26
|
+
"""
|
27
|
+
Celery task to geocode the address for a given order PK.
|
28
|
+
Accepts the Nominatim User-Agent as an argument.
|
29
|
+
Activates django-scopes organizer scope before querying scoped models.
|
30
|
+
"""
|
31
|
+
order = None # Initialize order to None
|
32
|
+
try:
|
33
|
+
try:
|
34
|
+
order = Order.objects.select_related('event__organizer', 'invoice_address').get(pk=order_pk)
|
35
|
+
organizer = order.event.organizer # Get organizer from the fetched order
|
36
|
+
except ObjectDoesNotExist:
|
37
|
+
logger.error(f"Order with PK {order_pk} not found in geocode_order_task.")
|
38
|
+
return
|
39
|
+
with scope(organizer=organizer):
|
40
|
+
logger.info(
|
41
|
+
f"Starting geocoding task for Order {order.code} (PK: {order_pk}) within scope of Organizer '{organizer.slug}'")
|
42
|
+
|
43
|
+
relation_name = 'geocode_data' # Ensure this matches your model
|
44
|
+
# Check existence within scope (safer)
|
45
|
+
if OrderGeocodeData.objects.filter(order_id=order_pk).exists():
|
46
|
+
logger.info(f"Geocode data already exists for Order {order.code} (checked within scope). Skipping.")
|
47
|
+
return
|
48
|
+
|
49
|
+
address_str = get_formatted_address_from_order(order)
|
50
|
+
if not address_str:
|
51
|
+
logger.info(f"Order {order.code} has no address suitable for geocoding. Storing null coordinates.")
|
52
|
+
# Store null within scope
|
53
|
+
with transaction.atomic():
|
54
|
+
OrderGeocodeData.objects.update_or_create(
|
55
|
+
order=order, defaults={'latitude': None, 'longitude': None}
|
56
|
+
)
|
57
|
+
return
|
58
|
+
|
59
|
+
logger.debug(f"Attempting to geocode address for Order {order.code}: '{address_str}'")
|
60
|
+
coordinates = geocode_address(address_str, nominatim_user_agent=nominatim_user_agent)
|
61
|
+
|
62
|
+
# Store result within scope
|
63
|
+
with transaction.atomic():
|
64
|
+
if coordinates:
|
65
|
+
latitude, longitude = coordinates
|
66
|
+
obj, created = OrderGeocodeData.objects.update_or_create(
|
67
|
+
order=order, defaults={'latitude': latitude, 'longitude': longitude}
|
68
|
+
)
|
69
|
+
log_level = logging.INFO if created else logging.DEBUG
|
70
|
+
logger.log(log_level,
|
71
|
+
f"Saved{' new' if created else ' updated'} geocode data for Order {order.code}: ({latitude}, {longitude})")
|
72
|
+
else:
|
73
|
+
logger.warning(f"Geocoding failed for Order {order.code}. Storing null coordinates.")
|
74
|
+
obj, created = OrderGeocodeData.objects.update_or_create(
|
75
|
+
order=order, defaults={'latitude': None, 'longitude': None}
|
76
|
+
)
|
77
|
+
log_level = logging.INFO if created else logging.DEBUG
|
78
|
+
logger.log(log_level,
|
79
|
+
f"Saved{' new' if created else ' updated'} null geocode data for Order {order.code} after failed attempt.")
|
80
|
+
# --- Scope deactivated automatically here ---
|
81
|
+
|
82
|
+
# Keep outer exception handling
|
83
|
+
except ObjectDoesNotExist:
|
84
|
+
# This case is now handled earlier, but keep for safety
|
85
|
+
logger.error(f"Order with PK {order_pk} not found outside scope handling.")
|
86
|
+
except Exception as e:
|
87
|
+
logger.exception(
|
88
|
+
f"Unexpected error in geocode_order_task for Order PK {order_pk} (potentially outside scope): {e}")
|
89
|
+
# Retry on unexpected errors before scope activation
|
90
|
+
raise self.retry(exc=e)
|
@@ -1 +0,0 @@
|
|
1
|
-
__version__ = "0.0.7"
|
@@ -1,90 +0,0 @@
|
|
1
|
-
import logging
|
2
|
-
from django.db import transaction
|
3
|
-
from django.core.exceptions import ObjectDoesNotExist
|
4
|
-
|
5
|
-
# --- Use Pretix Celery app instance ---
|
6
|
-
from pretix.celery_app import app
|
7
|
-
# --- Import necessary Pretix models ---
|
8
|
-
from pretix.base.models import Order
|
9
|
-
|
10
|
-
# --- Import your Geocode model and geocoding functions ---
|
11
|
-
from .models import OrderGeocodeData
|
12
|
-
from .geocoding import (
|
13
|
-
get_formatted_address_from_order,
|
14
|
-
geocode_address,
|
15
|
-
DEFAULT_NOMINATIM_USER_AGENT # Import default for safety/logging
|
16
|
-
)
|
17
|
-
|
18
|
-
logger = logging.getLogger(__name__)
|
19
|
-
|
20
|
-
|
21
|
-
# Define the Celery task
|
22
|
-
# bind=True gives access to self (the task instance) for retrying
|
23
|
-
# ignore_result=True as we don't need the return value stored in Celery backend
|
24
|
-
@app.task(bind=True, max_retries=3, default_retry_delay=60, ignore_result=True)
|
25
|
-
def geocode_order_task(self, order_pk: int,
|
26
|
-
nominatim_user_agent: str | None = None): # Added nominatim_user_agent kwarg
|
27
|
-
"""
|
28
|
-
Celery task to geocode the address for a given order PK.
|
29
|
-
Accepts the Nominatim User-Agent as an argument.
|
30
|
-
"""
|
31
|
-
try:
|
32
|
-
# Fetch order with related address and country data efficiently
|
33
|
-
order = Order.objects.select_related(
|
34
|
-
'invoice_address',
|
35
|
-
).get(pk=order_pk)
|
36
|
-
logger.info(f"Starting geocoding task for Order {order.code} (PK: {order_pk})")
|
37
|
-
|
38
|
-
# Check if already geocoded to prevent redundant work
|
39
|
-
# Replace 'geocode_data' if your related_name is different
|
40
|
-
relation_name = 'geocode_data' # Ensure this matches your OrderGeocodeData.order related_name
|
41
|
-
if hasattr(order, relation_name) and getattr(order, relation_name) is not None:
|
42
|
-
logger.info(f"Geocode data already exists for Order {order.code}. Skipping.")
|
43
|
-
return # Exit successfully
|
44
|
-
|
45
|
-
# 1. Get formatted address string
|
46
|
-
address_str = get_formatted_address_from_order(order)
|
47
|
-
if not address_str:
|
48
|
-
logger.info(f"Order {order.code} has no address suitable for geocoding. Storing null coordinates.")
|
49
|
-
# Store null to prevent reprocessing
|
50
|
-
with transaction.atomic():
|
51
|
-
OrderGeocodeData.objects.update_or_create(
|
52
|
-
order=order,
|
53
|
-
defaults={'latitude': None, 'longitude': None}
|
54
|
-
)
|
55
|
-
return # Exit successfully, nothing to geocode
|
56
|
-
|
57
|
-
# 2. Perform geocoding, passing the user agent received by the task
|
58
|
-
logger.debug(f"Attempting to geocode address for Order {order.code}: '{address_str}'")
|
59
|
-
coordinates = geocode_address(address_str, nominatim_user_agent=nominatim_user_agent)
|
60
|
-
|
61
|
-
# 3. Store result (or null if failed) using atomic transaction
|
62
|
-
with transaction.atomic():
|
63
|
-
if coordinates:
|
64
|
-
latitude, longitude = coordinates
|
65
|
-
obj, created = OrderGeocodeData.objects.update_or_create(
|
66
|
-
order=order,
|
67
|
-
defaults={'latitude': latitude, 'longitude': longitude}
|
68
|
-
)
|
69
|
-
log_level = logging.INFO if created else logging.DEBUG # Be less noisy on updates
|
70
|
-
logger.log(log_level,
|
71
|
-
f"Saved{' new' if created else ' updated'} geocode data for Order {order.code}: ({latitude}, {longitude})")
|
72
|
-
else:
|
73
|
-
logger.warning(f"Geocoding failed for Order {order.code}. Storing null coordinates.")
|
74
|
-
# Store nulls to indicate an attempt was made and failed
|
75
|
-
obj, created = OrderGeocodeData.objects.update_or_create(
|
76
|
-
order=order,
|
77
|
-
defaults={'latitude': None, 'longitude': None}
|
78
|
-
)
|
79
|
-
log_level = logging.INFO if created else logging.DEBUG
|
80
|
-
logger.log(log_level,
|
81
|
-
f"Saved{' new' if created else ' updated'} null geocode data for Order {order.code} after failed attempt.")
|
82
|
-
|
83
|
-
except ObjectDoesNotExist: # More specific exception
|
84
|
-
logger.error(f"Order with PK {order_pk} not found in geocode_order_task.")
|
85
|
-
# Don't retry if the order doesn't exist
|
86
|
-
except Exception as e:
|
87
|
-
# Catch any other unexpected errors
|
88
|
-
logger.exception(f"Unexpected error in geocode_order_task for Order PK {order_pk}: {e}")
|
89
|
-
# Retry on potentially temporary errors (database, network issues etc.)
|
90
|
-
raise self.retry(exc=e) # Let Celery handle retry logic
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{pretix_map-0.0.7 → pretix_map-0.1.1}/pretix_mapplugin/locale/de_Informal/LC_MESSAGES/django.mo
RENAMED
File without changes
|
{pretix_map-0.0.7 → pretix_map-0.1.1}/pretix_mapplugin/locale/de_Informal/LC_MESSAGES/django.po
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{pretix_map-0.0.7 → pretix_map-0.1.1}/pretix_mapplugin/static/pretix_mapplugin/css/salesmap.css
RENAMED
File without changes
|
{pretix_map-0.0.7 → pretix_map-0.1.1}/pretix_mapplugin/static/pretix_mapplugin/js/salesmap.js
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{pretix_map-0.0.7 → pretix_map-0.1.1}/pretix_mapplugin/templates/pretix_mapplugin/map_page.html
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|