Commit fc49b221 authored by Anthony Bicomong's avatar Anthony Bicomong

fixed announcement app bug with WidgetUser

parent 856d4cb0
# Generated by Django 3.2 on 2023-03-02 08:53
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('dashboard', '0001_initial'),
('announcements', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='announcement',
name='author',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='dashboard.widgetuser'),
),
]
......@@ -4,8 +4,7 @@ from django.urls import reverse
class Announcement(models.Model):
title = models.CharField(max_length=50)
body = models.CharField(max_length=700)
#author = models.ForeignKey("dashboard.WidgetUser", on_delete=models.CASCADE)
author = models.CharField(max_length=200)
author = models.ForeignKey("dashboard.WidgetUser", on_delete=models.CASCADE)
pub_datetime = models.DateTimeField()
def __str__(self):
......
......@@ -8,8 +8,8 @@ def index(request):
response = "Big Django Energy - Announcement Board<br><br>Announcements:<br>"
for announcement in all_announcements:
announcementpubdate = announcement.pub_datetime.strftime("%m/%d/%Y, %H:%M:%S") +", " #TO_DO: fix timezone
response = response + announcement.title + " by " + announcement.author.first_name + " " + announcement.author.last_name #TO_DO: widgetUser functionality (parsing author info)
announcementpubdate = announcement.pub_datetime.strftime("%m/%d/%Y, %H:%M:%S") +", "
response = response + announcement.title + " by " + announcement.author.__str__()
response = response + " published " + announcementpubdate + "<br>"
response = response + announcement.body + "<br>"
for reaction in all_reactions:
......
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