Commit 81e2336c authored by dorothee.kueppers's avatar dorothee.kueppers
Browse files

Todo auch ohne Wiederholung möglich

parent a01ed1fa
No preview for this file type
......@@ -16,6 +16,8 @@ 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(
......
......@@ -11,7 +11,7 @@ class Todo(models.Model):
duration = models.IntegerField(default=15)
created = models.DateField(default=datetime.date.today)
rank = models.IntegerField(default=1)
recurrences = RecurrenceField(null=True)
recurrences = RecurrenceField(blank=True, null=True)
def __str__(self):
return self.text
......
from django.db.models import Max
from django.http import HttpResponseRedirect
from django.shortcuts import render
from django.contrib import messages
......@@ -19,7 +20,10 @@ def add_todo(request):
if request.method == 'POST':
form = TodoForm(request.POST, instance=todo)
if form.is_valid():
form.save()
todo = form.instance
max_rank = Todo.objects.all().aggregate(Max('rank')).get('rank__max')
todo.rank = max_rank + 1
todo.save()
messages.success(request, "Dein Todo wurde abgespeichert")
return HttpResponseRedirect(reverse_lazy('landing_page'))
else:
......
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