Commit eb703cd5 authored by Colleen's avatar Colleen

Finalized Announcement_Board's views and model

parent e785edfd
# Generated by Django 4.1.6 on 2023-03-05 07:46
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('Dashboard', '0001_initial'),
('Announcement_Board', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='announcement',
name='author',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='Dashboard.widgetuser'),
),
]
......@@ -6,11 +6,26 @@ from .models import Announcement, Reaction
def index(request):
return_string = '<ul>'
for announcement in Announcement.objects.all():
return_string += '{} by {}: <br> published {}:<br>{} <br> Like: {} <br> Love: {} <br> Angry: {}<br><br>'.format(
return_string += '{} by {}: <br> published {}:<br>{} <br>'.format(
announcement.title, announcement.author,
announcement.pub_datetime,announcement.body,
Reaction.tally, Reaction.tally, Reaction.tally
)
announced = announcement
like = 0
love = 0
angry = 0
for reaction in Reaction.objects.all():
if reaction.name == "like" and reaction.announcement == announced:
like += reaction.tally
if reaction.name == "love" and reaction.announcement == announced:
love += reaction.tally
if reaction.name == "angry" and reaction.announcement == announced:
angry += reaction.tally
return_string += 'like: {} <br> love: {} <br> angry: {}<br><br>'.format(
like, love, angry,
)
return_string += '</ul>'
html_string = '<html><head>Widget’s Announcement Board<br><br>Announcements:</head><body>{}</body><html>'.format(return_string)
......
No preview for this file type
# Generated by Django 4.1.6 on 2023-03-05 08:38
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('widgetcalendar', '0002_alter_location_venue'),
]
operations = [
migrations.AlterField(
model_name='event',
name='activity',
field=models.TextField(default='', max_length=200),
),
]
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