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 fe98d32..971a776 100644
Binary files a/dump.rdb and b/dump.rdb differ
diff --git a/news/templates/news/news_update.html b/news/templates/news/news_update.html
index e3981ae..c423ab5 100644
--- a/news/templates/news/news_update.html
+++ b/news/templates/news/news_update.html
@@ -36,6 +36,7 @@ $(document).ready(function() {
});
});
+
{% 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