v4.1.0: DMS email documents, category-specific Nachweis linking, version system
Some checks failed
CI/CD Pipeline / test (push) Has been cancelled
CI/CD Pipeline / deploy (push) Has been cancelled
Code Quality / quality (push) Has been cancelled

- Save cover email body as DMS document with new 'email' context type
- Show email body separately from attachments in email detail view
- Add per-category DMS document assignment in quarterly confirmation
  (Studiennachweis, Einkommenssituation, Vermögenssituation)
- Add VERSION file and context processor for automatic version display
- Add MCP server, agent system, import/export, and new migrations
- Update compose files and production environment template

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
SysAdmin Agent
2026-03-15 18:48:52 +00:00
parent faeb7c1073
commit e0b377014c
49 changed files with 5913 additions and 55 deletions

View File

@@ -661,6 +661,15 @@
</a>
</div>
<!-- Daten -->
<div class="sidebar-section">
<div class="sidebar-heading">Daten</div>
<a class="sidebar-link" href="{% url 'stiftung:import_export_hub' %}">
<i class="fas fa-exchange-alt"></i>
<span>Import & Export</span>
</a>
</div>
<!-- System -->
<div class="sidebar-section">
<div class="sidebar-heading">System</div>
@@ -741,7 +750,7 @@
<!-- Footer -->
<footer class="main-footer">
&copy; 2026 van Hees-Theyssen-Vogel'sche Stiftung &middot;
<small>Vision 2026 &middot; v4.0.0</small>
<small>Vision 2026 &middot; v{{ APP_VERSION }}</small>
</footer>
</main>
@@ -995,5 +1004,464 @@
});
})();
</script>
{% if user.is_authenticated and perms.stiftung.can_use_agent %}
<!-- ══════════════════════════════════════════════════════════════
AI Agent Chat-Widget
══════════════════════════════════════════════════════════════ -->
<style>
#agent-fab {
position: fixed;
bottom: 1.5rem;
right: 1.5rem;
z-index: 9000;
width: 52px;
height: 52px;
border-radius: 50%;
background: var(--racing-green);
color: #fff;
border: none;
box-shadow: 0 4px 16px rgba(0,0,0,0.25);
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
font-size: 1.25rem;
transition: background 0.2s, transform 0.15s;
}
#agent-fab:hover { background: var(--racing-green-light); transform: scale(1.07); }
#agent-panel {
position: fixed;
bottom: 5.5rem;
right: 1.5rem;
z-index: 9001;
width: min(420px, calc(100vw - 2rem));
max-height: calc(100vh - 7rem);
background: #fff;
border-radius: 1rem;
box-shadow: 0 8px 40px rgba(0,0,0,0.2);
display: flex;
flex-direction: column;
overflow: hidden;
transform: translateY(10px) scale(0.97);
opacity: 0;
pointer-events: none;
transition: opacity 0.2s, transform 0.2s;
}
#agent-panel.open {
opacity: 1;
transform: translateY(0) scale(1);
pointer-events: all;
}
#agent-header {
background: var(--racing-green);
color: #fff;
padding: 0.75rem 1rem;
display: flex;
align-items: center;
gap: 0.5rem;
flex-shrink: 0;
}
#agent-header h6 { margin: 0; font-size: 0.9rem; font-weight: 600; flex: 1; }
#agent-header button { background: none; border: none; color: rgba(255,255,255,0.7); cursor: pointer; padding: 0 4px; font-size: 1rem; }
#agent-header button:hover { color: #fff; }
#agent-session-bar {
background: #f8f9fa;
border-bottom: 1px solid #e9ecef;
padding: 0.4rem 0.75rem;
display: flex;
align-items: center;
gap: 0.5rem;
flex-shrink: 0;
}
#agent-session-bar select {
flex: 1;
font-size: 0.8rem;
border: 1px solid #dee2e6;
border-radius: 4px;
padding: 2px 6px;
background: #fff;
}
#agent-session-bar button { font-size: 0.75rem; white-space: nowrap; }
#agent-messages {
flex: 1;
overflow-y: auto;
padding: 0.75rem;
display: flex;
flex-direction: column;
gap: 0.5rem;
min-height: 200px;
}
.agent-msg {
max-width: 85%;
padding: 0.5rem 0.75rem;
border-radius: 0.75rem;
font-size: 0.85rem;
line-height: 1.5;
word-break: break-word;
}
.agent-msg.user {
background: var(--racing-green);
color: #fff;
align-self: flex-end;
border-bottom-right-radius: 4px;
}
.agent-msg.assistant {
background: #f0f2f5;
color: #212529;
align-self: flex-start;
border-bottom-left-radius: 4px;
}
.agent-msg.tool-indicator {
background: #fff3cd;
color: #856404;
align-self: flex-start;
font-size: 0.78rem;
padding: 0.3rem 0.6rem;
}
.agent-msg pre { margin: 0; white-space: pre-wrap; font-family: inherit; }
.agent-msg code { background: rgba(0,0,0,0.08); border-radius: 3px; padding: 1px 4px; font-size: 0.82em; }
#agent-input-area {
border-top: 1px solid #e9ecef;
padding: 0.6rem 0.75rem;
display: flex;
gap: 0.5rem;
flex-shrink: 0;
}
#agent-input {
flex: 1;
border: 1px solid #dee2e6;
border-radius: 0.5rem;
padding: 0.4rem 0.65rem;
font-size: 0.85rem;
resize: none;
min-height: 36px;
max-height: 120px;
outline: none;
font-family: inherit;
}
#agent-input:focus { border-color: var(--racing-green); }
#agent-send-btn {
background: var(--racing-green);
color: #fff;
border: none;
border-radius: 0.5rem;
padding: 0 0.75rem;
cursor: pointer;
font-size: 1rem;
transition: background 0.15s;
align-self: flex-end;
height: 36px;
}
#agent-send-btn:disabled { background: #adb5bd; cursor: not-allowed; }
#agent-send-btn:not(:disabled):hover { background: var(--racing-green-light); }
.agent-typing { display: flex; gap: 4px; align-items: center; padding: 0.5rem 0.75rem; }
.agent-typing span {
width: 7px; height: 7px; background: #adb5bd;
border-radius: 50%; animation: agent-bounce 1s infinite;
}
.agent-typing span:nth-child(2) { animation-delay: 0.15s; }
.agent-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes agent-bounce {
0%,80%,100% { transform: translateY(0); }
40% { transform: translateY(-6px); }
}
</style>
<!-- FAB Button -->
<button id="agent-fab" title="AI-Assistent öffnen" onclick="agentToggle()">
<i class="fas fa-robot"></i>
</button>
<!-- Chat Panel -->
<div id="agent-panel">
<div id="agent-header">
<i class="fas fa-robot"></i>
<h6>RentmeisterAI</h6>
<button onclick="agentNewSession()" title="Neue Unterhaltung"><i class="fas fa-plus"></i></button>
<button onclick="agentToggle()" title="Schließen"><i class="fas fa-times"></i></button>
</div>
<div id="agent-session-bar">
<select id="agent-session-select" onchange="agentLoadSession(this.value)" title="Sitzung wechseln">
<option value="">— Neue Unterhaltung —</option>
</select>
<button class="btn btn-sm btn-outline-danger" onclick="agentDeleteSession()" title="Sitzung löschen">
<i class="fas fa-trash-alt"></i>
</button>
</div>
<div id="agent-messages">
<div class="agent-msg assistant">
Guten Tag! Ich bin RentmeisterAI. Wie kann ich Ihnen helfen?
</div>
</div>
<div id="agent-input-area">
<textarea id="agent-input" placeholder="Nachricht eingeben… (Enter = senden)" rows="1"
onkeydown="agentKeydown(event)"></textarea>
<button id="agent-send-btn" onclick="agentSend()" title="Senden">
<i class="fas fa-paper-plane"></i>
</button>
</div>
</div>
<script>
(function() {
const CSRF = '{{ csrf_token }}';
let currentSessionId = null;
let isStreaming = false;
window.agentToggle = function() {
const panel = document.getElementById('agent-panel');
const isOpen = panel.classList.contains('open');
panel.classList.toggle('open');
if (!isOpen) {
agentLoadSessions();
document.getElementById('agent-input').focus();
}
};
window.agentNewSession = function() {
currentSessionId = null;
document.getElementById('agent-session-select').value = '';
document.getElementById('agent-messages').innerHTML =
'<div class="agent-msg assistant">Neue Unterhaltung gestartet. Wie kann ich helfen?</div>';
};
window.agentKeydown = function(e) {
if (e.key === 'Enter' && !e.shiftKey) {
e.preventDefault();
agentSend();
}
};
window.agentSend = async function() {
if (isStreaming) return;
const input = document.getElementById('agent-input');
const msg = input.value.trim();
if (!msg) return;
input.value = '';
autoResizeTextarea(input);
appendMessage('user', msg);
const typingEl = appendTyping();
setSending(true);
// Seitenkontext: URL + Titel
const pageContext = `Seite: ${document.title}\nURL: ${window.location.href}`;
try {
const res = await fetch('/agent/chat/', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-CSRFToken': CSRF,
},
body: JSON.stringify({
message: msg,
session_id: currentSessionId,
page_context: pageContext,
}),
});
if (!res.ok) {
const err = await res.json().catch(() => ({}));
throw new Error(err.error || `HTTP ${res.status}`);
}
const data = await res.json();
currentSessionId = data.session_id;
// Session-Select aktualisieren
updateSessionSelect(data.session_id);
// SSE-Stream starten
typingEl.remove();
await agentStream(data.stream_url);
} catch (e) {
typingEl.remove();
appendMessage('assistant', `Fehler: ${e.message}`);
} finally {
setSending(false);
}
};
async function agentStream(url) {
const msgEl = appendMessage('assistant', '');
const contentEl = msgEl.querySelector('.agent-text');
return new Promise((resolve) => {
const es = new EventSource(url);
es.onmessage = function(e) {
try {
const chunk = JSON.parse(e.data);
if (chunk.type === 'text') {
contentEl.textContent += chunk.content;
scrollMessages();
} else if (chunk.type === 'tool_start') {
appendToolIndicator(chunk.name);
} else if (chunk.type === 'done') {
es.close();
renderMarkdown(contentEl);
agentLoadSessions();
resolve();
} else if (chunk.type === 'error') {
contentEl.textContent = `Fehler: ${chunk.message}`;
es.close();
resolve();
}
} catch(err) { /* ignore parse errors */ }
};
es.onerror = function() {
es.close();
if (!contentEl.textContent) {
contentEl.textContent = 'Verbindungsfehler.';
}
resolve();
};
});
}
function appendMessage(role, text) {
const messages = document.getElementById('agent-messages');
const div = document.createElement('div');
div.className = `agent-msg ${role}`;
const span = document.createElement('span');
span.className = 'agent-text';
span.textContent = text;
div.appendChild(span);
messages.appendChild(div);
scrollMessages();
return div;
}
function appendTyping() {
const messages = document.getElementById('agent-messages');
const div = document.createElement('div');
div.className = 'agent-msg assistant agent-typing-wrap';
div.innerHTML = '<div class="agent-typing"><span></span><span></span><span></span></div>';
messages.appendChild(div);
scrollMessages();
return div;
}
function appendToolIndicator(toolName) {
const messages = document.getElementById('agent-messages');
const div = document.createElement('div');
div.className = 'agent-msg tool-indicator';
div.innerHTML = `<i class="fas fa-cog fa-spin me-1"></i> Werkzeug: <em>${escHtml(toolName)}</em>`;
messages.appendChild(div);
scrollMessages();
}
function renderMarkdown(el) {
// Simple markdown: **bold**, `code`, newlines
let html = escHtml(el.textContent)
.replace(/\*\*(.+?)\*\*/g, '<strong>$1</strong>')
.replace(/`([^`]+)`/g, '<code>$1</code>')
.replace(/\n/g, '<br>');
el.innerHTML = html;
}
function scrollMessages() {
const m = document.getElementById('agent-messages');
m.scrollTop = m.scrollHeight;
}
function setSending(v) {
isStreaming = v;
document.getElementById('agent-send-btn').disabled = v;
document.getElementById('agent-input').disabled = v;
}
function autoResizeTextarea(el) {
el.style.height = 'auto';
el.style.height = Math.min(el.scrollHeight, 120) + 'px';
}
document.addEventListener('DOMContentLoaded', function() {
const input = document.getElementById('agent-input');
if (input) input.addEventListener('input', () => autoResizeTextarea(input));
});
window.agentLoadSessions = async function() {
try {
const res = await fetch('/agent/sessions/');
if (!res.ok) return;
const data = await res.json();
const sel = document.getElementById('agent-session-select');
// Keep current value
const current = sel.value;
sel.innerHTML = '<option value="">— Neue Unterhaltung —</option>';
data.sessions.forEach(s => {
const opt = document.createElement('option');
opt.value = s.id;
opt.textContent = (s.title || 'Unterhaltung').substring(0, 40);
sel.appendChild(opt);
});
if (currentSessionId) sel.value = currentSessionId;
else if (current) sel.value = current;
} catch(e) { /* ignore */ }
};
window.agentLoadSession = async function(sessionId) {
if (!sessionId) { agentNewSession(); return; }
currentSessionId = sessionId;
try {
const res = await fetch(`/agent/sessions/${sessionId}/`);
if (!res.ok) return;
const data = await res.json();
const messages = document.getElementById('agent-messages');
messages.innerHTML = '';
data.messages.forEach(m => {
if (m.role === 'tool') return;
const div = appendMessage(m.role, m.content);
renderMarkdown(div.querySelector('.agent-text'));
});
if (data.messages.length === 0) {
appendMessage('assistant', 'Wie kann ich Ihnen helfen?');
}
} catch(e) { /* ignore */ }
};
window.agentDeleteSession = async function() {
if (!currentSessionId) return;
if (!confirm('Diese Unterhaltung wirklich löschen?')) return;
try {
await fetch(`/agent/sessions/${currentSessionId}/loeschen/`, {
method: 'POST',
headers: { 'X-CSRFToken': CSRF },
});
agentNewSession();
agentLoadSessions();
} catch(e) { /* ignore */ }
};
function updateSessionSelect(id) {
const sel = document.getElementById('agent-session-select');
let found = false;
for (const opt of sel.options) { if (opt.value === id) { found = true; break; } }
if (!found) {
const opt = document.createElement('option');
opt.value = id;
opt.textContent = '(aktuelle Unterhaltung)';
sel.appendChild(opt);
}
sel.value = id;
}
function escHtml(s) {
return String(s).replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;').replace(/"/g,'&quot;');
}
})();
</script>
{% endif %}
</body>
</html>