Skip to content

Commit

Permalink
add price - ref GeotrekCE#3587
Browse files Browse the repository at this point in the history
  • Loading branch information
TheoLechemia committed Dec 14, 2023
1 parent 1b5c0be commit 031486f
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 4 deletions.
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 @@ -554,7 +554,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
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 031486f

Please sign in to comment.