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

Einbau django-recurrence für Todo Formular

parent fb40149f
No preview for this file type
......@@ -38,7 +38,8 @@ INSTALLED_APPS = [
'django.contrib.messages',
'django.contrib.staticfiles',
'todo',
'bootstrap4'
'bootstrap4',
'recurrence',
]
MIDDLEWARE = [
......@@ -121,3 +122,4 @@ USE_TZ = True
# https://docs.djangoproject.com/en/3.0/howto/static-files/
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
......@@ -13,14 +13,26 @@ Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.conf.urls import url
from django.contrib import admin
from django.urls import path
from django.views.i18n import JavaScriptCatalog
from todo.views import get_landing_page, get_selection_page
from todo.views import get_landing_page, get_selection_page, add_todo
urlpatterns = [
path('admin/', admin.site.urls),
path('start/', get_landing_page, name='landing_page'),
path('', get_landing_page, name='landing_page'),
path('selection/', get_selection_page, name='selection_page'),
path('todo/add/', add_todo, name='add_todo'),
]
# according to https://django-recurrence.readthedocs.io/en/latest/installation.html
js_info_dict = {
'packages': ('recurrence', ),
}
urlpatterns += [
url(r'^jsi18n/$', JavaScriptCatalog.as_view(), js_info_dict),
]
......@@ -31,3 +31,5 @@ sphinxcontrib-serializinghtml==1.1.4
sqlparse==0.3.1
urllib3==1.25.9
zipp==3.1.0
django-recurrence~=1.10.3
\ No newline at end of file
{% extends 'todo/base.html' %}
{% load bootstrap4 %}
{% block content %}
<form method="POST" class="post-form">
{% csrf_token %}
{{ form.media }}
{% bootstrap_form form %}
<button class="btn btn-primary" type="submit">Speichern</button>
</form>
{% endblock %}
\ No newline at end of file
......@@ -10,6 +10,15 @@
{% bootstrap_javascript jquery='full' %}
</head>
<body>
{# fix for https://github.com/django-recurrence/django-recurrence/issues/47 #}
{# no i18n #}
<script>
if (!pgettext) {
function pgettext(ignore, t) {
return gettext(t);
}
}
</script>
{% block header %}
{#Navigation#}
<nav class="navbar navbar-expand-lg navbar-light bg-light">
......@@ -33,11 +42,11 @@
</ul>
</div>
<!-- Navbar auf rechter Seite-->
<div class="navbar-nav">
<a class="nav-item nav-link" href="#">Login</a>
<a class="nav-item nav-link" href="#">Register</a>
<div class="navbar-nav">
<a class="nav-item nav-link" href="#">Login</a>
<a class="nav-item nav-link" href="#">Register</a>
</div>
</div>
</nav>
{% endblock %}
......
from django.forms import *
from todo.models import *
from django import forms
from recurrence.fields import RecurrenceField
from todo.models import Todo
class TodoForm(forms.ModelForm):
class Meta:
model = Todo
exclude = ['created']
# widgets = {
# 'recurrences': RecurrenceField(attrs={'style': 'width:400px; height:400px'})
# }
class SelectionForm(forms.Form):
......
# Generated by Django 3.0.7 on 2020-07-02 05:09
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('todo', '0003_selection_name'),
]
operations = [
migrations.AlterField(
model_name='selection',
name='total_time',
field=models.IntegerField(default=0),
),
]
# Generated by Django 3.0.7 on 2020-07-02 18:20
import datetime
from django.db import migrations, models
import recurrence.fields
class Migration(migrations.Migration):
dependencies = [
('todo', '0004_auto_20200702_0509'),
]
operations = [
migrations.AddField(
model_name='todo',
name='created',
field=models.DateTimeField(default=datetime.datetime.now),
),
migrations.AddField(
model_name='todo',
name='due_date',
field=models.DateTimeField(null=True),
),
migrations.AddField(
model_name='todo',
name='duration',
field=models.IntegerField(default=15),
),
migrations.AddField(
model_name='todo',
name='rank',
field=models.IntegerField(default=1),
),
migrations.AddField(
model_name='todo',
name='recurrences',
field=recurrence.fields.RecurrenceField(null=True),
),
]
# Generated by Django 3.0.7 on 2020-07-02 18:22
import datetime
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('todo', '0005_auto_20200702_1820'),
]
operations = [
migrations.AlterField(
model_name='todo',
name='created',
field=models.DateField(default=datetime.date.today),
),
]
from django.db import models
import datetime
# Create your models here.
from django.db import models
from recurrence.fields import RecurrenceField
from requests import hooks
class Todo(models.Model):
text = models.CharField(max_length=200)
complete = models.BooleanField(default=False)
duration = models.IntegerField(default=15)
due_date = models.DateTimeField(null=True)
created = models.DateField(default=datetime.date.today)
rank = models.IntegerField(default=1)
recurrences = RecurrenceField(null=True)
def __str__(self):
return self.text
......@@ -14,7 +21,7 @@ class Todo(models.Model):
class Selection(models.Model):
name = models.CharField(max_length=30, default="name")
items = models.ManyToManyField(Todo)
total_time = models.IntegerField(default=0) # in minutes
total_time = models.IntegerField(default=0) # in minutes
def __str__(self):
return f'{self.name} , duration: {self.total_time.__str__()}'
return f'{self.name}, total time: {self.total_time.__str__()}'
......@@ -12,6 +12,14 @@ def get_landing_page(request):
context = {'todo_list': todo_list}
return render(request, 'todo/landing_page.html', {'page_title': 'Feierabend!'})
def add_todo(request):
todo = Todo()
if(request.method == 'POST'):
pass
else:
form = TodoForm()
return render(request, 'todo/add_todo.html', {'form': form})
def get_selection_page(request):
selection = Selection()
......
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