update tasks view

This commit is contained in:
2020-10-11 20:33:23 +00:00
parent 3584bbe070
commit 40a7939e69
3 changed files with 101 additions and 39 deletions

View File

@@ -1,4 +1,5 @@
from django import forms
from django.utils.translation import gettext_lazy as _
from .models import Task
@@ -13,3 +14,14 @@ class TaskForm(forms.ModelForm):
'due_date',
'assigned_to',
]
labels = {
'title': _('Titel des Tasks'),
'task_list': _('Task-Gruppe'),
'due_date': _('Fälligkeitsdatum'),
'assigned_to': _('Zuweisen an'),
}
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs) # to get the self.fields set
self.fields['assigned_to'].empty_label = "Alle"

View File

@@ -46,7 +46,7 @@ def index(request):
users = User.objects.all()
context = {
"form": form,
"formset": form,
"tasks": tasks,
"users": users,
"current_user": current_user,

View File

@@ -2,11 +2,72 @@
{% block content %}
<div class="grid-container">
<h1>Tasks</h1>
<div class="grid-x">
<form action="" method="post">
{% csrf_token %}
{% if current_user != None %}
{% for user in users %}
{% if current_user == user.id %}
<h1>Task-Übersicht für {{ user.username }}</h1>
{% endif %}
{% endfor %}
{% else %}
<h1>Task-Übersicht für alle Mitarbeiter_innen</h1>
{% endif %}
<form action="" method="post">
{% csrf_token %}
<div class="grid-x grid-margin-x">
{% regroup tasks by task_list as section_list %}
{% for group in section_list %}
<div class="cell">
<ul class="no-bullet">
<h3>{{ group.grouper }}</h3>
{% for task in group.list %}
<div class="grid-x">
<div class="cell medium-3 large-3 small-10">
<input type="checkbox" name="checkbox" value="{{ task.id }}" {% if task.completed %} checked {% endif %}>
{{ task.title }}</a>
</div>
<div class="cell medium-4 large-4 small-10">
{% if task.due_date is not None %}
Fälligkeitsdatum: {{ task.due_date|date:"d.m.Y" }}
{% endif %}
</div>
</div>
{% endfor %}
</ul>
</div>
{% endfor %}
<div class="cell">
<ul class="no-bullet">
<input type="submit" class="button" name="btn_checkbox" value="Task abschließen">
</ul>
</div>
</div>
</form>
<h2>Andere Task-Übersicht anzeigen</h2>
<form action="" method="post">
{% csrf_token %}
<div class="grid-x grid-margin-x">
<div class="cell medium-4 large-3 small-10">
<label>User
<select id="id_user" name="user">
<option value="all">
@@ -19,59 +80,48 @@
{% endfor %}
</select>
</label>
</div>
<div class="cell medium-4 large-3 small-10">
<label>Aktion
<select id="id_action" name="action">
<option value="show_incompleted" {% if not current_action %} selected {% endif %}>unvollständige Tasks</option>
<option value="show_all" {% if current_action %} selected {% endif %}>alle Tasks</option>
</select>
</label>
</div>
<div class="cell medium-3 large-3 small-10 align-self-bottom">
<input type="submit" class="button" name="btn_user" value="Anzeigen">
</form>
</div>
</div>
<div class="grid-x">
</form>
<form action="" method="post">
{% csrf_token %}
{% regroup tasks by task_list as section_list %}
{% for group in section_list %}
<h2>Neuen Task hinzufügen</h2>
<div class="cell">
<ul class="no-bullet">
<form action="" method="post">
{% csrf_token %}
<h3>{{ group.grouper }}</h3>
<div class="grid-x grid-margin-x">
{% for task in group.list %}
<input type="checkbox" name="checkbox" value="{{ task.id }}" {% if task.completed %} checked {% endif %}>
{{ task.title }}</a>
{{ task.due_date|date:"d.m.Y" }}
<br>
{% endfor %}
</div>
{{ formset.management_form }}
{% for form in formset %}
<div class="cell medium-3 large-2 small-10">
{{ form.label }}
{{ form }}
</div>
{% endfor %}
<input type="submit" class="button" name="btn_checkbox" value="Task abschließen">
</form>
<div class="cell medium-3 large-2 small-10 align-self-bottom">
<input type="submit" class="button" name="btn_input" value="Hinzufügen">
</div>
</div>
</div>
<div class="grid-x">
<form action="" method="post">
<h2>neue Tasks hinzufügen</h2>
{% csrf_token %}
{{ form }}
<input type="submit" class="button" name="btn_input" value="Hinzufügen">
</form>
</div>
</form>
</div>