Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
H
Hunger Buster - Breadcrumbs
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
3
Issues
3
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Julia Santos
Hunger Buster - Breadcrumbs
Commits
445200ca
Commit
445200ca
authored
Mar 16, 2021
by
Julia Santos
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implemented logging in function, redirects to homepage
parent
6446f90c
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
55 additions
and
3 deletions
+55
-3
forms.py
Breadcrumbs/forms.py
+5
-0
homepage.html
Breadcrumbs/templates/homepage.html
+8
-0
loggedin.html
Breadcrumbs/templates/registration/loggedin.html
+7
-0
login.html
Breadcrumbs/templates/registration/login.html
+6
-0
urls.py
Breadcrumbs/urls.py
+4
-0
views.py
Breadcrumbs/views.py
+19
-1
settings.py
HungerBuster/settings.py
+6
-2
milk.png
media/upload/milk.png
+0
-0
No files found.
Breadcrumbs/forms.py
0 → 100644
View file @
445200ca
from
django
import
forms
class
LoginForm
(
forms
.
Form
):
user
=
forms
.
CharField
(
label
=
'username'
,
max_length
=
100
)
password
=
forms
.
CharField
(
widget
=
forms
.
PasswordInput
())
\ No newline at end of file
Breadcrumbs/templates/homepage.html
0 → 100644
View file @
445200ca
<html>
<title>
Home
</title>
<body>
<main>
HELLO
</main>
</body>
</html>
\ No newline at end of file
Breadcrumbs/templates/registration/loggedin.html
0 → 100644
View file @
445200ca
<html>
<body>
You are :
<strong>
{{username}}
</strong>
</body>
</html>
\ No newline at end of file
Breadcrumbs/templates/registration/login.html
0 → 100644
View file @
445200ca
<h2>
Log In
</h2>
<form
method=
"post"
>
{% csrf_token %}
{{ form.as_p }}
<button
type=
"submit"
>
Log In
</button>
</form>
\ No newline at end of file
Breadcrumbs/urls.py
View file @
445200ca
from
django.conf.urls
import
url
from
django.conf
import
settings
from
django.conf.urls.static
import
static
from
django.views.generic
import
TemplateView
from
django.urls
import
include
from
.views
import
UserListView
,
ProductListView
urlpatterns
=
[
url
(
r'^fridge/list/'
,
ProductListView
.
as_view
(),
name
=
'fridgeL'
),
url
(
'accounts/'
,
include
(
'django.contrib.auth.urls'
)),
url
(
''
,
TemplateView
.
as_view
(
template_name
=
'homepage.html'
),
name
=
'home'
)
]
if
settings
.
DEBUG
:
...
...
Breadcrumbs/views.py
View file @
445200ca
from
django.views.generic
import
ListView
from
.models
import
User
,
Product_Type
,
Item
,
Recipe
from
django.db.models
import
Q
from
.forms
import
LoginForm
from
django.http
import
HttpResponseRedirect
from
django.shortcuts
import
render
class
UserListView
(
ListView
):
model
=
User
...
...
@@ -15,4 +18,19 @@ class ProductListView(ListView):
context_object_name
=
'product'
def
get_queryset
(
self
):
return
Product_Type
.
objects
.
all
()
.
order_by
(
'Product_Name'
)
\ No newline at end of file
return
Product_Type
.
objects
.
all
()
.
order_by
(
'Product_Name'
)
def
login
(
request
):
username
=
"not logged in"
if
request
.
method
==
"POST"
:
MyLoginForm
=
LoginForm
(
request
.
POST
)
if
MyLoginForm
.
is_valid
():
username
=
MyLoginForm
.
cleaned_data
[
'username'
]
#return HttpResponseRedirect('/fridge/list')
else
:
MyLoginForm
=
Loginform
()
return
render
(
request
,
loggedin
.
html
,{
"username"
:
username
})
HungerBuster/settings.py
View file @
445200ca
...
...
@@ -55,7 +55,7 @@ ROOT_URLCONF = 'HungerBuster.urls'
TEMPLATES
=
[
{
'BACKEND'
:
'django.template.backends.django.DjangoTemplates'
,
'DIRS'
:
[],
'DIRS'
:
[
str
(
os
.
path
.
join
(
BASE_DIR
,
'templates'
))
],
'APP_DIRS'
:
True
,
'OPTIONS'
:
{
'context_processors'
:
[
...
...
@@ -123,7 +123,11 @@ USE_TZ = True
# https://docs.djangoproject.com/en/1.11/howto/static-files/
STATIC_URL
=
'/static/'
#for displaying images
STATICFILES_DIRS
=
(
os
.
path
.
join
(
BASE_DIR
,
'static'
),
)
STATIC_ROOT
=
os
.
path
.
join
(
BASE_DIR
,
'staticfiles'
)
MEDIA_URL
=
'/media/'
MEDIA_ROOT
=
os
.
path
.
join
(
BASE_DIR
,
'media'
)
\ No newline at end of file
MEDIA_ROOT
=
os
.
path
.
join
(
BASE_DIR
,
'media'
)
#for login
LOGIN_REDIRECT_uRL
=
'/'
media/upload/milk.png
0 → 100644
View file @
445200ca
19.4 KB
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