Commit 231659e6 authored by Carlo Joseph Echon's avatar Carlo Joseph Echon 🐟

Added author field in Announcements and created Reaction model

parent ef6e7a49
# Generated by Django 4.0.3 on 2022-04-01 11:35
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('homepage', '0001_initial'),
('announcements', '0001_initial'),
]
operations = [
migrations.AddField(
model_name='announcement',
name='author',
field=models.ForeignKey(default=1, on_delete=django.db.models.deletion.CASCADE, to='homepage.widgetuser'),
),
migrations.AlterField(
model_name='announcement',
name='announcement_body',
field=models.TextField(max_length=1500),
),
migrations.CreateModel(
name='Reaction',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('reaction_name', models.CharField(choices=[('LK', 'Like'), ('LV', 'Love'), ('AG', 'Angry')], default='LK', max_length=2)),
('tally', models.IntegerField(default=0)),
('announcement', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='announcements.announcement')),
],
),
]
# Generated by Django 4.0.3 on 2022-04-03 02:47
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('announcements', '0002_alter_announcement_announcement_body'),
('announcements', '0002_announcement_author_and_more'),
]
operations = [
]
from django.db import models from django.db import models
from homepage.models import WidgetUser
# Create your models here. # Create your models here.
class Announcement(models.Model): class Announcement(models.Model):
announcement_title = models.CharField(max_length=50) announcement_title = models.CharField(max_length=50)
announcement_body = models.TextField(max_length=1500) announcement_body = models.TextField(max_length=1500)
pub_date = models.DateTimeField("date published") pub_date = models.DateTimeField("date published")
author = models.ForeignKey(WidgetUser, on_delete=models.CASCADE)
def __str__(self): def __str__(self):
return self.announcement_title return self.announcement_title
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,
default=LIKE,
)
tally = models.IntegerField(default=0)
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment