Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
midterm_casanatics
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
John Aidan Vincent M. Ng
midterm_casanatics
Commits
63572b8e
Commit
63572b8e
authored
May 04, 2023
by
justin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: added DetailViews per user
parent
bc58a526
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
45 additions
and
1 deletion
+45
-1
models.cpython-310.pyc
...t_casanatics/dashboard/__pycache__/models.cpython-310.pyc
+0
-0
urls.cpython-310.pyc
widget_casanatics/dashboard/__pycache__/urls.cpython-310.pyc
+0
-0
views.cpython-310.pyc
...et_casanatics/dashboard/__pycache__/views.cpython-310.pyc
+0
-0
models.py
widget_casanatics/dashboard/models.py
+7
-0
dashboard.html
...t_casanatics/dashboard/templates/dashboard/dashboard.html
+1
-1
widgetuser-details.html
...ics/dashboard/templates/dashboard/widgetuser-details.html
+12
-0
urls.py
widget_casanatics/dashboard/urls.py
+10
-0
views.py
widget_casanatics/dashboard/views.py
+15
-0
No files found.
widget_casanatics/dashboard/__pycache__/models.cpython-310.pyc
View file @
63572b8e
No preview for this file type
widget_casanatics/dashboard/__pycache__/urls.cpython-310.pyc
View file @
63572b8e
No preview for this file type
widget_casanatics/dashboard/__pycache__/views.cpython-310.pyc
View file @
63572b8e
No preview for this file type
widget_casanatics/dashboard/models.py
View file @
63572b8e
from
django.db
import
models
from
django.urls
import
reverse
class
Department
(
models
.
Model
):
...
...
@@ -23,3 +24,9 @@ class WidgetUser(models.Model):
def
displayName
(
self
):
return
f
"{self.first_name} {self.last_name}"
def
get_absolute_url
(
self
):
return
reverse
(
"dashboard:user-detail"
,
kwargs
=
{
"pk"
:
self
.
pk
},
)
widget_casanatics/dashboard/templates/dashboard/dashboard.html
View file @
63572b8e
...
...
@@ -4,7 +4,7 @@
<h2>
Widget Users:
</h2>
<ul>
{% for user in users %}
<a
href=
""
>
<a
href=
"
{{user.get_absolute_url}}
"
>
<li>
{{ user.last_name }}, {{ user.first_name }}
</li>
</a>
{% endfor %}
...
...
widget_casanatics/dashboard/templates/dashboard/widgetuser-details.html
View file @
63572b8e
{% extends 'base.html' %}
{% block content %}
<div
class=
"user-name"
>
<h1>
{{ object.first_name }}
{{ object.middle_name }}
{{ object.last_name }}
</h1>
<h2>
{{ object.department.dept_name }}
</h2>
<h2>
{{ object.department.home_unit }}
</h2>
</div>
<a
href=
"./edit"
>
Edit Widget User
</a>
{% endblock %}
widget_casanatics/dashboard/urls.py
View file @
63572b8e
...
...
@@ -4,6 +4,16 @@ from . import views
urlpatterns
=
[
path
(
""
,
views
.
dashboard
,
name
=
"dashboard"
),
path
(
"widgetusers/<int:pk>/details"
,
views
.
WidgetUserDetailView
.
as_view
(),
name
=
"user-detail"
,
),
path
(
"widgetusers/add"
,
views
.
WidgetUserDetailView
.
as_view
(),
name
=
"user-add"
,
),
]
...
...
widget_casanatics/dashboard/views.py
View file @
63572b8e
# from django.http import HttpResponse
from
django.views.generic.detail
import
DetailView
from
django.views.generic.edit
import
UpdateView
,
CreateView
from
.models
import
WidgetUser
from
django.shortcuts
import
render
...
...
@@ -14,3 +16,16 @@ def dashboard(request):
users
=
WidgetUser
.
objects
.
all
()
context
=
{
"users"
:
users
}
return
render
(
request
,
"dashboard/dashboard.html"
,
context
)
class
WidgetUserDetailView
(
DetailView
):
model
=
WidgetUser
template_name
=
"dashboard/widgetuser-details.html"
class
WidgetUserUpdateView
(
UpdateView
):
model
=
WidgetUser
class
WidgetUserCreateView
(
CreateView
):
model
=
WidgetUser
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