Commit d94ef6f3 authored by Rau Layug's avatar Rau Layug

Completed calendarapp Final Project

parent 8f91c608
from django.urls import path
from . import views
from .views import CalendarView
urlpatterns = [
path('', views.calendar, name='calendar')
path('', CalendarView.as_view(), name='calendar')
]
app_name = "calendar"
from django.http import HttpResponse
from django.shortcuts import render
from django.core.files.storage import FileSystemStorage
from django.views import View
from .models import Event, Location
from .forms import EventForm
......@@ -8,14 +8,15 @@ from assignments.models import Course
# Create your views here.
class CalendarView(View):
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')})
def add_event(request):
if request.method == 'POST':
form = EventForm(request.POST, request.FILES)
if form.is_valid():
# upload = request.FILES['upload']
# fss = FileSystemStorage()
# file = fss.save(upload.name, upload)
# file_url = fss.url(file)
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_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)
......@@ -27,8 +28,8 @@ def add_event(request):
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 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):
......
......@@ -52,6 +52,11 @@ img {
display: block;
}
input {
font-family: 'Roboto', sans-serif;
font-size: 1rem;
}
ul {
list-style: none;
}
\ No newline at end of file
......@@ -11,8 +11,10 @@
<h1>New Event</h1>
<form method="post" enctype="multipart/form-data">
{% csrf_token %}
{{ form }}
<input type="submit" value="Submit">
<table>
{{ form }}
</table>
<input type="submit" value="Save Event" style="font-size: 2rem; margin-left: 8.2rem; background-color: darkseagreen; color: black; border: 0.2rem solid black">
</form>
<a href="http://127.0.0.1:8000/calendar"><button>Events Page</button></a>
{% endblock %}
\ 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