2019-11-25 00:10:39 +01:00
|
|
|
from django.shortcuts import render
|
2019-12-07 19:24:05 +01:00
|
|
|
from bestnotes.models import Note
|
2019-11-25 00:10:39 +01:00
|
|
|
# Create your views here.
|
|
|
|
|
|
|
|
from django.http import HttpResponse
|
|
|
|
|
2019-12-07 17:00:49 +01:00
|
|
|
def homepage(request):
|
|
|
|
#return HttpResponse("BestNotes' index will be here.")
|
|
|
|
return render(request, "homepage.html", {})
|
2019-11-28 11:26:30 +01:00
|
|
|
|
|
|
|
|
|
|
|
def subject(request):
|
|
|
|
return render(request, "subjects.html", {})
|
|
|
|
|
|
|
|
def subject_id(request,id):
|
2019-12-07 19:24:05 +01:00
|
|
|
return render(request, "subject.html", {'id': id})
|
|
|
|
|
|
|
|
def note_id(request,id):
|
|
|
|
all_notes = Note.objects.all()
|
|
|
|
notes = all_notes.filter(id=id)
|
|
|
|
if len(notes) > 0:
|
|
|
|
single_note = Note.objects.get(pk=id) # Get note with given id
|
|
|
|
context = {
|
|
|
|
'note': single_note
|
|
|
|
}
|
|
|
|
return render(request, "note.html", context)
|
|
|
|
else:
|
|
|
|
return HttpResponse("Note not found.")
|
|
|
|
|
|
|
|
|
|
|
|
#Give all notes connected with subject name and pass it to html
|
2019-12-08 01:05:41 +01:00
|
|
|
def notes_name(request,subject_id):
|
2019-12-07 19:24:05 +01:00
|
|
|
all_notes = Note.objects.all()
|
2019-12-08 01:05:41 +01:00
|
|
|
subject_notes = all_notes.filter(topic__subject__id=subject_id) #Get all notes with subject name
|
2019-12-07 19:24:05 +01:00
|
|
|
context = {
|
|
|
|
'notes' : subject_notes
|
|
|
|
}
|
|
|
|
#Change website here
|
2019-12-08 01:05:41 +01:00
|
|
|
return render(request, "notes.html", context)
|
2019-12-07 19:24:05 +01:00
|
|
|
|
|
|
|
def notes_all(request):
|
|
|
|
all_notes = Note.objects.all()
|
|
|
|
context = {
|
|
|
|
'notes' : all_notes
|
|
|
|
}
|
|
|
|
return render(request, "test.html", context)
|