diff --git a/digitaleagentur/__pycache__/settings.cpython-38.pyc b/digitaleagentur/__pycache__/settings.cpython-38.pyc index 33f2675..67562f9 100644 Binary files a/digitaleagentur/__pycache__/settings.cpython-38.pyc and b/digitaleagentur/__pycache__/settings.cpython-38.pyc differ diff --git a/digitaleagentur/__pycache__/urls.cpython-38.pyc b/digitaleagentur/__pycache__/urls.cpython-38.pyc index 48efc11..de9d1da 100644 Binary files a/digitaleagentur/__pycache__/urls.cpython-38.pyc and b/digitaleagentur/__pycache__/urls.cpython-38.pyc differ diff --git a/digitaleagentur/settings.py b/digitaleagentur/settings.py index 7c0c051..da2390f 100644 --- a/digitaleagentur/settings.py +++ b/digitaleagentur/settings.py @@ -173,7 +173,7 @@ SITE_ROOT = os.path.dirname(os.path.realpath(__file__)) + '/..' STATICFILES_DIRS = (os.path.join(SITE_ROOT, 'users/static/'),) -STATIC_ROOT = (os.path.join(SITE_ROOT, 'collectedstatic')) +#STATIC_ROOT = (os.path.join(SITE_ROOT, 'collectedstatic')) # CRISPY CRISPY_TEMPLATE_PACK = 'bootstrap4' diff --git a/digitaleagentur/urls.py b/digitaleagentur/urls.py index fbb3f52..4dc132f 100644 --- a/digitaleagentur/urls.py +++ b/digitaleagentur/urls.py @@ -35,8 +35,8 @@ urlpatterns = [ path('chat/', include('chat.urls'), name='chat'), path('api-token-auth/', obtain_auth_token, name='api-token-auth'), ] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) -#if settings.DEBUG: - # urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) +if settings.DEBUG: + urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) # ERROR HANDLERS handler404 = 'users.views.handler404' diff --git a/users/templates/users/support.html b/users/templates/users/support.html index 8ae0e98..85b5317 100644 --- a/users/templates/users/support.html +++ b/users/templates/users/support.html @@ -16,13 +16,14 @@ {% 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) +