Commit 007de444 authored by Mary Adelaide A. Salto's avatar Mary Adelaide A. Salto
parents cac7e59c 2f63d4da
File deleted
# Generated by Django 3.2 on 2023-03-06 05:46
from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone
class Migration(migrations.Migration):
dependencies = [
('dashboard', '0001_initial'),
('forum', '0001_initial'),
]
operations = [
migrations.AddField(
model_name='reply',
name='forum_post',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='forum.forumpost'),
),
migrations.AlterField(
model_name='forumpost',
name='author',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='dashboard.widgetuser'),
),
migrations.AlterField(
model_name='reply',
name='author',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='dashboard.widgetuser'),
),
migrations.AlterField(
model_name='reply',
name='pub_datetime',
field=models.DateTimeField(blank=True, default=django.utils.timezone.now, null=True),
),
]
...@@ -14,10 +14,13 @@ class ForumPost(models.Model): ...@@ -14,10 +14,13 @@ class ForumPost(models.Model):
class Reply(models.Model): class Reply(models.Model):
post = models.ForeignKey(ForumPost, on_delete=models.CASCADE, null=True) forum_post = models.ForeignKey(ForumPost, on_delete=models.CASCADE, null=True)
body = models.TextField() body = models.TextField()
author = models.ForeignKey(WidgetUser, on_delete=models.CASCADE) author = models.ForeignKey(WidgetUser, on_delete=models.CASCADE)
pub_datetime = models.DateTimeField(default=timezone.now, null=True, blank=True) pub_datetime = models.DateTimeField(default=timezone.now, null=True, blank=True)
def __str__(self): def __str__(self):
return self.post return 'Reply by {} {} posted {}'.format(
\ No newline at end of file self.author.first_name, self.author.last_name,
self.pub_datetime.strftime('%m/%d/%Y, %H:%M %p')
)
\ No newline at end of file
...@@ -12,7 +12,7 @@ def index(request): ...@@ -12,7 +12,7 @@ def index(request):
post.pub_datetime.strftime('%m/%d/%Y, %H:%M %p'), post.body post.pub_datetime.strftime('%m/%d/%Y, %H:%M %p'), post.body
) )
for reply in Reply.objects.all(): for reply in Reply.objects.all():
if reply.post==post.title: if reply.forum_post==post.title:
page_content += 'Reply by {} {} posted {}:<br>{}<br>'.format( page_content += 'Reply by {} {} posted {}:<br>{}<br>'.format(
reply.author.first_name, reply.author.last_name, reply.author.first_name, reply.author.last_name,
reply.pub_datetime.strftime('%m/%d/%Y, %H:%M %p'), reply.pub_datetime.strftime('%m/%d/%Y, %H:%M %p'),
......
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