Commit 6eea7d8d authored by Rau Layug's avatar Rau Layug

Updated calendarapp model and view

parent 6ce0a275
# Generated by Django 4.0.3 on 2022-04-02 19:29
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
('assignments', '0001_initial'),
]
operations = [
migrations.CreateModel(
name='Location',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('mode', models.CharField(choices=[('ONS', 'Onsite'), ('ONL', 'Online'), ('OAO', 'Onsite and Online')], max_length=18)),
('venue', models.CharField(max_length=150)),
],
),
migrations.CreateModel(
name='Event',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('target_date', models.DateField()),
('activity', models.CharField(max_length=150)),
('estimated_hours', models.FloatField()),
('course', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='assignments.course')),
('location', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='calendarapp.location')),
],
),
]
from django.db import models
from assignments.models import Course
# Create your models here.
class Location(models.Model):
......@@ -19,8 +21,7 @@ class Event(models.Model):
target_date = models.DateField()
activity = models.CharField(max_length=150)
estimated_hours = models.FloatField()
# to add when Course model is added in Assignments
# course =
course = models.ForeignKey(Course, on_delete=models.CASCADE)
location = models.ForeignKey(Location, on_delete=models.CASCADE)
def __str__(self):
......
from django.shortcuts import render
from django.http import HttpResponse
from .models import Event, Location
from .models import Event
# Create your views here.
......@@ -11,14 +10,15 @@ def index(request):
for event in events:
location = event.location
course = event.course
target_date = event.target_date
activity = event.activity
estimated_hours = event.estimated_hours
course_section = "foo"
course_section = "{} {} {}".format(course.course_code, course.course_title, course.section)
mode = location.get_mode_display()
venue = location.venue
response += "Target Date: {}<br>Activity: {}<br>Estimated Hours: {}<br>Course/Section: {}<br>Mode: {}<br>Venue: {}<br><br>".format(target_date, activity, estimated_hours, course_section, mode,
venue)
venue)
return HttpResponse(response)
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