From 19b4e6629bc20e50bfccf6e05aa040fa698c9223 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89lie=20Bouttier?= Date: Wed, 8 Nov 2017 00:18:46 +0100 Subject: [PATCH] admin: manage activities --- cfp/forms.py | 6 +++ cfp/models.py | 6 +++ cfp/templates/cfp/admin/activity_form.html | 33 +++++++++++++++ cfp/templates/cfp/admin/activity_list.html | 26 ++++++++++++ cfp/templates/cfp/admin/base.html | 7 ++-- cfp/urls.py | 3 ++ cfp/views.py | 31 +++++++++++++- locale/fr/LC_MESSAGES/django.mo | Bin 22602 -> 22833 bytes locale/fr/LC_MESSAGES/django.po | 45 +++++++++++++++------ 9 files changed, 140 insertions(+), 17 deletions(-) create mode 100644 cfp/templates/cfp/admin/activity_form.html create mode 100644 cfp/templates/cfp/admin/activity_list.html diff --git a/cfp/forms.py b/cfp/forms.py index 8e65a5b..603207c 100644 --- a/cfp/forms.py +++ b/cfp/forms.py @@ -326,6 +326,12 @@ class TagForm(OnSiteNamedModelForm): fields = ['name', 'color', 'inverted', 'public'] +class ActivityForm(OnSiteNamedModelForm): + class Meta: + model = Activity + fields = ['name', 'description'] + + class VolunteerForm(forms.ModelForm): def __init__(self, *args, **kwargs): self.conference = kwargs.pop('conference') diff --git a/cfp/models.py b/cfp/models.py index de85041..5e217a6 100644 --- a/cfp/models.py +++ b/cfp/models.py @@ -470,5 +470,11 @@ class Activity(models.Model): verbose_name = _('Activity') verbose_name_plural = _('Activities') + def get_absolute_url(self): + return reverse('activity-list') + + def get_filter_url(self): + return reverse('volunteer-list') + '?activity=' + self.slug + def __str__(self): return self.name diff --git a/cfp/templates/cfp/admin/activity_form.html b/cfp/templates/cfp/admin/activity_form.html new file mode 100644 index 0000000..6feb503 --- /dev/null +++ b/cfp/templates/cfp/admin/activity_form.html @@ -0,0 +1,33 @@ +{% extends 'cfp/admin/base.html' %} + +{% load bootstrap3 i18n %} + +{% block activitiestab %} class="active"{% endblock %} + +{% block css %} +{{ block.super }} +{{ form.media.css }} +{% endblock %} + +{% block content %} + +

+ {% if tag %} + {% trans "Edit activity" %} + {% else %} + {% trans "New activity" %} + {% endif %} +

+ +
+
+{% include "_form.html" %} +
+
+ +{% endblock %} + +{% block js_end %} +{{ block.super }} +{{ form.media.js }} +{% endblock %} diff --git a/cfp/templates/cfp/admin/activity_list.html b/cfp/templates/cfp/admin/activity_list.html new file mode 100644 index 0000000..4eb8fed --- /dev/null +++ b/cfp/templates/cfp/admin/activity_list.html @@ -0,0 +1,26 @@ +{% extends 'cfp/admin/base.html' %} + +{% load bootstrap3 cfp_tags i18n %} + +{% block activitiestab %} class="active"{% endblock %} + +{% block content %} + +

{% trans "Activities" %}

+ +

{% trans "Add an activity" %}

+ +

+ +{% endblock %} diff --git a/cfp/templates/cfp/admin/base.html b/cfp/templates/cfp/admin/base.html index f204984..fd40826 100644 --- a/cfp/templates/cfp/admin/base.html +++ b/cfp/templates/cfp/admin/base.html @@ -7,9 +7,10 @@ {{ block.super }}