diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..bd6db2c
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,4 @@
+MANAGE := poetry run python manage.py
+
+run:
+ $(MANAGE) runserver
diff --git a/djaif/book/migrations/0016_note.py b/djaif/book/migrations/0016_note.py
new file mode 100644
index 0000000..70a8eb4
--- /dev/null
+++ b/djaif/book/migrations/0016_note.py
@@ -0,0 +1,24 @@
+# Generated by Django 3.0.5 on 2021-06-04 16:31
+
+from django.db import migrations, models
+import django.db.models.deletion
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('book', '0015_droppeditemsave'),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name='Note',
+ fields=[
+ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+ ('text', models.TextField()),
+ ('created_at', models.DateTimeField(auto_now_add=True)),
+ ('updated_at', models.DateTimeField(auto_now=True)),
+ ('page', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='book.BookPage')),
+ ],
+ ),
+ ]
diff --git a/djaif/book/migrations/0017_note_progress.py b/djaif/book/migrations/0017_note_progress.py
new file mode 100644
index 0000000..ee6b85c
--- /dev/null
+++ b/djaif/book/migrations/0017_note_progress.py
@@ -0,0 +1,20 @@
+# Generated by Django 3.0.5 on 2021-06-04 16:39
+
+from django.db import migrations, models
+import django.db.models.deletion
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('book', '0016_note'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='note',
+ name='progress',
+ field=models.ForeignKey(default=42, on_delete=django.db.models.deletion.CASCADE, to='book.BookProgress'),
+ preserve_default=False,
+ ),
+ ]
diff --git a/djaif/book/migrations/0018_note_pinned.py b/djaif/book/migrations/0018_note_pinned.py
new file mode 100644
index 0000000..2d34978
--- /dev/null
+++ b/djaif/book/migrations/0018_note_pinned.py
@@ -0,0 +1,18 @@
+# Generated by Django 3.0.5 on 2021-06-04 17:24
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('book', '0017_note_progress'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='note',
+ name='pinned',
+ field=models.BooleanField(default=False),
+ ),
+ ]
diff --git a/djaif/book/models.py b/djaif/book/models.py
index a6eb567..15d505b 100644
--- a/djaif/book/models.py
+++ b/djaif/book/models.py
@@ -2,7 +2,6 @@
from django.db import models, transaction
-# Create your models here.
class Book(models.Model):
title = models.CharField(name='title', max_length=100, unique=True)
first_page = models.ForeignKey(
@@ -63,7 +62,9 @@ class Meta:
@classmethod
def start_reading(cls, user, book):
- progress = BookProgress(user=user, book=book, book_page=book.first_page)
+ progress = BookProgress(
+ user=user, book=book, book_page=book.first_page,
+ )
progress.save()
return progress
@@ -133,3 +134,17 @@ class DroppedItemSave(models.Model):
item = models.ForeignKey(Item, on_delete=models.CASCADE)
book_page = models.ForeignKey(BookPage, on_delete=models.CASCADE)
progress_save = models.ForeignKey(ProgressSave, on_delete=models.CASCADE)
+
+
+class Note(models.Model):
+ text = models.TextField()
+ progress = models.ForeignKey(BookProgress, on_delete=models.CASCADE)
+ page = models.ForeignKey(
+ BookPage,
+ on_delete=models.CASCADE,
+ null=True,
+ blank=True,
+ )
+ pinned = models.BooleanField(default=False)
+ created_at = models.DateTimeField(auto_now_add=True)
+ updated_at = models.DateTimeField(auto_now=True)
diff --git a/djaif/book/templates/note.html b/djaif/book/templates/note.html
new file mode 100644
index 0000000..eef7051
--- /dev/null
+++ b/djaif/book/templates/note.html
@@ -0,0 +1,45 @@
+
+
+
+
+ {{ page.book.title }}: {{ page.title }}
+
+
+
+ {{ page.title }}: Заметка
+
+
+
+
diff --git a/djaif/book/templates/page.html b/djaif/book/templates/page.html
index 51410b6..65bc705 100644
--- a/djaif/book/templates/page.html
+++ b/djaif/book/templates/page.html
@@ -5,63 +5,103 @@
{{ page.book.title }}: {{ page.title }}
-
- {{ page.title }}
-
- {{ page.body }}
- {% if page_items %}
- Вы видите
-
- {% endif %}
- {% if dropped_items %}
- Брошено вами ранее
-
- {% for dropped_item in dropped_items %}
- -
- {{ dropped_item.item.name }}
-
- [Подобрать]
-
-
- {% endfor %}
-
- {% endif %}
- Куда податься?
-
- {% for link, passable in links %}
- -
- {% if passable %}
-
- {{ link.name }}
-
- {% else %}
- {{ link.name }}
+
+
+
+ {{ page.title }}
+
+ {{ page.body }}
+ {% if page_items %}
+
Вы видите
+
{% endif %}
-
- {% endfor %}
-
- {% if progress.items.all %}
-
Инвентарь
-
- {% for item in progress.items.all %}
- -
- {{ item.name }}
-
- [Выбросить]
-
-
- {% endfor %}
-
- {% endif %}
-
-
Сохранения
+ {% if dropped_items %}
+
Брошено вами ранее
+
+ {% for dropped_item in dropped_items %}
+ -
+ {{ dropped_item.item.name }}
+
+ [Подобрать]
+
+
+ {% endfor %}
+
+ {% endif %}
+
Куда податься?
+
+ {% for link, passable in links %}
+ -
+ {% if passable %}
+
+ {{ link.name }}
+
+ {% else %}
+ {{ link.name }}
+ {% endif %}
+
+ {% endfor %}
+
+ {% if progress.items.all %}
+
Инвентарь
+
+ {% for item in progress.items.all %}
+ -
+ {{ item.name }}
+
+ [Выбросить]
+
+
+ {% endfor %}
+
+ {% endif %}
+
+
Сохранения
+
+
+