Commit 0e368614 authored by nheoxoz's avatar nheoxoz

updated course variable in calendar

parent 0e97873c
# Generated by Django 4.1.7 on 2023-03-06 01:57
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('assignments', '0001_initial'),
('widget_calendar', '0004_alter_event_location'),
]
operations = [
migrations.AlterField(
model_name='event',
name='course',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='event_course', to='assignments.course'),
),
migrations.AlterField(
model_name='location',
name='mode',
field=models.CharField(choices=[('onsite', 'onsite'), ('online', 'online'), ('hybrid', 'hybrid')], default='onsite', max_length=6),
),
]
...@@ -2,13 +2,13 @@ from django.db import models ...@@ -2,13 +2,13 @@ from django.db import models
class Location(models.Model): class Location(models.Model):
onsite = 'Onsite' onsite = 'onsite'
online = 'Online' online = 'online'
hybrid = 'Hybrid' hybrid = 'hybrid'
mode_choices = [ mode_choices = [
(onsite, 'Onsite'), (onsite, 'onsite'),
(online, 'Online'), (online, 'online'),
(hybrid, 'Hybrid'), (hybrid, 'hybrid'),
] ]
mode = models.CharField( mode = models.CharField(
max_length=6, choices=mode_choices, default=onsite, max_length=6, choices=mode_choices, default=onsite,
...@@ -24,7 +24,11 @@ class Event(models.Model): ...@@ -24,7 +24,11 @@ class Event(models.Model):
activity = models.CharField(max_length=255) activity = models.CharField(max_length=255)
estimated_hours = models.FloatField() estimated_hours = models.FloatField()
location = models.ForeignKey(Location, on_delete=models.CASCADE) location = models.ForeignKey(Location, on_delete=models.CASCADE)
course = models.CharField(max_length=100) course = models.ForeignKey(
'assignments.Course',
on_delete=models.CASCADE,
related_name="event_course"
)
def __str__(self): def __str__(self):
return '{}, {}'.format(self.activity, self.target_datetime) return '{}, {}'.format(self.activity, self.target_datetime)
...@@ -13,7 +13,11 @@ def index(request): ...@@ -13,7 +13,11 @@ def index(request):
) )
return_string += 'Activity: {}<br>'.format(events.activity) return_string += 'Activity: {}<br>'.format(events.activity)
return_string += 'Estimated Hours: {}<br>'.format(round_hours) return_string += 'Estimated Hours: {}<br>'.format(round_hours)
return_string += 'Course/Section: {}<br>'.format(events.course) return_string += 'Course/Section: {} {}-{}<br>'.format(
events.course.code,
events.course.title,
events.course.section,
)
return_string += 'Mode: {}<br>'.format(events.location.mode) return_string += 'Mode: {}<br>'.format(events.location.mode)
return_string += 'Venue: {}<br>'.format(events.location.venue) return_string += 'Venue: {}<br>'.format(events.location.venue)
return_string += '<br>' return_string += '<br>'
......
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