Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
widget_group3
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
Jonathan Talbot
widget_group3
Commits
77b7d1ee
Commit
77b7d1ee
authored
Apr 08, 2022
by
Isaiah Flores
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update widget_group3/widget_group3/models.py
parent
a4e83b42
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
12 deletions
+10
-12
models.py
widget_group3/widget_group3/models.py
+10
-12
No files found.
widget_group3/widget_group3/models.py
View file @
77b7d1ee
from
django.db
import
models
from
django.urls
import
reverse
class
Department
(
models
.
Model
):
dept_name
=
models
.
CharField
(
max_length
=
100
)
home_unit
=
models
.
CharField
(
max_length
=
100
)
def
__str__
(
self
):
return
'{}, {}'
.
format
(
self
.
dept_name
,
self
.
home_unit
)
class
WidgetUser
(
models
.
Model
):
id_num
=
models
.
IntegerField
()
first_name
=
models
.
CharField
(
max_length
=
10
0
)
first_name
=
models
.
CharField
(
max_length
=
9
0
)
middle_name
=
models
.
CharField
(
max_length
=
100
)
last_name
=
models
.
CharField
(
max_length
=
100
)
email
=
models
.
EmailField
()
def
__str__
(
self
):
return
'{}, {} {}: {}, {}'
.
format
(
self
.
last_name
,
self
.
first_name
,
self
.
middle_name
,
self
.
id_num
,
self
.
email
)
department
=
models
.
ForeignKey
(
Department
,
on_delete
=
models
.
CASCADE
,
default
=
1
)
def
get_absolute_url
(
self
):
return
reverse
(
'widget_user'
,
args
=
[(
self
.
full_name
)])
...
...
@@ -17,14 +22,6 @@ class WidgetUser(models.Model):
def
full_name
(
self
):
return
'{} {} {}'
.
format
(
self
.
first_name
,
self
.
middle_name
,
self
.
last_name
)
class
Department
(
models
.
Model
):
dept_name
=
models
.
CharField
(
max_length
=
100
)
home_unit
=
models
.
CharField
(
max_length
=
100
)
widget_user
=
models
.
ForeignKey
(
WidgetUser
,
on_delete
=
models
.
CASCADE
)
def
__str__
(
self
):
return
'{}, {}'
.
format
(
self
.
dept_name
,
self
.
home_unit
)
class
Announcement
(
models
.
Model
):
announcement_title
=
models
.
CharField
(
max_length
=
50
)
announcement_body
=
models
.
CharField
(
max_length
=
200
)
...
...
@@ -45,6 +42,7 @@ class Post(models.Model):
post_body
=
models
.
CharField
(
max_length
=
100
)
pub_date
=
models
.
DateTimeField
(
auto_now_add
=
True
,
editable
=
False
)
author
=
models
.
ForeignKey
(
WidgetUser
,
on_delete
=
models
.
CASCADE
)
# author_name = WidgetUser.objects.get(fk=author).full_name()
def
__str__
(
self
):
return
'{} by {} dated {}:<br> {}'
.
format
(
self
.
post_title
,
self
.
author
.
full_name
(),
self
.
pub_date
,
self
.
post_body
)
...
...
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