Commit 10200956 authored by Colleen's avatar Colleen

Modified Announcement_Board.admin, views, and models. Fixed a bug in Dashboard.models

parent 9d108ba9
......@@ -9,6 +9,5 @@ class ReactionAdmin(admin.ModelAdmin):
model = Reaction
list_display = ('name','tally','announcement',)
admin.site.register(Announcement, AnnouncementAdmin)
admin.site.register(Reaction, ReactionAdmin)
\ No newline at end of file
from django.db import models
from Dashboard.models import WidgetUser
class Announcement(models.Model):
title = models.CharField(max_length=100)
body = models.CharField(max_length=2000)
author = models.CharField(max_length=50)
author = models.ForeignKey(WidgetUser, on_delete = models.CASCADE)
pub_datetime = models.CharField(max_length=700)
def __str__(self):
return self.title
class Reaction(models.Model):
name_choices = (
('like','like'),
......@@ -14,4 +18,9 @@ class Reaction(models.Model):
)
name = models.CharField(max_length=100, choices=name_choices)
tally = models.IntegerField()
announcement = models.ForeignKey(Announcement, on_delete = models.CASCADE)
\ No newline at end of file
announcement = models.ForeignKey(Announcement, on_delete = models.CASCADE)
def __str__(self):
return self.name
......@@ -5,11 +5,13 @@ from .models import Announcement, Reaction
def index(request):
return_string = '<ul>'
for reaction in Reaction.objects.all():
return_string += '<li>{} {} {}: <br> {} <br> {} {} {} </li>'.format(
reaction.announcement.title, reaction.announcement.author, reaction.announcement.pub_datetime, reaction.announcement, reaction.tally, reaction.tally, reaction.tally
for announcement in Announcement.objects.all():
return_string += '{} by {}: <br> published {}:<br>{} <br> Like: {} <br> Love: {} <br> Angry: {}<br><br>'.format(
announcement.title, announcement.author,
announcement.pub_datetime,announcement.body,
Reaction.tally, Reaction.tally, Reaction.tally
)
return_string += '</ul>'
html_string = '<html><head>Widget’s Announcement Board<br> <br>Announcements:</head><body>{}</body><html>'.format(return_string)
html_string = '<html><head>Widget’s Announcement Board<br><br>Announcements:</head><body>{}</body><html>'.format(return_string)
return HttpResponse(html_string)
from django.db import models
class Department(models.Model):
default_string = "";
dept_name = models.CharField(max_length = 50, default = default_string);
home_unit = models.CharField(max_length = 50, default = default_string);
default_string = ""
dept_name = models.CharField(max_length = 50, default = default_string)
home_unit = models.CharField(max_length = 50, default = default_string)
def __str__(self):
return '{}'.format(self.dept_name)
class WidgetUser(models.Model):
default_string = "";
first_name = models.CharField(max_length = 50, default = default_string);
middle_name = models.CharField(max_length = 50, default = default_string);
last_name = models.CharField(max_length = 50, default = default_string);
department = models.ForeignKey(Department, on_delete = models.CASCADE);
default_string = ""
first_name = models.CharField(max_length = 50, default = default_string)
middle_name = models.CharField(max_length = 50, default = default_string)
last_name = models.CharField(max_length = 50, default = default_string)
department = models.ForeignKey(Department, on_delete = models.CASCADE)
def __str__(self):
return '{}'.format(self.first_name)
\ No newline at end of file
No preview for this file type
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