From cfb9840d1ab9995e3ae1001e22ea9c2a0a7db087 Mon Sep 17 00:00:00 2001 From: ksanu Date: Sat, 7 Dec 2019 19:24:05 +0100 Subject: [PATCH] BES-32 Added single note view by id --- .idea/workspace.xml | 15 +++++--- .../__pycache__/__init__.cpython-38.pyc | Bin 212 -> 205 bytes .../__pycache__/settings.cpython-38.pyc | Bin 2533 -> 2526 bytes .../__pycache__/urls.cpython-38.pyc | Bin 1135 -> 1128 bytes .../__pycache__/wsgi.cpython-38.pyc | Bin 633 -> 626 bytes bestnotes/__pycache__/__init__.cpython-38.pyc | Bin 205 -> 198 bytes bestnotes/__pycache__/admin.cpython-38.pyc | Bin 402 -> 424 bytes bestnotes/__pycache__/apps.cpython-38.pyc | Bin 431 -> 424 bytes bestnotes/__pycache__/models.cpython-38.pyc | Bin 1673 -> 1988 bytes bestnotes/__pycache__/urls.cpython-38.pyc | Bin 501 -> 633 bytes bestnotes/__pycache__/views.cpython-38.pyc | Bin 696 -> 1504 bytes bestnotes/admin.py | 5 +-- bestnotes/migrations/0003_note.py | 25 +++++++++++++ .../__pycache__/0001_initial.cpython-38.pyc | Bin 1061 -> 1054 bytes .../__pycache__/__init__.cpython-38.pyc | Bin 216 -> 209 bytes bestnotes/models.py | 6 ++++ bestnotes/static/note.css | 0 bestnotes/templates/note.html | 18 ++++++++++ bestnotes/templates/test.html | 12 +++++++ bestnotes/templates/testid.html | 12 +++++++ bestnotes/urls.py | 4 +++ bestnotes/views.py | 34 ++++++++++++++++-- db.sqlite3 | Bin 139264 -> 172032 bytes 23 files changed, 123 insertions(+), 8 deletions(-) create mode 100644 bestnotes/migrations/0003_note.py create mode 100644 bestnotes/static/note.css create mode 100644 bestnotes/templates/note.html create mode 100644 bestnotes/templates/test.html create mode 100644 bestnotes/templates/testid.html 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 eef0037c647297187176131cddb311e93659c588..4f67563bbaa01add005afdef59bbc219399a022a 100644 GIT binary patch delta 34 ocmcb@c$Senl$V!_0SFE~d_9rdhOua(hbx!1BBmyxk_@=Hcn-rUrp^wgC2+{EIN)S}5IOm+Y=yAEUk diff --git a/bestnotes/__pycache__/__init__.cpython-38.pyc b/bestnotes/__pycache__/__init__.cpython-38.pyc index 3dea93c95c30e3bee95c20e9edda9b38e31a7a7a..98cd8c1e40a73106401486571b40428ae131908c 100644 GIT binary patch delta 34 ocmX@hc#M%dl$V!_0SFE~d_9rdhB14hhbxj@0) diff --git a/bestnotes/__pycache__/admin.cpython-38.pyc b/bestnotes/__pycache__/admin.cpython-38.pyc index 6d225d1bafb7dbbd55421e8e30bcf7cc02005b81..51ff548daaab8691339a214d90f607c136aa2da9 100644 GIT binary patch delta 167 zcmbQlyn>l8l$V!_0SIg#zmAn)oX97`m@-jY*C>}Qij9#Wl`)Hb0Y@tHLPj{71&Pgy z#AcgVCCA7zai#+2Ef&B0l2kuU&WU?;l#AGbX5V5d&MZm2#Zi=+o>^RyTC|d(h#M#j kCVpj1W@B_^b8-#VH8z?Y!Kfp^1C-)n=3$gz;$Z|q02AFNE&u=k delta 130 zcmZ3%Jc*evl$V!_0SE+ap2U7$D>AzB=B5^4Z`CKi{Z7ER7!)Zqh3@-Xu- LiZJmo@-PAbjU^nS diff --git a/bestnotes/__pycache__/apps.cpython-38.pyc b/bestnotes/__pycache__/apps.cpython-38.pyc index 8684cee0f1c2b620497f6697c4cc6999b496ddb8..8222c11c1c9c4476d8eef096806b18a3e7fa50b0 100644 GIT binary patch delta 35 pcmZ3_yn>lKl$V!_0SFE~d_9r-E@S${m#%D1uEDy-Mw6`>O8~h%3dH~b delta 42 wcmZ3%yq=jml$V!_0SF#QJekOSmoabROIP09)S~p%l=$4l;*!*&$tH{?01r_P4FCWD diff --git a/bestnotes/__pycache__/models.cpython-38.pyc b/bestnotes/__pycache__/models.cpython-38.pyc index 1eb4246cd7981439dae53e1859dd9b40388e4a40..451b6ac6c2cd3d73f41324418a14312f8f9ecf9a 100644 GIT binary patch delta 388 zcmeC=J;Kiy%FD~e00dc&UdQUNPvnzf+%Qplu7o>7ia?5B3qy)vDq|K$GjkMQicm0v zrtrpd6^x9TliitI*_>R1b&ZWS&t&?{#CU6RFRNL7GRPogzzXCz0CBM&kVs{SVoYI( zVoGJsVo704Vd`a!Vg<6zQ35F(K&NotV)4r_Ni9+a8eOCUB-~^)8H+%E3DIOK;sA+qg9vsY;ioA$IgnMp zUKq%}#Zr=5QBtG^l2ZrqIf7k7;{8H>e4Jlsb1?D%p%9}0BUs!|lm8ZHN>*ZCdcIytQW4YS%dAz5T9ZB5)EFfu7qCe( H39$hHZ_-R7 delta 112 zcmX@Y-^t4t%FD~e00c*@pTx4UP2`hdoHtQ>E?bH~FoUMx#s?LQj0KY;nOu2uQ;X75 zQ{r#;Dhy?)Wc^fkT diff --git a/bestnotes/__pycache__/urls.cpython-38.pyc b/bestnotes/__pycache__/urls.cpython-38.pyc index 32bfb755bee5eda04bd6d1b1aee0d154e659963d..bf3bc276065c16e3a1fded175d2594cff70102c6 100644 GIT binary patch delta 271 zcmey${F6mHl$V!_0SI2bd>zZi#K7K=iOJVC} z2J-lUJkAsWC{GZ`<4O?%@zU9&xKo6K88k&Ec6GW|apvWhr0Uybrr6zL0WquCKxDE0 zEmkmHB?95v6qhDtr6!le=OyN*+TG#;i-I|Rnmm)m7%hz1K|=AFDYw8T7RM*%1~X{#P2AGS z?5D{&xrxz2io3KZry#MUB(*57cqKy-FHkv{_?0*LEu$-MZfa3_YD#==Vlhy~WD6#3 U0Un?V0VW=1J|-SUK1ROZ01fvaDF6Tf diff --git a/bestnotes/__pycache__/views.cpython-38.pyc b/bestnotes/__pycache__/views.cpython-38.pyc index 4c8494c6ff52f4110a2f9105f707307c2cb7a5b4..a58aadd47e94fe6884fd0b994864fdc4d10dbfa3 100644 GIT binary patch literal 1504 zcmb7EO^+Kj7#`a*naS7g78ME{&|U|rQM)}AAyk!CDu+fD5dw{ZMrrKbOgbOIc4!l2 zPs^46K#%c{K9k8-KyN_lDIitxBnM%xZsFS%tCp#M;I8$}FnVs3{}8Z6n#o|1Eyg zLub7W0?fP%0h4^V?$4@1EhcAbFtbIjDHXT~wfbeLjD6$j2rKVqkG~o}t>)^{q*UXP zUCM0onR;mki&Y)%;t45Y3diG`;Qya#ndS4jnp*QdE!~0@mrm2QF|EU` z9zoN1W4cS;oM#BsNJiZo5RV`qn$953nP!<4b?z zXY4$%Ez~~P1QfCjW$S{CKvD1@9LB5(k@x~a@x_b8r^>9`)VrM4hg7s<%#Tm2Whn=7 zq$#XAtQx3mG0F3~b(-Z?>00Efti_qKT0lt?esSwP7_U1#t3#q$kD3 zcct}#O>)y#i)@;vyNaddq)_@}SbEn+2G#)-2M!NS#neO-eSucTX}AnTQ#*?JgF!l?m=slwp<>*N$vWGj=+Ch>jC;wEoKMQLYG7uSw$r6G z4xZ#_{}K#}N~+v6%<68nXL#NmgWOBtE~ut!;wtU3cMdM$<`8r@Jo*|Im$~|esBNe$ PU<+6h1(Cpa5VijU{!2U; delta 322 zcmaFBy@Qo6l$V!_0SG!Rp2SXKoX97`Xfjb-Mu$0trG+7iC51JG4M?-5u%~bUX|@#3 zU%_rRJri7EPQV&&CcE`ISGJh0&EaH?=4|H6=bbvA86)XtF<}F$*V9 za^iaZ$y*tPHCch|B9Lkb!2x95VlOUD%1TWx;Q?}rnScZXV-eTnkBolxY(RDqH;6#f z!Ufe5pP9lBl!oa7nc%0%9wm^Hm6(^FuUDLrUsRG@T2frZ43xRW4HeEPDJdvo0T~N& qS`jD!ia=VCYysOR4|X1hO>TZlX-=vgBTz{(NQj4phlzuggBbw)|3v%% 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 58c19d09f80e6d88aea81576322bf6a5c0d99c90..6a55fba16b22282469829b0eb72feaf947f060ee 100644 GIT binary patch delta 37 scmZ3=F^_{gl$V!_0SFE~e7%wT0~2G_5l$V!_0SGpTJ>1Csfr+tk@*gHw-rUrp^wgC2+{EIN)S}7m%+~=OWe%kP diff --git a/bestnotes/migrations/__pycache__/__init__.cpython-38.pyc b/bestnotes/migrations/__pycache__/__init__.cpython-38.pyc index 04a14873531ecaed5ac0eb0d5e2cd708be3d10fc..feebe36cb7406eace3fa9c7eb7d6677dd337dd26 100644 GIT binary patch delta 34 ocmcb?c#)Ail$V!_0SFE~d_9rdhOum-hbx +{% 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 fe17d61ac766ee017bb262d0131eda087d124dd6..1562781eb43bbe62747ec09209792efdfa2d6988 100644 GIT binary patch delta 5986 zcmeHLeQaA-6@T}==lH$nkJF@a9W_n-?8J%PG>PA{9mg(N>ZR_7)}~)sJ64s{iC1 z_48NKh(CZuNJPq!@44sx&hLJmch0@?4tM1p;icBbF^Zyg;{WpB;p@BnwlS(NAR4fW zhWlE_PWS}wzmZ*nM%=IuVqvpeuxu7q^TsW1*5naZi_(^N1yyP`P!30QLRrYBGg)Q9 z=kxi;wO_JN3inEKuP-D@p@=^ekpq3QB!y&OWGfyb)eVuy7jhHR%4Bvto0&^aK5VQc z1%iX2KocJ8u8u8cTVG;Z1fXfS1CPR6Z~?vsFTfMf1KWTuI>nEyr<)oXFRBnE90}hl;~!L=|zd@c=}vsJf27;)8n(5bEX|uW(XBNOrw^3uHV+=u~--< z7tdwSkDr^*UU(9|1TWyJ*kGuMb=ay5wPhA;tfRH6(mC^6S%ERoAseBat34RH; z;oI;kd=XOcSr`Ey#&3q9MuDXqwhCFzK{Jn4treB-pozm;dqqneBGvPEK(rzn$^UP7&YT$2E*6&%KGw(BT{B3+wzQuc% zb{h`a-^- zJm6c}&62VCr&JO5zt36?aDake!^?00mLXMi`Ub$=$s9)i3f)jlsi#D189o^BhX+E% zpS>#k7!TO;#`nT4a0-sWV-SO32!kJbp&Ojg3O2lTZ(9!-7=#25k=;ag5$V<>-$`T# zkuD;gn&dNhggl|haw1&c?-@BBi;l&_gQI(6Pl&Gi&h>*`;*rrcRyM^YdR%1pu^X2c(>XRd zl)q(aS^n!;G)9~G*QussJ%~!C8-|xpOrnzwEJZOb1w6;@16Pg1M!VOGt{u$ACuWs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