Add notes listing html connected with backend

This commit is contained in:
Th3NiKo 2019-12-08 01:05:41 +01:00
parent cfb9840d1a
commit 587aec09bc
5 changed files with 47 additions and 10 deletions

View File

@ -0,0 +1,37 @@
{% extends 'base.html' %}
{% load static %}
{% block css %}
<link rel="stylesheet" type="text/css" href="{% static 'subject.css' %}">
{% endblock %}
{% block content %}
{% include 'navbar.html' %}
<div class="container d-flex justify-content-center">
<div class="row mt-4"><h1>{{id}}</h1></div>
</div>
<div class="container">
<div class="row">
<div class="col-sm-6">
<h2>Dostępne notatki</h2>
<ul class="list-group cProductsList mt-3">
{% for note in notes%}
{% if user.id != note.user.user.id %}
<a href="/bestnotes/note/{{ note.id }}" class="list-group-item list-group-item-action">{{ note.name }}</a>
{% endif %}
{% endfor %}
</ul>
</div>
<div class="col-sm-6">
<h2>Twoje notatki</h2>
<ul class="list-group cProductsList mt-3">
{% for note in notes%}
{% if user.id == note.user.user.id %}
<a href="/bestnotes/note/{{ note.id }}" class="list-group-item list-group-item-action">{{ note.name }}</a>
{% endif %}
{% endfor %}
</ul>
</div>
</div>
</div>
{% endblock %}

View File

@ -25,18 +25,18 @@
</div>
<a class="row justify-content-center">Liczba dostępnych przedmiotów: 3/5</a>
<ul class="list-group cProductsList mt-3">
<li class="list-group-item d-sm-flex justify-content-between"><p class="p-0 m-0 flex-grow-1">Sztuczna inteligencja</p>
<button class="btn-primary mr-1" ><a class="nolink" href="/bestnotes/subject/Sztuczna inteligencja">Zarządzaj</a></button>
<li class="list-group-item d-sm-flex justify-content-between"><p class="p-0 m-0 flex-grow-1">Programowanie</p>
<button class="btn-primary mr-1" ><a class="nolink" href="/bestnotes/notes/1">Zarządzaj</a></button>
<button class="btn-success mr-1">Edytuj</button>
<button class="btn-danger">Usuń</button>
</li>
<li class="list-group-item d-sm-flex justify-content-between"><p class="p-0 m-0 flex-grow-1">Systemy informatyczne</p>
<button class="btn-primary mr-1"><a class="nolink" href="/bestnotes/subject/Systemy informatyczne">Zarządzaj</a></button>
<li class="list-group-item d-sm-flex justify-content-between"><p class="p-0 m-0 flex-grow-1">Matematyka</p>
<button class="btn-primary mr-1"><a class="nolink" href="/bestnotes/notes/2">Zarządzaj</a></button>
<button class="btn-success mr-1">Edytuj</button>
<button class="btn-danger">Usuń</button>
</li>
<li class="list-group-item d-sm-flex justify-content-between"><p class="p-0 m-0 flex-grow-1">Programowanie</p>
<button class="btn-primary mr-1"><a class="nolink" href="/bestnotes/subject/Programowanie">Zarządzaj</a></button>
<li class="list-group-item d-sm-flex justify-content-between"><p class="p-0 m-0 flex-grow-1">Systemy informatyczne</p>
<button class="btn-primary mr-1"><a class="nolink" href="/bestnotes/notes/3">Zarządzaj</a></button>
<button class="btn-success mr-1">Edytuj</button>
<button class="btn-danger">Usuń</button>
</li>

View File

@ -11,5 +11,5 @@ urlpatterns = [
path('note/<id>', views.note_id, name="note"),
path('notes/', views.notes_all, name="notes"),
path('notes/<subject_name>', views.notes_name, name="notes_name")
path('notes/<subject_id>', views.notes_name, name="notes_id")
]

View File

@ -29,14 +29,14 @@ def note_id(request,id):
#Give all notes connected with subject name and pass it to html
def notes_name(request,subject_name):
def notes_name(request,subject_id):
all_notes = Note.objects.all()
subject_notes = all_notes.filter(topic__subject__name=subject_name) #Get all notes with subject name
subject_notes = all_notes.filter(topic__subject__id=subject_id) #Get all notes with subject name
context = {
'notes' : subject_notes
}
#Change website here
return render(request, "test.html", context)
return render(request, "notes.html", context)
def notes_all(request):
all_notes = Note.objects.all()

Binary file not shown.