Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
midterm_bigdjangoenergy
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
Alec Dayupay
midterm_bigdjangoenergy
Commits
56e03e5d
Commit
56e03e5d
authored
May 08, 2023
by
Jose Enrique D. Siongco
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dashboardv2'
parents
db44e158
04bb77ae
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
96 additions
and
19 deletions
+96
-19
models.py
widget_bigdjangoenergy/dashboard/models.py
+4
-1
dashboard.html
...djangoenergy/dashboard/templates/dashboard/dashboard.html
+21
-0
widgetuser-add.html
...oenergy/dashboard/templates/dashboard/widgetuser-add.html
+13
-0
widgetuser-details.html
...rgy/dashboard/templates/dashboard/widgetuser-details.html
+13
-0
widgetuser-edit.html
...energy/dashboard/templates/dashboard/widgetuser-edit.html
+13
-0
urls.py
widget_bigdjangoenergy/dashboard/urls.py
+8
-5
views.py
widget_bigdjangoenergy/dashboard/views.py
+24
-13
No files found.
widget_bigdjangoenergy/dashboard/models.py
View file @
56e03e5d
...
...
@@ -16,3 +16,6 @@ class WidgetUser(models.Model):
def
__str__
(
self
):
return
'{} {}'
.
format
(
self
.
first_name
,
self
.
last_name
)
def
get_absolute_url
(
self
):
return
reverse
(
"widgetuser-details"
,
kwargs
=
{
'pk'
:
self
.
pk
})
\ No newline at end of file
widget_bigdjangoenergy/dashboard/templates/dashboard/dashboard.html
0 → 100644
View file @
56e03e5d
{% extends 'base.html' %}
{% load static %}
{% block title %}Widget's Forum{% endblock %}
{% block heading %}Welcome to Widget's Forum!{% endblock %}
{% block content %}
<p>
Forum posts:
</p>
{% for user in WidgetUser %}
<p><a
href=
"{{ user.get_absolute_url }}"
>
{{ user.last_name }}, {{ user.first_name }}
</a></p>
{% endfor %}
<input
type=
"button"
value=
"Add Widget User"
onclick=
"location.href='{% url 'widgetuser-add' %}'"
/>
{% endblock %}
{% block links %}
<p><a
href=
"../announcements/"
>
Announcement
</a></p>
<p><a
href=
"../forum/"
>
Forum
</a></p>
<p><a
href=
"../assignments/"
>
Assignment
</a></p>
<p><a
href=
"../calendar/"
>
Calendar
</a></p>
{% endblock %}
\ No newline at end of file
widget_bigdjangoenergy/dashboard/templates/dashboard/widgetuser-add.html
0 → 100644
View file @
56e03e5d
{% extends 'base.html' %}
{% load static %}
{% block title %}Add Widget User{% endblock %}
{% block heading %}Add a new widget user:{% endblock %}
{% block content %}
<form
method=
"POST"
>
{% csrf_token %}
{{ form.as_p }}
<input
type=
"Submit"
value=
"Add Widget User"
>
</form>
{% endblock %}
\ No newline at end of file
widget_bigdjangoenergy/dashboard/templates/dashboard/widgetuser-details.html
0 → 100644
View file @
56e03e5d
{% extends 'base.html' %}
{% load static %}
{% block title %}{{ object.last_name }}, {{ object.first_name }}{% endblock %}
{% block heading %}{{ object.first_name }} {{ object.middle_name }} {{ object.last_name }}{% endblock %}
{% block content %}
<p>
{{ object.department }}
</p>
<p>
{{ object.department.home_unit }}
</p>
<input
type=
"button"
value=
"Edit Widget User"
onclick=
"location.href='{% url 'widgetuser-edit' object.pk %}'"
/>
{% endblock %}
\ No newline at end of file
widget_bigdjangoenergy/dashboard/templates/dashboard/widgetuser-edit.html
0 → 100644
View file @
56e03e5d
{% extends 'base.html' %}
{% load static %}
{% block title %}Edit Post{% endblock %}
{% block content %}
<p>
Edit Widget User:
</p>
<form
method=
"POST"
>
{% csrf_token %}
{{ form.as_p }}
<input
type=
"Submit"
value=
"Save Changes to Widget User"
>
</form>
{% endblock %}
\ No newline at end of file
widget_bigdjangoenergy/dashboard/urls.py
View file @
56e03e5d
from
django.urls
import
path
from
.views
import
dashboard
from
.views
import
(
dashboard
,
WidgetuserDetailView
,
WidgetuserCreateView
,
WidgetuserUpdateView
)
urlpatterns
=
[
path
(
''
,
dashboard
,
name
=
"dashboard"
)
path
(
''
,
dashboard
,
name
=
"dashboard"
),
path
(
'widgetuser/add'
,
WidgetuserCreateView
.
as_view
(),
name
=
"widgetuser-add"
),
path
(
'widgetuser/<int:pk>/details/'
,
WidgetuserDetailView
.
as_view
(),
name
=
"widgetuser-details"
),
path
(
'widgetuser/<int:pk>/edit/'
,
WidgetuserUpdateView
.
as_view
(),
name
=
"widgetuser-edit"
),
]
\ No newline at end of file
app_name
=
"dashboard"
\ No newline at end of file
widget_bigdjangoenergy/dashboard/views.py
View file @
56e03e5d
from
django.shortcuts
import
render
from
django.http
import
HttpResponse
from
django.views.generic.detail
import
DetailView
from
django.views.generic.edit
import
CreateView
,
UpdateView
from
.models
import
Department
,
WidgetUser
def
dashboard
(
request
):
widgetusers
=
WidgetUser
.
objects
.
all
()
response
=
"Welcome to Widget!<br><br>WIDGET USERS:<br>"
for
user
in
widgetusers
:
response
+=
"{}, {} {}: {}, {}<br>"
.
format
(
user
.
last_name
,
user
.
first_name
,
user
.
middle_name
,
user
.
department
,
user
.
department
.
home_unit
)
return
HttpResponse
(
response
)
\ No newline at end of file
return
render
(
request
,
'dashboard/dashboard.html'
,
{
'WidgetUser'
:
WidgetUser
.
objects
.
all
()})
class
WidgetuserDetailView
(
DetailView
):
model
=
WidgetUser
template_name
=
'dashboard/widgetuser-details.html'
fields
=
'__all__'
class
WidgetuserCreateView
(
CreateView
):
model
=
WidgetUser
fields
=
'__all__'
template_name
=
'dashboard/widgetuser-add.html'
class
WidgetuserUpdateView
(
UpdateView
):
model
=
WidgetUser
fields
=
'__all__'
template_name
=
'dashboard/widgetuser-edit.html'
\ 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