Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
widget_jupert
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
Joseph Izon
widget_jupert
Commits
c07c16ae
Commit
c07c16ae
authored
Apr 07, 2022
by
Joseph Izon
💀
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'izon/homepage'
parents
39ad5007
0191f2d7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
47 additions
and
4 deletions
+47
-4
admin.py
widget_jupert/homepage/admin.py
+11
-2
models.py
widget_jupert/homepage/models.py
+19
-1
views.py
widget_jupert/homepage/views.py
+17
-1
No files found.
widget_jupert/homepage/admin.py
View file @
c07c16ae
from
django.contrib
import
admin
from
django.contrib
import
admin
# Register your models here.
# Register your models here.
from
.models
import
WidgetUser
from
.models
import
Department
,
WidgetUser
class
WidgetUserAdmin
(
admin
.
ModelAdmin
):
class
WidgetUserAdmin
(
admin
.
ModelAdmin
):
model
=
WidgetUser
model
=
WidgetUser
search_fields
=
(
'first_name'
,
'last_name'
,)
search_fields
=
(
'first_name'
,
'last_name'
,)
list_display
=
(
'first_name'
,
'middle_name'
,
'last_name'
,)
list_display
=
(
'
id_num'
,
'
first_name'
,
'middle_name'
,
'last_name'
,)
list_filter
=
(
'first_name'
,
'middle_name'
,
'last_name'
,)
list_filter
=
(
'first_name'
,
'middle_name'
,
'last_name'
,)
class
DepartmentAdmin
(
admin
.
ModelAdmin
):
model
=
Department
search_fields
=
(
'dept_name'
,
'home_unit'
,)
list_display
=
(
'dept_name'
,
'home_unit'
,)
list_filter
=
(
'dept_name'
,
'home_unit'
,)
admin
.
site
.
register
(
WidgetUser
,
WidgetUserAdmin
)
admin
.
site
.
register
(
WidgetUser
,
WidgetUserAdmin
)
admin
.
site
.
register
(
Department
,
DepartmentAdmin
)
widget_jupert/homepage/models.py
View file @
c07c16ae
...
@@ -6,6 +6,24 @@ class WidgetUser(models.Model):
...
@@ -6,6 +6,24 @@ class WidgetUser(models.Model):
first_name
=
models
.
CharField
(
max_length
=
50
)
first_name
=
models
.
CharField
(
max_length
=
50
)
middle_name
=
models
.
CharField
(
max_length
=
50
)
middle_name
=
models
.
CharField
(
max_length
=
50
)
last_name
=
models
.
CharField
(
max_length
=
50
)
last_name
=
models
.
CharField
(
max_length
=
50
)
id_num
=
models
.
CharField
(
max_length
=
7
)
email
=
models
.
EmailField
(
max_length
=
100
)
def
__str__
(
self
):
def
__str__
(
self
):
return
self
.
last_name
return
self
.
last_name
\ No newline at end of file
class
Department
(
models
.
Model
):
#Two Parameters (Model to which the Association is being made, process that you want to be done when a particular model is deleted)
user
=
models
.
ForeignKey
(
WidgetUser
,
on_delete
=
models
.
CASCADE
)
dept_name
=
models
.
CharField
(
max_length
=
50
)
home_unit
=
models
.
CharField
(
max_length
=
50
)
#so that when calling the objects of the department, the title would be displayed instead of a number
def
__str__
(
self
):
return
self
.
dept_name
widget_jupert/homepage/views.py
View file @
c07c16ae
from
urllib
import
response
from
django.http
import
HttpResponse
from
django.http
import
HttpResponse
from
homepage.models
import
WidgetUser
from
homepage.models
import
Department
# Create your views here.
# Create your views here.
def
index
(
request
):
def
index
(
request
):
return
HttpResponse
(
"Welcome to the Widget's Home Page!"
)
widgetuser_objects
=
WidgetUser
.
objects
.
all
()
\ No newline at end of file
department_objects
=
Department
.
objects
.
all
()
title
=
"Welcome to the Widget's Home Page!<br><br>"
response
=
"WIDGET USERS:<br>"
for
dept
in
department_objects
:
response
=
(
response
+
f
"{dept.user.last_name}, {dept.user.first_name} {dept.user.middle_name}: "
+
f
"{dept.user.id_num}, {dept.user.email}, "
+
f
"{dept.dept_name}, {dept.home_unit}<br>"
)
return
HttpResponse
(
title
+
response
)
\ 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