Updated FBV implementation to use template

parent 14ed12cb
from django.shortcuts import render
from .models import Event from .models import Event
from django.http import HttpResponse from django.http import HttpResponse
from forum.views import convert_utc_to_local from forum.views import convert_utc_to_local
...@@ -6,40 +7,11 @@ from django.urls import reverse ...@@ -6,40 +7,11 @@ from django.urls import reverse
def index(request): def index(request):
html_string = ''' events = Event.objects.all()
<title>robo_mommy’s Calendar of Activities</title> context = {
<h2>robo_mommy’s Calendar of Activities</h2><ul> 'events': events
''' }
for eventItem in Event.objects.all(): return render(request, 'widget_Calendar/calendar.html', context)
eventId = str(eventItem.pk)
href = '<a href="widget_Calendar/Events/'+eventId+'/details">'
html_string += '''
<br><li> {}
Date and Time: {}<br>
Activity: {}<br>
Estimated Hours: {}<br>
Course/Section: {}<br>
Mode: {}<br>
Venue: {}<br>
</li><br>
'''.format(
href,
convert_utc_to_local(eventItem.target_datetime, '%d/%m/%Y|%I:%M %p'),
eventItem.activity,
eventItem.estimated_hours,
eventItem.course.code,
eventItem.location.mode,
eventItem.location.venue,
)
html_string += '''
</ul>
<a href="widget_Calendar/Events/add"><button value="click here">New Activity</button></a><br><br>
<a href="/dashboard/">dashboard</a><br>
<a href="/announcements/">Announcements</a><br>
<a href="/forum/">Forum</a><br>
<a href="/assignments">Assignments</a><br>
'''
return HttpResponse(html_string)
class EventDetailView(generic.DetailView): class EventDetailView(generic.DetailView):
......
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