diff --git a/docs/changelog.rst b/docs/changelog.rst index 0760c2e173..f230b2d2cf 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -5,6 +5,8 @@ CHANGELOG 2.102.1+dev (XXXX-XX-XX) ------------------------ +- Tourism : add price to TouristicEvent model - ref #3587 + 2.102.1 (2024-02-20) -------------------- diff --git a/docs/install/advanced-configuration.rst b/docs/install/advanced-configuration.rst index 27fef76484..cdfcfec679 100644 --- a/docs/install/advanced-configuration.rst +++ b/docs/install/advanced-configuration.rst @@ -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", @@ -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", @@ -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", diff --git a/geotrek/api/tests/test_v2.py b/geotrek/api/tests/test_v2.py index bad2747d2b..23393f56b0 100644 --- a/geotrek/api/tests/test_v2.py +++ b/geotrek/api/tests/test_v2.py @@ -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([ diff --git a/geotrek/api/v2/serializers.py b/geotrek/api/v2/serializers.py index d7205d5222..51c64a65b9 100644 --- a/geotrek/api/v2/serializers.py +++ b/geotrek/api/v2/serializers.py @@ -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): diff --git a/geotrek/tourism/forms.py b/geotrek/tourism/forms.py index a92670a311..de29723bd5 100644 --- a/geotrek/tourism/forms.py +++ b/geotrek/tourism/forms.py @@ -84,6 +84,7 @@ class TouristicEventForm(CommonForm): 'start_time', 'end_time', 'duration', + 'price', 'place', 'meeting_point', 'description_teaser', @@ -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()} diff --git a/geotrek/tourism/migrations/0050_touristicevent_price.py b/geotrek/tourism/migrations/0050_touristicevent_price.py new file mode 100644 index 0000000000..df51f4be01 --- /dev/null +++ b/geotrek/tourism/migrations/0050_touristicevent_price.py @@ -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'), + ), + ] diff --git a/geotrek/tourism/models.py b/geotrek/tourism/models.py index 5b685ba716..72fdb988d1 100644 --- a/geotrek/tourism/models.py +++ b/geotrek/tourism/models.py @@ -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' diff --git a/geotrek/tourism/templates/tourism/sql/post_20_views.sql b/geotrek/tourism/templates/tourism/sql/post_20_views.sql index 2718db6fb1..732beec8f6 100644 --- a/geotrek/tourism/templates/tourism/sql/post_20_views.sql +++ b/geotrek/tourism/templates/tourism/sql/post_20_views.sql @@ -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 %} diff --git a/geotrek/tourism/templates/tourism/sql/post_90_defaults.sql b/geotrek/tourism/templates/tourism/sql/post_90_defaults.sql index 24c7265d64..4a92ebc24d 100644 --- a/geotrek/tourism/templates/tourism/sql/post_90_defaults.sql +++ b/geotrek/tourism/templates/tourism/sql/post_90_defaults.sql @@ -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 diff --git a/geotrek/tourism/templates/tourism/touristicevent_detail_attributes.html b/geotrek/tourism/templates/tourism/touristicevent_detail_attributes.html index f23b02b5a7..0f40de100f 100644 --- a/geotrek/tourism/templates/tourism/touristicevent_detail_attributes.html +++ b/geotrek/tourism/templates/tourism/touristicevent_detail_attributes.html @@ -46,6 +46,10 @@