Commit da63b246 authored by Rau Layug's avatar Rau Layug

Removed commented code

parent 9f4d9bb7
...@@ -5,19 +5,6 @@ import datetime ...@@ -5,19 +5,6 @@ import datetime
from .models import Location, Event from .models import Location, Event
from assignments.models import Course from assignments.models import Course
'''
class LocationForm(forms.ModelForm):
model = Location
fields = ['mode', 'venue', 'image']
class EventForm(forms.ModelForm):
class Meta:
model = Event
fields = ['target_date', 'activity', 'estimated_hours', 'course',
'location']
'''
class EventForm(forms.Form): class EventForm(forms.Form):
target_date = forms.DateField(initial=datetime.date.today) target_date = forms.DateField(initial=datetime.date.today)
......
...@@ -12,7 +12,10 @@ class Location(models.Model): ...@@ -12,7 +12,10 @@ class Location(models.Model):
] ]
mode = models.CharField(max_length=3, choices=MODE_CHOICES) mode = models.CharField(max_length=3, choices=MODE_CHOICES)
venue = models.CharField(max_length=150) venue = models.CharField(max_length=150)
image = models.ImageField(upload_to='calendarapp/location_images', height_field=None, width_field=None, max_length=100) image = models.ImageField(upload_to='calendarapp/location_images',
height_field=None,
width_field=None,
max_length=100)
def __str__(self): def __str__(self):
......
...@@ -10,27 +10,33 @@ from assignments.models import Course ...@@ -10,27 +10,33 @@ from assignments.models import Course
# Create your views here. # Create your views here.
class CalendarView(View): class CalendarView(View):
def get(self, request): def get(self, request):
return render(request, 'calendarapp/calendar.html', {'Courses': Course.objects.all().order_by('course_code'), 'Events': Event.objects.all().order_by('target_date')}) return render(request, 'calendarapp/calendar.html',
{'Courses': Course.objects.all().order_by('course_code'),
'Events': Event.objects.all().order_by('target_date')})
def add_event(request): def add_event(request):
if request.method == 'POST': if request.method == 'POST':
form = EventForm(request.POST, request.FILES) form = EventForm(request.POST, request.FILES)
if form.is_valid(): if form.is_valid():
new_location = Location(mode=form.cleaned_data.get('mode'), venue=form.cleaned_data.get('venue'), image=form.cleaned_data.get('image')) new_location = Location(mode=form.cleaned_data.get('mode'),
venue=form.cleaned_data.get('venue'),
image=form.cleaned_data.get('image'))
new_location.save() new_location.save()
new_event = Event(target_date=form.cleaned_data.get('target_date'), activity=form.cleaned_data.get('activity'), estimated_hours=form.cleaned_data.get('estimated_hours'), course=form.cleaned_data.get('course'), location=new_location) new_event = Event(target_date=form.cleaned_data.get('target_date'),
activity=form.cleaned_data.get('activity'),
estimated_hours=form.cleaned_data.get('estimated_hours'),
course=form.cleaned_data.get('course'),
location=new_location)
new_event.save() new_event.save()
return render(request, 'calendarapp/events.html', {'event': Event.objects.get(id=new_event.id)}) return render(request, 'calendarapp/events.html',
{'event': Event.objects.get(id=new_event.id)})
return HttpResponse('invalid form') return HttpResponse('invalid form')
else: else:
form = EventForm() form = EventForm()
return render(request, 'calendarapp/add_event.html', {'form': form}) return render(request, 'calendarapp/add_event.html', {'form': form})
# def calendar(request):
# return render(request, 'calendarapp/calendar.html', {'Courses': Course.objects.all().order_by('course_code'), 'Events': Event.objects.all().order_by('target_date')})
def events(request, id): def events(request, id):
return render(request, 'calendarapp/events.html', {'event': Event.objects.get(id=id)}) return render(request, 'calendarapp/events.html',
{'event': Event.objects.get(id=id)})
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