BES-49 Change subjects website look, add IDs for testing, add buttons in note by id

This commit is contained in:
Th3NiKo 2019-12-13 12:20:11 +01:00
parent 348fd7b790
commit 1b7dcdaf5f
8 changed files with 72 additions and 60 deletions

View File

@ -16,20 +16,20 @@
<div class="container-fluid">
<div class="row">
<div class="col-6 my-auto">
<img src="{% static 'laptop.png' %}" class="w-25 img-fluid mx-auto d-block"/>
<div class="col-6 my-auto" id="laptop_container">
<img id="laptop_img" src="{% static 'laptop.png' %}" class="w-25 img-fluid mx-auto d-block"/>
</div>
<div class="col-6 my-auto">
<h3 class="text-white text-center">Stwórz najlepszą wersję mobilnych notatek</h3>
<div class="col-6 my-auto" id="text0_container">
<h3 class="text-white text-center" id="text0">Stwórz najlepszą wersję mobilnych notatek</h3>
</div>
</div>
<div class="row mt-5">
<div class="col-6 my-auto">
<h3 class="text-white text-center">Dziel się notatkami ze znajomymi</h3>
<div class="col-6 my-auto" id="text1_container">
<h3 class="text-white text-center" id="text1">Dziel się notatkami ze znajomymi</h3>
</div>
<div class="col-6 my-auto">
<img src="{% static 'userplus.png' %}" class="w-25 img-fluid mx-auto d-block"/>
<div class="col-6 my-auto" id="userplus_container">
<img "userplus_img" src="{% static 'userplus.png' %}" class="w-25 img-fluid mx-auto d-block"/>
</div>
</div>

View File

@ -7,13 +7,13 @@
<span class="navbar-toggler-icon"></span>
</button>
<ul class="navbar-nav collapse navbar-collapse" id="navbarNav">
<li class="nav-item nav-link"><a class="nolink" href="{% url 'homepage' %}"><i class="fa fa-home fa-2x"></a></i></li>
<li id="home" class="nav-item nav-link"><a class="nolink" href="{% url 'homepage' %}"><i class="fa fa-home fa-2x"></a></i></li>
{% if user.is_authenticated %}
<li class="nav-item nav-link"><a class="nolink" href="#"><i class="fa fa-pencil-square-o fa-2x"></a></i></li>
<li class="nav-item nav-link active"><a class="nolink" href="{% url 'subject' %}"><i class="fa fa-list-ul fa-2x"></i></a></li>
<li class="nav-item nav-link"><a class="nolink" href="{% url 'logout' %}"><i class="fa fa-sign-out fa-2x"></i></a></li>
<li id="add_note" class="nav-item nav-link"><a class="nolink" href="#"><i class="fa fa-pencil-square-o fa-2x"></a></i></li>
<li id="all_subjects" class="nav-item nav-link active"><a class="nolink" href="{% url 'subject' %}"><i class="fa fa-list-ul fa-2x"></i></a></li>
<li id="logout" class="nav-item nav-link"><a class="nolink" href="{% url 'logout' %}"><i class="fa fa-sign-out fa-2x"></i></a></li>
{% else %}
<li class="nav-item nav-link"><a class="nolink" href="{% url 'login' %}">Zaloguj się</a></li>
<li id="login" class="nav-item nav-link"><a class="nolink" href="{% url 'login' %}">Zaloguj się</a></li>
{% endif %}
</ul>
</nav>

View File

@ -6,12 +6,17 @@
{% block content %}
{% include 'navbar.html' %}
<div class="container d-flex justify-content-center">
<div class="row mt-4"><h1 class="text-white">Tytuł: {{ note.name }}</h1></div>
<div class="row mt-4"><h1 id="note_title" class="text-white">Tytuł: {{ note.name }}</h1></div>
</div>
{% if note.user.user.id == user.id %}
<div class="container">
<div class="row d-flex justify-content-center"><button id="edit_note" class="btn-success mr-1">Edytuj</button> <button id="delete_note" class="btn-danger">Usuń</button></div>
</div>
{% endif %}
<div class="container">
<div class="d-flex justify-content-center mt-5">
<h3 class="text-white"> {{ note.text }}</h3>
<h3 class="text-white" id="note_text"> {{ note.text }}</h3>
</div>
</div>

View File

@ -11,23 +11,23 @@
<div class="container">
<div class="row">
<div class="col-sm-6">
<h2 class="text-white text-center">Dostępne notatki</h2>
<ul class="list-group cProductsList mt-3">
{% for note in notes%}
<div class="col-sm-6" id="all_container">
<h2 class="text-white text-center" id="avaliable_notes">Dostępne notatki</h2>
<ul class="list-group cProductsList mt-3" id="all_notes_list">
{% 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 %}
<a href="/bestnotes/note/{{ note.id }}" id="{{ note_name }}{{note_id}}" class="list-group-item list-group-item-action">{{ note.name }}</a>
{% endif %}
{% endfor %}
</ul>
</div>
<div class="col-sm-6">
<h2 class="text-white text-center">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 %}
<div class="col-sm-6" id="your_container">
<h2 class="text-white text-center" id="your_notes">Twoje notatki</h2>
<ul class="list-group cProductsList mt-3" id="your_notes_list">
{% for note in notes %}
{% if user.id == note.user.user.id %}
<a href="/bestnotes/note/{{ note.id }}" id="{{ note_name }}{{note_id}}" class="list-group-item list-group-item-action">{{ note.name }}</a>
{% endif %}
{% endfor %}
</ul>
</div>

View File

@ -10,37 +10,32 @@
{% include 'navbar.html' %}
<div class="container">
<div class="d-flex justify-content-center mt-5">
<h3 class="text-white">Dodaj nowy przedmiot</h3>
<div class="mb-5">
<div>
<img src="{% static 'laptop2.jpg' %}" class="w-100 img-fluid"/>
</div>
</div>
<div class="container mb-5">
<div class="row">
<div class="col-sm-6 mb-5">
<h2 class="text-white text-center mb-5 bg-dark" id="avaliable_notes">Dostępne notatki</h2>
<h4 class="text-white text-center" id="choose_subject_all">Wybierz przedmiot</h4>
<ul class="list-group cProductsList mt-3" id="list_all">
{% for subject in subjects %}
<a href="/bestnotes/subject/{{ subject.id }}" id="{{ subject.name }}{{subject.id}}" class="list-group-item list-group-item-action">{{ subject.name }}</a>
{% endfor %}
</ul>
</div>
<div class="col-sm-6">
<h2 class="text-white text-center mb-5 bg-dark" id="your_notes">Twoje notatki</h2>
<h4 class="text-white text-center" id="choose_subject_yours">Wybierz przedmiot</h4>
<ul class="list-group cProductsList mt-3" id="list_yours">
{% for subject in student_subjects %}
<a href="/bestnotes/subject/{{ subject.id }}" id="{{ subject.name }}{{subject.id}}" class="list-group-item list-group-item-action">{{ subject.name }}</a>
{% endfor %}
</ul>
</div>
<div class="d-flex justify-content-center mt-3">
<form role="form">
<input type="text" class="form-control" placeholder="Nowy przedmiot" name="przedmiot">
</form>
<button type="button" class="btn btn btn-primary ml-1">Dodaj</button>
</div>
<div class="d-flex justify-content-center mt-5">
<h3 class="text-white">Lista przedmiotów</h3>
</div>
<a class="row justify-content-center text-white">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">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">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">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>
</ul>
</div>
{% else %}

View File

@ -6,7 +6,7 @@ urlpatterns = [
path('', views.homepage, name='homepage'),
#path('/', views.login),
path('accounts/', include("django.contrib.auth.urls")),
path('subject/', views.subject, name="subject"),
path('subject/', views.subjects_all, name="subject"),
path('subject/<id>', views.subject_id, name="subjectid"),
path('note/<id>', views.note_id, name="note"),

View File

@ -1,5 +1,5 @@
from django.shortcuts import render
from bestnotes.models import Note
from bestnotes.models import Note,Subject
# Create your views here.
from django.http import HttpResponse
@ -43,4 +43,16 @@ def notes_all(request):
context = {
'notes' : all_notes
}
return render(request, "test.html", context)
return render(request, "test.html", context)
def subjects_all(request):
all_subjects = Subject.objects.all()
student_notes = Note.objects.all().filter(user__user__id=request.user.id)
student_subjects = []
for note in student_notes:
student_subjects.append(note.topic.subject)
context = {
'subjects' : all_subjects,
'student_subjects': student_subjects
}
return render(request, "subjects.html", context)

Binary file not shown.