Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
midterm_huli
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
Izaac Daniel B. Muncal
midterm_huli
Commits
16fec26a
Commit
16fec26a
authored
Mar 06, 2023
by
Richie Villareal
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added admin, models and views
parent
aaab9057
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
0 deletions
+47
-0
models.py
widget_huli/Announcement_Board/models.py
+20
-0
views.py
widget_huli/Announcement_Board/views.py
+27
-0
No files found.
widget_huli/Announcement_Board/models.py
View file @
16fec26a
from
django.db
import
models
from
django.urls
import
reverse
from
dashboard.model
import
WidgetUser
# Create your models here.
class
Announcement
(
models
.
Model
):
title
=
models
.
CharField
(
max_length
=
50
)
body
=
models
.
TextField
()
author
=
models
.
ForeignKey
(
WidgetUser
,
on_delete
=
models
.
CASCADE
)
pub_datetime
=
models
.
DateTimeField
()
class
Reaction
(
models
.
Model
):
name
=
models
.
CharField
(
max_length
=
50
)
tally
=
models
.
IntegerField
()
announcement
=
models
.
ForeignKey
(
Announcement
,
on_delete
=
models
.
CASCADE
)
widget_huli/Announcement_Board/views.py
View file @
16fec26a
from
django.shortcuts
import
render
from
django.http
import
HttpResponse
from
.models
import
Announcement
,
Reaction
# Create your views here.
def
index
(
request
):
return_string
=
'<body> <ul>'
reaction_string
=
''
for
announcement
in
Announcement
.
objects
.
all
():
announcement_string
=
'<li>{} by {} published <br>{}</li>'
.
format
(
announcement
.
title
,
announcement
.
author
,
announcement
.
pub_datetime
.
strftime
(
'
%
m/
%
d/
%
Y
%
H:
%
M
%
p'
),
announcement
.
body
)
for
reaction
in
Reaction
.
objects
.
all
():
if
reaction
.
announcement
==
announcement
:
reaction_string
+=
'<li>{}: {}</li>'
.
format
(
reaction
.
name
,
reaction
.
tally
)
return_string
+=
announcement_string
return_string
+=
reaction_string
return_string
+=
'<br>'
return_string
+=
'</ul></body>'
html_string
=
'<htmk>{}</html>'
.
format
(
return_string
)
return
HttpResponse
(
html_string
)
\ 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