--- /dev/null
+# Generated by Django 4.0.8 on 2024-08-28 08:06
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('catalogue', '0047_book_translators'),
+ ]
+
+ operations = [
+ migrations.RemoveField(
+ model_name='collection',
+ name='kind',
+ ),
+ migrations.RemoveField(
+ model_name='tag',
+ name='for_books',
+ ),
+ migrations.RemoveField(
+ model_name='tag',
+ name='for_pictures',
+ ),
+ migrations.AlterField(
+ model_name='book',
+ name='translators',
+ field=models.ManyToManyField(blank=True, to='catalogue.tag'),
+ ),
+ migrations.AlterField(
+ model_name='tag',
+ name='category',
+ field=models.CharField(choices=[('author', 'autor'), ('epoch', 'epoka'), ('kind', 'rodzaj'), ('genre', 'gatunek'), ('theme', 'motyw'), ('set', 'półka')], db_index=True, max_length=50, verbose_name='kategoria'),
+ ),
+ ]
('genre', _('gatunek')),
('theme', _('motyw')),
('set', _('półka')),
- ('thing', _('obiekt')), # things shown on pictures
)
'kategoria', max_length=50, blank=False, null=False, db_index=True, choices=TAG_CATEGORIES)
description = models.TextField('opis', blank=True)
- for_books = models.BooleanField(default=False)
- for_pictures = models.BooleanField(default=False)
-
user = models.ForeignKey(User, models.CASCADE, blank=True, null=True)
gazeta_link = models.CharField(blank=True, max_length=240)
culturepl_link = models.CharField(blank=True, max_length=240)
'gatunek': 'genre',
'motyw': 'theme',
'polka': 'set',
- 'obiekt': 'thing',
}
categories_dict = dict((item[::-1] for item in categories_rev.items()))
# TODO: remove magic.
if self.category == 'set':
return reverse('social_my_shelf')
- elif self.category == 'thing':
- return ''
else:
return reverse(f'{self.category}_catalogue')
+++ /dev/null
-# This file is part of Wolne Lektury, licensed under GNU Affero GPLv3 or later.
-# Copyright © Fundacja Wolne Lektury. See NOTICE for more information.
-#
-from django.db import models, transaction
-import catalogue.models
-from sorl.thumbnail import ImageField
-from django.conf import settings
-from django.contrib.contenttypes.fields import GenericRelation
-from django.core.files.storage import FileSystemStorage
-from django.urls import reverse
-from slugify import slugify
-
-from catalogue.models.tag import prefetched_relations
-from catalogue.utils import split_tags
-from wolnelektury.utils import cached_render, clear_cached_renders
-from io import BytesIO
-import itertools
-import json
-import logging
-import re
-
-from PIL import Image
-
-from newtagging import managers
-from os import path
-
-
-picture_storage = FileSystemStorage(location=path.join(
- settings.MEDIA_ROOT, 'pictures'),
- base_url=settings.MEDIA_URL + "pictures/")
-
-
-class PictureArea(models.Model):
- picture = models.ForeignKey('picture.Picture', models.CASCADE, related_name='areas')
- area = models.TextField('obszar', default='{}', editable=False)
- kind = models.CharField(
- 'typ', max_length=10, blank=False, null=False, db_index=True,
- choices=(('thing', 'przedmiot'), ('theme', 'motyw'))
- )
-
- objects = models.Manager()
- tagged = managers.ModelTaggedItemManager(catalogue.models.Tag)
- tags = managers.TagDescriptor(catalogue.models.Tag)
- tag_relations = GenericRelation(catalogue.models.Tag.intermediary_table_model)
-
-
-class Picture(models.Model):
- """
- Picture resource.
-
- """
- title = models.CharField('tytuł', max_length=32767)
- slug = models.SlugField('slug', max_length=120, db_index=True, unique=True)
- sort_key = models.CharField('klucz sortowania', max_length=120, db_index=True, editable=False)
- sort_key_author = models.CharField(
- 'klucz sortowania wg autora', max_length=120, db_index=True, editable=False, default='')
- created_at = models.DateTimeField('data utworzenia', auto_now_add=True, db_index=True)
- changed_at = models.DateTimeField('data zmiany', auto_now=True, db_index=True)
- xml_file = models.FileField('plik xml', upload_to="xml", storage=picture_storage)
- image_file = ImageField('plik obrazu', upload_to="images", storage=picture_storage)
- html_file = models.FileField('plik html', upload_to="html", storage=picture_storage)
- areas_json = models.TextField('obszary w JSON', default='{}', editable=False)
- extra_info = models.TextField('dodatkowa informacja', default='{}')
- culturepl_link = models.CharField(blank=True, max_length=240)
- wiki_link = models.CharField(blank=True, max_length=240)
-
- width = models.IntegerField(null=True)
- height = models.IntegerField(null=True)
-
- objects = models.Manager()
- tagged = managers.ModelTaggedItemManager(catalogue.models.Tag)
- tags = managers.TagDescriptor(catalogue.models.Tag)
- tag_relations = GenericRelation(catalogue.models.Tag.intermediary_table_model)
-
- class Meta:
- ordering = ('sort_key_author', 'sort_key')
-
- verbose_name = 'obraz'
- verbose_name_plural = 'obrazy'
-
- def __str__(self):
- return self.title