Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
widget_group 6
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
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
Patricia Isabella Nava
widget_group 6
Commits
e7be278c
Commit
e7be278c
authored
May 25, 2022
by
Pierre Ashley Salcedo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: add views and add templates to views in homepage app
parent
739ba144
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
121 additions
and
20 deletions
+121
-20
test.jpg
widget_group_6/homepage/static/homepage/images/test.jpg
+0
-0
style.css
widget_group_6/homepage/static/homepage/style.css
+46
-0
base.html
widget_group_6/homepage/templates/homepage/base.html
+17
-0
detail.html
widget_group_6/homepage/templates/homepage/detail.html
+20
-0
index.html
widget_group_6/homepage/templates/homepage/index.html
+18
-0
urls.py
widget_group_6/homepage/urls.py
+4
-4
views.py
widget_group_6/homepage/views.py
+16
-16
No files found.
widget_group_6/homepage/static/homepage/images/test.jpg
0 → 100644
View file @
e7be278c
34.5 KB
widget_group_6/homepage/static/homepage/style.css
0 → 100644
View file @
e7be278c
body
{
background-color
:
rgb
(
40
,
105
,
239
);
font-family
:
'Montserrat'
,
serif
;
color
:
rgb
(
255
,
255
,
255
);
margin
:
0
;
}
header
{
background-color
:
rgb
(
27
,
27
,
27
);
color
:
rgb
(
241
,
65
,
65
);
}
h1
{
text-transform
:
uppercase
;
text-align
:
center
;
padding
:
10px
;
margin
:
0
;
}
h2
{
padding
:
10px
;
font-weight
:
700
;
}
ul
,
ol
{
font-weight
:
500
;
margin
:
1em
;
}
ul
{
list-style-type
:
none
;
}
li
{
margin
:
10px
0
;
}
a
{
color
:
rgb
(
255
,
255
,
255
);
}
img
{
width
:
400px
;
}
#userInfo
{
display
:
flex
;
flex-flow
:
row
wrap-reverse
;
justify-content
:
space-evenly
;
}
#userInfo
>
div
{
flex
:
0
1
auto
;
}
\ No newline at end of file
widget_group_6/homepage/templates/homepage/base.html
0 → 100644
View file @
e7be278c
<!-- project/template/base.html -->
<!DOCTYPE html>
{% load static %}
<html
lang=
"en"
>
<head>
<link
rel=
"stylesheet"
href=
"{% static 'homepage\style.css' %}"
>
<meta
charset=
"UTF-8"
>
<meta
name =
"viewport"
content=
"width-device width, initial scale=1"
>
<title>
{% block title%} Homepage {% endblock %}
</title>
</head>
<body>
<div
id=
"content"
>
{% block content %}
{% endblock %}
</body>
</html>
\ No newline at end of file
widget_group_6/homepage/templates/homepage/detail.html
0 → 100644
View file @
e7be278c
{% extends "homepage/base.html" %}
{% load static %}
{% block title%} {{user.last_name}}, {{user.first_name}} {{user.middle_name}} {% endblock %}
{% block content %}
<header><h1>
{{user.last_name}}, {{user.first_name}} {{user.middle_name}}
</h1></header>
<div
id=
"userInfo"
>
<div>
<ul>
<li>
ID number: {{user.id_num}}
</li>
<li>
Email address: {{user.email}}
</li>
<li>
Department name: {{user.department.dept_name}}
</li>
<li>
Home unit: {{user.department.home_unit}}
</li>
</ul>
</div>
<div>
<img
src =
"{% static 'homepage/images/test.jpg' %}"
alt =
"profile image"
>
</div>
</div>
{% endblock %}
\ No newline at end of file
widget_group_6/homepage/templates/homepage/index.html
0 → 100644
View file @
e7be278c
{% extends "homepage/base.html" %}
{% block content %}
<header><h1>
Welcome to Widget!
</h1></header>
<h2>
Widget Users:
</h2>
{% if user_list %}
<ol>
{% for user in user_list %}
<li>
<a
href =
"{% url 'homepage:detail' user.id_num %}"
>
{{user.last_name}}, {{user.first_name}} {{user.middle_name}}
</a></li>
{% endfor %}
</ol>
{% else %}
<p>
No users available.
</p>
{% endif %}
{% endblock %}
\ No newline at end of file
widget_group_6/homepage/urls.py
View file @
e7be278c
from
django.urls
import
path
from
django.urls
import
path
from
.
import
views
from
.
import
views
app_name
=
"homepage"
urlpatterns
=
[
urlpatterns
=
[
path
(
""
,
views
.
index
,
name
=
"homepage"
)
path
(
""
,
views
.
index
,
name
=
"homepage"
),
path
(
"<int:user_id>/details"
,
views
.
detail
,
name
=
"detail"
)
]
]
\ No newline at end of file
app_name
=
"homepage"
widget_group_6/homepage/views.py
View file @
e7be278c
from
django.http
import
HttpResponse
from
django.shortcuts
import
render
from
django.http
import
Http404
,
HttpResponse
from
.models
import
WidgetUser
from
.models
import
WidgetUser
# Create your views here.
# Create your views here.
def
index
(
request
):
def
index
(
request
):
widget_users
=
WidgetUser
.
objects
.
all
()
user_list
=
WidgetUser
.
objects
.
order_by
(
"last_name"
)
context
=
{
"user_list"
:
user_list
}
return
render
(
request
,
"homepage/index.html"
,
context
)
html
=
"<html><body><h1>WIDGET USERS:</h1>"
def
detail
(
request
,
user_id
):
for
widget_user
in
widget_users
:
try
:
html
+=
"<p> {}, {} {}: {}, {}, {}, {} </p>"
.
format
(
user
=
WidgetUser
.
objects
.
get
(
id_num
=
user_id
)
widget_user
.
last_name
,
except
WidgetUser
.
DoesNotExist
:
widget_user
.
first_name
,
raise
Http404
(
"User does not exist!"
)
widget_user
.
middle_name
,
context
=
{
widget_user
.
id_num
,
"user"
:
user
widget_user
.
email
,
}
widget_user
.
department
.
dept_name
,
return
render
(
request
,
"homepage/detail.html"
,
context
)
widget_user
.
department
.
home_unit
\ No newline at end of file
)
html
+=
"</body></html>"
return
HttpResponse
(
html
)
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