Skip to content

Commit

Permalink
✨ [FEATURE] add price to TouristicEvent model - ref GeotrekCE#3587
Browse files Browse the repository at this point in the history
  • Loading branch information
TheoLechemia committed Feb 23, 2024
1 parent c46c2e5 commit b7d9e2a
Show file tree
Hide file tree
Showing 11 changed files with 48 additions and 6 deletions.
6 changes: 6 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ CHANGELOG

2.102.1+dev (XXXX-XX-XX)
------------------------
- Tourism : add price to TouristicEvent model - ref #3587)

2.102.1 (2024-02-20)
--------------------
Expand All @@ -30,6 +31,7 @@ CHANGELOG

**New features**

<<<<<<< HEAD
- Add UUIDs of parent and children ``Courses`` and ``Sites`` in APIv2 (#3569)

**Improvements**
Expand All @@ -46,6 +48,10 @@ CHANGELOG

- Land: Add ``CirculationEdge`` model to manage circulation types and authorization types in the land module (#3578)
- Generalize``AccessMean`` model and add field ``access`` to ``Intervention`` (#3819)
=======
-Land: Add ``CirculationEdge`` model to manage circulation types and authorization types in the land module (#3578)
-Tourism: Add price to `TouristicEvent` model
>>>>>>> 73269bbb7 (:sparkles: [FEATURE] add price to TouristicEvent model - ref #3587)

**Improvements**

Expand Down
7 changes: 5 additions & 2 deletions docs/install/advanced-configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1410,6 +1410,7 @@ A (nearly?) exhaustive list of attributes available for display and export as co
"place",
'preparation_duration',
'intervention_duration',
'price'
]
COLUMNS_LISTS["feedback_view"] = [
"email",
Expand Down Expand Up @@ -1954,7 +1955,8 @@ A (nearly?) exhaustive list of attributes available for display and export as co
"cancellation_reason"
"place",
'preparation_duration',
'intervention_duration'
'intervention_duration',
'price'
]
COLUMNS_LISTS["feedback_export"] = [
"comment",
Expand Down Expand Up @@ -2294,7 +2296,8 @@ An exhaustive list of form fields hideable in each module.
'cancellation_reason'
'place',
'preparation_duration',
'intervention_duration'
'intervention_duration',
'price'
],
HIDDEN_FORM_FIELDS["report"] = [
"email",
Expand Down
2 changes: 1 addition & 1 deletion geotrek/api/tests/test_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@
'description', 'description_teaser', 'districts', 'duration', 'email', 'end_date', 'external_id', 'geometry',
'meeting_point', 'start_time', 'meeting_time', 'end_time', 'name', 'organizer', 'organizer_id', 'capacity', 'pdf', 'place', 'portal',
'practical_info', 'provider', 'published', 'source', 'speaker', 'structure', 'target_audience', 'themes',
'type', 'update_datetime', 'url', 'uuid', 'website', 'cancelled', 'cancellation_reason', 'participant_number'
'type', 'update_datetime', 'url', 'uuid', 'website', 'cancelled', 'cancellation_reason', 'participant_number', 'price'
])

TOURISTIC_EVENT_PLACE_DETAIL_JSON_STRUCTURE = sorted([
Expand Down
2 changes: 1 addition & 1 deletion geotrek/api/v2/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ class Meta(TimeStampedSerializer.Meta):
'meeting_time', 'name', 'organizer', 'organizer_id', 'participant_number', 'pdf', 'place',
'portal', 'practical_info', 'provider', 'published', 'source', 'speaker',
'start_time', 'structure', 'target_audience', 'themes', 'type',
'url', 'uuid', 'website'
'url', 'uuid', 'website', 'price'
)

class TouristicEventPlaceSerializer(serializers.ModelSerializer):
Expand Down
3 changes: 2 additions & 1 deletion geotrek/tourism/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ class TouristicEventForm(CommonForm):
'start_time',
'end_time',
'duration',
'price',
'place',
'meeting_point',
'description_teaser',
Expand Down Expand Up @@ -132,7 +133,7 @@ class Meta:
'start_time', 'end_time', 'contact', 'email', 'website', 'organizer', 'speaker',
'type', 'accessibility', 'capacity', 'booking', 'target_audience',
'practical_info', 'approved', 'source', 'portal', 'geom', 'eid', 'structure', 'bookable',
'cancelled', 'cancellation_reason', 'preparation_duration', 'intervention_duration']
'cancelled', 'cancellation_reason', 'preparation_duration', 'intervention_duration', 'price']
model = TouristicEvent
widgets = {'geom': AutoLocateMapWidget()}

Expand Down
19 changes: 19 additions & 0 deletions geotrek/tourism/migrations/0050_touristicevent_price.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Generated by Django 3.2.23 on 2023-12-13 12:42

import django.core.validators
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('tourism', '0049_alter_touristiccontentcategory_color'),
]

operations = [
migrations.AddField(
model_name='touristicevent',
name='price',
field=models.FloatField(blank=True, help_text='0 mean free', null=True, validators=[django.core.validators.MinValueValidator(0)], verbose_name='Price'),
),
]
7 changes: 7 additions & 0 deletions geotrek/tourism/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,13 @@ class TouristicEvent(ZoningPropertiesMixin, AddPropertyMixin, PublishableMixin,
help_text=_("In hours (1.5 = 1 h 30, 24 = 1 day, 48 = 2 days)"),
validators=[MinValueValidator(0)]
)
price = models.FloatField(
null=True,
blank=True,
verbose_name=_("Price"),
help_text=_("0 mean free"),
validators=[MinValueValidator(0)]
)
objects = TouristicEventManager()
place = models.ForeignKey(TouristicEventPlace, related_name="touristicevents", verbose_name=_("Event place"), on_delete=models.PROTECT, null=True, blank=True, help_text=_("Select a place in the list or locate the event directly on the map"))
id_prefix = 'E'
Expand Down
1 change: 1 addition & 0 deletions geotrek/tourism/templates/tourism/sql/post_20_views.sql
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ SELECT a.id,
WHEN a.bookable IS TRUE THEN 'Yes'
END AS "Bookable {{ lang }}",
a.cancelled AS "Canceled",
a.price AS "Price",
{% for lang in MODELTRANSLATION_LANGUAGES %}
cr.label_{{ lang }} AS "Cancellation reason {{ lang }}",
{% endfor %}
Expand Down
1 change: 1 addition & 0 deletions geotrek/tourism/templates/tourism/sql/post_90_defaults.sql
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ ALTER TABLE tourism_touristiccontent ALTER COLUMN date_update SET DEFAULT now();
-- preparation_duration
-- intervention_duration
ALTER TABLE tourism_touristicevent ALTER COLUMN provider SET DEFAULT '';
--price


-- TouristicEventParticipantCount
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ <h3>{% trans "Attributes" %}</h3>
<th>{{ object|verbose:"duration" }}</th>
<td>{{ object.duration }}</td>
</tr>
<tr>
<th>{{ object|verbose:"price" }}</th>
<td>{{ object.price }}</td>
</tr>
<tr>
<th>{{ object|verbose:"meeting_point" }}</th>
<td>{{ object.meeting_point }}</td>
Expand Down
2 changes: 1 addition & 1 deletion geotrek/tourism/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ class TouristicEventFormatList(MapEntityFormat, TouristicEventList):
'review', 'published', 'publication_date',
'cities', 'districts', 'areas', 'approved', 'uuid',
'cancelled', 'cancellation_reason', 'total_participants', 'place',
'preparation_duration', 'intervention_duration',
'preparation_duration', 'intervention_duration', 'price'
]

def get_queryset(self):
Expand Down

0 comments on commit b7d9e2a

Please sign in to comment.