mirror of https://gitlab.crans.org/bde/nk20
Create activities
This commit is contained in:
parent
213e5a8369
commit
45b14ed1bd
|
@ -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__'
|
|
@ -2,29 +2,36 @@
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
from django.views.generic import CreateView, DetailView, UpdateView, TemplateView
|
from django.views.generic import CreateView, DetailView, UpdateView, TemplateView
|
||||||
|
from django.utils.translation import gettext_lazy as _
|
||||||
from django_tables2.views import SingleTableView
|
from django_tables2.views import SingleTableView
|
||||||
|
|
||||||
|
from .forms import ActivityForm
|
||||||
from .models import Activity
|
from .models import Activity
|
||||||
|
|
||||||
|
|
||||||
class ActivityCreateView(CreateView):
|
class ActivityCreateView(CreateView):
|
||||||
model = Activity
|
model = Activity
|
||||||
template_name = 'activity_create.html'
|
form_class = ActivityForm
|
||||||
|
|
||||||
|
|
||||||
class ActivityListView(SingleTableView):
|
class ActivityListView(SingleTableView):
|
||||||
model = Activity
|
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):
|
class ActivityDetailView(DetailView):
|
||||||
model = Activity
|
model = Activity
|
||||||
template_name = 'activty_detail.html'
|
|
||||||
|
|
||||||
|
|
||||||
class ActivityUpdateView(UpdateView):
|
class ActivityUpdateView(UpdateView):
|
||||||
model = Activity
|
model = Activity
|
||||||
template_name = 'activity_update.html'
|
form_class = ActivityForm
|
||||||
|
|
||||||
|
|
||||||
class ActivityEntryView(TemplateView):
|
class ActivityEntryView(TemplateView):
|
||||||
|
|
|
@ -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 %}
|
|
@ -2,15 +2,9 @@
|
||||||
{% load render_table from django_tables2 %}
|
{% load render_table from django_tables2 %}
|
||||||
{% load i18n crispy_forms_tags%}
|
{% load i18n crispy_forms_tags%}
|
||||||
{% block content %}
|
{% 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 %}
|
{% render_table table %}
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
<a class="btn btn-primary" href="{% url 'activity:activity_create' %}">{% trans 'New activity' %}</a>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block extrajavascript %}
|
{% block extrajavascript %}
|
||||||
|
|
Loading…
Reference in New Issue