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
2e64e15e
Commit
2e64e15e
authored
Jul 05, 2020
by
Hänzelmann, Antje
Browse files
login register
parent
0593a758
Changes
5
Hide whitespace changes
Inline
Side-by-side
oos_2020_todo/urls.py
View file @
2e64e15e
...
...
@@ -20,7 +20,8 @@ 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
,
add_todo
,
get_impressum
,
get_show_todo
,
get_archiv
,
\
get_register
,
get_login
urlpatterns
=
[
path
(
'admin/'
,
admin
.
site
.
urls
),
...
...
@@ -31,6 +32,8 @@ urlpatterns = [
path
(
'impressum/'
,
get_impressum
,
name
=
'impressum'
),
path
(
'todo/show/'
,
get_show_todo
,
name
=
'show_todo'
),
path
(
'todo/archiv/'
,
get_archiv
,
name
=
'archv'
),
path
(
'todo/register/'
,
get_register
,
name
=
"register"
),
path
(
'todo/login/'
,
get_login
,
name
=
"login"
),
]
if
settings
.
DEBUG
:
...
...
templates/todo/login.html
View file @
2e64e15e
{% extends 'todo/base.html' %}
{% load bootstrap4 %}
<!DOCTYPE html>
<html>
<head>
<title>
Login
</title>
<link
rel=
"stylesheet"
href=
"https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css"
integrity=
"sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO"
crossorigin=
"anonymous"
>
<script
src=
"https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"
></script>
<link
rel=
"stylesheet"
href=
"https://use.fontawesome.com/releases/v5.6.1/css/all.css"
integrity=
"sha384-gfdkjb5BdAXd+lj+gudLWI+BXq4IuLW5IT+brZEZsLFm++aCMlF1V92rMkPaX4PP"
crossorigin=
"anonymous"
>
{% block content %}
{% endblock %}
\ No newline at end of file
<style>
body
,
html
{
margin
:
0
;
padding
:
0
;
height
:
100%
;
background
:
#FFFFFF
!important
;
}
.user_card
{
width
:
350px
;
margin-top
:
auto
;
margin-bottom
:
auto
;
background
:
#74cfbf
;
position
:
relative
;
display
:
flex
;
justify-content
:
center
;
flex-direction
:
column
;
padding
:
10px
;
box-shadow
:
0
4px
8px
0
rgba
(
0
,
0
,
0
,
0.2
),
0
6px
20px
0
rgba
(
0
,
0
,
0
,
0.19
);
-webkit-box-shadow
:
0
4px
8px
0
rgba
(
0
,
0
,
0
,
0.2
),
0
6px
20px
0
rgba
(
0
,
0
,
0
,
0.19
);
-moz-box-shadow
:
0
4px
8px
0
rgba
(
0
,
0
,
0
,
0.2
),
0
6px
20px
0
rgba
(
0
,
0
,
0
,
0.19
);
border-radius
:
5px
;
}
.form_container
{
margin-top
:
20px
;
}
#form-title
{
color
:
#fff
;
}
.login_btn
{
width
:
100%
;
background
:
#33ccff
!important
;
color
:
white
!important
;
}
.login_btn
:focus
{
box-shadow
:
none
!important
;
outline
:
0px
!important
;
}
.login_container
{
padding
:
0
2rem
;
}
.input-group-text
{
background
:
#f7ba5b
!important
;
color
:
white
!important
;
border
:
0
!important
;
border-radius
:
0.25rem
0
0
0.25rem
!important
;
}
.input_user
,
.input_pass
:focus
{
box-shadow
:
none
!important
;
outline
:
0px
!important
;
}
#messages
{
background-color
:
grey
;
color
:
#fff
;
padding
:
10px
;
margin-top
:
10px
;
}
</style>
</head>
<body>
<div
class=
"container h-100"
>
<div
class=
"d-flex justify-content-center h-100"
>
<div
class=
"user_card"
>
<div
class=
"d-flex justify-content-center"
>
<h3
id=
"form-title"
>
LOGIN
</h3>
</div>
<div
class=
"d-flex justify-content-center form_container"
>
<form
method=
"POST"
action=
""
>
<div
class=
"input-group mb-3"
>
<div
class=
"input-group-append"
>
<span
class=
"input-group-text"
><i
class=
"fas fa-user"
></i></span>
</div>
<input
type=
"text"
name=
"username"
placeholder=
"Username..."
class=
"form-control"
>
</div>
<div
class=
"input-group mb-2"
>
<div
class=
"input-group-append"
>
<span
class=
"input-group-text"
><i
class=
"fas fa-key"
></i></span>
</div>
<input
type=
"password"
name=
"password"
placeholder=
"Password..."
class=
"form-control"
>
</div>
<div
class=
"d-flex justify-content-center mt-3 login_container"
>
<input
class=
"btn login_btn"
type=
"submit"
value=
"Login"
>
</div>
</form>
</div>
<div
class=
"mt-4"
>
<div
class=
"d-flex justify-content-center links"
>
Noch kein Konto?
<a
href=
"{% url 'register' %}"
class=
"ml-2"
>
Anmelden
</a>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
\ No newline at end of file
templates/todo/register.html
View file @
2e64e15e
{% extends 'todo/base.html' %}
{% load bootstrap4 %}
<!DOCTYPE html>
<html>
<head>
<title>
Login
</title>
<link
rel=
"stylesheet"
href=
"https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css"
integrity=
"sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO"
crossorigin=
"anonymous"
>
<script
src=
"https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"
></script>
<link
rel=
"stylesheet"
href=
"https://use.fontawesome.com/releases/v5.6.1/css/all.css"
integrity=
"sha384-gfdkjb5BdAXd+lj+gudLWI+BXq4IuLW5IT+brZEZsLFm++aCMlF1V92rMkPaX4PP"
crossorigin=
"anonymous"
>
{% block content %}
{% endblock %}
\ No newline at end of file
<style>
body
,
html
{
margin
:
0
;
padding
:
0
;
height
:
100%
;
background
:
#FFFFFF
!important
;
}
.user_card
{
width
:
350px
;
margin-top
:
auto
;
margin-bottom
:
auto
;
background
:
#74cfbf
;
position
:
relative
;
display
:
flex
;
justify-content
:
center
;
flex-direction
:
column
;
padding
:
10px
;
box-shadow
:
0
4px
8px
0
rgba
(
0
,
0
,
0
,
0.2
),
0
6px
20px
0
rgba
(
0
,
0
,
0
,
0.19
);
-webkit-box-shadow
:
0
4px
8px
0
rgba
(
0
,
0
,
0
,
0.2
),
0
6px
20px
0
rgba
(
0
,
0
,
0
,
0.19
);
-moz-box-shadow
:
0
4px
8px
0
rgba
(
0
,
0
,
0
,
0.2
),
0
6px
20px
0
rgba
(
0
,
0
,
0
,
0.19
);
border-radius
:
5px
;
}
.form_container
{
margin-top
:
20px
;
}
#form-title
{
color
:
#fff
;
}
.login_btn
{
width
:
100%
;
background
:
#33ccff
!important
;
color
:
white
!important
;
}
.login_btn
:focus
{
box-shadow
:
none
!important
;
outline
:
0px
!important
;
}
.login_container
{
padding
:
0
2rem
;
}
.input-group-text
{
background
:
#f7ba5b
!important
;
color
:
white
!important
;
border
:
0
!important
;
border-radius
:
0.25rem
0
0
0.25rem
!important
;
}
.input_user
,
.input_pass
:focus
{
box-shadow
:
none
!important
;
outline
:
0px
!important
;
}
#messages
{
background-color
:
grey
;
color
:
#fff
;
padding
:
10px
;
margin-top
:
10px
;
}
</style>
</head>
<body>
<div
class=
"container h-100"
>
<div
class=
"d-flex justify-content-center h-100"
>
<div
class=
"user_card"
>
<div
class=
"d-flex justify-content-center"
>
<h3
id=
"form-title"
>
LOGIN
</h3>
</div>
<div
class=
"d-flex justify-content-center form_container"
>
<form
method=
"POST"
action=
""
>
<div
class=
"input-group mb-3"
>
<div
class=
"input-group-append"
>
<span
class=
"input-group-text"
><i
class=
"fas fa-user"
></i></span>
</div>
<input
type=
"text"
name=
"username"
placeholder=
"Username..."
class=
"form-control"
>
</div>
<div
class=
"input-group mb-2"
>
<div
class=
"input-group-append"
>
<span
class=
"input-group-text"
><i
class=
"fas fa-key"
></i></span>
</div>
<input
type=
"password"
name=
"password"
placeholder=
"Password..."
class=
"form-control"
>
</div>
<div
class=
"d-flex justify-content-center mt-3 login_container"
>
<input
class=
"btn login_btn"
type=
"submit"
value=
"Login"
>
</div>
</form>
</div>
<div
class=
"mt-4"
>
<div
class=
"d-flex justify-content-center links"
>
Don't have an account?
<a
href=
"{% url 'register' %}"
class=
"ml-2"
>
Sign Up
</a>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
\ No newline at end of file
todo/forms.py
View file @
2e64e15e
from
django
import
forms
from
todo.models
import
Todo
from
django.contrib.auth.forms
import
UserCreationForm
from
django.contrib.auth.models
import
User
from
django
import
forms
class
CreateUserForm
(
UserCreationForm
):
class
Meta
:
model
=
User
fields
=
[
'username'
,
'email'
,
'password1'
,
'password2'
]
class
TodoForm
(
forms
.
ModelForm
):
class
Meta
:
...
...
todo/views.py
View file @
2e64e15e
...
...
@@ -4,10 +4,28 @@ from django.shortcuts import render
from
django.contrib
import
messages
from
django.urls
import
reverse_lazy
from
django.utils
import
timezone
from
django.contrib.auth.forms
import
UserCreationForm
from
.forms
import
CreateUserForm
from
todo.forms
import
*
from
todo.models
import
*
def
registerPage
(
request
):
form
=
CreateUserForm
()
if
request
.
method
==
'POST'
:
form
=
CreateUserForm
(
request
.
POST
)
if
form
.
is_valid
():
form
.
save
()
context
=
{
'form'
:
form
}
return
render
(
request
,
'accounts/register.html'
,
context
)
def
loginPage
(
request
):
context
=
{}
return
render
(
request
,
'accounts/login.html'
,
context
)
def
get_landing_page
(
request
):
todo_list
=
Todo
.
objects
.
order_by
(
'id'
)
...
...
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