Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
widget_group22
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 Tamano
widget_group22
Commits
4aef3fdf
Commit
4aef3fdf
authored
May 17, 2022
by
John Tamano
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'tamano/homepage_final'
parents
2a7e03cd
4d4e7cba
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
56 additions
and
11 deletions
+56
-11
forms.cpython-38.pyc
widget_group22/homepage/__pycache__/forms.cpython-38.pyc
+0
-0
models.cpython-38.pyc
widget_group22/homepage/__pycache__/models.cpython-38.pyc
+0
-0
urls.cpython-38.pyc
widget_group22/homepage/__pycache__/urls.cpython-38.pyc
+0
-0
views.cpython-38.pyc
widget_group22/homepage/__pycache__/views.cpython-38.pyc
+0
-0
forms.py
widget_group22/homepage/forms.py
+8
-0
adduser.html
widget_group22/homepage/templates/homepage/adduser.html
+17
-0
homepage.html
widget_group22/homepage/templates/homepage/homepage.html
+4
-0
urls.py
widget_group22/homepage/urls.py
+4
-3
views.py
widget_group22/homepage/views.py
+23
-8
No files found.
widget_group22/homepage/__pycache__/forms.cpython-38.pyc
0 → 100644
View file @
4aef3fdf
File added
widget_group22/homepage/__pycache__/models.cpython-38.pyc
View file @
4aef3fdf
No preview for this file type
widget_group22/homepage/__pycache__/urls.cpython-38.pyc
View file @
4aef3fdf
No preview for this file type
widget_group22/homepage/__pycache__/views.cpython-38.pyc
View file @
4aef3fdf
No preview for this file type
widget_group22/homepage/forms.py
0 → 100644
View file @
4aef3fdf
from
tkinter
import
Widget
from
django.forms
import
ModelForm
from
.models
import
WidgetUser
,
Department
class
addWidgetUserForm
(
ModelForm
):
class
Meta
:
model
=
WidgetUser
fields
=
[
"first_name"
,
"middle_name"
,
"last_name"
,
"id_num"
,
"email"
,
"department"
]
\ No newline at end of file
widget_group22/homepage/templates/homepage/adduser.html
0 → 100644
View file @
4aef3fdf
{% extends "homepage/base.html" %}
{% block content %}
<h1>
Add Widget User
</h1>
<form
action=
"{% url 'homepage:addWidgetUser' %}"
method=
"POST"
>
{% csrf_token %}
{{ addwidgetuser }}
<button
class=
"button"
type=
"submit"
>
Save New User
</button>
</form>
<br>
<p1>
<a
href =
"/homepage/"
>
Back to Homepage
</a>
</p1>
{% endblock %}
\ No newline at end of file
widget_group22/homepage/templates/homepage/homepage.html
View file @
4aef3fdf
...
...
@@ -10,4 +10,8 @@
</p1>
{% endfor %}
</ol>
<br>
<form
action=
"/users/add"
>
<input
type=
"submit"
value=
"Add Widget User"
/>
</form>
{% endblock %}
\ No newline at end of file
widget_group22/homepage/urls.py
View file @
4aef3fdf
from
django.urls
import
path
from
.views
import
displayWidgetUsers
,
displayUserDetails
from
.views
import
displayWidgetUsers
,
displayUserDetails
,
addWidgetUser
urlpatterns
=
[
path
(
'homepage/'
,
displayWidgetUsers
,
name
=
'displayWidgetUsers'
),
path
(
'users/<int:user_id>/details'
,
displayUserDetails
,
name
=
'displayUserDetails'
)
path
(
'homepage/'
,
displayWidgetUsers
.
as_view
(),
name
=
'displayWidgetUsers'
),
path
(
'users/<int:user_id>/details'
,
displayUserDetails
,
name
=
'displayUserDetails'
),
path
(
'users/add'
,
addWidgetUser
,
name
=
'addWidgetUser'
)
]
app_name
=
"homepage"
\ No newline at end of file
widget_group22/homepage/views.py
View file @
4aef3fdf
from
tkinter
import
Widget
from
django.shortcuts
import
render
from
django.template.loader
import
get_template
from
django.shortcuts
import
redirect
,
render
from
django.views
import
View
from
homepage.models
import
Department
,
WidgetUser
from
django.template
import
Template
,
Context
from
django.http
import
Http404
,
HttpResponse
from
.
import
models
from
.forms
import
addWidgetUserForm
def
index
(
request
):
return
HttpResponse
(
'Welcome to Widget!'
)
def
displayWidgetUsers
(
request
):
WidgetUsers
=
models
.
WidgetUser
.
objects
.
order_by
(
"last_name"
)
context
=
{
class
displayWidgetUsers
(
View
):
template
=
'homepage/homepage.html'
def
get
(
self
,
request
):
WidgetUsers
=
models
.
WidgetUser
.
objects
.
order_by
(
"last_name"
)
context
=
{
"WidgetUsers"
:
WidgetUsers
}
return
render
(
request
,
"homepage/homepage.html"
,
context
)
}
return
render
(
request
,
self
.
template
,
context
)
def
displayUserDetails
(
request
,
user_id
):
try
:
...
...
@@ -27,4 +30,16 @@ def displayUserDetails(request, user_id):
}
return
render
(
request
,
"homepage/details.html"
,
context
)
def
addWidgetUser
(
request
):
Departments
=
models
.
Department
.
objects
.
all
()
if
request
.
method
==
"POST"
:
add_WidgetUser
=
addWidgetUserForm
(
request
.
POST
)
if
add_WidgetUser
.
is_valid
():
new_WidgetUser
=
add_WidgetUser
.
save
()
return
redirect
(
"homepage:addWidgetUser"
)
else
:
add_WidgetUser
=
addWidgetUserForm
()
return
render
(
request
,
"homepage/adduser.html"
,
{
"addwidgetuser"
:
add_WidgetUser
})
# Create your views here.
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