From 69b7f31eed5fa960799e9a987be77c1d31b5fbde Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Sun, 12 Apr 2020 02:30:48 +0200 Subject: [PATCH] Add lorem ipsum, update WEI --- apps/wei/apps.py | 1 - apps/wei/forms.py | 21 ++++++++++++ apps/wei/models.py | 3 +- apps/wei/tables.py | 2 +- apps/wei/urls.py | 3 +- apps/wei/views.py | 19 +++++++++-- templates/wei/weiclub_form.html | 11 ++++++ templates/wei/weiclub_info.html | 5 +-- templates/wei/weiclub_tables.html | 57 +++++++++++++++++++++++++++++++ 9 files changed, 112 insertions(+), 10 deletions(-) create mode 100644 apps/wei/forms.py create mode 100644 templates/wei/weiclub_form.html diff --git a/apps/wei/apps.py b/apps/wei/apps.py index f6332232..23351283 100644 --- a/apps/wei/apps.py +++ b/apps/wei/apps.py @@ -8,4 +8,3 @@ from django.utils.translation import gettext_lazy as _ class WeiConfig(AppConfig): name = 'wei' verbose_name = _('WEI') - diff --git a/apps/wei/forms.py b/apps/wei/forms.py new file mode 100644 index 00000000..48a0a00a --- /dev/null +++ b/apps/wei/forms.py @@ -0,0 +1,21 @@ +# Copyright (C) 2018-2020 by BDE ENS Paris-Saclay +# SPDX-License-Identifier: GPL-3.0-or-later + +from django import forms +from note_kfet.inputs import AmountInput, DatePickerInput + +from .models import WEIClub + + +class WEIForm(forms.ModelForm): + class Meta: + model = WEIClub + exclude = ('parent_club', 'require_memberships', 'membership_duration', ) + widgets = { + "membership_fee_paid": AmountInput(), + "membership_fee_unpaid": AmountInput(), + "membership_start": DatePickerInput(), + "membership_end": DatePickerInput(), + "date_start": DatePickerInput(), + "date_end": DatePickerInput(), + } diff --git a/apps/wei/models.py b/apps/wei/models.py index 08ebbc8c..326882ca 100644 --- a/apps/wei/models.py +++ b/apps/wei/models.py @@ -193,7 +193,7 @@ class WEIRegistration(models.Model): self.information_json = json.dumps(information) @property - def is_1A(self): + def is_first_year(self): """ We assume that a user is a new member if it not fully registered yet. """ @@ -236,4 +236,3 @@ class WEIMembership(Membership): related_name="membership", verbose_name=_("WEI registration"), ) - diff --git a/apps/wei/tables.py b/apps/wei/tables.py index 8cb23ef2..40d11b8d 100644 --- a/apps/wei/tables.py +++ b/apps/wei/tables.py @@ -4,7 +4,7 @@ import django_tables2 as tables from django.urls import reverse_lazy -from wei.models import WEIClub +from .models import WEIClub class WEITable(tables.Table): diff --git a/apps/wei/urls.py b/apps/wei/urls.py index 71af9cb7..f8981ed8 100644 --- a/apps/wei/urls.py +++ b/apps/wei/urls.py @@ -3,11 +3,12 @@ from django.urls import path -from .views import WEIListView, WEIDetailView +from .views import WEIListView, WEIDetailView, WEIUpdateView app_name = 'wei' urlpatterns = [ path('list/', WEIListView.as_view(), name="wei_list"), path('detail//', WEIDetailView.as_view(), name="wei_detail"), + path('update//', WEIUpdateView.as_view(), name="wei_update"), ] diff --git a/apps/wei/views.py b/apps/wei/views.py index eb66a74f..0ead8b94 100644 --- a/apps/wei/views.py +++ b/apps/wei/views.py @@ -6,17 +6,18 @@ from datetime import datetime from django.contrib.auth.mixins import LoginRequiredMixin from django.contrib.auth.models import User from django.db.models import Q -from django.views.generic import DetailView +from django.urls import reverse_lazy +from django.views.generic import DetailView, UpdateView from django_tables2 import SingleTableView - from member.models import Membership from member.tables import MembershipTable from note.models import Transaction from note.tables import HistoryTable from permission.backends import PermissionBackend from permission.views import ProtectQuerysetMixin -from wei.models import WEIClub +from .models import WEIClub +from .forms import WEIForm from .tables import WEITable @@ -68,3 +69,15 @@ class WEIDetailView(ProtectQuerysetMixin, LoginRequiredMixin, DetailView): .has_perm(self.request.user, "member.add_membership", empty_membership) return context + + +class WEIUpdateView(ProtectQuerysetMixin, LoginRequiredMixin, UpdateView): + """ + Update the information of the WEI. + """ + model = WEIClub + context_object_name = "club" + form_class = WEIForm + + def get_success_url(self): + return reverse_lazy("wei:wei_detail", kwargs={"pk": self.object.pk}) diff --git a/templates/wei/weiclub_form.html b/templates/wei/weiclub_form.html new file mode 100644 index 00000000..ea29d966 --- /dev/null +++ b/templates/wei/weiclub_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/wei/weiclub_info.html b/templates/wei/weiclub_info.html index 3c2f6eea..c47b9127 100644 --- a/templates/wei/weiclub_info.html +++ b/templates/wei/weiclub_info.html @@ -54,10 +54,11 @@ {% trans "Register 2A+" %} {% endif %} {% if ".change_"|has_perm:club %} - {% trans "Edit" %} + {% trans "Edit" %} {% endif %} {% url 'wei:wei_detail' club.pk as club_detail_url %} {%if request.path_info != club_detail_url %} {% trans 'View WEI' %} - {% endif %} + {% endif %} + diff --git a/templates/wei/weiclub_tables.html b/templates/wei/weiclub_tables.html index e937fbe9..bdd345c9 100644 --- a/templates/wei/weiclub_tables.html +++ b/templates/wei/weiclub_tables.html @@ -1,5 +1,62 @@ {% load render_table from django_tables2 %} {% load i18n %} +
+
+

WEI

+
+
+

LE WEI, c'est cool !

+ +

+ Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore + magna aliqua. Dapibus ultrices in iaculis nunc sed augue. In hendrerit gravida rutrum quisque non tellus orci + ac. Massa vitae tortor condimentum lacinia quis vel eros. Elit ut aliquam purus sit amet. Aliquam faucibus + purus in massa tempor. Quisque id diam vel quam elementum pulvinar etiam non. Condimentum id venenatis a + condimentum vitae sapien pellentesque habitant. Egestas congue quisque egestas diam in. Vestibulum rhoncus + est pellentesque elit ullamcorper. Massa sed elementum tempus egestas sed sed. Sapien pellentesque habitant + morbi tristique. Lectus vestibulum mattis ullamcorper velit sed ullamcorper morbi tincidunt ornare. Sed + adipiscing diam donec adipiscing. Leo integer malesuada nunc vel risus commodo viverra maecenas. +

+ +

+ Fusce id velit ut tortor pretium viverra suspendisse. Urna condimentum mattis pellentesque id nibh tortor id + aliquet. Vel facilisis volutpat est velit egestas dui. Turpis egestas sed tempus urna et pharetra pharetra + massa massa. Eget nunc scelerisque viverra mauris in. Etiam dignissim diam quis enim. Urna cursus eget nunc + scelerisque viverra mauris in aliquam sem. Amet porttitor eget dolor morbi non arcu risus quis. Ullamcorper + sit amet risus nullam eget felis. Ullamcorper eget nulla facilisi etiam dignissim diam quis. Enim nulla + aliquet porttitor lacus luctus accumsan tortor. Urna condimentum mattis pellentesque id nibh tortor id. + Feugiat in fermentum posuere urna nec. Risus nec feugiat in fermentum posuere urna nec tincidunt. Porttitor + massa id neque aliquam vestibulum morbi. Diam quis enim lobortis scelerisque. Ornare massa eget egestas + purus. Ut tortor pretium viverra suspendisse. Purus in mollis nunc sed. Tristique magna sit amet purus + gravida. +

+ +

+ Ut porttitor leo a diam sollicitudin tempor. Viverra nam libero justo laoreet sit amet cursus sit amet. + Lectus arcu bibendum at varius vel pharetra vel turpis nunc. Vivamus arcu felis bibendum ut tristique et + egestas quis ipsum. Parturient montes nascetur ridiculus mus mauris. A cras semper auctor neque vitae + tempus quam pellentesque. Netus et malesuada fames ac. Mauris in aliquam sem fringilla ut. Sapien + pellentesque habitant morbi tristique. Mauris sit amet massa vitae tortor condimentum. Sagittis + aliquam malesuada bibendum arcu vitae elementum curabitur vitae nunc. Amet consectetur adipiscing elit + duis tristique sollicitudin nibh sit. Nunc mattis enim ut tellus elementum. Sapien eget mi proin sed libero + enim. Pulvinar sapien et ligula ullamcorper. Nibh mauris cursus mattis molestie a iaculis at erat + pellentesque. Molestie at elementum eu facilisis. Velit sed ullamcorper morbi tincidunt. Quam vulputate + dignissim suspendisse in est ante. +

+ +

+ Id cursus metus aliquam eleifend mi. Eu turpis egestas pretium aenean pharetra magna ac. Faucibus ornare + suspendisse sed nisi lacus sed viverra tellus. Sed vulputate mi sit amet mauris commodo. Lacus laoreet non + curabitur gravida arcu ac. At ultrices mi tempus imperdiet nulla malesuada pellentesque elit eget. Fusce ut + placerat orci nulla pellentesque dignissim. Quis blandit turpis cursus in hac habitasse platea dictumst + quisque. Tellus id interdum velit laoreet id donec ultrices. Risus feugiat in ante metus dictum. Velit ut + tortor pretium viverra suspendisse. Lacus vel facilisis volutpat est velit egestas dui id. Nunc eget lorem + dolor sed viverra ipsum nunc aliquet bibendum. Varius quam quisque id diam vel quam. Orci dapibus ultrices + in iaculis. Neque gravida in fermentum et sollicitudin ac orci. +

+
+
+ {% if member_list.data %}