diff --git a/.idea/workspace.xml b/.idea/workspace.xml index c9ea7c4..18ebf11 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,10 +2,15 @@ - + + + + + - + + @@ -32,6 +38,7 @@ + @@ -49,7 +56,7 @@ - + - + diff --git a/BestNotesProject/__pycache__/__init__.cpython-38.pyc b/BestNotesProject/__pycache__/__init__.cpython-38.pyc index eef0037..4f67563 100644 Binary files a/BestNotesProject/__pycache__/__init__.cpython-38.pyc and b/BestNotesProject/__pycache__/__init__.cpython-38.pyc differ diff --git a/BestNotesProject/__pycache__/settings.cpython-38.pyc b/BestNotesProject/__pycache__/settings.cpython-38.pyc index 3d5303c..713bf6f 100644 Binary files a/BestNotesProject/__pycache__/settings.cpython-38.pyc and b/BestNotesProject/__pycache__/settings.cpython-38.pyc differ diff --git a/BestNotesProject/__pycache__/urls.cpython-38.pyc b/BestNotesProject/__pycache__/urls.cpython-38.pyc index 03fff54..6e26703 100644 Binary files a/BestNotesProject/__pycache__/urls.cpython-38.pyc and b/BestNotesProject/__pycache__/urls.cpython-38.pyc differ diff --git a/BestNotesProject/__pycache__/wsgi.cpython-38.pyc b/BestNotesProject/__pycache__/wsgi.cpython-38.pyc index b762953..b904c6c 100644 Binary files a/BestNotesProject/__pycache__/wsgi.cpython-38.pyc and b/BestNotesProject/__pycache__/wsgi.cpython-38.pyc differ diff --git a/bestnotes/__pycache__/__init__.cpython-38.pyc b/bestnotes/__pycache__/__init__.cpython-38.pyc index 3dea93c..98cd8c1 100644 Binary files a/bestnotes/__pycache__/__init__.cpython-38.pyc and b/bestnotes/__pycache__/__init__.cpython-38.pyc differ diff --git a/bestnotes/__pycache__/admin.cpython-38.pyc b/bestnotes/__pycache__/admin.cpython-38.pyc index 6d225d1..51ff548 100644 Binary files a/bestnotes/__pycache__/admin.cpython-38.pyc and b/bestnotes/__pycache__/admin.cpython-38.pyc differ diff --git a/bestnotes/__pycache__/apps.cpython-38.pyc b/bestnotes/__pycache__/apps.cpython-38.pyc index 8684cee..8222c11 100644 Binary files a/bestnotes/__pycache__/apps.cpython-38.pyc and b/bestnotes/__pycache__/apps.cpython-38.pyc differ diff --git a/bestnotes/__pycache__/models.cpython-38.pyc b/bestnotes/__pycache__/models.cpython-38.pyc index 1eb4246..451b6ac 100644 Binary files a/bestnotes/__pycache__/models.cpython-38.pyc and b/bestnotes/__pycache__/models.cpython-38.pyc differ diff --git a/bestnotes/__pycache__/urls.cpython-38.pyc b/bestnotes/__pycache__/urls.cpython-38.pyc index 32bfb75..bf3bc27 100644 Binary files a/bestnotes/__pycache__/urls.cpython-38.pyc and b/bestnotes/__pycache__/urls.cpython-38.pyc differ diff --git a/bestnotes/__pycache__/views.cpython-38.pyc b/bestnotes/__pycache__/views.cpython-38.pyc index 4c8494c..a58aadd 100644 Binary files a/bestnotes/__pycache__/views.cpython-38.pyc and b/bestnotes/__pycache__/views.cpython-38.pyc differ diff --git a/bestnotes/admin.py b/bestnotes/admin.py index 4036e30..da673ae 100644 --- a/bestnotes/admin.py +++ b/bestnotes/admin.py @@ -2,8 +2,9 @@ from django.contrib import admin # Register your models here. from django.contrib import admin -from .models import StudentProfile, Subject, Topic +from .models import StudentProfile, Subject, Topic, Note admin.site.register(StudentProfile) admin.site.register(Subject) -admin.site.register(Topic) \ No newline at end of file +admin.site.register(Topic) +admin.site.register(Note) \ No newline at end of file diff --git a/bestnotes/migrations/0003_note.py b/bestnotes/migrations/0003_note.py new file mode 100644 index 0000000..9747d54 --- /dev/null +++ b/bestnotes/migrations/0003_note.py @@ -0,0 +1,25 @@ +# Generated by Django 2.2.7 on 2019-12-07 17:37 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('bestnotes', '0002_subject_topic'), + ] + + operations = [ + migrations.CreateModel( + name='Note', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=30)), + ('text', models.TextField()), + ('add_date', models.DateField()), + ('topic', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='bestnotes.Topic')), + ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='bestnotes.StudentProfile')), + ], + ), + ] diff --git a/bestnotes/migrations/__pycache__/0001_initial.cpython-38.pyc b/bestnotes/migrations/__pycache__/0001_initial.cpython-38.pyc index 58c19d0..6a55fba 100644 Binary files a/bestnotes/migrations/__pycache__/0001_initial.cpython-38.pyc and b/bestnotes/migrations/__pycache__/0001_initial.cpython-38.pyc differ diff --git a/bestnotes/migrations/__pycache__/__init__.cpython-38.pyc b/bestnotes/migrations/__pycache__/__init__.cpython-38.pyc index 04a1487..feebe36 100644 Binary files a/bestnotes/migrations/__pycache__/__init__.cpython-38.pyc and b/bestnotes/migrations/__pycache__/__init__.cpython-38.pyc differ diff --git a/bestnotes/models.py b/bestnotes/models.py index 112a068..8c78b99 100644 --- a/bestnotes/models.py +++ b/bestnotes/models.py @@ -46,3 +46,9 @@ class Topic(models.Model): add_date = models.DateField() +class Note(models.Model): + name = models.CharField(max_length=30) + text = models.TextField(blank=False) + topic = models.ForeignKey(Topic, on_delete=models.SET_NULL, null=True) + user = models.ForeignKey(StudentProfile, on_delete=models.CASCADE) + add_date = models.DateField() \ No newline at end of file diff --git a/bestnotes/static/note.css b/bestnotes/static/note.css new file mode 100644 index 0000000..e69de29 diff --git a/bestnotes/templates/note.html b/bestnotes/templates/note.html new file mode 100644 index 0000000..e84c3c8 --- /dev/null +++ b/bestnotes/templates/note.html @@ -0,0 +1,18 @@ +{% extends 'base.html' %} +{% load static %} +{% block css %} + +{% endblock %} +{% block content %} +{% include 'navbar.html' %} +
+

Tytuł: {{ note.name }}

+
+ +
+
+

{{ note.text }}

+
+
+ +{% endblock %} diff --git a/bestnotes/templates/test.html b/bestnotes/templates/test.html new file mode 100644 index 0000000..31ab943 --- /dev/null +++ b/bestnotes/templates/test.html @@ -0,0 +1,12 @@ +{% extends 'base.html' %} +{% load static %} + +{% block content %} + +{% for note in notes%} + +{{ note.name }} + +{% endfor %} + +{% endblock %} \ No newline at end of file diff --git a/bestnotes/templates/testid.html b/bestnotes/templates/testid.html new file mode 100644 index 0000000..31ab943 --- /dev/null +++ b/bestnotes/templates/testid.html @@ -0,0 +1,12 @@ +{% extends 'base.html' %} +{% load static %} + +{% block content %} + +{% for note in notes%} + +{{ note.name }} + +{% endfor %} + +{% endblock %} \ No newline at end of file diff --git a/bestnotes/urls.py b/bestnotes/urls.py index 9caec86..4e4bb0d 100644 --- a/bestnotes/urls.py +++ b/bestnotes/urls.py @@ -8,4 +8,8 @@ urlpatterns = [ path('accounts/', include("django.contrib.auth.urls")), path('subject/', views.subject, name="subject"), path('subject/', views.subject_id, name="subjectid"), + path('note/', views.note_id, name="note"), + + path('notes/', views.notes_all, name="notes"), + path('notes/', views.notes_name, name="notes_name") ] diff --git a/bestnotes/views.py b/bestnotes/views.py index 7fac749..9748aa4 100644 --- a/bestnotes/views.py +++ b/bestnotes/views.py @@ -1,5 +1,5 @@ from django.shortcuts import render - +from bestnotes.models import Note # Create your views here. from django.http import HttpResponse @@ -13,4 +13,34 @@ def subject(request): return render(request, "subjects.html", {}) def subject_id(request,id): - return render(request, "subject.html", {'id': id}) \ No newline at end of file + 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 +def notes_name(request,subject_name): + all_notes = Note.objects.all() + subject_notes = all_notes.filter(topic__subject__name=subject_name) #Get all notes with subject name + context = { + 'notes' : subject_notes + } + #Change website here + return render(request, "test.html", context) + +def notes_all(request): + all_notes = Note.objects.all() + context = { + 'notes' : all_notes + } + return render(request, "test.html", context) \ No newline at end of file diff --git a/db.sqlite3 b/db.sqlite3 index fe17d61..1562781 100644 Binary files a/db.sqlite3 and b/db.sqlite3 differ