Commit 074879db authored by nheoxoz's avatar nheoxoz

updated models of announcements

parent 3bfe208f
# Generated by Django 4.1.7 on 2023-03-04 04:26
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Announcement',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('title', models.CharField(max_length=100)),
('body', models.TextField()),
('author', models.CharField(max_length=100)),
('pub_datetime', models.CharField(max_length=100)),
],
),
migrations.CreateModel(
name='Reaction',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=100)),
('tally', models.IntegerField()),
('announcement', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='announcements.announcement')),
],
),
]
# Generated by Django 4.1.7 on 2023-03-04 05:46
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('announcements', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='announcement',
name='pub_datetime',
field=models.DateTimeField(),
),
migrations.AlterField(
model_name='reaction',
name='name',
field=models.CharField(choices=[('Like', 'LIKE'), ('Love', 'LOVE'), ('Angry', 'ANGRY')], default='Like', max_length=5),
),
]
from django.db import models from django.db import models
# Create your models here.
class Announcement(models.Model):
title = models.CharField(max_length=100)
body = models.TextField()
author = models.CharField(max_length=100)
pub_datetime = models.DateTimeField()
def __str__(self):
return '''{} by <authors first name> <authors last name> published {}
\n{}'''.format(self.title, self.pub_datetime, self.body)
class Reaction(models.Model):
REACTION_LIKE = "Like"
REACTION_LOVE = "Love"
REACTION_ANGRY = "Angry"
REACTION_CHOICES = [
(REACTION_LIKE, "LIKE"),
(REACTION_LOVE, "LOVE"),
(REACTION_ANGRY, "ANGRY"),
]
name = models.CharField(
max_length=5,
choices=REACTION_CHOICES,
default=REACTION_LIKE,
)
tally = models.IntegerField()
announcement = models.ForeignKey(Announcement, on_delete=models.CASCADE)
def __str__(self):
return '''Like: {}\nLove: {}\nAngry: {}'''.format(self.tally, self.tally, self.tally)
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