Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
widget_django unchained
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
1
Merge Requests
1
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
Jose Emmanuel B. Laurel
widget_django unchained
Commits
578c4f34
Commit
578c4f34
authored
Apr 04, 2022
by
Joshua Son
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
'y
parent
6f2945ed
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
30 additions
and
4 deletions
+30
-4
urls.cpython-39.pyc
...o_unchained/announcements/__pycache__/urls.cpython-39.pyc
+0
-0
views.cpython-39.pyc
..._unchained/announcements/__pycache__/views.cpython-39.pyc
+0
-0
models.py
widget_django_unchained/announcements/models.py
+3
-1
announcement_board.html
...unchained/announcements/templates/announcement_board.html
+14
-0
reactions_list
...t_django_unchained/announcements/templates/reactions_list
+7
-0
urls.py
widget_django_unchained/announcements/urls.py
+1
-1
views.py
widget_django_unchained/announcements/views.py
+5
-2
No files found.
widget_django_unchained/announcements/__pycache__/urls.cpython-39.pyc
View file @
578c4f34
No preview for this file type
widget_django_unchained/announcements/__pycache__/views.cpython-39.pyc
View file @
578c4f34
No preview for this file type
widget_django_unchained/announcements/models.py
View file @
578c4f34
...
...
@@ -5,14 +5,16 @@ class Announcement(models.Model):
announcement_title
=
models
.
CharField
(
max_length
=
50
)
announcement_body
=
models
.
CharField
(
max_length
=
500
)
pub_date
=
models
.
DateTimeField
(
"date published"
)
def
__str__
(
self
):
return
self
.
announcement_title
class
Reaction
(
models
.
Model
):
announcement
=
models
.
ForeignKey
(
Announcement
,
on_delete
=
models
.
CASCADE
)
announcement
=
models
.
ForeignKey
(
'Announcement'
,
on_delete
=
models
.
CASCADE
)
reaction_name
=
models
.
CharField
(
max_length
=
10
)
tally
=
models
.
IntegerField
(
default
=
0
)
def
__str__
(
self
):
return
self
.
reaction_name
\ No newline at end of file
widget_django_unchained/announcements/templates/announcement_board.html
View file @
578c4f34
<p>
<h2>
ANNOUNCEMENTS:
</h2>
{% for announcement in announcements%}
<p><b>
{{announcement.announcement_title}}
</b>
dated {{announcement.pub_date}}
</p>
<p>
{{announcement.announcement_body}}
</p>
{% if announcement.reaction_list != NULL %}
<p>
{% include "reaction_list.html" with reaction=announcement.reaction_list %}
</p>
{% endif %}
{{ value|linebreaks }}
{% endfor %}
</p>
\ No newline at end of file
widget_django_unchained/announcements/templates/reactions_list
0 → 100644
View file @
578c4f34
<p>
{% for reaction in reactions %}
<p>{{ reaction.reaction_name }} : {{reaction.tally}} </p>
{{ value|linebreaks }}
{% endfor %}
</p>
\ No newline at end of file
widget_django_unchained/announcements/urls.py
View file @
578c4f34
...
...
@@ -3,5 +3,5 @@ from django.urls import path
from
.
import
views
urlpatterns
=
[
path
(
''
,
views
.
index
,
name
=
'index
'
)
path
(
''
,
views
.
show_announcements
,
name
=
'show_announcements
'
)
]
\ No newline at end of file
widget_django_unchained/announcements/views.py
View file @
578c4f34
from
django.http
import
HttpResponse
from
django.shortcuts
import
render
from
.models
import
Announcement
,
Reaction
# Create your views here.
def
index
(
request
):
return
HttpResponse
(
"This is the Announcement Board!"
)
\ No newline at end of file
def
show_announcements
(
request
):
announcement
=
Announcement
.
objects
.
all
()
return
render
(
request
,
'announcement_board.html'
,
{
'announcements'
:
announcement
})
\ 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