From 94ea27b6154c2123c26846ccfe77608b5f6a55bb Mon Sep 17 00:00:00 2001 From: "holger.trampe" Date: Fri, 15 Jan 2021 18:13:25 +0100 Subject: [PATCH] Standard Gruppen weiter ausgebaut, Bug mit den Punkten im Editor gefixed --- dasettings/views.py | 44 ++++- dump.rdb | Bin 15530 -> 18079 bytes news/templates/news/news_update.html | 1 + .../organizer/passwords_content.html | 1 - .../templates/standards/standards_single.html | 85 ++++++++- standards/urls.py | 2 +- standards/views.py | 34 ++++ users/templates/users/base.html | 10 +- users/templates/users/newbill_mail.html | 2 +- users/templates/users/rechnung_mail.html | 177 ++++++++++++++++++ users/templates/users/register_mail.html | 5 +- users/views.py | 103 ++++++---- 12 files changed, 410 insertions(+), 54 deletions(-) create mode 100644 users/templates/users/rechnung_mail.html diff --git a/dasettings/views.py b/dasettings/views.py index ca8f6b1..62f67bb 100644 --- a/dasettings/views.py +++ b/dasettings/views.py @@ -36,6 +36,13 @@ import json from django.conf import settings # import the settings file from PIL import Image +''' MAIL ''' +from django.core.mail import EmailMessage +from django.core.mail import EmailMultiAlternatives +import io as BytesIO +import base64 +from django.http import HttpResponse + def randomString(stringLength=10): """Generate a random string of fixed length """ letters = string.ascii_lowercase @@ -300,7 +307,7 @@ from django.http import HttpResponse def GetBillPDF(request, pk): bill = AgencyBills.objects.get(pk=pk) # Sicherheitscheck, ob der angefragte User zur Agentur gehört und das Recht hat, Agenturinfos zu bearbeiten - if (bill.agency == request.user.profile.agency and request.user.has_perm("users.agencyinfo")) or request.user.is_staff: + if ((bill.agency == request.user.profile.agency and request.user.has_perm("users.agencyinfo")) or request.user.is_staff): headers = { 'Authorization': 'Bearer ' + settings.LEX_API, 'Content-Type': 'application/json', @@ -1817,7 +1824,40 @@ class BillPlanUpdate(UpdateView): mail_to_send = self.request.user.profile.agency.payment_address msg_html = render_to_string('users/newbill_mail.html', {}) - send_mail('Digitale Agentur | Rechnung', 'Sehr geehrte Nutzer, es wurde eine Rechnung für Ihre digitale Agentur erstellt. Diese können Sie unter Einstellungen, Abrechnung einsehen.','noreply@digitale-agentur.com',[mail_to_send],html_message=msg_html,fail_silently=True) + + # BCC Mail with Object - NICHT DEN IMPORT VERGESSEN!!! + email = EmailMultiAlternatives( + 'Digitale Agentur | Rechnung ' + str(response_text["voucherNumber"]), + 'Sehr geehrte Nutzer, hiermit erhalten Sie eine neue Rechnung für die Digitale Agentur. Ihr Team der Digitalen Agentur', + 'noreply@digitale-agentur.com', + [mail_to_send], + ['info@digitale-agentur.com'], + headers={}, + ) + + headers = { + 'Authorization': 'Bearer ' + settings.LEX_API, + 'Content-Type': 'application/json', + 'Accept': 'application/json', + } + + lexdata = { + "renderType" : "pdf" + } + + r_final = requests.get("https://api.lexoffice.io/v1/invoices/"+newbill_id+"/document", data=json_data, headers=headers) + json.loads(r_final.text) + + base64String = requests.get("https://api.lexoffice.io/v1/files/"+json.loads(r_final.text)["documentFileId"]+"/", data=json_data, headers=headers) + + content = base64.b64decode(base64String.text) + + msg_html = render_to_string('users/newbill_mail.html', {}) + email.attach_alternative(msg_html, "text/html") + email.attach('Rechnung_' + str(response_text["voucherNumber"]) + '.pdf', content, "application/pdf") + email.send() + + #send_mail('Digitale Agentur | Rechnung', 'Sehr geehrte Nutzer, es wurde eine Rechnung für Ihre digitale Agentur erstellt. Diese können Sie unter Einstellungen, Abrechnung einsehen.','noreply@digitale-agentur.com',[mail_to_send],html_message=msg_html,fail_silently=True) else: messages.warning(self.request, f"Fehlercode "+str(r.status_code)+". Es wurde keine Rechnung erstellt. Bitte wenden Sie sich an den Support!") diff --git a/dump.rdb b/dump.rdb index fe98d324b0d04fee72cd13cf7cc74c313887fd06..971a776fa48614b421d79407bef4c95b46e95bf4 100644 GIT binary patch literal 18079 zcmb`P3DBNZeZ@nWD3L`YSgbA94^3GVy!%2GQ*l9Sp@Jf~1nwFVS<-~Xq85v?R4q#t z5Ks`s!M378t*C$^SXW#?r3@8{L#+fg2v}5PpuY#EGvv)ozqyl-%s|L;-upcF-v4sW z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TvWdItH0VbrO@&I zJ2{lr(7WUiu<{|z-e@3hX`G2oZc^x)hj&Z^Jq44*85M!MH-voxh1SyW$>+g!q + {% else %}

Das Modul News wurde in ihrer Agentur deaktiviert.

{% endif %} diff --git a/organizer/templates/organizer/passwords_content.html b/organizer/templates/organizer/passwords_content.html index b7e8a73..d5a9096 100644 --- a/organizer/templates/organizer/passwords_content.html +++ b/organizer/templates/organizer/passwords_content.html @@ -133,7 +133,6 @@ var workingpass = ""; //GROUPS function showGroupChangeModal(tochangeid){ - console.log("HI!"); $("#changeGroupOfPass").modal("toggle"); $(".groupclass").attr("checked", false); workingpass = tochangeid; diff --git a/standards/templates/standards/standards_single.html b/standards/templates/standards/standards_single.html index 65de2dd..d5ffc01 100644 --- a/standards/templates/standards/standards_single.html +++ b/standards/templates/standards/standards_single.html @@ -94,7 +94,7 @@ {% endif %} - {% if standard.authority_group.count > 0 or standard.executor_group.count > 0 or standard.representative_group.count > 0 %} + {% if standard.authority_group.count > 0 or standard.executor_group.count > 0 or standard.representative_group.count > 0 %}
Gruppen
@@ -103,7 +103,7 @@ {% if standard.executor_group.count > 0 %} Ausführende
{% for g in standard.executor_group.all %} - {{g.agencygroupname}}{% if forloop.counter < standard.executor_group.count%} | {% endif %} + {{g.agencygroupname}}{% if forloop.counter < standard.executor_group.count%} | {% endif %} {% endfor %}
{% endif %} @@ -111,7 +111,7 @@ {% if standard.representative_group.count > 0 %} Vertretende
{% for g in standard.representative_group.all %} - {{g.agencygroupname}}{% if forloop.counter < standard.representative_group.count%} | {% endif %} + {{g.agencygroupname}}{% if forloop.counter < standard.representative_group.count%} | {% endif %} {% endfor %}
{% endif %} @@ -120,7 +120,7 @@ {% if standard.authority_group.count > 0 %} Verantwortliche
{% for g in standard.authority_group.all %} - {{g.agencygroupname}}{% if forloop.counter < standard.authority_group.count%} | {% endif %} + {{g.agencygroupname}}{% if forloop.counter < standard.authority_group.count%} | {% endif %} {% endfor %}
{% endif %} @@ -318,6 +318,31 @@ {% endfor %} + + + + + + + -{% endblock content %} \ No newline at end of file +{% endblock content %} + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/standards/urls.py b/standards/urls.py index de9f11d..ebc3723 100644 --- a/standards/urls.py +++ b/standards/urls.py @@ -24,7 +24,7 @@ urlpatterns = [ path('standard//task', views.StandardTask, name="standard-task"), path('standardsagn/', views.StandardFromAgn, name="standard-agn"), path('standardcopy/', views.CopyStandard, name="standard-copyagn"), - + path('loadaggroupm/', views.LoadAGGroupMembers, name="standard-loadaggroupmembers"), ] \ No newline at end of file diff --git a/standards/views.py b/standards/views.py index 06edd3a..1c1e8bd 100644 --- a/standards/views.py +++ b/standards/views.py @@ -618,6 +618,40 @@ def StandardAdd(request, id=False): return render(request, 'standards/standards_add.html', context) +''' + Gibt die Daten der Agenturgruppen zurück, welche in diesem Standard sind. +''' +@login_required +def LoadAGGroupMembers(request): + if request.method == "GET": + + aggroupid = request.GET['aggroup'] + try: + aggroup = AgencyGroup.objects.get(pk=aggroupid) + except: + return JsonResponse({"status" : "err", "message" : "Fehler! Diese Gruppe gibt es nicht."}) + + members_string = "" + if request.user.profile.agency == aggroup.agency: + members = User.objects.filter(groups__name=aggroup.group.name) + counter = 0 + for member in members: + members_string += member.get_full_name() + counter += 1 + + if counter+1 <= len(members): + members_string += ", " + + if counter == 0: + members_string = "Gruppe hat keine Mitglieder." + + else: + return JsonResponse({"status" : "err", "message" : "Sie haben auf diese Gruppe keinen Zugriff!"}) + return JsonResponse({"status" : "ok", "aggroupname" : aggroup.agencygroupname, "members" : members_string}) + else: + return JsonResponse({"status" : "err", "message" : "Allgemeiner Fehler."}) + + # Funktion zum versenden einer Mail inkl. TEmplate def sendMailNoti(notificationtext, user_touched, linktarget=""): username = user_touched.first_name + " " + user_touched.last_name diff --git a/users/templates/users/base.html b/users/templates/users/base.html index b59cb77..bed69c1 100644 --- a/users/templates/users/base.html +++ b/users/templates/users/base.html @@ -579,7 +579,15 @@ {% endif %}
- + + diff --git a/users/templates/users/newbill_mail.html b/users/templates/users/newbill_mail.html index 523eaf3..595f771 100644 --- a/users/templates/users/newbill_mail.html +++ b/users/templates/users/newbill_mail.html @@ -124,7 +124,7 @@

Sehr geehrte Nutzer,

-

es wurde eine neue Rechnung für Ihre digitale Agentur erstellt. Sie können die Rechnung unter Einstellungen, Abrechnung einsehen.

+

es wurde eine neue Rechnung für Ihre digitale Agentur erstellt. Sie können die Rechnung unter Einstellungen, Abrechnung einsehen oder im Anhang herunterladen.

Mit freundlichen Grüßen

Ihr Team von Digitale Agentur

diff --git a/users/templates/users/rechnung_mail.html b/users/templates/users/rechnung_mail.html new file mode 100644 index 0000000..61ab629 --- /dev/null +++ b/users/templates/users/rechnung_mail.html @@ -0,0 +1,177 @@ + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + + + + + +
+ +
+ + + + + + + + + + + + + + + + +
+

+

+ +
+
+

Digitale Agentur | Rechnung RECHNUNGSNUMMER

+
+
+
+

Hallo VORNAME UND NACHNAME,

im Anhang erhalten Sie die Rechnung mit der Rechnungsnummer RECHNUNGSNUMMER für die Nutzung der Digitalen Agentur.

Sollten Sie Fragen haben, melden Sie sich jederzeit per E-Mail an support@digitale-agentur.com.

Mit freundlichen Grüßen

+

Ihr Team von Digitale Agentur

+
+
+

+

+ +
+
Bitte antworten Sie nicht auf diese E-Mail. Diese Adresse ist nicht für den Empfang für E-Mails eingerichtet. Sie können uns über die E-Mail-Adresse support@digitale-agentur.com oder über das Support-Formular in Ihrer Digitalen Agentur kontaktieren.
+
+
+ +
+
+ +
+ + + \ No newline at end of file diff --git a/users/templates/users/register_mail.html b/users/templates/users/register_mail.html index d61b845..415d970 100644 --- a/users/templates/users/register_mail.html +++ b/users/templates/users/register_mail.html @@ -123,8 +123,9 @@
-

Hallo {{username}},

Ihre Agentur wurde erstellt. Sie können sich nun hier anmelden und Ihre Agentur gestalten: -

https://app.digitale-agentur.com


Ihr Benutzername: {{ username_log }}
Weitere Informationen erhalten Sie in unserem Wiki https://digitale-agentur.com/ oder per E-Mail an support@digitale-agentur.com!

+

Hallo {{username}},

Ihre Agentur wurde erstellt. Sie können sich nun mit Ihrer E-Mailadresse hier anmelden und Ihre Agentur gestalten: +

https://app.digitale-agentur.com

+
Weitere Informationen erhalten Sie in unserem Wiki https://digitale-agentur.com/ oder per E-Mail an support@digitale-agentur.com!

Mit freundlichen Grüßen

Ihr Team von Digitale Agentur

diff --git a/users/views.py b/users/views.py index 026710f..ee70588 100644 --- a/users/views.py +++ b/users/views.py @@ -58,6 +58,13 @@ from ics import Calendar, Event import base64 from django.contrib.auth import authenticate +''' MAIL ''' +from django.core.mail import EmailMessage +from django.core.mail import EmailMultiAlternatives +import io as BytesIO +import base64 +from django.http import HttpResponse + def getICSFile(request, ag): if 'HTTP_AUTHORIZATION' in request.META: auth = request.META['HTTP_AUTHORIZATION'].split() @@ -636,8 +643,6 @@ class AgencyCreateView(CreateView): return super().form_valid(form) -#from django.core.mail import EmailMessage -#from django.core.mail import EmailMultiAlternatives from auditlog.models import LogEntry @@ -665,26 +670,12 @@ def showUserLog(request, pk): context = {} return render(request, 'users/userlog_forbidden.html', context) + + @login_required def dashboard(request): # UPDATE FUNCTIONS BY NEW MODEL-CHANGES FOR COPIEN SOME DATA toUpdate(request) - ''' - # BCC Mail with Object - NICHT DEN IMPORT VERGESSEN!!! - email = EmailMultiAlternatives( - 'Subject', - 'Bitte aktivieren Sie HTML in Ihrem Mailprogramm.', - 'noreply@digitale-agentur.com', - ['mail@holgertrampe.de'], - ['htrampe@gmail.com'], - #reply_to=['noreply@digitale-agentur.com'], - headers={}, - ) - email.attach_alternative("

Lobbt der Shit!


", "text/html") - email.send() - ''' - - #storageinfo = sys.getfilesystemencoding() @@ -1860,28 +1851,61 @@ def cronactionsbill(request, code): r = requests.post("https://api.lexoffice.io/v1/invoices/?finalize=true", data=json_data, headers=headers) if(r.status_code == 201): - messages.success(request, f"Rechnung erstellt!") - # Response in JSON umwandeln - - response_text = json.loads(r.text) - newbill_id = response_text["id"] + try: + response_text = json.loads(r.text) + newbill_id = response_text["id"] - # OrganizationId berechnen, wenn noch nicht gesetzt - r = requests.get("https://api.lexoffice.io/v1/invoices/" + response_text["id"], data=json_data, headers=headers) - response_text = json.loads(r.text) + # OrganizationId berechnen, wenn noch nicht gesetzt + r = requests.get("https://api.lexoffice.io/v1/invoices/" + response_text["id"], data=json_data, headers=headers) + response_text = json.loads(r.text) - newbill = AgencyBills(agency=agency, lexid=newbill_id, billtype="invoice", billnumber=response_text["voucherNumber"], billstatus=response_text["voucherStatus"], start=start_date, end=end_date, plan=plan, usercount=usercount) - newbill.save() - - mail_to_send = "" - if(agency.payment_address == ""): - mail_to_send = agency.agency_email - else: - mail_to_send = agency.payment_address - msg_html = render_to_string('users/newbill_mail.html', {}) - send_mail('Digitale Agentur | Rechnung', 'Sehr geehrte Nutzer, es wurde eine Rechnung für Ihre Digitale Agentur erstellt. Diese können Sie unter Einstellungen, Abrechnung einsehen.','noreply@digitale-agentur.com',[mail_to_send],html_message=msg_html,fail_silently=True) - data.update({"newBill_" + str(agency.pk) : newbill.lexid}) - mailstatus += "NEW BILL FOR AGENCY " + str(agency.pk) + newbill = AgencyBills(agency=agency, lexid=newbill_id, billtype="invoice", billnumber=response_text["voucherNumber"], billstatus=response_text["voucherStatus"], start=start_date, end=end_date, plan=plan, usercount=usercount) + newbill.save() + + mail_to_send = "" + if(agency.payment_address == ""): + mail_to_send = agency.agency_email + else: + mail_to_send = agency.payment_address + + # BCC Mail with Object - NICHT DEN IMPORT VERGESSEN!!! + email = EmailMultiAlternatives( + 'Digitale Agentur | Rechnung ' + str(response_text["voucherNumber"]), + 'Sehr geehrte Nutzer, hiermit erhalten Sie eine neue Rechnung für die Digitale Agentur. Ihr Team der Digitalen Agentur', + 'noreply@digitale-agentur.com', + [mail_to_send], + ['info@digitale-agentur.com'], + headers={}, + ) + + headers = { + 'Authorization': 'Bearer ' + settings.LEX_API, + 'Content-Type': 'application/json', + 'Accept': 'application/json', + } + + lexdata = { + "renderType" : "pdf" + } + + json_data = json.dumps(lexdata) + + r_final = requests.get("https://api.lexoffice.io/v1/invoices/"+newbill_id+"/document", data=json_data, headers=headers) + json.loads(r_final.text) + + base64String = requests.get("https://api.lexoffice.io/v1/files/"+json.loads(r_final.text)["documentFileId"]+"/", data=json_data, headers=headers) + + content = base64.b64decode(base64String.text) + + msg_html = render_to_string('users/newbill_mail.html', {}) + email.attach_alternative(msg_html, "text/html") + email.attach('Rechnung_' + str(response_text["voucherNumber"]) + '.pdf', content, "application/pdf") + email.send() + #send_mail('Digitale Agentur | Rechnung', 'Sehr geehrte Nutzer, es wurde eine Rechnung für Ihre Digitale Agentur erstellt. Diese können Sie unter Einstellungen, Abrechnung einsehen.','noreply@digitale-agentur.com',[mail_to_send],html_message=msg_html,fail_silently=True) + data.update({"newBill_" + str(agency.pk) : newbill.lexid}) + mailstatus += "NEW BILL FOR AGENCY " + str(agency.pk) + except: + mailstatus += "ERROR BY SENDING NEW MAIL TO " + str(agency.pk) else: data.update({"status" : "failed"}) @@ -1892,11 +1916,8 @@ def cronactionsbill(request, code): ["htrampe@gmail.com", "info@digitale-agentur.com"], fail_silently=True ) - return JsonResponse(data) - - def sendMailNoti(notificationtext, user_touched, linktarget=""): username = user_touched.first_name + " " + user_touched.last_name