mirror of
https://gitlab.crans.org/bde/nk20
synced 2024-12-22 23:42:25 +00:00
Create activities
This commit is contained in:
parent
213e5a8369
commit
45b14ed1bd
12
apps/activity/forms.py
Normal file
12
apps/activity/forms.py
Normal 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__'
|
@ -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):
|
||||
|
11
templates/activity/activity_form.html
Normal file
11
templates/activity/activity_form.html
Normal 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 %}
|
@ -2,15 +2,9 @@
|
||||
{% load render_table from django_tables2 %}
|
||||
{% load i18n crispy_forms_tags%}
|
||||
{% block content %}
|
||||
{% render_table table %}
|
||||
|
||||
<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 %}
|
||||
|
Loading…
Reference in New Issue
Block a user