From 4bb8d00c901030a5f9ed7c92818fa80d2646c963 Mon Sep 17 00:00:00 2001 From: Nanoy Date: Tue, 26 Feb 2019 23:18:53 +0100 Subject: [PATCH] Suppression de cotisations, informations utilisateurs --- preferences/views.py | 9 ++- templates/form.html | 2 +- users/migrations/0004_auto_20190226_2313.py | 25 +++++++ users/models.py | 13 ---- users/templates/users/bulletin.tex | 70 ++++++++++++++++++++ users/templates/users/coope.png | Bin 0 -> 5143 bytes users/templates/users/profile.html | 9 +-- users/urls.py | 4 +- users/views.py | 45 ++++++------- 9 files changed, 131 insertions(+), 46 deletions(-) create mode 100644 users/migrations/0004_auto_20190226_2313.py create mode 100644 users/templates/users/bulletin.tex create mode 100644 users/templates/users/coope.png diff --git a/preferences/views.py b/preferences/views.py index 5fd61a5..06fc628 100644 --- a/preferences/views.py +++ b/preferences/views.py @@ -6,6 +6,7 @@ from django.urls import reverse from django.contrib.auth.decorators import login_required, permission_required from django.http import HttpResponse from django.forms.models import model_to_dict +from django.http import Http404 from coopeV3.acl import active_required @@ -263,7 +264,11 @@ def get_config(request): """ Load the config and return it in a json format """ - gp,_ = GeneralPreferences.objects.get_or_create(pk=1).defer("statutes", "rules", "menu") - data = json.dumps(model_to_dict(gp)) + gp, _ = GeneralPreferences.objects.defer("statutes", "rules", "menu").get_or_create(pk=1) + gp_dict = model_to_dict(gp) + del gp_dict["statutes"] + del gp_dict["rules"] + del gp_dict["menu"] + data = json.dumps(gp_dict) return HttpResponse(data, content_type='application/json') \ No newline at end of file diff --git a/templates/form.html b/templates/form.html index 8f49a3e..949eecd 100644 --- a/templates/form.html +++ b/templates/form.html @@ -16,7 +16,7 @@ {% csrf_token %} {{ form }}
- {{ extra_html | safe }} + {{ extra_html | safe }}

diff --git a/users/migrations/0004_auto_20190226_2313.py b/users/migrations/0004_auto_20190226_2313.py new file mode 100644 index 0000000..bb26d11 --- /dev/null +++ b/users/migrations/0004_auto_20190226_2313.py @@ -0,0 +1,25 @@ +# Generated by Django 2.1 on 2019-02-26 22:13 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('users', '0003_auto_20190219_1921'), + ] + + operations = [ + migrations.AlterModelOptions( + name='cotisationhistory', + options={'verbose_name': 'Historique cotisation'}, + ), + migrations.RemoveField( + model_name='cotisationhistory', + name='valid', + ), + migrations.RemoveField( + model_name='historicalcotisationhistory', + name='valid', + ), + ] diff --git a/users/models.py b/users/models.py index b586df7..214894b 100644 --- a/users/models.py +++ b/users/models.py @@ -26,18 +26,6 @@ class CotisationHistory(models.Model): """ class Meta: verbose_name = "Historique cotisation" - permissions = ( - ("validate_cotisationhistory", "Peut (in)valider les cotisations"), - ) - - WAITING = 0 - VALID = 1 - INVALID = 2 - VALIDATION_CHOICES = ( - (WAITING, 'En attente de validation'), - (VALID, 'Validée'), - (INVALID, 'Invalidée'), - ) user = models.ForeignKey(User, on_delete=models.PROTECT, verbose_name="Client") amount = models.DecimalField(max_digits=5, decimal_places=2, verbose_name="Montant") duration = models.PositiveIntegerField(verbose_name="Durée") @@ -46,7 +34,6 @@ class CotisationHistory(models.Model): paymentMethod = models.ForeignKey(PaymentMethod, on_delete=models.PROTECT, verbose_name="Moyen de paiement") cotisation = models.ForeignKey(Cotisation, on_delete=models.PROTECT, verbose_name="Type de cotisation") coopeman = models.ForeignKey(User, on_delete=models.PROTECT, related_name="cotisation_made") - valid = models.IntegerField(choices=VALIDATION_CHOICES, default=WAITING) history = HistoricalRecords() class WhiteListHistory(models.Model): diff --git a/users/templates/users/bulletin.tex b/users/templates/users/bulletin.tex new file mode 100644 index 0000000..6c70bf5 --- /dev/null +++ b/users/templates/users/bulletin.tex @@ -0,0 +1,70 @@ +\documentclass[a4paper, 12pt]{article} +\usepackage[utf8]{inputenc} +\usepackage[french]{babel} +\usepackage{eurosym} +\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry} +\usepackage{tabularx} +\usepackage{longtable} +\usepackage{tabu} +\usepackage{fancyhdr} +\usepackage{natbib} +\usepackage{graphicx} + +\setlength{\parindent}{0pt} + +\pagestyle{fancy} +\renewcommand{\headrulewidth}{0pt} +\fancyhead[C]{\includegraphics[scale=0.3]{ {{- path -}} }} + +\begin{document} +\vspace*{0.3\baselineskip} +\begin{center} +\huge{Bulletin d'adhésion à l'association Coopé Technopôle Metz} +\end{center} +\vspace*{\baselineskip} +Je soussigné(e), {{user.first_name}} {{user.last_name}}, +\begin{itemize} +\item atteste sur l'honneur que les informations fournies à l'association Coopé Technopôle Metz sont correctes et que je n'ai jamais été enregistré dans l'association sous un autre nom / pseudonyme +\item joins l'association de mon plein gré +\item m'engage à respecter les statuts et le réglement intérieur de l'association +\item reconnais le but de l'assocation Coopé Technopôle Metz et atteste avoir pris conaissances des droits et des devoirs des membres de l'association +\item consent à ce que les données fournies à l'association, ainsi que mes autres données de compte (débit, crédit, solde et historique des transactions) soient stockées dans le logiciel de gestion et accessibles par tous les membres actifs de l'association, en particulier par le comité de direction +\end{itemize} + +\begin{flushright} +Fait à Metz, le {{user.date_joined.strftime('%d/%m/%Y')}} +\end{flushright} +Ce bulletin a été validé électroniquement par {{user.first_name}} {{user.last_name}} le {{user.date_joined.strftime('%d/%m/%Y %H:%M:%S')}}, heure de Paris. + +\newpage + +\begin{center} +\huge{Historique des cotisations à l'association} +\end{center} +\vspace*{\baselineskip} +\begin{longtabu}{|c|X|X|X|X|X|} +\hline +\# & Date & Montant & Durée & Moyen de paiement & Date de fin\\ +\hline +{% for cotisation in cotisations %} +{{cotisation.pk}} & {{cotisation.paymentDate.strftime('%d/%M/%Y %H:%M')}} & {{cotisation.amount}} \euro{} & {{cotisation.duration}} jour(s)& {{cotisation.paymentMethod}} & {{cotisation.endDate.strftime('%d/%M/%Y %H:%M')}} \\ +\hline +{% endfor %} +\end{longtabu} + +\newpage +\begin{center} +\huge{Attestation d'adhésion} +\end{center} +\vspace*{\baselineskip} +Le comité de direction de la Coopé Technopôle Metz atteste avoir reçu les cotisations de la part de {{user.first_name}} {{user.last_name}}. {% if user.profile.is_adherent %}Le comité atteste aussi que {{user.first_name}} {{user.last_name}} est membre adhérent de l'association au {{now.strftime('%d/%m/%Y')}}.{% endif %} + +{% if user.is_staff %} +\vspace*{\baselineskip} +Le membre est jugé comme membre actif par le comité de direction. +{% endif %} + +\vspace*{\baselineskip} + +Cette attestation est délivrée pour jouir des droits qui lui sont dus. +\end{document} diff --git a/users/templates/users/coope.png b/users/templates/users/coope.png new file mode 100644 index 0000000000000000000000000000000000000000..f73fc591e1beaea0fd42b8e7c4454cc910ac41aa GIT binary patch literal 5143 zcmV+y6zJ=TP)`)xK9udFz-=L5YGvsoM1dBi24NWK0!Mti2DSQ-xp~6 z1T6#mxWGCm=yiFDPKB)>7Jnp4W&uVL$3GIuk5xq$t3Lev`BOxR5=CGB`=8$@haV~P zZA<*AzHjl*fBk!3@*S(gk4y5@W*nP7N))yLtdIEn8h-*<*W@|+H%NYX6!`lic^+Oj zS3rfo@5ocH0PBaSS))W@Yu4oO;{|>{XvGg@&(Xh8ZV%7r_*xaZ-wyxV;QuZW>I?G! z_2K_X)U55AP7`HzrhgZQ4q0k^PNqCHRm>$-@{;Gk?AlNhtIQOOQYiq_C+2I4n%6E4 zj|6|u6i`nRHLE>@mk5j?4K4vvO`$qD&Yl|I=d;6J3B);p8YYq=_BK!3GW+lkZ0jHR z_m-N~QM2+pLux|_cWB;4aH|E{XO2o@ zduXSu>V<<|U_#9~BY<|THRS>hJoachvKDVVFEIJ`&z3qX-aSzW$S94lfVw zvM1w1-9>8r zZ&S|$s?Ma#C7f+)2qvs+G^cV?txkeDq@VBFoq$OsjoUy2f)!2N89L+F9l@D*J*XJ4 zemPw0+@p^s*8yBvGv5%}xb@RlSPuh3YS6oLgwq1n+cvJ9OrkE_5HO8rQOouSR&oR> z740k%?Qn4b;9P~=VWGiV0`A;Fzx@?`*}!4Njo^7pTC|s&_aVcoTqgjVSwQ=Axc)RE z8W^k&I+o)XNkDt)8}$WNa=mj=bCM(i+XGn9WJ*z!`h@fe;am-&!}FcGT#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p#d$mqCm|k z1lb>s+awXzDB_p$A5vSZk{EpSh5$(6J4!TBhcEvZU;x>TW`)0ay;lGL002ovPDHLk FV1jd5&yD~9 literal 0 HcmV?d00001 diff --git a/users/templates/users/profile.html b/users/templates/users/profile.html index fcdb7bf..e369a31 100644 --- a/users/templates/users/profile.html +++ b/users/templates/users/profile.html @@ -51,7 +51,7 @@
@@ -227,7 +230,6 @@ Date de paiement Moyen de paiement Date de fin - État Modération @@ -239,8 +241,7 @@ {{cotisation.paymentDate}} {{cotisation.paymentMethod}} {{cotisation.endDate}} - {{cotisation.valid}} - {% if perms.users.validate_cotisationHistory %} Valider Invalider{% endif %} + {% if perms.users.delete_cotisationhistory %} Supprimer{% endif %} {% endfor %} diff --git a/users/urls.py b/users/urls.py index 2201cae..51532e8 100644 --- a/users/urls.py +++ b/users/urls.py @@ -33,8 +33,7 @@ urlpatterns = [ path('non-admin-users-autocomplete', views.NonAdminUserAutocomplete.as_view(), name="non-admin-users-autocomplete"), path('getUser/', views.getUser, name="getUser"), path('addCotisationHistory/', views.addCotisationHistory, name="addCotisationHistory"), - path('validateCotisationHistory/', views.validateCotisationHistory, name="validateCotisationHistory"), - path('invalidateCotisationHistory/', views.invalidateCotisationHistory, name="invalidateCotisationHistory"), + path('deleteCotisationHistory/', views.deleteCotisationHistory, name="deleteCotisationHistory"), path('addWhiteListHistory/', views.addWhiteListHistory, name="addWhiteListHistory"), path('schoolsIndex', views.schoolsIndex, name="schoolsIndex"), path('createSchool', views.createSchool, name="createSchool"), @@ -45,4 +44,5 @@ urlpatterns = [ path('allMenus//', views.all_menus, name="allMenus"), path('exportCSV', views.export_csv, name="exportCSV"), path('switchActivateUser/', views.switch_activate_user, name="switchActivateUser"), + path('genUserInfos/', views.gen_user_infos, name="genUserInfos"), ] diff --git a/users/views.py b/users/views.py index 33d57ca..8868a27 100644 --- a/users/views.py +++ b/users/views.py @@ -9,12 +9,16 @@ from django.core.paginator import EmptyPage, PageNotAnInteger, Paginator from django.contrib.auth.decorators import login_required, permission_required from django.forms.models import model_to_dict from django.utils import timezone +from django.conf import settings import simplejson as json from datetime import datetime, timedelta from dal import autocomplete import csv +import os + +from django_tex.views import render_to_pdf from coopeV3.acl import admin_required, superuser_required, self_or_has_perm, active_required from .models import CotisationHistory, WhiteListHistory, School from .forms import CreateUserForm, LoginForm, CreateGroupForm, EditGroupForm, SelectUserForm, GroupsEditForm, EditPasswordForm, addCotisationHistoryForm, addCotisationHistoryForm, addWhiteListHistoryForm, SelectNonAdminUserForm, SelectNonSuperUserForm, SchoolForm, ExportForm @@ -156,7 +160,7 @@ def profile(request, pk): """ user = get_object_or_404(User, pk=pk) self = request.user == user - cotisations = CotisationHistory.objects.filter(user=user) + cotisations = CotisationHistory.objects.filter(user=user).order_by('-paymentDate') whitelists = WhiteListHistory.objects.filter(user=user) reloads = Reload.objects.filter(customer=user).order_by('-date')[:5] consumptionsChart = Consumption.objects.filter(customer=user) @@ -509,7 +513,17 @@ def switch_activate_user(request, pk): user.save() messages.success(request, "Le statut de l'utilisateur a bien été changé") return HttpResponseRedirect(request.META.get('HTTP_REFERER', '/')) - + +@active_required +@login_required +@permission_required('auth.view_user') +def gen_user_infos(request, pk): + user= get_object_or_404(User, pk=pk) + cotisations = CotisationHistory.objects.filter(user=user).order_by('-paymentDate') + now = datetime.now() + path = os.path.join(settings.BASE_DIR, "users/templates/users/coope.png") + return render_to_pdf(request, 'users/bulletin.tex', {"user": user, "now": now, "cotisations": cotisations, "path":path}, filename="bulletin_" + user.first_name + "_" + user.last_name + ".pdf") + ########## Groups ########## @active_required @@ -889,39 +903,22 @@ def addCotisationHistory(request, pk): @active_required @login_required -@permission_required('users.validate_cotisationhistory') -def validateCotisationHistory(request, pk): +@permission_required('users.delete_cotisationhistory') +def deleteCotisationHistory(request, pk): """ - Validate the requested :model:`users.CotisationHistory` + Delete the requested :model:`users.CotisationHistory` ``pk`` The primary key of the :model:`users.CotisationHistory` """ cotisationHistory = get_object_or_404(CotisationHistory, pk=pk) - cotisationHistory.valid = CotisationHistory.VALID - cotisationHistory.save() - messages.success(request, "La cotisation a bien été validée") - return HttpResponseRedirect(request.META.get('HTTP_REFERER')) - -@active_required -@login_required -@permission_required('users.validate_cotisationhistory') -def invalidateCotisationHistory(request, pk): - """ - Invalidate the requested :model:`users.CotisationHistory` - - ``pk`` - The primary key of the :model:`users.CotisationHistory` - """ - cotisationHistory = get_object_or_404(CotisationHistory, pk=pk) - cotisationHistory.valid = CotisationHistory.INVALID - cotisationHistory.save() user = cotisationHistory.user user.profile.cotisationEnd = user.profile.cotisationEnd - timedelta(days=cotisationHistory.duration) if(cotisationHistory.paymentMethod.affect_balance): user.profile.debit -= cotisationHistory.cotisation.amount user.save() - messages.success(request, "La cotisation a bien été invalidée") + cotisationHistory.delete() + messages.success(request, "La cotisation a bien été supprimée") return HttpResponseRedirect(request.META.get('HTTP_REFERER')) ########## Whitelist ##########