Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
widget_Alipins
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
Angelico Ruiz T. Teaño
widget_Alipins
Commits
c0d3b24d
Commit
c0d3b24d
authored
May 19, 2022
by
Irish Danielle Morales
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Convert homepage details view to CBV
parent
20bec783
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
17 deletions
+13
-17
index.html
widget_alipins/homepage/templates/homepage/index.html
+1
-1
widgetuser_detail.html
...lipins/homepage/templates/homepage/widgetuser_detail.html
+8
-8
urls.py
widget_alipins/homepage/urls.py
+1
-1
views.py
widget_alipins/homepage/views.py
+3
-7
No files found.
widget_alipins/homepage/templates/homepage/index.html
View file @
c0d3b24d
...
@@ -20,7 +20,7 @@
...
@@ -20,7 +20,7 @@
{% if user_list %}
{% if user_list %}
<ol>
<ol>
{% for user in user_list %}
{% for user in user_list %}
<li><a
href=
"{% url 'homepage:
d
etails' user.id%}"
>
{{user.last_name}}, {{user.first_name}} {{user.middle_name}}
</a></li>
<li><a
href=
"{% url 'homepage:
userD
etails' user.id%}"
>
{{user.last_name}}, {{user.first_name}} {{user.middle_name}}
</a></li>
{% endfor %}
{% endfor %}
</ol>
</ol>
{% else %}
{% else %}
...
...
widget_alipins/homepage/templates/homepage/detail.html
→
widget_alipins/homepage/templates/homepage/
widgetuser_
detail.html
View file @
c0d3b24d
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
<link
rel=
"stylesheet"
type=
"text/css"
href=
"{% static 'homepage/style.css' %}"
>
<link
rel=
"stylesheet"
type=
"text/css"
href=
"{% static 'homepage/style.css' %}"
>
{% endblock %}
{% endblock %}
{% block title %}{{
user.user_id
}}{% endblock %}
{% block title %}{{
object.pk
}}{% endblock %}
{% block content %}
{% block content %}
<nav
class=
"topnav"
>
<nav
class=
"topnav"
>
<a
href=
"{% url 'homepage:indexHomepage' %}"
>
Homepage
</a>
<a
href=
"{% url 'homepage:indexHomepage' %}"
>
Homepage
</a>
...
@@ -16,16 +16,16 @@
...
@@ -16,16 +16,16 @@
<div
class=
"flex-container"
>
<div
class=
"flex-container"
>
<div
class=
"user-card"
>
<div
class=
"user-card"
>
<h1>
{{
user.last_name}}, {{user.first_name}} {{user
.middle_name}}
</h1>
<h1>
{{
object.last_name}}, {{object.first_name}} {{object
.middle_name}}
</h1>
<div>
<div>
{% if
user
.image %}
{% if
object
.image %}
<img
class=
"user-image flex-item"
src =
"{{
user
.image.url }}"
>
<img
class=
"user-image flex-item"
src =
"{{
object
.image.url }}"
>
{% endif %}
{% endif %}
<ul
class=
"flex-item"
>
<ul
class=
"flex-item"
>
<li>
ID Number: {{
user
.id_num}}
</li>
<li>
ID Number: {{
object
.id_num}}
</li>
<li>
Email Address: {{
user
.email}}
</li>
<li>
Email Address: {{
object
.email}}
</li>
<li>
Department: {{
user
.department.dept_name}}
</li>
<li>
Department: {{
object
.department.dept_name}}
</li>
<li>
Home Unit: {{
user
.department.home_unit}}
</li>
<li>
Home Unit: {{
object
.department.home_unit}}
</li>
</ul>
</ul>
</div>
</div>
</div>
</div>
...
...
widget_alipins/homepage/urls.py
View file @
c0d3b24d
...
@@ -4,5 +4,5 @@ from . import views
...
@@ -4,5 +4,5 @@ from . import views
app_name
=
"homepage"
app_name
=
"homepage"
urlpatterns
=
[
urlpatterns
=
[
path
(
''
,
views
.
index
,
name
=
"indexHomepage"
),
path
(
''
,
views
.
index
,
name
=
"indexHomepage"
),
path
(
'<int:
user_id>/details'
,
views
.
details
,
name
=
"d
etails"
)
path
(
'<int:
pk>/details'
,
views
.
UserDetailView
.
as_view
(),
name
=
"userD
etails"
)
]
]
\ No newline at end of file
widget_alipins/homepage/views.py
View file @
c0d3b24d
from
django.http
import
Http404
from
django.http
import
Http404
from
django.shortcuts
import
render
from
django.shortcuts
import
render
from
django.views.generic.detail
import
DetailView
from
.models
import
WidgetUser
from
.models
import
WidgetUser
def
index
(
request
):
def
index
(
request
):
...
@@ -10,10 +11,5 @@ def index(request):
...
@@ -10,10 +11,5 @@ def index(request):
return
render
(
request
,
"homepage/index.html"
,
context
)
return
render
(
request
,
"homepage/index.html"
,
context
)
def
details
(
request
,
user_id
):
class
UserDetailView
(
DetailView
):
try
:
model
=
WidgetUser
user
=
WidgetUser
.
objects
.
get
(
pk
=
user_id
)
\ No newline at end of file
except
WidgetUser
.
DoesNotExist
:
raise
Http404
(
"User does not exist!"
)
return
render
(
request
,
"homepage/detail.html"
,
{
"user"
:
user
})
\ No newline at end of file
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