Initial claims system setup
This commit is contained in:
113
claims/templates/claims/admin_list.html
Normal file
113
claims/templates/claims/admin_list.html
Normal file
@@ -0,0 +1,113 @@
|
||||
{% extends "claims/base.html" %}
|
||||
|
||||
{% block title %}Admin – Utlägg{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<h1>Inkomna utlägg</h1>
|
||||
<p>Endast användare med behörighet att se utlägg kommer åt den här sidan.</p>
|
||||
|
||||
<div>
|
||||
<strong>Filtrera:</strong>
|
||||
<a href="?status=all"{% if status_filter == "all" %} aria-current="page"{% endif %}>Alla</a>
|
||||
{% for value, label in status_choices %}
|
||||
|
|
||||
<a href="?status={{ value }}"{% if status_filter == value %} aria-current="page"{% endif %}>
|
||||
{{ label }}
|
||||
</a>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Person & kontakt</th>
|
||||
<th>Belopp</th>
|
||||
<th>Projekt</th>
|
||||
<th>Status</th>
|
||||
<th>Kvittens</th>
|
||||
<th>Logg</th>
|
||||
<th>Senast uppdaterad</th>
|
||||
{% if can_change %}<th>Åtgärd</th>{% endif %}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for claim in claims %}
|
||||
<tr>
|
||||
<td>
|
||||
<strong>{{ claim.full_name }}</strong><br>
|
||||
{{ claim.email }}<br>
|
||||
Konto: {{ claim.account_number }}<br>
|
||||
<em>{{ claim.description|linebreaksbr }}</em>
|
||||
<div>
|
||||
{% if claim.submitted_by %}
|
||||
<small>Inskickad av inloggad användare: {{ claim.submitted_by.get_username }}</small>
|
||||
{% else %}
|
||||
<small>Inskickad av gäst</small>
|
||||
{% endif %}
|
||||
</div>
|
||||
</td>
|
||||
<td>{{ claim.amount }} {{ claim.currency }}</td>
|
||||
<td>{{ claim.project|default:"-" }}</td>
|
||||
<td>
|
||||
{{ claim.get_status_display }}<br>
|
||||
{% if claim.decision_note %}<small>Kommentar: {{ claim.decision_note }}</small>{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
{% if claim.receipt %}
|
||||
<a href="{{ claim.receipt.url }}" target="_blank" rel="noopener">Visa fil</a>
|
||||
{% else %}
|
||||
–
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
<details>
|
||||
<summary>Visa logg</summary>
|
||||
<ul>
|
||||
{% for log in claim.logs.all %}
|
||||
<li>
|
||||
{{ log.created_at|date:"Y-m-d H:i" }} –
|
||||
{{ log.get_action_display }}:
|
||||
{% if log.from_status %}{{ log.get_from_status_display }} → {% endif %}
|
||||
{{ log.get_to_status_display }}
|
||||
{% if log.performed_by %}
|
||||
(av {{ log.performed_by.get_username }})
|
||||
{% endif %}
|
||||
{% if log.note %}
|
||||
– "{{ log.note }}"
|
||||
{% endif %}
|
||||
</li>
|
||||
{% empty %}
|
||||
<li>Ingen logg än.</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</details>
|
||||
</td>
|
||||
<td>{{ claim.updated_at|date:"Y-m-d H:i" }}</td>
|
||||
{% if can_change %}
|
||||
<td>
|
||||
<form method="post">
|
||||
{% csrf_token %}
|
||||
<input type="hidden" name="claim_id" value="{{ claim.id }}">
|
||||
<label>
|
||||
Åtgärd
|
||||
<select name="action">
|
||||
{% for value, label in decision_choices %}
|
||||
<option value="{{ value }}">{{ label }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</label>
|
||||
<label>
|
||||
Kommentar
|
||||
<textarea name="decision_note" rows="2">{{ claim.decision_note }}</textarea>
|
||||
</label>
|
||||
<button type="submit">Uppdatera</button>
|
||||
</form>
|
||||
</td>
|
||||
{% endif %}
|
||||
</tr>
|
||||
{% empty %}
|
||||
<tr><td colspan="{% if can_change %}8{% else %}7{% endif %}">Inga utlägg än.</td></tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
{% endblock %}
|
||||
48
claims/templates/claims/base.html
Normal file
48
claims/templates/claims/base.html
Normal file
@@ -0,0 +1,48 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>{% block title %}Claims{% endblock %}</title>
|
||||
<style>
|
||||
body { font-family: sans-serif; margin: 2rem; }
|
||||
form { max-width: 480px; display: grid; gap: 1rem; }
|
||||
label { font-weight: 600; }
|
||||
input, textarea { padding: 0.5rem; }
|
||||
table { border-collapse: collapse; width: 100%; margin-top: 1rem; }
|
||||
th, td { border: 1px solid #ccc; padding: 0.5rem; text-align: left; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<nav>
|
||||
<a href="{% url 'claims:submit' %}">Skicka utlägg</a> |
|
||||
<a href="{% url 'claims:admin-list' %}">Admin</a> |
|
||||
<a href="{% url 'claims:export' %}">Export</a> |
|
||||
{% if user.is_authenticated %}
|
||||
<a href="{% url 'claims:my-claims' %}">Mina utlägg</a> |
|
||||
{% if perms.auth.view_user %}
|
||||
<a href="{% url 'claims:user-manage' %}">Användare</a> |
|
||||
{% endif %}
|
||||
{% if user.is_staff %}
|
||||
<a href="{% url 'admin:index' %}">Kontohantering</a> |
|
||||
{% endif %}
|
||||
Inloggad som {{ user.get_username }}
|
||||
<form action="{% url 'logout' %}" method="post" style="display:inline;">
|
||||
{% csrf_token %}
|
||||
<button type="submit">Logga ut</button>
|
||||
</form>
|
||||
{% else %}
|
||||
<a href="{% url 'login' %}">Logga in</a>
|
||||
{% endif %}
|
||||
</nav>
|
||||
<hr>
|
||||
{% if messages %}
|
||||
<ul>
|
||||
{% for message in messages %}
|
||||
<li>{{ message }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
{% block content %}{% endblock %}
|
||||
</body>
|
||||
</html>
|
||||
20
claims/templates/claims/export_placeholder.html
Normal file
20
claims/templates/claims/export_placeholder.html
Normal file
@@ -0,0 +1,20 @@
|
||||
{% extends "claims/base.html" %}
|
||||
|
||||
{% block title %}Export{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<h1>Export till redovisningssystem</h1>
|
||||
<p>Detta är ett framtida steg. Här kommer du att kunna:</p>
|
||||
<ul>
|
||||
<li>Välja tidsperiod eller status</li>
|
||||
<li>Exportera till t.ex. bankfil eller SIE</li>
|
||||
<li>Skicka data via API till externa system</li>
|
||||
</ul>
|
||||
<p>Planerade åtgärder:</p>
|
||||
<ol>
|
||||
<li>Definiera format</li>
|
||||
<li>Implementera exportkommando/API</li>
|
||||
<li>Bygga integrationsinställningar</li>
|
||||
</ol>
|
||||
<p>Tills vidare kan du ladda ner data via Django admin eller med ett enkelt SQL-utdrag.</p>
|
||||
{% endblock %}
|
||||
63
claims/templates/claims/my_claims.html
Normal file
63
claims/templates/claims/my_claims.html
Normal file
@@ -0,0 +1,63 @@
|
||||
{% extends "claims/base.html" %}
|
||||
|
||||
{% block title %}Mina utlägg{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<h1>Mina utlägg</h1>
|
||||
<p>Här ser du status för de utlägg du skickat in när du varit inloggad.</p>
|
||||
|
||||
{% if claims %}
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Skickad</th>
|
||||
<th>Beskrivning</th>
|
||||
<th>Belopp</th>
|
||||
<th>Projekt</th>
|
||||
<th>Status</th>
|
||||
<th>Kvitto</th>
|
||||
<th>Logg</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for claim in claims %}
|
||||
<tr>
|
||||
<td>{{ claim.created_at|date:"Y-m-d H:i" }}</td>
|
||||
<td>{{ claim.description|linebreaksbr }}</td>
|
||||
<td>{{ claim.amount }} {{ claim.currency }}</td>
|
||||
<td>{{ claim.project|default:"-" }}</td>
|
||||
<td>{{ claim.get_status_display }}</td>
|
||||
<td>
|
||||
{% if claim.receipt %}
|
||||
<a href="{{ claim.receipt.url }}" target="_blank" rel="noopener">Visa fil</a>
|
||||
{% else %}
|
||||
–
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
<details>
|
||||
<summary>Visa logg</summary>
|
||||
<ul>
|
||||
{% for log in claim.logs.all %}
|
||||
<li>
|
||||
{{ log.created_at|date:"Y-m-d H:i" }} –
|
||||
{{ log.get_action_display }}
|
||||
{% if log.from_status %} ({{ log.get_from_status_display }} → {{ log.get_to_status_display }}){% endif %}
|
||||
{% if log.note %}
|
||||
– "{{ log.note }}"
|
||||
{% endif %}
|
||||
</li>
|
||||
{% empty %}
|
||||
<li>Ingen logg än.</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</details>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
{% else %}
|
||||
<p>Du har inte skickat in några utlägg ännu eller så gjordes de utan inloggning.</p>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
54
claims/templates/claims/submit_claim.html
Normal file
54
claims/templates/claims/submit_claim.html
Normal file
@@ -0,0 +1,54 @@
|
||||
{% extends "claims/base.html" %}
|
||||
|
||||
{% block title %}Skicka utlägg{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<h1>Skicka in utlägg</h1>
|
||||
<p>Formuläret är öppet för alla. Du kan fylla i flera rader innan du skickar in.</p>
|
||||
<p>Behöver du fler rader än som visas? Lägg till <code>?forms=n</code> i URL:en (max {{ max_extra_forms }}).</p>
|
||||
<form method="post" enctype="multipart/form-data">
|
||||
{% csrf_token %}
|
||||
<fieldset>
|
||||
<legend>Dina uppgifter</legend>
|
||||
{{ claimant_form.as_p }}
|
||||
</fieldset>
|
||||
{{ formset.management_form }}
|
||||
{% for form in formset %}
|
||||
<fieldset>
|
||||
<legend>Utlägg {{ forloop.counter }}</legend>
|
||||
{{ form.non_field_errors }}
|
||||
{% for hidden in form.hidden_fields %}{{ hidden }}{% endfor %}
|
||||
<p>
|
||||
{{ form.description.label_tag }}
|
||||
{{ form.description }}
|
||||
{{ form.description.errors }}
|
||||
</p>
|
||||
<p>
|
||||
{{ form.amount.label_tag }}
|
||||
{{ form.amount }}
|
||||
{{ form.amount.errors }}
|
||||
</p>
|
||||
<details>
|
||||
<summary>Avancerat: ändra valuta (standard SEK)</summary>
|
||||
<p>
|
||||
{{ form.currency.label_tag }}
|
||||
{{ form.currency }}
|
||||
{{ form.currency.errors }}
|
||||
</p>
|
||||
<p>
|
||||
{{ form.project.label_tag }}
|
||||
{{ form.project }}
|
||||
{{ form.project.errors }}
|
||||
</p>
|
||||
</details>
|
||||
<p>
|
||||
{{ form.receipt.label_tag }}
|
||||
{{ form.receipt }}
|
||||
{{ form.receipt.errors }}
|
||||
</p>
|
||||
</fieldset>
|
||||
{% endfor %}
|
||||
<button type="submit">Skicka in utlägg</button>
|
||||
</form>
|
||||
<p>När du skickar formuläret lotsas du till adminvyn. Saknar du inloggning får du möjlighet att logga in.</p>
|
||||
{% endblock %}
|
||||
78
claims/templates/claims/user_management.html
Normal file
78
claims/templates/claims/user_management.html
Normal file
@@ -0,0 +1,78 @@
|
||||
{% extends "claims/base.html" %}
|
||||
|
||||
{% block title %}Användarhantering{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<h1>Användare & behörigheter</h1>
|
||||
<p>Skapa nya konton, underhåll behörigheter och ta bort användare kopplat till utläggssystemet.</p>
|
||||
|
||||
<p><small>Notis: sidan hanterar direkta behörigheter. Behörigheter via grupper eller superuser-status gäller även om kryssrutorna avmarkeras.</small></p>
|
||||
|
||||
<section>
|
||||
<h2>Skapa ny användare</h2>
|
||||
<form method="post">
|
||||
{% csrf_token %}
|
||||
<input type="hidden" name="action" value="create">
|
||||
{{ create_form.as_p }}
|
||||
<button type="submit">Skapa användare</button>
|
||||
</form>
|
||||
</section>
|
||||
|
||||
<hr>
|
||||
|
||||
<section>
|
||||
<h2>Befintliga användare</h2>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Användare</th>
|
||||
<th>Namn</th>
|
||||
<th>E-post</th>
|
||||
<th>Behörigheter</th>
|
||||
<th>Ta bort</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for row in user_rows %}
|
||||
{% with user=row.user %}
|
||||
<tr>
|
||||
<td>
|
||||
{{ user.username }}
|
||||
{% if user.is_superuser %}<span title="Superuser">⭐</span>{% endif %}
|
||||
</td>
|
||||
<td>{{ user.get_full_name|default:"-" }}</td>
|
||||
<td>{{ user.email|default:"-" }}</td>
|
||||
<td>
|
||||
{% with form=row.permission_form %}
|
||||
<form method="post">
|
||||
{% csrf_token %}
|
||||
<input type="hidden" name="action" value="update">
|
||||
{{ form.user_id }}
|
||||
<label>{{ form.is_staff }} {{ form.is_staff.label }}</label><br>
|
||||
<label>{{ form.grant_view }} {{ form.grant_view.label }}</label><br>
|
||||
<label>{{ form.grant_change }} {{ form.grant_change.label }}</label><br>
|
||||
<button type="submit">Spara</button>
|
||||
</form>
|
||||
{% endwith %}
|
||||
</td>
|
||||
<td>
|
||||
{% if row.delete_form %}
|
||||
<form method="post" onsubmit="return confirm('Ta bort {{ user.username }}?');">
|
||||
{% csrf_token %}
|
||||
<input type="hidden" name="action" value="delete">
|
||||
{{ row.delete_form.user_id }}
|
||||
<button type="submit">Ta bort</button>
|
||||
</form>
|
||||
{% else %}
|
||||
<em>—</em>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endwith %}
|
||||
{% empty %}
|
||||
<tr><td colspan="5">Inga användare upplagda.</td></tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user