BES-32 Added single note view by id
This commit is contained in:
parent
16f0e52ff9
commit
cfb9840d1a
@ -2,10 +2,15 @@
|
|||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="b23c009e-2f8a-48f7-8b29-023f93596932" name="Default Changelist" comment="">
|
<list default="true" id="b23c009e-2f8a-48f7-8b29-023f93596932" name="Default Changelist" comment="">
|
||||||
<change afterPath="$PROJECT_DIR$/bestnotes/dbAPI.py" afterDir="false" />
|
<change afterPath="$PROJECT_DIR$/bestnotes/static/note.css" afterDir="false" />
|
||||||
|
<change afterPath="$PROJECT_DIR$/bestnotes/templates/note.html" afterDir="false" />
|
||||||
|
<change afterPath="$PROJECT_DIR$/bestnotes/templates/test.html" afterDir="false" />
|
||||||
|
<change afterPath="$PROJECT_DIR$/bestnotes/templates/testid.html" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/bestnotes/admin.py" beforeDir="false" afterPath="$PROJECT_DIR$/bestnotes/admin.py" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/bestnotes/models.py" beforeDir="false" afterPath="$PROJECT_DIR$/bestnotes/models.py" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/bestnotes/models.py" beforeDir="false" afterPath="$PROJECT_DIR$/bestnotes/models.py" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/bestnotes/tests.py" beforeDir="false" afterPath="$PROJECT_DIR$/bestnotes/tests.py" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/bestnotes/urls.py" beforeDir="false" afterPath="$PROJECT_DIR$/bestnotes/urls.py" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/bestnotes/views.py" beforeDir="false" afterPath="$PROJECT_DIR$/bestnotes/views.py" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/db.sqlite3" beforeDir="false" afterPath="$PROJECT_DIR$/db.sqlite3" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/db.sqlite3" beforeDir="false" afterPath="$PROJECT_DIR$/db.sqlite3" afterDir="false" />
|
||||||
</list>
|
</list>
|
||||||
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
|
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
|
||||||
@ -18,6 +23,7 @@
|
|||||||
<option name="RECENT_TEMPLATES">
|
<option name="RECENT_TEMPLATES">
|
||||||
<list>
|
<list>
|
||||||
<option value="Python Script" />
|
<option value="Python Script" />
|
||||||
|
<option value="HTML File" />
|
||||||
</list>
|
</list>
|
||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
@ -32,6 +38,7 @@
|
|||||||
<component name="ProjectId" id="1U5Jq3TEUnuX8tmyYK4OsXqAEBc" />
|
<component name="ProjectId" id="1U5Jq3TEUnuX8tmyYK4OsXqAEBc" />
|
||||||
<component name="ProjectLevelVcsManager" settingsEditedManually="true" />
|
<component name="ProjectLevelVcsManager" settingsEditedManually="true" />
|
||||||
<component name="PropertiesComponent">
|
<component name="PropertiesComponent">
|
||||||
|
<property name="DefaultHtmlFileTemplate" value="HTML File" />
|
||||||
<property name="SHARE_PROJECT_CONFIGURATION_FILES" value="true" />
|
<property name="SHARE_PROJECT_CONFIGURATION_FILES" value="true" />
|
||||||
<property name="last_opened_file_path" value="$PROJECT_DIR$" />
|
<property name="last_opened_file_path" value="$PROJECT_DIR$" />
|
||||||
<property name="settings.editor.selected.configurable" value="preferences.general" />
|
<property name="settings.editor.selected.configurable" value="preferences.general" />
|
||||||
@ -49,7 +56,7 @@
|
|||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
<component name="RunManager">
|
<component name="RunManager">
|
||||||
<configuration name="Unittests in bestnotesunittests.py" type="tests" factoryName="Unittests" temporary="true" nameIsGenerated="true">
|
<configuration name="Unittests in E:/MojeDane/StudiaWMI/Semestr_2_Zimowy_2019-20/Systemy_informatyczne/BES-32/BestNotes/bestnotes/bestnotesunittests.py" type="tests" factoryName="Unittests" temporary="true" nameIsGenerated="true">
|
||||||
<module name="BestNotesProject" />
|
<module name="BestNotesProject" />
|
||||||
<option name="INTERPRETER_OPTIONS" value="" />
|
<option name="INTERPRETER_OPTIONS" value="" />
|
||||||
<option name="PARENT_ENVS" value="true" />
|
<option name="PARENT_ENVS" value="true" />
|
||||||
@ -65,7 +72,7 @@
|
|||||||
</configuration>
|
</configuration>
|
||||||
<recent_temporary>
|
<recent_temporary>
|
||||||
<list>
|
<list>
|
||||||
<item itemvalue="Python tests.Unittests in bestnotesunittests.py" />
|
<item itemvalue="Python tests.Unittests in E:/MojeDane/StudiaWMI/Semestr_2_Zimowy_2019-20/Systemy_informatyczne/BES-32/BestNotes/bestnotes/bestnotesunittests.py" />
|
||||||
</list>
|
</list>
|
||||||
</recent_temporary>
|
</recent_temporary>
|
||||||
</component>
|
</component>
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -2,8 +2,9 @@ from django.contrib import admin
|
|||||||
|
|
||||||
# Register your models here.
|
# Register your models here.
|
||||||
from django.contrib import admin
|
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(StudentProfile)
|
||||||
admin.site.register(Subject)
|
admin.site.register(Subject)
|
||||||
admin.site.register(Topic)
|
admin.site.register(Topic)
|
||||||
|
admin.site.register(Note)
|
25
bestnotes/migrations/0003_note.py
Normal file
25
bestnotes/migrations/0003_note.py
Normal file
@ -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')),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
]
|
Binary file not shown.
Binary file not shown.
@ -46,3 +46,9 @@ class Topic(models.Model):
|
|||||||
add_date = models.DateField()
|
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()
|
0
bestnotes/static/note.css
Normal file
0
bestnotes/static/note.css
Normal file
18
bestnotes/templates/note.html
Normal file
18
bestnotes/templates/note.html
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
{% extends 'base.html' %}
|
||||||
|
{% load static %}
|
||||||
|
{% block css %}
|
||||||
|
<link rel="stylesheet" type="text/css" href="{% static 'note.css' %}">
|
||||||
|
{% endblock %}
|
||||||
|
{% block content %}
|
||||||
|
{% include 'navbar.html' %}
|
||||||
|
<div class="container d-flex justify-content-center">
|
||||||
|
<div class="row mt-4"><h1>Tytuł: {{ note.name }}</h1></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="container">
|
||||||
|
<div class="d-flex justify-content-center mt-5">
|
||||||
|
<h3> {{ note.text }}</h3>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% endblock %}
|
12
bestnotes/templates/test.html
Normal file
12
bestnotes/templates/test.html
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
{% extends 'base.html' %}
|
||||||
|
{% load static %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
{% for note in notes%}
|
||||||
|
|
||||||
|
{{ note.name }}
|
||||||
|
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
{% endblock %}
|
12
bestnotes/templates/testid.html
Normal file
12
bestnotes/templates/testid.html
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
{% extends 'base.html' %}
|
||||||
|
{% load static %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
{% for note in notes%}
|
||||||
|
|
||||||
|
{{ note.name }}
|
||||||
|
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
{% endblock %}
|
@ -8,4 +8,8 @@ urlpatterns = [
|
|||||||
path('accounts/', include("django.contrib.auth.urls")),
|
path('accounts/', include("django.contrib.auth.urls")),
|
||||||
path('subject/', views.subject, name="subject"),
|
path('subject/', views.subject, name="subject"),
|
||||||
path('subject/<id>', views.subject_id, name="subjectid"),
|
path('subject/<id>', views.subject_id, name="subjectid"),
|
||||||
|
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")
|
||||||
]
|
]
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
from django.shortcuts import render
|
from django.shortcuts import render
|
||||||
|
from bestnotes.models import Note
|
||||||
# Create your views here.
|
# Create your views here.
|
||||||
|
|
||||||
from django.http import HttpResponse
|
from django.http import HttpResponse
|
||||||
@ -14,3 +14,33 @@ def subject(request):
|
|||||||
|
|
||||||
def subject_id(request,id):
|
def subject_id(request,id):
|
||||||
return render(request, "subject.html", {'id': id})
|
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)
|
BIN
db.sqlite3
BIN
db.sqlite3
Binary file not shown.
Loading…
Reference in New Issue
Block a user