Create activities

This commit is contained in:
Yohann D'ANELLO 2020-03-27 01:31:54 +01:00
parent 213e5a8369
commit 45b14ed1bd
4 changed files with 36 additions and 12 deletions

12
apps/activity/forms.py Normal file
View File

@ -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__'

View File

@ -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):

View File

@ -0,0 +1,11 @@
{% extends "base.html" %}
{% load static %}
{% load i18n %}
{% load crispy_forms_tags %}
{% block content %}
<form method="post">
{% csrf_token %}
{{form|crispy}}
<button class="btn btn-primary" type="submit">{% trans "Submit" %}</button>
</form>
{% endblock %}

View File

@ -2,15 +2,9 @@
{% load render_table from django_tables2 %}
{% load i18n crispy_forms_tags%}
{% block content %}
<a class="btn btn-primary" href="{% url 'activity:activity_create' %}">{% trans 'New activity' %}</a>
<div class="row">
<div id="replaceable-content" class="col-6">
{% render_table table %}
</div>
</div>
<a class="btn btn-primary" href="{% url 'activity:activity_create' %}">{% trans 'New activity' %}</a>
{% endblock %}
{% block extrajavascript %}