mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-16 08:23:12 +00:00
[Printer] Send information on how to pick up printings.
Sorry, for now it is strongly based on Cr@ns infrastructure, but it won't last, don't worry.
This commit is contained in:
parent
cf159f79ae
commit
5213ade25c
3 changed files with 85 additions and 1 deletions
30
printer/templates/printer/email_printer
Normal file
30
printer/templates/printer/email_printer
Normal file
|
@ -0,0 +1,30 @@
|
|||
=== English version below ===
|
||||
|
||||
Bonjour {{name}},
|
||||
|
||||
Vos impressions ont été envoyées à l'imprimante située {{printer_access_fr}}, et vous pourrez les récupérer d'ici quelques minutes.
|
||||
|
||||
{% if digicode %}
|
||||
Pour ouvrir la porte du local, veuillez utiliser le code suivant {{code}}. Il est valide jusqu'à {{end_validity}}.
|
||||
{% endif %}
|
||||
|
||||
En cas de question, n’hésitez pas à nous contacter par mail à {{contact_mail}}.
|
||||
|
||||
Cordialement,
|
||||
L’équipe de {{asso_name}}
|
||||
|
||||
|
||||
=== English version ===
|
||||
|
||||
Dear {{name}},
|
||||
|
||||
Your files have been successfuly sent to the printer located {{printer_acces_en}}, and you will soon be able to pick them up.
|
||||
|
||||
{% if digicode %}
|
||||
To open the door of the printer room, please use the following code {{code}}. It is valid until {{end_validity}}.
|
||||
{% endif %}
|
||||
|
||||
Should you need extra information, you can email us at {{contact_mail}}.
|
||||
|
||||
Best regards,
|
||||
{{ asso_name }}'s team
|
|
@ -3,6 +3,15 @@ import subprocess
|
|||
import os
|
||||
import unidecode
|
||||
|
||||
from django.template.loader import get_template
|
||||
from django.core.mail import EmailMessage
|
||||
|
||||
from preferences.models import OptionalPrinter, GeneralOption, AssoOption
|
||||
|
||||
from numpy.random import randint
|
||||
|
||||
import datetime
|
||||
|
||||
def user_printing_path(instance, filename):
|
||||
"""
|
||||
Defines the path where will be uploaded the files
|
||||
|
@ -54,3 +63,47 @@ def pdfbook(file_path):
|
|||
'-o', newfile,
|
||||
])
|
||||
return newfile
|
||||
|
||||
|
||||
def gen_code():
|
||||
code = randint(10**9, 10**10-1)
|
||||
while code % 1437 != 38:
|
||||
code = randint(10**9, 10**10-1)
|
||||
return (str(code) + '#')
|
||||
|
||||
|
||||
def send_mail_printer(client):
|
||||
"""Sends an email to the client explaning how to get the printings"""
|
||||
|
||||
template = get_template('printer/email_printer')
|
||||
code = gen_code()
|
||||
|
||||
|
||||
printer_access_fr = "au quatrième (4) étage du bâtiment J (code B7806)"
|
||||
printer_access_en = "on fourth (4th) floor of building J (code B7806)"
|
||||
digicode = True
|
||||
|
||||
end_validity = datetime.datetime.now() + datetime.timedelta(3)
|
||||
end_validity = str(end_validity.date())
|
||||
|
||||
ctx = {
|
||||
'name': "{} {}".format(
|
||||
client.name,
|
||||
client.surname
|
||||
),
|
||||
'printer_access_fr' : printer_access_fr,
|
||||
'printer_access_en' : printer_access_en,
|
||||
'digicode' : digicode,
|
||||
'code' : code,
|
||||
'end_validity' : end_validity,
|
||||
'contact_mail': AssoOption.get_cached_value('contact'),
|
||||
'asso_name': AssoOption.get_cached_value('name')
|
||||
}
|
||||
|
||||
mail = EmailMessage(
|
||||
'Information',
|
||||
template.render(ctx),
|
||||
GeneralOption.get_cached_value('email_from'),
|
||||
[client.get_mail],
|
||||
)
|
||||
mail.send()
|
||||
|
|
|
@ -18,7 +18,7 @@ from users.models import User
|
|||
|
||||
from . import settings
|
||||
|
||||
from .utils import pdfinfo
|
||||
from .utils import pdfinfo, send_mail_printer
|
||||
|
||||
from .models import (
|
||||
JobWithOptions,
|
||||
|
@ -197,6 +197,7 @@ def payment(request):
|
|||
))
|
||||
|
||||
def success(request):
|
||||
send_mail_printer(request.user)
|
||||
return form(
|
||||
{},
|
||||
'printer/success.html',
|
||||
|
|
Loading…
Reference in a new issue