Commit cda4fa9e authored by shibadisaster's avatar shibadisaster

Added forum models and populated them

parent 0ba74979
# Generated by Django 3.2 on 2023-03-05 07:28
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('dashboard', '0001_initial'),
('announcementBoard', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='announcement',
name='author',
field=models.ForeignKey(default=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='announcements', to='dashboard.widgetuser'),
),
migrations.AlterField(
model_name='reaction',
name='annoucement',
field=models.ForeignKey(default=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='reactions', to='announcementBoard.announcement'),
),
migrations.AlterField(
model_name='reaction',
name='name',
field=models.CharField(choices=[('Like', 'Like'), ('Love', 'Love'), ('Angry', 'Angry')], default='Like', max_length=5),
),
migrations.AlterField(
model_name='reaction',
name='tally',
field=models.PositiveIntegerField(default=0),
),
]
from django.contrib import admin from django.contrib import admin
from .models import ForumPost, Reply
# Register your models here. class ForumPostAdmin(admin.ModelAdmin):
model = ForumPost
list_display = ('title', 'body', 'author', 'pub_datetime')
search_fields = ('title', 'author', 'pub_datetime',)
list_filter = ('title', 'author', 'pub_datetime',)
class ReplyAdmin(admin.ModelAdmin):
model = Reply
list_display = ('body', 'post', 'author', 'pub_datetime',)
search_fields = ('author', 'pub_datetime',)
list_filter = ('author', 'pub_datetime',)
admin.site.register(ForumPost, ForumPostAdmin)
admin.site.register(Reply, ReplyAdmin)
# Generated by Django 3.2 on 2023-03-05 07:28
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='Reply',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('body', models.CharField(max_length=200)),
('pub_datetime', models.DateTimeField()),
('author', models.ForeignKey(default=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='dashboard.widgetuser')),
],
),
migrations.CreateModel(
name='ForumPost',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('title', models.CharField(max_length=100)),
('body', models.CharField(max_length=200)),
('pub_datetime', models.DateTimeField()),
('author', models.ForeignKey(default=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='dashboard.widgetuser')),
],
),
]
# Generated by Django 3.2 on 2023-03-05 08:57
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('forum', '0001_initial'),
]
operations = [
migrations.AddField(
model_name='reply',
name='post',
field=models.ForeignKey(default=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='forum.forumpost'),
),
]
# forum/models.py
from django.db import models from django.db import models
from dashboard.models import WidgetUser
# Create your models here. class ForumPost(models.Model):
title = models.CharField(max_length=100)
body = models.CharField(max_length=200)
author = models.ForeignKey(
WidgetUser,
null=True,
default=True,
on_delete=models.CASCADE,
)
pub_datetime = models.DateTimeField()
def __str__(self):
return self.title
class Reply(models.Model):
post = models.ForeignKey(
ForumPost,
null=True,
default=True,
on_delete=models.CASCADE,
)
body = models.CharField(max_length=200)
author = models.ForeignKey(
WidgetUser,
null=True,
default=True,
on_delete=models.CASCADE,
)
pub_datetime = models.DateTimeField()
def __str__(self):
return self.body
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