Commit b284f9b5 authored by Junho Park's avatar Junho Park

feat: update models and respective entries in announcement app

parent f6998759
No preview for this file type
from django.contrib import admin from django.contrib import admin
from .models import Announcement from .models import Announcement, Reaction
# Register your models here. # Register your models here.
class AnnouncementAdmin(admin.ModelAdmin):
model = Announcement
admin.site.register(Announcement) admin.site.register(Announcement)
class ReactionAdmin(admin.ModelAdmin):
model = Reaction
admin.site.register(Reaction)
# Generated by Django 3.2.12 on 2022-04-07 16:34
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('announcements', '0001_initial'),
]
operations = [
migrations.CreateModel(
name='Reaction',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('reaction_name', models.CharField(choices=[('LV', 'Love'), ('LK', 'Like'), ('AG', 'Angry')], default=None, max_length=2)),
('tally', models.IntegerField()),
],
),
migrations.AddField(
model_name='announcement',
name='reaction',
field=models.ForeignKey(default=None, null=True, on_delete=django.db.models.deletion.CASCADE, to='announcements.reaction'),
),
]
# Generated by Django 3.2.12 on 2022-04-07 17:07
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('homepage', '0002_auto_20220407_0505'),
('announcements', '0002_auto_20220407_1634'),
]
operations = [
migrations.AddField(
model_name='announcement',
name='author',
field=models.ForeignKey(default=None, null=True, on_delete=django.db.models.deletion.CASCADE, to='homepage.widgetuser'),
),
migrations.AlterField(
model_name='reaction',
name='reaction_name',
field=models.CharField(choices=[('Love', 'Love'), ('Like', 'Like'), ('Angry', 'Angry')], default=None, max_length=5),
),
]
from django.db import models from django.db import models
from homepage.models import WidgetUser
# Create your models here. # Create your models here.
class Reaction(models.Model):
LOVE = 'Love'
LIKE = 'Like'
ANGRY = 'Angry'
REACTION_CHOICES = [
(LOVE, 'Love'),
(LIKE, 'Like'),
(ANGRY, 'Angry'),
]
reaction_name = models.CharField(
max_length=5,
choices=REACTION_CHOICES,
default=None,
)
tally = models.IntegerField()
def __str__(self):
return self.reaction_name
class Announcement(models.Model): class Announcement(models.Model):
announcement_title = models.CharField(max_length=100) announcement_title = models.CharField(max_length=100)
announcement_body = models.CharField(max_length=1000) announcement_body = models.CharField(max_length=1000)
pub_date = models.DateTimeField('date published') pub_date = models.DateTimeField('date published')
author = models.ForeignKey(
'homepage.WidgetUser',
on_delete=models.CASCADE,
default=None,
null=True
)
reaction = models.ForeignKey(
'Reaction',
on_delete=models.CASCADE,
default=None,
null=True
)
def __str__(self): def __str__(self):
return self.announcement_title return self.announcement_title
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