From 78a1744cc03bc604ed4941d50d5b30c141ff0de2 Mon Sep 17 00:00:00 2001 From: Emilie Date: Mon, 7 Nov 2016 16:31:22 +0100 Subject: [PATCH] Event : add price description --- app/organization/agenda/admin.py | 12 ++++++++ .../migrations/0019_eventpricedescription.py | 30 +++++++++++++++++++ app/organization/agenda/models.py | 9 ++++++ app/organization/agenda/translation.py | 12 ++++++++ .../agenda/includes/event_metainfo.html | 6 ++-- 5 files changed, 66 insertions(+), 3 deletions(-) create mode 100644 app/organization/agenda/migrations/0019_eventpricedescription.py diff --git a/app/organization/agenda/admin.py b/app/organization/agenda/admin.py index aa86bf51..7c332f4f 100644 --- a/app/organization/agenda/admin.py +++ b/app/organization/agenda/admin.py @@ -61,6 +61,16 @@ class EventRelatedTitleAdmin(TranslationTabularInline): model = EventRelatedTitle +class EventPriceDescriptionAdmin(TranslationTabularInline): + + model = EventPriceDescription + + +class CustomEventPriceAdmin(BaseTranslationModelAdmin): + + inlines = [EventPriceDescriptionAdmin,] + + class DynamicContentEventInline(TabularDynamicInlineAdmin): model = DynamicContentEvent @@ -111,8 +121,10 @@ class EventTrainingLevelAdmin(BaseTranslationModelAdmin): admin.site.unregister(Event) +admin.site.unregister(EventPrice) admin.site.unregister(EventCategory) admin.site.register(EventPublicType, EventPublicTypeAdmin) admin.site.register(EventTrainingLevel, EventTrainingLevelAdmin) admin.site.register(Event, CustomEventAdmin) admin.site.register(EventCategory, CustomEventCategoryAdmin) +admin.site.register(EventPrice, CustomEventPriceAdmin) diff --git a/app/organization/agenda/migrations/0019_eventpricedescription.py b/app/organization/agenda/migrations/0019_eventpricedescription.py new file mode 100644 index 00000000..d31808f1 --- /dev/null +++ b/app/organization/agenda/migrations/0019_eventpricedescription.py @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.10 on 2016-11-07 15:14 +from __future__ import unicode_literals + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('mezzanine_agenda', '0015_auto_20161021_1937'), + ('organization-agenda', '0018_auto_20161104_1820'), + ] + + operations = [ + migrations.CreateModel( + name='EventPriceDescription', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('description', models.TextField(blank=True, null=True, verbose_name='description')), + ('description_fr', models.TextField(blank=True, null=True, verbose_name='description')), + ('description_en', models.TextField(blank=True, null=True, verbose_name='description')), + ('event_price', models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='event_price_description', to='mezzanine_agenda.EventPrice', verbose_name='event_price_description')), + ], + options={ + 'verbose_name': 'Additionnal description', + }, + ), + ] diff --git a/app/organization/agenda/models.py b/app/organization/agenda/models.py index e0029aa4..ba70279c 100644 --- a/app/organization/agenda/models.py +++ b/app/organization/agenda/models.py @@ -118,3 +118,12 @@ class DynamicContentEvent(DynamicContent, Orderable): class Meta: verbose_name = 'Dynamic Content Event' + + +class EventPriceDescription(models.Model): + + event_price = models.OneToOneField(EventPrice, verbose_name=_('event_price_description'), related_name='event_price_description', blank=True, null=True, on_delete=models.SET_NULL) + description = models.TextField(_('description'), blank=True, null=True) + + class Meta: + verbose_name = 'Additionnal description' diff --git a/app/organization/agenda/translation.py b/app/organization/agenda/translation.py index a8584341..45cfb599 100644 --- a/app/organization/agenda/translation.py +++ b/app/organization/agenda/translation.py @@ -73,3 +73,15 @@ class EventRelatedTitleTranslationOptions(TranslationOptions): class DynamicContentEventTranslationOptions(TranslationOptions): fields = () + + +@register(EventPriceDescription) +class EventPriceDescriptionTranslationOptions(TranslationOptions): + + fields = ('description', ) + + +@register(EventPrice) +class EventPriceTranslationOptions(TranslationOptions): + + fields = () diff --git a/app/templates/agenda/includes/event_metainfo.html b/app/templates/agenda/includes/event_metainfo.html index 123132b9..9234d523 100644 --- a/app/templates/agenda/includes/event_metainfo.html +++ b/app/templates/agenda/includes/event_metainfo.html @@ -47,10 +47,10 @@
{% trans "Prices" %}

{% endif %} - {% if price.unit %} - {{ price.unit }}: + {% if price.event_price_description.description %} + {{ price.event_price_description.description }} : {% endif %} - {{ price.value|floatformat:"-2" }} €{% if not forloop.last %}
{% endif %} + {{ price.value|floatformat:"-2" }} {{ price.unit }} {% if not forloop.last %}
{% endif %} {% if forloop.last %}

{% endif %} -- 2.39.5