Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
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
f76bd1a8
Commit
f76bd1a8
authored
Jul 06, 2020
by
dorothee.kueppers
Browse files
all-auth added
parent
24a82c55
Changes
4
Show whitespace changes
Inline
Side-by-side
oos_2020_todo/settings.py
View file @
f76bd1a8
...
@@ -34,12 +34,12 @@ DEBUG = True
...
@@ -34,12 +34,12 @@ DEBUG = True
ALLOWED_HOSTS
=
[]
ALLOWED_HOSTS
=
[]
# Application definition
# Application definition
INSTALLED_APPS
=
[
INSTALLED_APPS
=
[
'django_crontab'
,
'django_crontab'
,
'django.contrib.admin'
,
'django.contrib.admin'
,
'django.contrib.sites'
,
'django.contrib.auth'
,
'django.contrib.auth'
,
'django.contrib.contenttypes'
,
'django.contrib.contenttypes'
,
'django.contrib.sessions'
,
'django.contrib.sessions'
,
...
@@ -48,6 +48,10 @@ INSTALLED_APPS = [
...
@@ -48,6 +48,10 @@ INSTALLED_APPS = [
'todo'
,
'todo'
,
'bootstrap4'
,
'bootstrap4'
,
'recurrence'
,
'recurrence'
,
'allauth'
,
'allauth.account'
,
'allauth.socialaccount'
,
]
]
MIDDLEWARE
=
[
MIDDLEWARE
=
[
...
@@ -67,8 +71,7 @@ ROOT_URLCONF = 'oos_2020_todo.urls'
...
@@ -67,8 +71,7 @@ ROOT_URLCONF = 'oos_2020_todo.urls'
TEMPLATES
=
[
TEMPLATES
=
[
{
{
'BACKEND'
:
'django.template.backends.django.DjangoTemplates'
,
'BACKEND'
:
'django.template.backends.django.DjangoTemplates'
,
'DIRS'
:
[
os
.
path
.
join
(
BASE_DIR
,
'templates'
)]
'DIRS'
:
[
os
.
path
.
join
(
BASE_DIR
,
'templates'
)],
,
'APP_DIRS'
:
True
,
'APP_DIRS'
:
True
,
'OPTIONS'
:
{
'OPTIONS'
:
{
'context_processors'
:
[
'context_processors'
:
[
...
@@ -81,8 +84,17 @@ TEMPLATES = [
...
@@ -81,8 +84,17 @@ TEMPLATES = [
},
},
]
]
WSGI_APPLICATION
=
'oos_2020_todo.wsgi.application'
SITE_ID
=
1
AUTHENTICATION_BACKENDS
=
[
# Needed to login by username in Django admin, regardless of `allauth`
'django.contrib.auth.backends.ModelBackend'
,
# `allauth` specific authentication methods, such as login by e-mail
'allauth.account.auth_backends.AuthenticationBackend'
,
]
WSGI_APPLICATION
=
'oos_2020_todo.wsgi.application'
# Database
# Database
# https://docs.djangoproject.com/en/3.0/ref/settings/#databases
# https://docs.djangoproject.com/en/3.0/ref/settings/#databases
...
@@ -97,7 +109,6 @@ WSGI_APPLICATION = 'oos_2020_todo.wsgi.application'
...
@@ -97,7 +109,6 @@ WSGI_APPLICATION = 'oos_2020_todo.wsgi.application'
DATABASES
=
{}
DATABASES
=
{}
DATABASES
[
'default'
]
=
dj_database_url
.
config
(
conn_max_age
=
600
)
DATABASES
[
'default'
]
=
dj_database_url
.
config
(
conn_max_age
=
600
)
# Password validation
# Password validation
# https://docs.djangoproject.com/en/3.0/ref/settings/#auth-password-validators
# https://docs.djangoproject.com/en/3.0/ref/settings/#auth-password-validators
...
@@ -116,7 +127,6 @@ AUTH_PASSWORD_VALIDATORS = [
...
@@ -116,7 +127,6 @@ AUTH_PASSWORD_VALIDATORS = [
},
},
]
]
# Internationalization
# Internationalization
# https://docs.djangoproject.com/en/3.0/topics/i18n/
# https://docs.djangoproject.com/en/3.0/topics/i18n/
...
@@ -132,7 +142,6 @@ USE_TZ = True
...
@@ -132,7 +142,6 @@ USE_TZ = True
RECURRENCE_USE_TZ
=
True
RECURRENCE_USE_TZ
=
True
# Static files (CSS, JavaScript, Images)
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.0/howto/static-files/
# https://docs.djangoproject.com/en/3.0/howto/static-files/
...
@@ -144,12 +153,11 @@ CRONJOBS = [
...
@@ -144,12 +153,11 @@ CRONJOBS = [
(
'0 8 * * *'
,
'todo.cron.email_todays_todos'
)
(
'0 8 * * *'
,
'todo.cron.email_todays_todos'
)
]
]
# EMAIL_HOST = 'mail.gmx.net'
EMAIL_HOST
=
'mail.gmx.net'
# EMAIL_PORT: 587
EMAIL_PORT
:
587
# EMAIL_HOST_USER: 'feierabend-todo@gmx.de'
EMAIL_HOST_USER
:
'feierabend-todo@gmx.de'
# EMAIL_HOST_PASSWORD: 'oos_2020_todo'
EMAIL_HOST_PASSWORD
:
'oos_2020_todo'
# EMAIL_USE_TLS = True
EMAIL_USE_TLS
=
True
# Activate Django-Heroku.
# Activate Django-Heroku.
django_heroku
.
settings
(
locals
())
django_heroku
.
settings
(
locals
())
...
...
oos_2020_todo/urls.py
View file @
f76bd1a8
...
@@ -16,12 +16,12 @@ Including another URLconf
...
@@ -16,12 +16,12 @@ Including another URLconf
from
django.conf.urls
import
url
from
django.conf.urls
import
url
from
django.conf.urls.static
import
static
from
django.conf.urls.static
import
static
from
django.contrib
import
admin
from
django.contrib
import
admin
from
django.urls
import
path
from
django.urls
import
path
,
include
from
django.views.i18n
import
JavaScriptCatalog
from
django.views.i18n
import
JavaScriptCatalog
from
django.conf
import
settings
from
django.conf
import
settings
from
todo.views
import
get_landing_page
,
get_selection_page
,
todo_details
,
get_impressum
,
get_show_todo
,
\
from
todo.views
import
get_landing_page
,
get_selection_page
,
todo_details
,
get_impressum
,
get_show_todo
,
\
get_archiv
,
get_selection_id
,
delete_todo
,
get_register
,
get_login
get_archiv
,
get_selection_id
,
delete_todo
,
redirect_profile
urlpatterns
=
[
urlpatterns
=
[
path
(
'admin/'
,
admin
.
site
.
urls
),
path
(
'admin/'
,
admin
.
site
.
urls
),
...
@@ -36,8 +36,11 @@ urlpatterns = [
...
@@ -36,8 +36,11 @@ urlpatterns = [
path
(
'impressum/'
,
get_impressum
,
name
=
'impressum'
),
path
(
'impressum/'
,
get_impressum
,
name
=
'impressum'
),
path
(
'todo/show/'
,
get_show_todo
,
name
=
'show_todo'
),
path
(
'todo/show/'
,
get_show_todo
,
name
=
'show_todo'
),
path
(
'todo/archiv/'
,
get_archiv
,
name
=
'archiv'
),
path
(
'todo/archiv/'
,
get_archiv
,
name
=
'archiv'
),
path
(
'todo/register/'
,
get_register
,
name
=
"register"
),
# path('accounts/register/', get_register, name="register"),
path
(
'todo/login/'
,
get_login
,
name
=
"login"
),
# path('accounts/login/', get_login, name="login"),
# path('accounts/logout/', get_login, name="login"),
path
(
'accounts/'
,
include
(
'allauth.urls'
)),
path
(
'accounts/profile/'
,
redirect_profile
,
name
=
"redirect_profile"
),
]
]
if
settings
.
DEBUG
:
if
settings
.
DEBUG
:
...
...
templates/todo/base.html
View file @
f76bd1a8
...
@@ -51,13 +51,9 @@
...
@@ -51,13 +51,9 @@
</div>
</div>
<!-- Navbar auf rechter Seite/Log In und Register Seite-->
<!-- Navbar auf rechter Seite/Log In und Register Seite-->
<div
class=
"navbar-nav"
>
<div
class=
"navbar-nav"
>
<a
class=
"nav-item nav-link active"
href=
"{% url 'login' %}"
>
Login
</a>
<a
class=
"nav-item nav-link active"
href=
"accounts/logout"
>
Logout
</a>
</div>
</div>
<div
class=
"navbar-nav"
>
<a
class=
"nav-item nav-link active"
href=
"{% url 'register' %}"
>
Register
</a>
</div>
</nav>
</nav>
{% endblock %}
{% endblock %}
...
...
todo/views.py
View file @
f76bd1a8
import
logging
from
django.contrib
import
messages
from
django.contrib
import
messages
from
django.core.mail
import
send_mail
from
django.contrib.auth.decorators
import
login_required
from
django.db.models
import
Max
,
Model
from
django.http
import
HttpResponseRedirect
from
django.http
import
HttpResponseRedirect
from
django.shortcuts
import
render
,
redirect
from
django.shortcuts
import
render
,
redirect
from
django.urls
import
reverse_lazy
from
django.urls
import
reverse_lazy
from
django.utils
import
timezone
from
django.utils
import
timezone
from
django.contrib.auth.decorators
import
login_required
from
oos_2020_todo
import
settings
from
todo.forms
import
*
from
todo.forms
import
*
from
todo.models
import
*
from
todo.models
import
*
logger
=
logging
.
getLogger
(
'views'
)
def
register_page
(
request
):
if
request
.
user
.
is_authenticated
:
return
redirect
(
'landing_page'
)
else
:
form
=
CreateUserForm
()
if
request
.
method
==
'POST'
:
form
=
CreateUserForm
(
request
.
POST
)
if
form
.
is_valid
():
form
.
save
()
return
redirect
(
'login'
)
context
=
{
'form'
:
form
}
return
render
(
request
,
'todo/register.html'
,
context
)
def
login_page
(
request
):
if
request
.
user
.
is_authenticated
:
return
redirect
(
'login'
)
else
:
context
=
{}
return
render
(
request
,
'todo/login.html'
,
context
)
@
login_required
(
login_url
=
'login'
)
# def register_page(request):
# if request.user.is_authenticated:
# return redirect('landing_page')
# else:
# form = CreateUserForm()
# if request.method == 'POST':
# form = CreateUserForm(request.POST)
# if form.is_valid():
# form.save()
# return redirect('login')
#
# context = {'form': form}
# return render(request, 'todo/register.html', context)
#
#
# def login_page(request):
# if request.user.is_authenticated:
# return redirect('login')
# else:
# context = {}
# return render(request, 'todo/login.html', context)
@
login_required
()
def
get_landing_page
(
request
):
def
get_landing_page
(
request
):
try
:
try
:
selection
=
Selection
.
objects
.
filter
(
active
=
True
).
latest
(
'endtime'
)
selection
=
Selection
.
objects
.
filter
(
active
=
True
).
latest
(
'endtime'
)
...
@@ -55,7 +50,8 @@ def get_landing_page(request):
...
@@ -55,7 +50,8 @@ def get_landing_page(request):
return
render
(
request
,
'todo/landing_page.html'
,
content
)
return
render
(
request
,
'todo/landing_page.html'
,
content
)
@
login_required
(
login_url
=
'login'
)
@
login_required
()
def
todo_details
(
request
,
pk
=
None
):
def
todo_details
(
request
,
pk
=
None
):
if
pk
:
if
pk
:
todo
=
Todo
.
objects
.
get
(
pk
=
pk
)
todo
=
Todo
.
objects
.
get
(
pk
=
pk
)
...
@@ -77,7 +73,8 @@ def todo_details(request, pk=None):
...
@@ -77,7 +73,8 @@ def todo_details(request, pk=None):
return
render
(
request
,
'todo/add_todo.html'
,
{
'page_title'
:
'Lege eine neue Aufgabe an! '
,
return
render
(
request
,
'todo/add_todo.html'
,
{
'page_title'
:
'Lege eine neue Aufgabe an! '
,
'form'
:
form
})
'form'
:
form
})
@
login_required
(
login_url
=
'login'
)
@
login_required
()
def
delete_todo
(
request
,
pk
=
None
,
source
=
'show_todo'
,
s_id
=
None
):
def
delete_todo
(
request
,
pk
=
None
,
source
=
'show_todo'
,
s_id
=
None
):
if
pk
:
if
pk
:
Todo
.
objects
.
get
(
pk
=
pk
).
delete
()
Todo
.
objects
.
get
(
pk
=
pk
).
delete
()
...
@@ -86,7 +83,8 @@ def delete_todo(request, pk=None, source='show_todo', s_id=None):
...
@@ -86,7 +83,8 @@ def delete_todo(request, pk=None, source='show_todo', s_id=None):
else
:
else
:
return
HttpResponseRedirect
(
reverse_lazy
(
source
))
return
HttpResponseRedirect
(
reverse_lazy
(
source
))
@
login_required
(
login_url
=
'login'
)
@
login_required
()
def
get_selection_page
(
request
):
def
get_selection_page
(
request
):
selection
=
Selection
()
selection
=
Selection
()
...
@@ -125,7 +123,8 @@ def get_selection_page(request):
...
@@ -125,7 +123,8 @@ def get_selection_page(request):
}
}
return
render
(
request
,
'todo/selection_page.html'
,
content
)
return
render
(
request
,
'todo/selection_page.html'
,
content
)
@
login_required
(
login_url
=
'login'
)
@
login_required
()
def
get_selection_id
(
request
,
pk
=
None
):
def
get_selection_id
(
request
,
pk
=
None
):
if
request
.
method
==
'POST'
:
if
request
.
method
==
'POST'
:
form
=
CheckedTodosForm
(
request
.
POST
)
form
=
CheckedTodosForm
(
request
.
POST
)
...
@@ -161,7 +160,7 @@ def get_selection_id(request, pk=None):
...
@@ -161,7 +160,7 @@ def get_selection_id(request, pk=None):
}
}
return
render
(
request
,
'todo/show_selection.html'
,
content
)
return
render
(
request
,
'todo/show_selection.html'
,
content
)
@
login_required
(
login_url
=
'login'
)
def
sort_todos
(
todos_late
,
todos_someday
,
todos_soon
,
todos_today
,
select_id
=
None
):
def
sort_todos
(
todos_late
,
todos_someday
,
todos_soon
,
todos_today
,
select_id
=
None
):
if
select_id
is
None
:
if
select_id
is
None
:
todos_with_recurrence
=
Todo
.
objects
.
filter
(
complete
=
False
).
exclude
(
recurrences__exact
=
''
)
todos_with_recurrence
=
Todo
.
objects
.
filter
(
complete
=
False
).
exclude
(
recurrences__exact
=
''
)
...
@@ -196,7 +195,8 @@ def get_impressum(request):
...
@@ -196,7 +195,8 @@ def get_impressum(request):
content
=
{
'page_title'
:
'Impressum'
}
content
=
{
'page_title'
:
'Impressum'
}
return
render
(
request
,
'todo/impressum.html'
,
content
)
return
render
(
request
,
'todo/impressum.html'
,
content
)
@
login_required
(
login_url
=
'login'
)
@
login_required
()
def
get_show_todo
(
request
):
def
get_show_todo
(
request
):
if
request
.
method
==
'POST'
:
if
request
.
method
==
'POST'
:
form
=
CheckedTodosForm
(
request
.
POST
)
form
=
CheckedTodosForm
(
request
.
POST
)
...
@@ -232,19 +232,15 @@ def get_show_todo(request):
...
@@ -232,19 +232,15 @@ def get_show_todo(request):
}
}
return
render
(
request
,
'todo/show_todo.html'
,
content
)
return
render
(
request
,
'todo/show_todo.html'
,
content
)
@
login_required
(
login_url
=
'login'
)
@
login_required
()
def
get_archiv
(
request
):
def
get_archiv
(
request
):
todos
=
Todo
.
objects
.
filter
(
complete
=
True
)
todos
=
Todo
.
objects
.
filter
(
complete
=
True
)
content
=
{
'page_title'
:
'Archiv'
,
content
=
{
'page_title'
:
'Archiv'
,
'todos_complete'
:
todos
}
'todos_complete'
:
todos
}
return
render
(
request
,
'todo/archiv.html'
,
content
)
return
render
(
request
,
'todo/archiv.html'
,
content
)
def
get_login
(
request
):
@
login_required
()
content
=
{
'page_title'
:
'Log In'
}
def
redirect_profile
(
request
):
return
render
(
request
,
'todo/login.html'
,
content
)
return
HttpResponseRedirect
(
reverse_lazy
(
'landing_page'
))
login_required
()
def
get_register
(
request
):
content
=
{
'page_title'
:
'Register'
}
return
render
(
request
,
'todo/register.html'
,
content
)
Write
Preview
Markdown
is supported
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