QS 0.9.1 PORD

This commit is contained in:
Holger Trampe 2020-06-01 01:10:45 +02:00
parent c8bb742d70
commit 23d2405838
7 changed files with 29 additions and 6 deletions

View File

@ -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'

View File

@ -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'

View File

@ -16,13 +16,14 @@
</form>
</div>
<script type="text/javascript">
/*
$(document).ready(function() {
$('#id_problem').summernote({
height: 320,
lang: "de-DE",
disableDragAndDrop: true
});
});
});*/
</script>
{% endblock content %}

View File

@ -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):

View File

@ -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)