Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
widget_Francoconuts
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Chester Tan
widget_Francoconuts
Commits
73953eaa
Commit
73953eaa
authored
Apr 03, 2022
by
Bryan Carlo Guanlao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Announcement: models added and modified
added Reaction model, its foreign key and fields for announcement model
parent
b99e11d4
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
62 additions
and
3 deletions
+62
-3
admin.py
widget_Francoconuts/announcements/admin.py
+7
-1
0001_initial.py
widget_Francoconuts/announcements/migrations/0001_initial.py
+13
-1
0002_rename_announcement_name_reaction_announcement.py
...ns/0002_rename_announcement_name_reaction_announcement.py
+18
-0
models.py
widget_Francoconuts/announcements/models.py
+23
-0
0001_initial.py
widget_Francoconuts/homepage/migrations/0001_initial.py
+1
-1
__init__.py
widget_Francoconuts/homepage/migrations/__init__.py
+0
-0
No files found.
widget_Francoconuts/announcements/admin.py
View file @
73953eaa
from
django.contrib
import
admin
from
django.contrib
import
admin
from
.models
import
Announcement
from
.models
import
Announcement
,
Reaction
class
AnnouncementAdmin
(
admin
.
ModelAdmin
):
class
AnnouncementAdmin
(
admin
.
ModelAdmin
):
...
@@ -8,4 +8,10 @@ class AnnouncementAdmin(admin.ModelAdmin):
...
@@ -8,4 +8,10 @@ class AnnouncementAdmin(admin.ModelAdmin):
list_display
=
(
'announcement_title'
,
'pub_date'
)
list_display
=
(
'announcement_title'
,
'pub_date'
)
class
ReactionAdmin
(
admin
.
ModelAdmin
):
model
=
Reaction
list_display
=
(
'reaction_name'
,
'announcement'
,
'tally'
)
admin
.
site
.
register
(
Announcement
,
AnnouncementAdmin
)
admin
.
site
.
register
(
Announcement
,
AnnouncementAdmin
)
admin
.
site
.
register
(
Reaction
,
ReactionAdmin
)
widget_Francoconuts/announcements/migrations/0001_initial.py
View file @
73953eaa
# Generated by Django 3.2.12 on 2022-0
3-22 18:58
# Generated by Django 3.2.12 on 2022-0
4-03 02:52
from
django.db
import
migrations
,
models
from
django.db
import
migrations
,
models
import
django.db.models.deletion
class
Migration
(
migrations
.
Migration
):
class
Migration
(
migrations
.
Migration
):
...
@@ -8,6 +9,7 @@ class Migration(migrations.Migration):
...
@@ -8,6 +9,7 @@ class Migration(migrations.Migration):
initial
=
True
initial
=
True
dependencies
=
[
dependencies
=
[
(
'homepage'
,
'0001_initial'
),
]
]
operations
=
[
operations
=
[
...
@@ -18,6 +20,16 @@ class Migration(migrations.Migration):
...
@@ -18,6 +20,16 @@ class Migration(migrations.Migration):
(
'announcement_title'
,
models
.
CharField
(
max_length
=
50
)),
(
'announcement_title'
,
models
.
CharField
(
max_length
=
50
)),
(
'announcement_body'
,
models
.
TextField
(
max_length
=
500
)),
(
'announcement_body'
,
models
.
TextField
(
max_length
=
500
)),
(
'pub_date'
,
models
.
DateField
(
auto_now_add
=
True
)),
(
'pub_date'
,
models
.
DateField
(
auto_now_add
=
True
)),
(
'author'
,
models
.
ForeignKey
(
on_delete
=
django
.
db
.
models
.
deletion
.
CASCADE
,
to
=
'homepage.widgetuser'
)),
],
),
migrations
.
CreateModel
(
name
=
'Reaction'
,
fields
=
[
(
'id'
,
models
.
BigAutoField
(
auto_created
=
True
,
primary_key
=
True
,
serialize
=
False
,
verbose_name
=
'ID'
)),
(
'reaction_name'
,
models
.
CharField
(
choices
=
[(
'Like'
,
'Like'
),
(
'Love'
,
'Love'
),
(
'Hate'
,
'Hate'
)],
default
=
'Like'
,
max_length
=
10
)),
(
'tally'
,
models
.
IntegerField
()),
(
'announcement_name'
,
models
.
ForeignKey
(
on_delete
=
django
.
db
.
models
.
deletion
.
CASCADE
,
to
=
'announcements.announcement'
)),
],
],
),
),
]
]
widget_Francoconuts/announcements/migrations/0002_rename_announcement_name_reaction_announcement.py
0 → 100644
View file @
73953eaa
# Generated by Django 3.2.12 on 2022-04-03 02:55
from
django.db
import
migrations
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'announcements'
,
'0001_initial'
),
]
operations
=
[
migrations
.
RenameField
(
model_name
=
'reaction'
,
old_name
=
'announcement_name'
,
new_name
=
'announcement'
,
),
]
widget_Francoconuts/announcements/models.py
View file @
73953eaa
from
django.db
import
models
from
django.db
import
models
from
homepage.models
import
WidgetUser
REACTION_CHOICES
=
[(
'Like'
,
'Like'
),
(
'Love'
,
'Love'
),
(
'Hate'
,
'Hate'
)]
class
Announcement
(
models
.
Model
):
class
Announcement
(
models
.
Model
):
author
=
models
.
ForeignKey
(
WidgetUser
,
on_delete
=
models
.
CASCADE
,
)
announcement_title
=
models
.
CharField
(
max_length
=
50
)
announcement_title
=
models
.
CharField
(
max_length
=
50
)
announcement_body
=
models
.
TextField
(
max_length
=
500
)
announcement_body
=
models
.
TextField
(
max_length
=
500
)
pub_date
=
models
.
DateField
(
auto_now_add
=
True
)
pub_date
=
models
.
DateField
(
auto_now_add
=
True
)
def
__str__
(
self
):
def
__str__
(
self
):
return
'{}'
.
format
(
self
.
announcement_title
)
return
'{}'
.
format
(
self
.
announcement_title
)
class
Reaction
(
models
.
Model
):
announcement
=
models
.
ForeignKey
(
Announcement
,
on_delete
=
models
.
CASCADE
,
)
reaction_name
=
models
.
CharField
(
max_length
=
10
,
choices
=
REACTION_CHOICES
,
default
=
'Like'
)
tally
=
models
.
IntegerField
()
def
_str_
(
self
):
return
'{}: {}'
.
format
(
self
.
reaction_name
,
self
.
tally
)
widget_Francoconuts/homepage/migrations/0001_initial.py
View file @
73953eaa
# Generated by Django
4.0.3 on 2022-03-22 03:09
# Generated by Django
3.2.12 on 2022-04-03 02:44
from
django.db
import
migrations
,
models
from
django.db
import
migrations
,
models
...
...
widget_Francoconuts/homepage/migrations/__init__.py
0 → 100644
View file @
73953eaa
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