polished html formats for apps

parent 43e1401e
# Generated by Django 4.1.6 on 2023-03-05 07:46 # Generated by Django 4.1.7 on 2023-03-06 09:31
from django.db import migrations, models from django.db import migrations, models
import django.db.models.deletion import django.db.models.deletion
......
# Generated by Django 4.1.7 on 2023-03-06 09:35
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('Dashboard', '0001_initial'),
('Announcement_Board', '0002_alter_announcement_author'),
]
operations = [
migrations.AlterField(
model_name='announcement',
name='author',
field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='Dashboard.widgetuser'),
),
migrations.AlterField(
model_name='announcement',
name='pub_datetime',
field=models.DateTimeField(),
),
migrations.AlterField(
model_name='reaction',
name='announcement',
field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='Announcement_Board.announcement'),
),
]
...@@ -4,8 +4,8 @@ from Dashboard.models import WidgetUser ...@@ -4,8 +4,8 @@ from Dashboard.models import WidgetUser
class Announcement(models.Model): class Announcement(models.Model):
title = models.CharField(max_length=100) title = models.CharField(max_length=100)
body = models.CharField(max_length=2000) body = models.CharField(max_length=2000)
author = models.ForeignKey(WidgetUser, on_delete = models.CASCADE) author = models.ForeignKey(WidgetUser, on_delete = models.PROTECT)
pub_datetime = models.CharField(max_length=700) pub_datetime = models.DateTimeField()
def __str__(self): def __str__(self):
return self.title return self.title
...@@ -18,7 +18,7 @@ class Reaction(models.Model): ...@@ -18,7 +18,7 @@ class Reaction(models.Model):
) )
name = models.CharField(max_length=100, choices=name_choices) name = models.CharField(max_length=100, choices=name_choices)
tally = models.IntegerField() tally = models.IntegerField()
announcement = models.ForeignKey(Announcement, on_delete = models.CASCADE) announcement = models.ForeignKey(Announcement, on_delete = models.PROTECT)
def __str__(self): def __str__(self):
return self.name return self.name
......
...@@ -6,9 +6,9 @@ from .models import Announcement, Reaction ...@@ -6,9 +6,9 @@ from .models import Announcement, Reaction
def index(request): def index(request):
return_string = '<ul>' return_string = '<ul>'
for announcement in Announcement.objects.all(): for announcement in Announcement.objects.all():
return_string += '{} by {}: <br> published {}:<br>{} <br>'.format( return_string += '{} by {} published {}:<br>{} <br>'.format(
announcement.title, announcement.author, announcement.title, announcement.author,
announcement.pub_datetime,announcement.body, announcement.pub_datetime.strftime("%x, %I:%M %p"),announcement.body,
) )
announced = announcement announced = announcement
like = 0 like = 0
...@@ -21,7 +21,7 @@ def index(request): ...@@ -21,7 +21,7 @@ def index(request):
love += reaction.tally love += reaction.tally
if reaction.name == "angry" and reaction.announcement == announced: if reaction.name == "angry" and reaction.announcement == announced:
angry += reaction.tally angry += reaction.tally
return_string += 'like: {} <br> love: {} <br> angry: {}<br><br>'.format( return_string += 'Like: {} <br> Love: {} <br> Angry: {}<br><br>'.format(
like, love, angry, like, love, angry,
) )
......
...@@ -20,4 +20,4 @@ class Assignment(models.Model): ...@@ -20,4 +20,4 @@ class Assignment(models.Model):
@property @property
def passing_score(self): def passing_score(self):
return self.perfect_score*0.60 return int(self.perfect_score*0.60)
\ No newline at end of file \ No newline at end of file
# Generated by Django 4.1.7 on 2023-03-06 09:37
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('Dashboard', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='widgetuser',
name='department',
field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='Dashboard.department'),
),
]
...@@ -13,7 +13,7 @@ class WidgetUser(models.Model): ...@@ -13,7 +13,7 @@ class WidgetUser(models.Model):
first_name = models.CharField(max_length = 50, default = default_string) first_name = models.CharField(max_length = 50, default = default_string)
middle_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) last_name = models.CharField(max_length = 50, default = default_string)
department = models.ForeignKey(Department, on_delete = models.CASCADE) department = models.ForeignKey(Department, on_delete = models.PROTECT)
def __str__(self): def __str__(self):
return '{}'.format(self.first_name) return '{}'.format(self.first_name)
\ No newline at end of file
# Generated by Django 4.1.7 on 2023-03-06 09:06
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('Dashboard', '0001_initial'),
('Forum', '0002_rename_reply_to_reply_forum_post'),
]
operations = [
migrations.AlterField(
model_name='forumpost',
name='author',
field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='Dashboard.widgetuser'),
),
migrations.AlterField(
model_name='reply',
name='author',
field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='Dashboard.widgetuser'),
),
]
from django.db import models from django.db import models
from Dashboard.models import WidgetUser
class ForumPost(models.Model): class ForumPost(models.Model):
title = models.CharField(max_length = 100) title = models.CharField(max_length = 100)
body = models.TextField() body = models.TextField()
author = models.CharField(max_length = 50) author = models.ForeignKey(WidgetUser, on_delete=models.PROTECT)
pub_datetime = models.DateTimeField() pub_datetime = models.DateTimeField()
def __str__(self): def __str__(self):
...@@ -11,7 +12,7 @@ class ForumPost(models.Model): ...@@ -11,7 +12,7 @@ class ForumPost(models.Model):
class Reply(models.Model): class Reply(models.Model):
body = models.TextField() body = models.TextField()
author = models.CharField(max_length = 50) author = models.ForeignKey(WidgetUser, on_delete=models.PROTECT)
pub_datetime = models.DateTimeField() pub_datetime = models.DateTimeField()
forum_post = models.ForeignKey(ForumPost, on_delete=models.CASCADE) forum_post = models.ForeignKey(ForumPost, on_delete=models.CASCADE)
......
No preview for this file type
# Generated by Django 4.1.7 on 2023-03-06 08:56
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('Assignments', '0001_initial'),
('widgetcalendar', '0003_alter_event_activity'),
]
operations = [
migrations.AlterField(
model_name='event',
name='course',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='course_name', to='Assignments.course'),
),
]
# Generated by Django 4.1.7 on 2023-03-06 09:06
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('Assignments', '0001_initial'),
('widgetcalendar', '0004_alter_event_course'),
]
operations = [
migrations.AlterField(
model_name='event',
name='course',
field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='course_name', to='Assignments.course'),
),
migrations.AlterField(
model_name='event',
name='location',
field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='course_name', to='widgetcalendar.location'),
),
]
from django.db import models from django.db import models
from django.urls import reverse from django.urls import reverse
from assignments.models import Course from Assignments.models import Course
class Location(models.Model): class Location(models.Model):
...@@ -25,12 +25,12 @@ class Event(models.Model): ...@@ -25,12 +25,12 @@ class Event(models.Model):
estimated_hours = models.FloatField() estimated_hours = models.FloatField()
location = models.ForeignKey( location = models.ForeignKey(
Location, Location,
on_delete=models.CASCADE, on_delete=models.PROTECT,
related_name='course_name' related_name='course_name'
) )
course = models.ForeignKey( course = models.ForeignKey(
Course, Course,
on_delete=models.CASCADE, on_delete=models.PROTECT,
related_name='course_name' related_name='course_name'
) )
......
...@@ -5,8 +5,8 @@ from .models import Event ...@@ -5,8 +5,8 @@ from .models import Event
def index(request): def index(request):
return_string = '' return_string = ''
for events in Event.objects.all(): for events in Event.objects.all():
return_string += 'Date and Time: {}<br>Activity: {}<br>Estimated Hours: {}<br>Course/Secion: {}<br>Mode: {}<br>Venue: {}<br></br>'.format( return_string += 'Date and Time: {}<br>Activity: {}<br>Estimated Hours: {}<br>Course/Section: {} {}-{}<br>Mode: {}<br>Venue: {}<br></br>'.format(
events.target_datetime.strftime("%x, %I:%M %p"), events.activity, events.estimated_hours, events.course, events.location.mode, events.location.venue events.target_datetime.strftime("%x, %I:%M %p"), events.activity, events.estimated_hours, events.course.code, events.course.title, events.course.section, events.location.mode, events.location.venue
) )
html_string = '<html><head>Widget\'s Calendar of Activities<br></br></head><body>{}</body><html>'.format(return_string) html_string = '<html><head>Widget\'s Calendar of Activities<br></br></head><body>{}</body><html>'.format(return_string)
return HttpResponse(html_string) return HttpResponse(html_string)
\ 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