Commit d8a352a7 authored by dorothee.kueppers's avatar dorothee.kueppers
Browse files

Todos auf Selection-Seitee

parent 81e2336c
No preview for this file type
......@@ -107,9 +107,9 @@ AUTH_PASSWORD_VALIDATORS = [
# Internationalization
# https://docs.djangoproject.com/en/3.0/topics/i18n/
LANGUAGE_CODE = 'en-us'
LANGUAGE_CODE = 'de-de'
TIME_ZONE = 'UTC'
TIME_ZONE = 'Europe/Berlin'
USE_I18N = True
......@@ -117,6 +117,8 @@ USE_L10N = True
USE_TZ = True
RECURRENCE_USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.0/howto/static-files/
......
/*.todo-box {*/
/* background: lightgrey;*/
/*}*/
div.form-control.recurrence-widget{
height: max-content;
margin-bottom: 16px;
}
\ No newline at end of file
......@@ -9,6 +9,7 @@
{% bootstrap_css %}
{% bootstrap_javascript jquery='full' %}
<link rel="stylesheet" href="{% static 'css/main.css' %}">
<script type='text/javascript' src={% static 'js/selectionpage.js' %}></script>
</head>
<body>
{# fix for https://github.com/django-recurrence/django-recurrence/issues/47 #}
......@@ -31,7 +32,7 @@
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav">
<li class="nav-item active">
<a class="nav-link" href="#">neues Todo <span class="sr-only">(current)</span></a>
<a class="nav-link" href="/todo/add">neues Todo <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">alle Todos</a>
......
......@@ -2,7 +2,7 @@
{% block content %}
<div class="row justify-content-center m-2">
<a class="btn btn-primary btn-lg" href="#">LOSLEGEN</a>
<a class="btn btn-primary btn-lg" href="/selection">LOSLEGEN</a>
</div>
<div class="row justify-content-center m-2">
<a class="btn btn-primary btn-lg" href="/todo/add/">TO DO ANLEGEN</a>
......
......@@ -3,6 +3,7 @@
{% load bootstrap4 %}
{% block content %}
<script src='../../todo/static/js/selectionpage.js'></script>
<div class="row">
<form action="" enctype="multipart/form-data" method="POST">
{% csrf_token %}
......@@ -18,9 +19,96 @@
</div>
</div>
</form>
<div class="col-sm todo-box">
<div class="col-sm" id="todo-choices">
<div class="row justify-content-center">
<img alt="some image" src="{% static "todo/mole.png" %}" width="100px" height="100px"/>
<div id="accordion">
<div class="card">
<div class="card-header" id="headingOne">
<h5 class="mb-0">
<button class="btn btn-link" data-toggle="collapse" data-target="#collapseOne"
aria-expanded="true" aria-controls="collapseOne">
Dinge, die heute zu erledigen sind
</button>
</h5>
</div>
<div id="collapseOne" class="collapse show" aria-labelledby="headingOne"
data-parent="#accordion">
<div class="card-body">
<div class="list-group list group-flush">
{% for todo in todos_today %}
<button type="button" class="list-group-item list-group-item-action">
{{ todo.0.text }}, {{ todo.1 }}
</button>
{% endfor %}
</div>
</div>
</div>
</div>
<div class="card">
<div class="card-header" id="headingTwo">
<h5 class="mb-0">
<button class="btn btn-link collapsed" data-toggle="collapse" data-target="#collapseTwo"
aria-expanded="false" aria-controls="collapseTwo">
Dinge, die bald zu erledigen sind
</button>
</h5>
</div>
<div id="collapseTwo" class="collapse" aria-labelledby="headingTwo" data-parent="#accordion">
<div class="card-body">
<ul class="list-group list group-flush">
{% for todo in todos_soon %}
<li class="list-group-item">{{ todo.0.text }}, {{ todo.1 }}</li>
{% endfor %}
</ul>
</div>
</div>
</div>
<div class="card">
<div class="card-header" id="headingThree">
<h5 class="mb-0">
<button class="btn btn-link collapsed" data-toggle="collapse"
data-target="#collapseThree" aria-expanded="false"
aria-controls="collapseThree">
Dinge, die keinen Zeitdruck haben
</button>
</h5>
</div>
<div id="collapseThree" class="collapse" aria-labelledby="headingThree"
data-parent="#accordion">
<div class="card-body">
<ul class="list-group list group-flush">
{% for todo in todos_someday %}
<li class="list-group-item">{{ todo.text }}</li>
{% endfor %}
</ul>
</div>
</div>
</div>
<div class="card">
<div class="card-header" id="headingFour">
<h5 class="mb-0">
<button class="btn btn-link collapsed" data-toggle="collapse"
data-target="#collapseFour" aria-expanded="false"
aria-controls="collapseFour">
Dinge, die eigentlich schon getan sein sollten
</button>
</h5>
</div>
<div id="collapseFour" class="collapse" aria-labelledby="headingFour"
data-parent="#accordion">
<div class="card-body">
<ul class="list-group list group-flush">
{% for todo in todos_late %}
<li class="list-group-item">{{ todo.0.text }}, {{ todo.1 }}</li>
{% endfor %}
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
......
......@@ -16,21 +16,19 @@ class TodoForm(forms.ModelForm):
'duration': 'Was meinst du, wie lange die Aufgabe dauert? (in Minuten) *',
'recurrences': 'Wiederholungen'}
# def clean_rank(selfself):
class SelectionForm(forms.Form):
duration_hours = forms.IntegerField(
label='Stunden',
max_value=24,
min_value=0,
widget=forms.NumberInput(attrs={'max': 24, 'min': 0, 'style': 'width: 200px;'})
widget=forms.NumberInput(attrs={'max': 24, 'min': 0, 'style': 'width:150px;'})
)
duration_minutes = forms.IntegerField(
label='Minuten',
max_value=59,
min_value=0,
widget=forms.NumberInput(attrs={'max': 55, 'min': 0, 'step': 5, 'style': 'width: 200px;'})
widget=forms.NumberInput(attrs={'max': 55, 'min': 0, 'step': 5, 'style': 'width: 150px;'})
)
def calc_total_time(self):
......
......@@ -2,7 +2,6 @@ import datetime
from django.db import models
from recurrence.fields import RecurrenceField
from requests import hooks
class Todo(models.Model):
......
.todo-box {
background: lightgrey;
}
/*.todo-box {*/
/* background: lightgrey;*/
/*}*/
div.form-control.recurrence-widget{ height: max-content; }
\ No newline at end of file
div.form-control.recurrence-widget{
height: max-content;
margin-bottom: 16px;
}
\ No newline at end of file
$('#todo-choices').visibility = false;
\ No newline at end of file
......@@ -3,6 +3,7 @@ from django.http import HttpResponseRedirect
from django.shortcuts import render
from django.contrib import messages
from django.urls import reverse_lazy
from django.utils import timezone
from todo.forms import *
from todo.models import *
......@@ -22,6 +23,9 @@ def add_todo(request):
if form.is_valid():
todo = form.instance
max_rank = Todo.objects.all().aggregate(Max('rank')).get('rank__max')
if max_rank is None:
todo.rank = 1
else:
todo.rank = max_rank + 1
todo.save()
messages.success(request, "Dein Todo wurde abgespeichert")
......@@ -36,6 +40,29 @@ def add_todo(request):
def get_selection_page(request):
selection = Selection()
todos_with_recurrence = Todo.objects.exclude(recurrences__exact='')
todos_without_recurrence = Todo.objects.filter(recurrences__exact='')
todos_today = []
todos_soon = []
todos_late = []
for recur_todo in todos_with_recurrence:
next_occur = recur_todo.recurrences.after(
datetime.datetime.now() - datetime.timedelta(days=1),
inc=True,
)
if next_occur is None:
last_occur = recur_todo.recurrences.before(
datetime.datetime.now(),
inc=True,
)
todos_late.append((recur_todo, last_occur.date()))
else:
recur_todo = (recur_todo, next_occur.date())
if next_occur.date() == datetime.date.today():
todos_today.append(recur_todo)
else:
todos_soon.append(recur_todo)
if request.method == 'POST':
form = SelectionForm(request.POST)
......@@ -49,5 +76,13 @@ def get_selection_page(request):
messages.error(request, 'Data incorrect')
else:
form = SelectionForm()
return render(request, 'todo/selection_page.html', {'page_title': 'Leg eine Liste an!',
'form': form})
content = {'page_title': 'Leg eine Liste an',
'form': form,
'todos_today': todos_today,
'todos_soon': todos_soon,
'todos_late': todos_late,
'todos_someday': todos_without_recurrence,
'todos_selection': [],
}
return render(request, 'todo/selection_page.html', content)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment