diff --git a/django_tex/core.py b/django_tex/core.py
index 1c4d409..676d813 100644
--- a/django_tex/core.py
+++ b/django_tex/core.py
@@ -16,7 +16,7 @@ def run_tex(source):
with open(filename, 'x', encoding='utf-8') as f:
f.write(source)
latex_interpreter = getattr(settings, 'LATEX_INTERPRETER', DEFAULT_INTERPRETER)
- latex_command = f'cd "{tempdir}" && {latex_interpreter} -interaction=batchmode {os.path.basename(filename)}'
+ latex_command = 'cd "{tempdir}" && {latex_interpreter} -interaction=batchmode {path}'.format(tempdir=tempdir, latex_interpreter=latex_interpreter, path=os.path.basename(filename))
process = run(latex_command, shell=True, stdout=PIPE, stderr=PIPE)
try:
if process.returncode == 1:
diff --git a/gestion/models.py b/gestion/models.py
index 9921418..e608ff5 100644
--- a/gestion/models.py
+++ b/gestion/models.py
@@ -47,12 +47,11 @@ class Product(models.Model):
def user_ranking(self, pk):
user = User.objects.get(pk=pk)
- consumptions = ConsumptionHistory.objects.filter(customer=user).filter(product=self)
- # add menu
- nb = 0
- for consumption in consumptions:
- nb += consumption.quantity
- return (user, nb)
+ consumptions = Consumption.objects.filter(customer=user).filter(product=self)
+ if consumptions:
+ return (user, consumptions[0].quantity)
+ else:
+ return (user, 0)
@property
def ranking(self):
diff --git a/preferences/views.py b/preferences/views.py
index e5a3f7a..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)
- 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 be760ba..949eecd 100644
--- a/templates/form.html
+++ b/templates/form.html
@@ -16,6 +16,7 @@
{% csrf_token %}
{{ form }}
+ {{ extra_html | safe }}
diff --git a/users/migrations/0002_auto_20190218_2231.py b/users/migrations/0002_auto_20190218_2231.py
new file mode 100644
index 0000000..338ab47
--- /dev/null
+++ b/users/migrations/0002_auto_20190218_2231.py
@@ -0,0 +1,23 @@
+# Generated by Django 2.1 on 2019-02-18 21:31
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('users', '0001_initial'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='historicalprofile',
+ name='date_verified',
+ field=models.DateTimeField(blank=True, null=True),
+ ),
+ migrations.AddField(
+ model_name='profile',
+ name='date_verified',
+ field=models.DateTimeField(blank=True, null=True),
+ ),
+ ]
diff --git a/users/migrations/0003_auto_20190219_1921.py b/users/migrations/0003_auto_20190219_1921.py
new file mode 100644
index 0000000..972914a
--- /dev/null
+++ b/users/migrations/0003_auto_20190219_1921.py
@@ -0,0 +1,21 @@
+# Generated by Django 2.1 on 2019-02-19 18:21
+
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('users', '0002_auto_20190218_2231'),
+ ]
+
+ operations = [
+ migrations.RemoveField(
+ model_name='historicalprofile',
+ name='date_verified',
+ ),
+ migrations.RemoveField(
+ model_name='profile',
+ name='date_verified',
+ ),
+ ]
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 0000000..f73fc59
Binary files /dev/null and b/users/templates/users/coope.png differ
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 @@