Commit 245ee6c2 authored by Lance Cedric Tan's avatar Lance Cedric Tan

Updated forum models and views to new spec

parent 9a27651e
...@@ -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