diff --git a/apps/activity/forms.py b/apps/activity/forms.py new file mode 100644 index 00000000..a36f85cd --- /dev/null +++ b/apps/activity/forms.py @@ -0,0 +1,12 @@ +# Copyright (C) 2018-2020 by BDE ENS Paris-Saclay +# SPDX-License-Identifier: GPL-3.0-or-later + +from django import forms + +from activity.models import Activity + + +class ActivityForm(forms.ModelForm): + class Meta: + model = Activity + fields = '__all__' diff --git a/apps/activity/views.py b/apps/activity/views.py index f6c3ad1d..224181ef 100644 --- a/apps/activity/views.py +++ b/apps/activity/views.py @@ -2,29 +2,36 @@ # SPDX-License-Identifier: GPL-3.0-or-later from django.views.generic import CreateView, DetailView, UpdateView, TemplateView +from django.utils.translation import gettext_lazy as _ from django_tables2.views import SingleTableView +from .forms import ActivityForm from .models import Activity class ActivityCreateView(CreateView): model = Activity - template_name = 'activity_create.html' + form_class = ActivityForm class ActivityListView(SingleTableView): model = Activity - template_name = 'activity_list.html' + + def get_context_data(self, **kwargs): + ctx = super().get_context_data(**kwargs) + + ctx['title'] = _("Upcoming activities") + + return ctx class ActivityDetailView(DetailView): model = Activity - template_name = 'activty_detail.html' class ActivityUpdateView(UpdateView): model = Activity - template_name = 'activity_update.html' + form_class = ActivityForm class ActivityEntryView(TemplateView): diff --git a/templates/activity/activity_form.html b/templates/activity/activity_form.html new file mode 100644 index 00000000..99c254e3 --- /dev/null +++ b/templates/activity/activity_form.html @@ -0,0 +1,11 @@ +{% extends "base.html" %} +{% load static %} +{% load i18n %} +{% load crispy_forms_tags %} +{% block content %} +
+{% csrf_token %} +{{form|crispy}} + +
+{% endblock %} diff --git a/templates/activity/activity_list.html b/templates/activity/activity_list.html index 7f682d4c..9092e2ca 100644 --- a/templates/activity/activity_list.html +++ b/templates/activity/activity_list.html @@ -2,15 +2,9 @@ {% load render_table from django_tables2 %} {% load i18n crispy_forms_tags%} {% block content %} + {% render_table table %} -{% trans 'New activity' %} - -
-
- {% render_table table %} -
-
- + {% trans 'New activity' %} {% endblock %} {% block extrajavascript %}