Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
widget_group22
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
John Tamano
widget_group22
Commits
5efaa9c2
Commit
5efaa9c2
authored
Apr 05, 2022
by
Julliana Zarah C. Cruz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added Reaction model and changed Announcement body to text field
parent
fa1ee550
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
47 additions
and
9 deletions
+47
-9
admin.py
widget_group22/announcements/admin.py
+17
-1
models.py
widget_group22/announcements/models.py
+27
-2
urls.py
widget_group22/announcements/urls.py
+2
-2
views.py
widget_group22/announcements/views.py
+1
-4
No files found.
widget_group22/announcements/admin.py
View file @
5efaa9c2
from
django.contrib
import
admin
from
.models
import
Announcement
,
Reaction
# Register your models here.
class
AnnouncementAdmin
(
admin
.
ModelAdmin
):
model
=
Announcement
list_display
=
(
'announcement_title'
,
'pub_date'
)
class
ReactionAdmin
(
admin
.
ModelAdmin
):
model
=
Reaction
list_display
=
(
'announcement'
,
'reaction_name'
,
'tally'
)
admin
.
site
.
register
(
Announcement
,
AnnouncementAdmin
)
admin
.
site
.
register
(
Reaction
,
ReactionAdmin
)
widget_group22/announcements/models.py
View file @
5efaa9c2
from
django.db
import
models
class
Reaction
(
models
.
Model
):
like
=
'Like'
love
=
'Love'
angry
=
'Angry'
REACTION_CHOICES
=
[
(
like
,
'Like'
),
(
love
,
'Love'
),
(
angry
,
'Angry'
)
]
announcement
=
models
.
ForeignKey
(
'Announcement'
,
on_delete
=
models
.
CASCADE
,
)
reaction_name
=
models
.
CharField
(
max_length
=
5
,
choices
=
REACTION_CHOICES
,
)
tally
=
models
.
AutoField
(
primary_key
=
True
)
class
Announcement
(
models
.
Model
):
announcement_title
=
models
.
CharField
(
max_length
=
100
)
announcement_body
=
models
.
CharField
(
max_length
=
400
)
announcement_body
=
models
.
TextField
(
)
pub_date
=
models
.
DateField
(
auto_now_add
=
True
)
author
=
models
.
ForeignKey
(
'homepage.WidgetUser'
,
on_delete
=
models
.
CASCADE
,
#related_name='author'
)
\ No newline at end of file
widget_group22/announcements/urls.py
View file @
5efaa9c2
from
django.urls
import
path
from
.views
import
index
from
.views
import
announcements
urlpatterns
=
[
path
(
''
,
index
,
name
=
'index
'
),
path
(
''
,
announcements
,
name
=
'announcements
'
),
]
app_name
=
"announcements"
widget_group22/announcements/views.py
View file @
5efaa9c2
from
django.shortcuts
import
render
from
django.http
import
HttpResponse
def
index
(
request
):
def
announcements
(
request
):
return
HttpResponse
(
'This is the Announcement Board!'
)
# Create your views here.
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