Commit e26c6ff8 authored by Ysabella Panghulan's avatar Ysabella Panghulan

edited views.py

parent 3d07daed
from django.shortcuts import render
from django.shortcuts import render, redirect
from django.http import HttpResponse
from .models import Location, Event
# Create your views here.
def index(request):
def Calendar(request):
locations = Location.objects.all()
events = Event.objects.all()
welcomeMessage = 'Widget\'s Calendar of Activities <br><br>'
activities = ''
for event in events:
activities += 'Date and Time: ' + event.target_datetime.strftime('%m/%d/%Y, %I:%M %p') + '<br>'
activities += 'Activity: '+ event.activity + '<br>'
activities += 'Estimated Hours: ' + str(event.estimated_hours) + '<br>'
activities += 'Course/Section: ' + event.course.code + ' ' + event.course.title + '-' + event.course.section + '<br>'
activities += 'Mode: ' + event.location.mode + '<br>'
activities += 'Venue: ' + event.location.venue + '<br><br>'
return HttpResponse(welcomeMessage + activities)
\ No newline at end of file
context = {
'locations': locations,
'events': events,
}
return render(request, 'widget_calendar/calendar.html', context)
\ 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