From 23d24058385b1fa3be8e6c6392d8da2316b5f7fd Mon Sep 17 00:00:00 2001 From: Holger Trampe Date: Mon, 1 Jun 2020 01:10:45 +0200 Subject: [PATCH] QS 0.9.1 PORD --- .../__pycache__/settings.cpython-38.pyc | Bin 4110 -> 4064 bytes .../__pycache__/urls.cpython-38.pyc | Bin 2522 -> 2584 bytes digitaleagentur/settings.py | 2 +- digitaleagentur/urls.py | 4 +-- users/templates/users/support.html | 3 ++- users/usersforms.py | 3 +++ users/views.py | 23 ++++++++++++++++-- 7 files changed, 29 insertions(+), 6 deletions(-) diff --git a/digitaleagentur/__pycache__/settings.cpython-38.pyc b/digitaleagentur/__pycache__/settings.cpython-38.pyc index 33f2675795a4ee0a4936a5cfbac052d4b79679ad..67562f971e069c32a80ac59f37a671db1ad6ba81 100644 GIT binary patch delta 147 zcmeBEcp%Rk%FD~e00e%PSK?|W^2#z!*{Ge!Xps^arJl-|#kxQ>l`|!1Aybq_N^q2B zidU3YN=TG;N@xmaCS#ONN?1yGN<=0jkgc1-6wII*x%m>~JbvHaqjMFij5O t%VpCAnqQ1ME%FD~e00f)2U5=}s$ScdZXrp!_qgyIt7V84lRF#y#g-lWEDM3*hP!Z0Q zV4#R*N=TGeidU3&N@$c$N>~bKCS#OtN_a{{N@OM@kgb=(6wII*wfP9+Jx&4sJ;jJi__QD#nUl9G|1-`7law)?;kQ* ffK!@H8)!|D_GClONXCH4-JCw`(j1H;%q)xmo=PHI delta 73 zcmbOsa!Z&ul$V!_0SLY {% endblock content %} diff --git a/users/usersforms.py b/users/usersforms.py index c2d4ce1..bc9ba65 100644 --- a/users/usersforms.py +++ b/users/usersforms.py @@ -163,6 +163,9 @@ class SupportForm(forms.Form): self.fields['problem'] = forms.CharField(required=True, widget=forms.Textarea, label="Ausführliche Problembeschreibung") self.fields['name'].widget.attrs['readonly'] = True self.fields['mail'].widget.attrs['readonly'] = True + self.fields["attachment_1"] = forms.FileField(label="Anhang 1", required=False) + self.fields["attachment_2"] = forms.FileField(label="Anhang 2", required=False) + self.fields["attachment_3"] = forms.FileField(label="Anhang 3", required=False) class NewAgencyForm(forms.Form): def __init__(self, *args, **kwargs): diff --git a/users/views.py b/users/views.py index 9e862ea..2987323 100644 --- a/users/views.py +++ b/users/views.py @@ -42,6 +42,7 @@ from channels_presence.models import Presence import channels.layers from datetime import date from timemanagement.models import Workday +import base64 def randomString(stringLength=10): """Generate a random string of fixed length """ @@ -740,6 +741,18 @@ def support(request): if request.method == 'POST': form = request.POST + + attachments=[] #myfile is the key of a multi value dictionary, values are the uploaded files + for f in request.FILES.getlist('attachment_1'): #myfile is the name of your html file button + filename = f.name + attachments.append({str(filename) : str(base64.b64encode(f.read()))}) + for f in request.FILES.getlist('attachment_2'): #myfile is the name of your html file button + filename = f.name + attachments.append({str(filename) : str(base64.b64encode(f.read()))}) + for f in request.FILES.getlist('attachment_2'): #myfile is the name of your html file button + filename = f.name + attachments.append({str(filename) : str(base64.b64encode(f.read()))}) + #image = request.FILES supportdata = dict(form) # Data from Form to JSON-Format @@ -748,6 +761,8 @@ def support(request): problemconc = str(supportdata['problemconc'][0]) problem = str(supportdata['problem'][0]) + + # HEADERS CURL headers = {'X-API-Key': 'F025A238EB74914E3653BA2989BFF7C4'} subject = "Digitale Agentur: " + str(problemconc) @@ -759,12 +774,15 @@ def support(request): "email": mail, "subject": 'Digitale Agentur: '+problemconc, "ip": "1.1.1.1", - "message": "data/html;charset=utf-8;*****************************\nAgentur: "+ request.user.profile.agency.name +" (ID: "+ str(request.user.profile.agency.pk) +")\nBenutzer: "+request.user.first_name+" "+request.user.last_name+" (ID: "+ str(request.user.pk) +")\n*******************************\n\n" + problem + "message": "*****************************\nAgentur: "+ request.user.profile.agency.name +" (ID: "+ str(request.user.profile.agency.pk) +")\nBenutzer: "+request.user.first_name+" "+request.user.last_name+" (ID: "+ str(request.user.pk) +")\n*******************************\n\n" + problem, + "attachments" : attachments + } json_data = json.dumps(ostdata) r = requests.post("https://support.vh-solutions.de/api/http.php/tickets.json", data=json_data, headers=headers) - # IF request FAILED error-Message + + # IF request FAILED error-Message if(r.status_code != 201): messages.warning(request, f'Supportanfrage fehlgeschlagen!' + str(r)) else: @@ -916,3 +934,4 @@ def cronactionsdaily(request, code): data.update({"status" : "failed"}) return JsonResponse(data) +