Commit ac190421 authored by iceman2434's avatar iceman2434

Changed functions and linebreaks

fixed __str__ functions in models.py
added replied_post to search fields in ReplyAdmin
changed /n to <br>
parent 70b0fc23
......@@ -69,9 +69,9 @@ class PostAdmin(admin.ModelAdmin):
class ReplyAdmin(admin.ModelAdmin):
model = Reply
search_fields = ('reply_body', 'pub_date', 'author')
list_display = ('reply_body', 'pub_date', 'author')
list_filter = ('reply_body', 'pub_date', 'author')
search_fields = ('reply_body', 'pub_date', 'author', 'replied_post')
list_display = ('reply_body', 'pub_date', 'author', 'replied_post')
list_filter = ('reply_body', 'pub_date', 'author', 'replied_post')
fieldsets = [
('Reply Data', {
......@@ -109,9 +109,6 @@ class AssignmentAdmin(admin.ModelAdmin):
# Register models
admin.site.register(WidgetUser, WidgetUserAdmin)
admin.site.register(Post, PostAdmin)
......
......@@ -47,7 +47,7 @@ class Post(models.Model):
author = models.ForeignKey(WidgetUser, on_delete=models.CASCADE)
def __str__(self):
return '{} by {} dated {}:\n {}'.format(self.post_title, self.author.get_absolute_url(), self.pub_date, self.post_body)
return '{} by {} dated {}:<br> {}'.format(self.post_title, self.author.full_name(), self.pub_date, self.post_body)
def get_absolute_url(self):
return reverse('forum', args=[(self.post_title)])
......@@ -59,7 +59,7 @@ class Reply(models.Model):
replied_post = models.ForeignKey(Post, on_delete=models.CASCADE)
def __str__(self):
return 'Reply by {} dated {}:\n {}'.format(self.author.get_absolute_url(), self.pub_date, self.reply_body)
return '<br>Reply by {} dated {}:<br> {}'.format(self.author.full_name(), self.pub_date, self.reply_body)
class Assignment(models.Model):
name = models.CharField(max_length = 100)
......@@ -71,3 +71,4 @@ class Assignment(models.Model):
def get_absolute_url(self):
return reverse('assignment', args=[(self.name)])
......@@ -15,5 +15,5 @@ def announcements(request):
def forum(request):
post = Post.objects.all()
reply = Reply.objects.all()
output = "FORUM POSTS:\n" + "\n".join([str(x) for x in post]) + "\n".join([str(z) for z in reply])
output = "FORUM POSTS:<br>" + "<br>".join([str(x) for x in post]) + "<br>".join([str(z) for z in reply])
return HttpResponse(output, content_type="text/plain")
\ No newline at end of file
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