Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Küppers, Dorothee
oos_2020_todo
Commits
9903d9d0
Commit
9903d9d0
authored
Jul 06, 2020
by
dorothee.kueppers
Browse files
- aktuelle Selection anzeigen (falls eine läuft)
- Todos editieren und löschen
parent
0593a758
Changes
6
Hide whitespace changes
Inline
Side-by-side
oos_2020_todo/urls.py
View file @
9903d9d0
...
...
@@ -20,17 +20,22 @@ from django.urls import path
from
django.views.i18n
import
JavaScriptCatalog
from
django.conf
import
settings
from
todo.views
import
get_landing_page
,
get_selection_page
,
add_todo
,
get_impressum
,
get_show_todo
,
get_archiv
from
todo.views
import
get_landing_page
,
get_selection_page
,
todo_details
,
get_impressum
,
get_show_todo
,
\
get_archiv
,
get_selection_id
,
delete_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'
),
path
(
'selection/<int:pk>/'
,
get_selection_id
,
name
=
'selection_id'
),
path
(
'todo/add/'
,
todo_details
,
name
=
'add_todo'
),
path
(
'todo/edit/<int:pk>/'
,
todo_details
,
name
=
'edit_todo'
),
path
(
'todo/delte/<int:pk>/'
,
delete_todo
,
name
=
'delete_todo'
),
path
(
'impressum/'
,
get_impressum
,
name
=
'impressum'
),
path
(
'todo/show/'
,
get_show_todo
,
name
=
'show_todo'
),
path
(
'todo/archiv/'
,
get_archiv
,
name
=
'archv'
),
path
(
'todo/archiv/'
,
get_archiv
,
name
=
'archiv'
),
]
if
settings
.
DEBUG
:
...
...
templates/todo/base.html
View file @
9903d9d0
...
...
@@ -9,6 +9,7 @@
{% bootstrap_css %}
{% bootstrap_javascript jquery='full' %}
<link
rel=
"stylesheet"
href=
"{% static 'css/main.css' %}"
>
<link
href=
"https://fonts.googleapis.com/icon?family=Material+Icons"
rel=
"stylesheet"
>
</head>
<body>
{# fix for https://github.com/django-recurrence/django-recurrence/issues/47 #}
...
...
@@ -31,24 +32,30 @@
<div
class=
"collapse navbar-collapse"
id=
"navbarNav"
>
<ul
class=
"navbar-nav"
>
<li
class=
"nav-item active"
>
<a
class=
"nav-link"
href=
"
/todo/add"
>
neues Todo
<span
class=
"sr-only"
>
(current)
</span></a>
<a
class=
"nav-link"
href=
"
{% url 'landing_page' %}"
>
Start
<span
class=
"sr-only"
>
(current)
</span></a>
</li>
<li
class=
"nav-item"
>
<a
class=
"nav-link"
href=
"#"
>
alle Todos
</a>
<li
class=
"nav-item active"
>
<a
class=
"nav-link"
href=
"{% url 'selection_page' %}"
>
Aufgabenliste
<span
class=
"sr-only"
>
(current)
</span></a>
</li>
<li
class=
"nav-item active"
>
<a
class=
"nav-link"
href=
"{% url 'add_todo' %}"
>
neue Aufgabe
<span
class=
"sr-only"
>
(current)
</span></a>
</li>
<li
class=
"nav-item"
>
<a
class=
"nav-link"
href=
"#"
>
alte Todos
</a>
<li
class=
"nav-item active"
>
<a
class=
"nav-link"
href=
"{% url 'show_todo' %}"
>
alle Aufgaben
</a>
</li>
<li
class=
"nav-item active"
>
<a
class=
"nav-link"
href=
"{% url 'archiv' %}"
>
Archiv
</a>
</li>
</ul>
</div>
<!-- Navbar auf rechter Seite/Log In und Register Seite-->
<div
class=
"navbar-nav"
>
<a
class=
"nav-item nav-link"
href=
"todo/login"
>
Login
</a>
<a
class=
"nav-item nav-link
active
"
href=
"todo/login"
>
Login
</a>
</div>
<div
class=
"navbar-nav"
>
<a
class=
"nav-item nav-link"
href=
"todo/register"
>
Register
</a>
<a
class=
"nav-item nav-link
active
"
href=
"todo/register"
>
Register
</a>
</div>
</nav>
...
...
@@ -68,7 +75,7 @@
</div>
{% block footer %}
<nav
class=
"navbar fixed-bottom navbar-light bg-light"
>
<a
class=
"navbar-brand"
href=
"
/
impressum"
>
Impressum
</a>
<a
class=
"navbar-brand"
href=
"
{% url '
impressum
' %}
"
>
Impressum
</a>
</nav>
<script
type=
'text/javascript'
src=
{%
static
'
js
/
selectionpage.js
'
%}
></script>
<script
type=
'text/javascript'
src=
{%
static
'
js
/
showtodos.js
'
%}
></script>
...
...
templates/todo/landing_page.html
View file @
9903d9d0
{% extends 'todo/base.html' %}
{% block content %}
{% if not running_selection %}
<div
class=
"row justify-content-center m-2"
>
<a
class=
"btn btn-primary btn-lg"
href=
"
/
selection
"
>
LOSLEGEN
</a>
<a
class=
"btn btn-primary btn-lg"
href=
"
{% url '
selection
_page' %}"
>
Aufgabenliste Anlegen
</a>
</div>
{% endif %}
{% if running_selection %}
<div
class=
"row justify-content-center m-2"
>
<a
class=
"btn btn-primary btn-lg"
href=
"
/todo/add/"
>
TO DO ANLEGEN
</a>
<a
class=
"btn btn-primary btn-lg"
href=
"
{% url 'selection_id' pk=selection.id %}"
>
aktuelle Aufgabenliste
</a>
</div>
{% endif %}
<div
class=
"row justify-content-center m-2"
>
<a
class=
"btn btn-primary btn-lg"
href=
"
/todo/show"
>
TO DO´S ANZEIGEN
</a>
<a
class=
"btn btn-primary btn-lg"
href=
"
{% url 'add_todo' %}"
>
Neue Aufgabe Anlegen
</a>
</div>
<div
class=
"row justify-content-center m-2"
>
<a
class=
"btn btn-primary btn-lg"
href=
"/todo/archiv"
>
ARCHIV
</a>
<a
class=
"btn btn-primary btn-lg"
href=
"{% url 'show_todo' %}"
>
Alle Aufgaben anzeigen
</a>
</div>
<div
class=
"row justify-content-center m-2"
>
<a
class=
"btn btn-primary btn-lg"
href=
"{% url 'archiv' %}"
>
Archiv
</a>
</div>
{% endblock %}
templates/todo/show_todo.html
View file @
9903d9d0
...
...
@@ -26,15 +26,29 @@
data-parent=
"#accordion"
>
<div
class=
"card-body"
id=
"body-late"
>
<div
class=
"list-group list-group-flush"
>
{% for todo in todos_late %}
<div
class=
"list-group-item list-group-item-action select-todo-grid-show"
>
<input
class=
"todo-check"
type=
"checkbox"
>
<div
class=
"todo-text"
>
{{ todo.0.text }}
</div>
<div
class=
"todo-duration"
>
{{ todo.0.duration }} Minuten
</div>
<div
class=
"todo-due"
>
{{ todo.1 }}
</div>
<div
class=
"todo-id"
hidden
>
{{ todo.0.id }}
</div>
</div>
{% endfor %}
{% if todos_late %}
{% for todo in todos_late %}
<div
class=
"list-group-item list-group-item-action select-todo-grid-show"
>
<input
class=
"todo-check"
type=
"checkbox"
>
<div
class=
"todo-text"
>
{{ todo.0.text }}
</div>
<div
class=
"todo-duration"
>
{{ todo.0.duration }} Minuten
</div>
<div
class=
"todo-due"
>
{{ todo.1 }}
</div>
<div
class=
"todo-edit"
>
<a
href=
"{% url 'edit_todo' pk=todo.0.id %}"
>
<span
class=
"material-icons"
>
edit
</span>
</a>
</div>
<div
class=
"todo-delete"
>
<a
href=
"{% url 'delete_todo' pk=todo.0.id %}"
>
<span
class=
"material-icons"
>
delete
</span>
</a>
</div>
<div
class=
"todo-id"
hidden
>
{{ todo.0.id }}
</div>
</div>
{% endfor %}
{% else %}
<p>
Keine Aufgaben in dieser Kategorie!
</p>
{% endif %}
</div>
</div>
</div>
...
...
@@ -52,15 +66,29 @@
<div
id=
"collapseTwo"
class=
"collapse"
aria-labelledby=
"headingTwo"
data-parent=
"#accordion"
>
<div
class=
"card-body"
>
<div
class=
"list-group list-group-flush"
>
{% for todo in todos_today %}
<div
class=
"list-group-item list-group-item-action select-todo-grid-show"
>
<input
class=
"todo-check"
type=
"checkbox"
>
<div
class=
"todo-text"
>
{{ todo.0.text }}
</div>
<div
class=
"todo-duration"
>
{{ todo.0.duration }} Minuten
</div>
<div
class=
"todo-due"
>
{{ todo.1 }}
</div>
<div
class=
"todo-id"
hidden
>
{{ todo.0.id }}
</div>
</div>
{% endfor %}
{% if todos_today %}
{% for todo in todos_today %}
<div
class=
"list-group-item list-group-item-action select-todo-grid-show"
>
<input
class=
"todo-check"
type=
"checkbox"
>
<div
class=
"todo-text"
>
{{ todo.0.text }}
</div>
<div
class=
"todo-duration"
>
{{ todo.0.duration }} Minuten
</div>
<div
class=
"todo-due"
>
{{ todo.1 }}
</div>
<div
class=
"todo-edit"
>
<a
href=
"{% url 'edit_todo' pk=todo.0.id %}"
>
<span
class=
"material-icons"
>
edit
</span>
</a>
</div>
<div
class=
"todo-delete"
>
<a
href=
"{% url 'delete_todo' pk=todo.0.id %}"
>
<span
class=
"material-icons"
>
delete
</span>
</a>
</div>
<div
class=
"todo-id"
hidden
>
{{ todo.0.id }}
</div>
</div>
{% endfor %}
{% else %}
<p>
Keine Aufgaben in dieser Kategorie!
</p>
{% endif %}
</div>
</div>
</div>
...
...
@@ -79,15 +107,29 @@
data-parent=
"#accordion"
>
<div
class=
"card-body"
>
<div
class=
"list-group list-group-flush"
>
{% for todo in todos_soon %}
<div
class=
"list-group-item list-group-item-action select-todo-grid-show"
>
<input
class=
"todo-check"
type=
"checkbox"
>
<div
class=
"todo-text"
>
{{ todo.0.text }}
</div>
<div
class=
"todo-duration"
>
{{ todo.0.duration }} Minuten
</div>
<div
class=
"todo-due"
>
{{ todo.1 }}
</div>
<div
class=
"todo-id"
hidden
>
{{ todo.0.id }}
</div>
</div>
{% endfor %}
{% if todos_soon %}
{% for todo in todos_soon %}
<div
class=
"list-group-item list-group-item-action select-todo-grid-show"
>
<input
class=
"todo-check"
type=
"checkbox"
>
<div
class=
"todo-text"
>
{{ todo.0.text }}
</div>
<div
class=
"todo-duration"
>
{{ todo.0.duration }} Minuten
</div>
<div
class=
"todo-due"
>
{{ todo.1 }}
</div>
<div
class=
"todo-edit"
>
<a
href=
"{% url 'edit_todo' pk=todo.0.id %}"
>
<span
class=
"material-icons"
>
edit
</span>
</a>
</div>
<div
class=
"todo-delete"
>
<a
href=
"{% url 'delete_todo' pk=todo.0.id %}"
>
<span
class=
"material-icons"
>
delete
</span>
</a>
</div>
<div
class=
"todo-id"
hidden
>
{{ todo.0.id }}
</div>
</div>
{% endfor %}
{% else %}
<p>
Keine Aufgaben in dieser Kategorie!
</p>
{% endif %}
</div>
</div>
</div>
...
...
@@ -106,14 +148,28 @@
data-parent=
"#accordion"
>
<div
class=
"card-body"
>
<ul
class=
"list-group list-group-flush"
>
{% for todo in todos_someday %}
<div
class=
"list-group-item list-group-item-action select-todo-grid-show"
>
<input
class=
"todo-check"
type=
"checkbox"
>
<div
class=
"todo-text"
>
{{ todo.text }}
</div>
<div
class=
"todo-duration"
>
{{ todo.duration }} Minuten
</div>
<div
class=
"todo-id"
hidden
>
{{ todo.id }}
</div>
</div>
{% endfor %}
{% if todos_someday %}
{% for todo in todos_someday %}
<div
class=
"list-group-item list-group-item-action select-todo-grid-show"
>
<input
class=
"todo-check"
type=
"checkbox"
>
<div
class=
"todo-text"
>
{{ todo.text }}
</div>
<div
class=
"todo-duration"
>
{{ todo.duration }} Minuten
</div>
<div
class=
"todo-edit"
>
<a
href=
"{% url 'edit_todo' pk=todo.0.id %}"
>
<span
class=
"material-icons"
>
edit
</span>
</a>
</div>
<div
class=
"todo-delete"
>
<a
href=
"{% url 'delete_todo' pk=todo.0.id %}"
>
<span
class=
"material-icons"
>
delete
</span>
</a>
</div>
<div
class=
"todo-id"
hidden
>
{{ todo.id }}
</div>
</div>
{% endfor %}
{% else %}
<p>
Keine Aufgaben in dieser Kategorie!
</p>
{% endif %}
</ul>
</div>
</div>
...
...
todo/static/css/main.css
View file @
9903d9d0
...
...
@@ -64,7 +64,7 @@ div.form-control.recurrence-widget {
/*show todos*/
.list-group-item.select-todo-grid-show
{
display
:
grid
;
grid-template-columns
:
20px
auto
auto
3
0px
3
0px
;
grid-template-columns
:
20px
auto
auto
5
0px
5
0px
;
grid-template-rows
:
auto
auto
;
}
...
...
@@ -76,6 +76,7 @@ div.form-control.recurrence-widget {
.select-todo-grid-show
.todo-text
{
grid-column-start
:
2
;
align-self
:
center
;
}
.select-todo-grid-show
.todo-due
{
...
...
@@ -92,6 +93,18 @@ div.form-control.recurrence-widget {
width
:
fit-content
;
}
.select-todo-grid-show
.todo-edit
{
grid-column-start
:
4
;
justify-self
:
end
;
width
:
fit-content
;
}
.select-todo-grid-show
.todo-delete
{
grid-column-start
:
5
;
justify-self
:
end
;
width
:
fit-content
;
}
#show-todos
#accordion
{
width
:
-webkit-fill-available
;
}
\ No newline at end of file
todo/views.py
View file @
9903d9d0
from
django.db.models
import
Max
from
django.contrib
import
messages
from
django.db.models
import
Max
,
Model
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
...
...
@@ -10,13 +10,28 @@ from todo.models import *
def
get_landing_page
(
request
):
todo_list
=
Todo
.
objects
.
order_by
(
'id'
)
context
=
{
'todo_list'
:
todo_list
}
return
render
(
request
,
'todo/landing_page.html'
,
{
'page_title'
:
'Feierabend!'
})
try
:
selection
=
Selection
.
objects
.
filter
(
active
=
True
).
latest
(
'endtime'
)
except
Model
.
DoesNotExist
:
selection
=
None
if
selection
is
not
None
and
selection
.
endtime
>
timezone
.
now
():
running_selection
=
True
else
:
running_selection
=
False
content
=
{
'page_title'
:
'Feierabend!'
,
'running_selection'
:
running_selection
,
'selection'
:
selection
}
def
add_todo
(
request
):
todo
=
Todo
()
return
render
(
request
,
'todo/landing_page.html'
,
content
)
def
todo_details
(
request
,
pk
=
None
):
if
pk
:
todo
=
Todo
.
objects
.
get
(
pk
=
pk
)
else
:
todo
=
Todo
()
if
request
.
method
==
'POST'
:
form
=
TodoForm
(
request
.
POST
,
instance
=
todo
)
...
...
@@ -33,11 +48,18 @@ def add_todo(request):
else
:
messages
.
error
(
request
,
'Deine Eingabe war leider nicht korrekt.'
)
else
:
form
=
TodoForm
()
form
=
TodoForm
(
instance
=
todo
)
return
render
(
request
,
'todo/add_todo.html'
,
{
'page_title'
:
'Lege eine neue Aufgabe an! '
,
'form'
:
form
})
def
delete_todo
(
request
,
pk
=
None
):
if
pk
:
Todo
.
objects
.
get
(
pk
=
pk
).
delete
()
return
HttpResponseRedirect
(
reverse_lazy
(
'show_todo'
))
def
get_selection_page
(
request
):
selection
=
Selection
()
...
...
@@ -75,37 +97,53 @@ def get_selection_page(request):
'todos_selection'
:
[],
}
return
render
(
request
,
'todo/selection_page.html'
,
content
)
# show to do Anfang
todos_with_recurrence
=
Todo
.
objects
.
filter
(
complete
=
False
).
exclude
(
recurrences__exact
=
''
)
todos_without_recurrence
=
Todo
.
objects
.
filter
(
complete
=
False
).
filter
(
recurrences__exact
=
''
)
def
get_selection_id
(
request
,
pk
=
None
):
if
request
.
method
==
'POST'
:
form
=
CheckedTodosForm
(
request
.
POST
)
if
form
.
is_valid
():
checked_ids
=
form
.
todos_string_to_list
()
if
checked_ids
and
checked_ids
!=
[
''
]:
for
todo_id
in
checked_ids
:
todo
=
Todo
.
objects
.
get
(
pk
=
todo_id
)
todo
.
complete
=
True
todo
.
save
()
messages
.
success
(
request
,
'Änderung gespeichert'
)
return
HttpResponseRedirect
(
reverse_lazy
(
'landing_page'
))
else
:
print
(
'Data incorrect'
)
messages
.
error
(
request
,
'Data incorrect'
)
form
=
CheckedTodosForm
()
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
())
todos_someday
=
[]
sort_todos
(
todos_late
,
todos_someday
,
todos_soon
,
todos_today
,
pk
)
if
next_occur
.
date
()
==
datetime
.
date
.
today
():
todos_today
.
append
(
recur_todo
)
else
:
todos_soon
.
append
(
recur_todo
)
# show to do - Ende
content
=
{
'page_title'
:
'Deine aktuelle Aufgabenliste'
,
'form'
:
form
,
'todos_today'
:
todos_today
,
'todos_soon'
:
todos_soon
,
'todos_late'
:
todos_late
,
'todos_someday'
:
todos_someday
,
'todos_selection'
:
[],
}
# content = {'page_title': 'to Dos anzeigen'}
return
render
(
request
,
'todo/show_todo.html'
,
content
)
def
sort_todos
(
todos_late
,
todos_someday
,
todos_soon
,
todos_today
,
select_id
=
None
):
if
select_id
is
None
:
todos_with_recurrence
=
Todo
.
objects
.
filter
(
complete
=
False
).
exclude
(
recurrences__exact
=
''
)
todos_someday
=
Todo
.
objects
.
filter
(
complete
=
False
).
filter
(
recurrences__exact
=
''
)
else
:
todos_with_recurrence
=
Todo
.
objects
.
filter
(
complete
=
False
).
filter
(
selection_id
=
select_id
).
exclude
(
recurrences__exact
=
''
)
todos_someday
=
Todo
.
objects
.
filter
(
complete
=
False
).
filter
(
selection_id
=
select_id
).
filter
(
recurrences__exact
=
''
)
def
sort_todos
(
todos_late
,
todos_someday
,
todos_soon
,
todos_today
):
todos_with_recurrence
=
Todo
.
objects
.
filter
(
complete
=
False
).
exclude
(
recurrences__exact
=
''
)
todos_someday
=
Todo
.
objects
.
filter
(
complete
=
False
).
filter
(
recurrences__exact
=
''
)
for
recur_todo
in
todos_with_recurrence
:
next_occur
=
recur_todo
.
recurrences
.
after
(
datetime
.
datetime
.
now
()
-
datetime
.
timedelta
(
days
=
1
),
...
...
@@ -171,10 +209,12 @@ def get_archiv(request):
content
=
{
'page_title'
:
'Archiv'
}
return
render
(
request
,
'todo/archiv.html'
,
content
)
def
get_login
(
request
):
content
=
{
'page_title'
:
'Log In'
}
return
render
(
request
,
'todo/login.html'
,
content
)
def
get_register
(
request
):
content
=
{
'page_title'
:
'Register'
}
return
render
(
request
,
'todo/register.html'
,
content
)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment