image feature + refactor

This commit is contained in:
JMARyA 2024-12-06 12:10:30 +01:00
parent 73e019de9a
commit d64efb663a
Signed by: jmarya
GPG key ID: 901B2ADDF27C2263
13 changed files with 221 additions and 37 deletions

View file

@ -2,7 +2,7 @@
{% if late_reports > 1 %}
<div class="bg-yellow-100 border-l-4 border-yellow-500 text-yellow-700 p-4 mr-10 ml-10 mt-6" role="alert">
<div class="bg-yellow-100 border-l-4 border-yellow-500 text-yellow-700 p-4 mr-10 ml-10 mt-2" role="alert">
<p class="font-bold"> Du bist nicht aktuell! </p>
<p> Du hast noch {{ late_reports }} Berichtshefte nachzuschreiben. </p>
</div>

View file

@ -12,17 +12,30 @@
</span>
</p>
</div>
<div class="border-t border-gray-200 mt-4 pt-4">
<h2 class="text-lg font-medium text-gray-800 mb-2">Content:</h2>
<dl class="space-y-2">
{% load markdown %}
<div class="flex items-start space-x-4 justify-between">
<div>
{% load access markdown %}
{% for key, value in report.content.items %}
<div class="justify-between items-start">
<h4 class="text-sm font-medium text-gray-600">{{ key }}</h4>
<span class="text-sm text-gray-800 mb-4">{{ value|markdown|safe }}</span>
<h4 class="text-sm font-medium text-gray-600">{{ form.display_names|access:key|safe }}</h4>
<div class="text-sm text-gray-800 mb-4">{{ value|markdown|safe }}</div>
</div>
{% endfor %}
</div>
{% if report.image is not None %}
{% load b64 %}
<div class="w-36">
<img src="data:image/*;base64,{{ report.image|b64 }}" width="128"
class="-mt-8 w-32 h-32 border-2 border-black cursor-pointer rounded-lg shadow-lg hover:shadow-2xl transition-all duration-300">
</div>
{% endif %}
</div>
</dl>
</div>
</main>

View file

@ -8,7 +8,7 @@
<!-- Main wrapper that will hold the header, sidebar, and content -->
<div class="flex flex-col min-h-screen">
<header class="w-full bg-red-600 text-white flex py-4 shadow-md max-h-20 h-full max-h-20">
<button id="menu-toggle" class="text-2xl focus:outline-none ml-5">
<button id="menu-toggle" class="text-2xl focus:outline-none ml-5" onclick="toggleSidepanel()">
&#9776;
</button>
@ -38,11 +38,9 @@
</div>
<!-- Script to toggle the sidebar -->
<script>
const menuToggle = document.getElementById('menu-toggle');
const sidepanel = document.getElementById('sidepanel');
<script>
function toggleSidepanel() {
const sidepanel = document.getElementById('sidepanel');
if (sidepanel.classList.contains('w-0')) {
sidepanel.classList.remove('w-0');
sidepanel.classList.add('w-60');
@ -59,8 +57,6 @@
});
}
}
menuToggle.addEventListener('click', () => toggleSidepanel());
</script>
</body>

View file

@ -12,7 +12,7 @@
</p>
</div>
<form method="post" class="space-y-4">
<form method="post" class="space-y-4" enctype="multipart/form-data">
{% load access set_content %}
@ -24,7 +24,11 @@
{% if field.id_for_label == "id_department" %}
{% if draft is not None %}
{{ field|set_content:draft.department }}
{% else %}
{{ field }}
{% endif %}
{% else %}
{% with content=draft.content|access:field.id_for_label %}