Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
widgets_FEKK
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
Kyla Martin
widgets_FEKK
Commits
31836b43
Commit
31836b43
authored
Apr 04, 2022
by
Franco Velasco
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'velasco/homepage' into 'master'
Created Department Model, Linked Models to View See merge request
!7
parents
95715cd4
9f5c0b77
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
5 deletions
+45
-5
admin.py
WidgetFEKK/Homepage/admin.py
+12
-2
models.py
WidgetFEKK/Homepage/models.py
+24
-2
views.py
WidgetFEKK/Homepage/views.py
+9
-1
No files found.
WidgetFEKK/Homepage/admin.py
View file @
31836b43
from
django.contrib
import
admin
from
.models
import
WidgetUser
from
.models
import
WidgetUser
,
Department
# Register your models here.
class
WidgetUserAdmin
(
admin
.
ModelAdmin
):
model
=
WidgetUser
list_display
=
(
'first_name'
,
'last_name'
,)
search_fields
=
(
'last_name'
,
'first_name'
)
list_display
=
(
'last_name'
,
'first_name'
,)
filter
=
(
'department'
,
)
class
DepartmentAdmin
(
admin
.
ModelAdmin
):
model
=
Department
list_display
=
(
'dept_name'
,)
admin
.
site
.
register
(
WidgetUser
,
WidgetUserAdmin
)
admin
.
site
.
register
(
Department
,
DepartmentAdmin
)
WidgetFEKK/Homepage/models.py
View file @
31836b43
from
django.db
import
models
# Create your models here.
"""
A model for a school department in Widget.
Has fields for the names of the department and the unit it is associated with.
"""
class
Department
(
models
.
Model
):
dept_name
=
models
.
CharField
(
max_length
=
50
)
home_unit
=
models
.
CharField
(
max_length
=
50
)
def
__str__
(
self
):
return
f
"{self.dept_name}, {self.home_unit}"
"""
A model for users of Widget.
Asks for firstname, middle name, last name, ID number, and Email.
"""
class
WidgetUser
(
models
.
Model
):
first_name
=
models
.
CharField
(
max_length
=
50
)
middle_name
=
models
.
CharField
(
max_length
=
50
)
last_name
=
models
.
CharField
(
max_length
=
50
)
id_num
=
models
.
IntegerField
()
email
=
models
.
EmailField
()
department
=
models
.
ForeignKey
(
Department
,
on_delete
=
models
.
CASCADE
)
def
__str__
(
self
):
return
f
"{self.last_name}, {self.first_name} {self.middle_name}"
return
f
"""{self.last_name}, {self.first_name} {self.middle_name}:
{self.id_num}, {self.email}, {self.department}"""
WidgetFEKK/Homepage/views.py
View file @
31836b43
from
django.shortcuts
import
render
from
django.http
import
HttpResponse
from
.models
import
WidgetUser
def
index
(
response
):
userString
=
"WIDGET USERS:<br>"
users
=
WidgetUser
.
objects
.
all
()
for
user
in
users
:
userString
+=
f
"""{user}<br>"""
return
HttpResponse
(
'<span style="color: #365f90; font-size: xx-large; font-weight: bold; font-family: helvetica"> Welcome to Widget! </span>'
userString
)
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