Standards drucken
This commit is contained in:
parent
6e8c7ba9e0
commit
7e1ea6d634
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1,12 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>TITEL</title>
|
||||
<style type="text/css">
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
{{content}}
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -222,10 +222,17 @@
|
|||
{% endif %}
|
||||
</div>
|
||||
<div class="mt-2">
|
||||
<a href="{% url 'ajax-standardpdf' standard.pk %}" target="_blank" class="btn btn-primary btn-sm mr-2" onclick="javascript:printStandard()">
|
||||
<i class="fas fa-print"></i>
|
||||
</a>
|
||||
|
||||
|
||||
<small>
|
||||
{% if not standard.created_standard_by %} Erstellt von gelöschtem Mitarbeiter {% else %} Erstellt durch <a href="{% url 'orga-single' standard.created_standard_by.pk %}">{{standard.created_standard_by.first_name}} {{standard.created_standard_by.last_name}}</a> {% endif %} am {{standard.created_standard_date}} | {% if not standard.last_modified_by %} Zuletzt bearbeitet von gelöschtem Benutzer {% else %} Zuletzt bearbeitet von <a href="{% url 'orga-single' standard.last_modified_by.pk %}">{{ standard.last_modified_by.first_name}} {{ standard.last_modified_by.last_name}}</a>{% endif %} am {{ standard.last_modified_on}}
|
||||
</small>
|
||||
|
||||
<!-- PRINT -->
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
@ -314,6 +321,7 @@
|
|||
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
function goToStandardMain(){
|
||||
localStorage.setItem('activeTab', "");
|
||||
location.href = "{% url 'standards' %}";
|
||||
|
|
|
|||
|
|
@ -0,0 +1,9 @@
|
|||
<div class="content-section col-12">
|
||||
<h2>{{standard_name}}
|
||||
</h2>
|
||||
|
||||
<hr>
|
||||
{{standard_content}}
|
||||
|
||||
|
||||
</div>
|
||||
Binary file not shown.
|
|
@ -13,6 +13,7 @@ urlpatterns = [
|
|||
path('standardadd/<int:id>', views.StandardAdd, name='standard-add'),
|
||||
#path('standardupdate/<int:id>', views.StandardUpdate, name='standard-update'),
|
||||
path('ajax/loadtasks/', views.load_tasks, name='ajax_loadtasks'),
|
||||
path('pdf/<int:pk>', views.getStandardPDF, name="ajax-standardpdf"),
|
||||
path('ajups/<int:pk>', views.updatesbyajax, name='update_standard_by_ajax'),
|
||||
path('ajupsagn/<int:pk>', views.updatesbyajax_agn, name='update_standard_by_ajax_agn'),
|
||||
path('standards/<int:pk>/delete', StandardDeleteView.as_view(), name='standard-delete'),
|
||||
|
|
|
|||
|
|
@ -844,6 +844,42 @@ def updatesbyajax(request, pk):
|
|||
return JsonResponse({"success" : success})
|
||||
|
||||
|
||||
# CREATE PDF FROM STANDARD
|
||||
from io import BytesIO
|
||||
from xhtml2pdf import pisa
|
||||
|
||||
|
||||
# Utility function
|
||||
def convert_html_to_pdf(source_html, output_filename):
|
||||
result = BytesIO()
|
||||
pdf = pisa.pisaDocument(BytesIO(source_html.encode("ISO-8859-1")), result)
|
||||
if not pdf.err:
|
||||
return HttpResponse(result.getvalue(), content_type='application/pdf')
|
||||
return None
|
||||
|
||||
@login_required
|
||||
def getStandardPDF(request, pk):
|
||||
standard = Standards.objects.get(pk=pk)
|
||||
# CHECK IF USER HAS RIGHTS TO SEE THIS Standard
|
||||
groupsofstandard = Standards.objects.get(pk=pk, agency=request.user.profile.agency)
|
||||
|
||||
userisingroup = False
|
||||
|
||||
if len(groupsofstandard.visibleby.all()) == 0:
|
||||
userisingroup = True
|
||||
else:
|
||||
for ag in groupsofstandard.visibleby.all():
|
||||
if ag.group in request.user.groups.all():
|
||||
userisingroup = True
|
||||
|
||||
if userisingroup:
|
||||
pdf = convert_html_to_pdf(standard.content, "final.pdf")
|
||||
return HttpResponse(pdf, content_type='application/pdf')
|
||||
else:
|
||||
messages.warning(request, f'Diesen Standard dürfen Sie nicht sehen!')
|
||||
return redirect('standards')
|
||||
|
||||
|
||||
@login_required
|
||||
def StandardFromAgn(request, pk):
|
||||
try:
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@ def loadingFreeDays(plz):
|
|||
# Getting land
|
||||
|
||||
file_path = os.path.join(settings.STATIC_ROOT, 'users/extra/plz_short.csv')
|
||||
|
||||
land = False
|
||||
|
||||
with open(file_path, 'rt') as csvfile:
|
||||
|
|
|
|||
Loading…
Reference in New Issue