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): ...@@ -69,9 +69,9 @@ class PostAdmin(admin.ModelAdmin):
class ReplyAdmin(admin.ModelAdmin): class ReplyAdmin(admin.ModelAdmin):
model = Reply model = Reply
search_fields = ('reply_body', 'pub_date', 'author') search_fields = ('reply_body', 'pub_date', 'author', 'replied_post')
list_display = ('reply_body', 'pub_date', 'author') list_display = ('reply_body', 'pub_date', 'author', 'replied_post')
list_filter = ('reply_body', 'pub_date', 'author') list_filter = ('reply_body', 'pub_date', 'author', 'replied_post')
fieldsets = [ fieldsets = [
('Reply Data', { ('Reply Data', {
...@@ -109,9 +109,6 @@ class AssignmentAdmin(admin.ModelAdmin): ...@@ -109,9 +109,6 @@ class AssignmentAdmin(admin.ModelAdmin):
# Register models # Register models
admin.site.register(WidgetUser, WidgetUserAdmin) admin.site.register(WidgetUser, WidgetUserAdmin)
admin.site.register(Post, PostAdmin) admin.site.register(Post, PostAdmin)
......
...@@ -47,7 +47,7 @@ class Post(models.Model): ...@@ -47,7 +47,7 @@ class Post(models.Model):
author = models.ForeignKey(WidgetUser, on_delete=models.CASCADE) author = models.ForeignKey(WidgetUser, on_delete=models.CASCADE)
def __str__(self): 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): def get_absolute_url(self):
return reverse('forum', args=[(self.post_title)]) return reverse('forum', args=[(self.post_title)])
...@@ -59,7 +59,7 @@ class Reply(models.Model): ...@@ -59,7 +59,7 @@ class Reply(models.Model):
replied_post = models.ForeignKey(Post, on_delete=models.CASCADE) replied_post = models.ForeignKey(Post, on_delete=models.CASCADE)
def __str__(self): 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): class Assignment(models.Model):
name = models.CharField(max_length = 100) name = models.CharField(max_length = 100)
...@@ -71,3 +71,4 @@ class Assignment(models.Model): ...@@ -71,3 +71,4 @@ class Assignment(models.Model):
def get_absolute_url(self): def get_absolute_url(self):
return reverse('assignment', args=[(self.name)]) return reverse('assignment', args=[(self.name)])
...@@ -15,5 +15,5 @@ def announcements(request): ...@@ -15,5 +15,5 @@ def announcements(request):
def forum(request): def forum(request):
post = Post.objects.all() post = Post.objects.all()
reply = Reply.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") 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