Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
midterm_vincentdjango
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
Almira Redoble
midterm_vincentdjango
Commits
426d6222
Commit
426d6222
authored
Mar 04, 2023
by
Jayson Lim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated Reaction class attributes and implemented admin panel
parent
91fb39ba
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
66 additions
and
3 deletions
+66
-3
admin.cpython-39.pyc
...django/announcementBoard/__pycache__/admin.cpython-39.pyc
+0
-0
models.cpython-39.pyc
...jango/announcementBoard/__pycache__/models.cpython-39.pyc
+0
-0
admin.py
widget_vincentdjango/announcementBoard/admin.py
+26
-1
0001_initial.py
...incentdjango/announcementBoard/migrations/0001_initial.py
+35
-0
0001_initial.cpython-39.pyc
...tBoard/migrations/__pycache__/0001_initial.cpython-39.pyc
+0
-0
models.py
widget_vincentdjango/announcementBoard/models.py
+5
-2
db.sqlite3
widget_vincentdjango/db.sqlite3
+0
-0
No files found.
widget_vincentdjango/announcementBoard/__pycache__/admin.cpython-39.pyc
View file @
426d6222
No preview for this file type
widget_vincentdjango/announcementBoard/__pycache__/models.cpython-39.pyc
View file @
426d6222
No preview for this file type
widget_vincentdjango/announcementBoard/admin.py
View file @
426d6222
from
django.contrib
import
admin
from
django.contrib
import
admin
from
.models
import
Announcement
,
Reaction
# Register your models here.
class
ReactionInline
(
admin
.
TabularInline
):
model
=
Reaction
class
AnnouncementAdmin
(
admin
.
ModelAdmin
):
model
=
Announcement
list_display
=
(
'title'
,
'author'
,
)
search_fields
=
(
'title'
,
'body'
,
'author'
,
)
list_filter
=
(
'title'
,
'author'
)
fieldsets
=
[
(
'Announcement'
,
{
'fields'
:
(
'title'
,
'body'
,
'author'
)
})
]
inlines
=
[
ReactionInline
]
class
ReactionAdmin
(
admin
.
ModelAdmin
):
model
=
Reaction
admin
.
site
.
register
(
Announcement
,
AnnouncementAdmin
)
admin
.
site
.
register
(
Reaction
,
ReactionAdmin
)
widget_vincentdjango/announcementBoard/migrations/0001_initial.py
0 → 100644
View file @
426d6222
# Generated by Django 3.2 on 2023-03-04 07:17
from
django.db
import
migrations
,
models
import
django.db.models.deletion
class
Migration
(
migrations
.
Migration
):
initial
=
True
dependencies
=
[
(
'dashboard'
,
'0001_initial'
),
]
operations
=
[
migrations
.
CreateModel
(
name
=
'Announcement'
,
fields
=
[
(
'id'
,
models
.
BigAutoField
(
auto_created
=
True
,
primary_key
=
True
,
serialize
=
False
,
verbose_name
=
'ID'
)),
(
'title'
,
models
.
CharField
(
default
=
''
,
max_length
=
250
)),
(
'body'
,
models
.
TextField
(
blank
=
True
,
null
=
True
)),
(
'pub_datetime'
,
models
.
DateTimeField
(
auto_now_add
=
True
)),
(
'author'
,
models
.
ForeignKey
(
default
=
True
,
null
=
True
,
on_delete
=
django
.
db
.
models
.
deletion
.
SET_DEFAULT
,
to
=
'dashboard.widgetuser'
)),
],
),
migrations
.
CreateModel
(
name
=
'Reaction'
,
fields
=
[
(
'id'
,
models
.
BigAutoField
(
auto_created
=
True
,
primary_key
=
True
,
serialize
=
False
,
verbose_name
=
'ID'
)),
(
'name'
,
models
.
CharField
(
max_length
=
10
)),
(
'tally'
,
models
.
IntegerField
(
default
=
0
)),
(
'annoucement'
,
models
.
ForeignKey
(
default
=
True
,
null
=
True
,
on_delete
=
django
.
db
.
models
.
deletion
.
SET_DEFAULT
,
to
=
'announcementBoard.announcement'
)),
],
),
]
widget_vincentdjango/announcementBoard/migrations/__pycache__/0001_initial.cpython-39.pyc
0 → 100644
View file @
426d6222
File added
widget_vincentdjango/announcementBoard/models.py
View file @
426d6222
...
@@ -16,8 +16,11 @@ class Announcement(models.Model):
...
@@ -16,8 +16,11 @@ class Announcement(models.Model):
return
self
.
title
return
self
.
title
class
Reaction
(
models
.
Model
):
class
Reaction
(
models
.
Model
):
name
=
models
.
CharField
(
max_length
=
10
,
null
=
False
,
blank
=
False
)
name
=
models
.
CharField
(
max_length
=
5
,
choices
=
[
tally
=
models
.
IntegerField
(
default
=
0
)
(
'Like'
,
'Like'
),
(
'Love'
,
'Love'
),
(
'Angry'
,
'Angry'
)],
default
=
'Like'
)
tally
=
models
.
PositiveIntegerField
(
default
=
0
)
annoucement
=
models
.
ForeignKey
(
annoucement
=
models
.
ForeignKey
(
Announcement
,
Announcement
,
null
=
True
,
null
=
True
,
...
...
widget_vincentdjango/db.sqlite3
View file @
426d6222
No preview for this file type
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