-FROM python:3.10-slim-trixie AS base
+FROM python:3.12-slim-trixie AS base
ARG UID=8200
ARG GID=8200
--- /dev/null
+# make test
+# make test ARGS=catalogue
+
+name: redakcja-test
+
+x-env: &env
+ POSTGRES_USER: wl
+ POSTGRES_PASSWORD: wl
+
+services:
+ test:
+ build:
+ context: .
+ target: test
+ args:
+ UID: ${UID:-1000}
+ GID: ${GID:-1000}
+ environment:
+ <<: *env
+ SECRET_KEY: test
+ ALLOWED_HOSTS: "*"
+ COVERAGE_FILE: /tmp/.coverage
+ volumes:
+ - ./htmlcov:/app/htmlcov
+ - ./scripts:/app/scripts
+ depends_on: [db]
+ #entrypoint: /app/scripts/entrypoint.sh
+
+ db:
+ image: postgres:18
+ environment: *env
+ tmpfs: [/var/lib/postgresql]
+
## Python libraries
jsmin==3.0.1
-merge3==0.0.13
-PyYAML==6.0
-Pillow==9.5.0
+merge3==1.0.0
+PyYAML==6.0.4
+Pillow==13.0.0
oauth2
httplib2 # oauth2 dependency
-python-slugify==8.0.1
-python-docx==0.8.11
-Wikidata==0.7
+python-slugify==9.2.0
+python-docx==1.2.0
+requests==2.34.2
+Wikidata==0.9
librarian==26.11
## Django
-Django==4.1.9
-psycopg2-binary
-fnpdjango==0.7
-django-pipeline==2.1.0
-django-cas-ng==4.3.0
-sorl-thumbnail==12.9.0
-fnp-django-pagination==2.2.6
-django-gravatar2==1.4.4
-django-extensions==3.2.3
-django-bootstrap4==23.1
-django-debug-toolbar==4.1.0
+Django==5.2.19
+psycopg2-binary==2.9.13
+fnpdjango==0.8
+django-pipeline==4.1.0
+django-cas-ng==5.1.2
+sorl-thumbnail==13.5.0
+fnp-django-pagination==2.2.13
+django-gravatar2==1.4.5
+django-extensions==4.1
+django-bootstrap4==26.3
+django-debug-toolbar==8.0.0
django-admin-numeric-filter==0.1.9
-djangorestframework==3.14.0
-django-filter==23.2
-django-modeltranslation==0.18.10
-django-admin-ordering==0.17
-django-reversion==5.0.6
+djangorestframework==3.18.3
+django-filter==26.2
+django-modeltranslation==0.20.6
+django-admin-ordering==0.23
+django-reversion==6.5.2
-sentry-sdk==1.25.1
+sentry-sdk==3.0.1
ipython
--- /dev/null
+#!/bin/bash
+
+# For use in development only.
+# Installs in editable mode any libs mounted under /editable/
+# This way, we can easily work on e.g. librarian.
+
+for lib in /editable/*
+do
+ [ -d "$lib" ] || continue
+ pip install -e $lib
+done
+
+exec "$@"
--- /dev/null
+# Generated by Django 4.1.9 on 2026-11-28 23:48
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('catalogue', '0055_book_parent_book_parent_number_editornote'),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name='notablebook',
+ name='ordering',
+ field=models.PositiveIntegerField(db_index=True, default=0, verbose_name='ordering'),
+ ),
+ ]
data = urlopen(url).read().decode('utf-16')
lines = data.split('\n')[1:]
for line in lines:
- m = re.match('^/katalog/lektura/([^,./]+)\.html,', line)
+ m = re.match(r'^/katalog/lektura/([^,./]+)\.html,', line)
if m is not None:
which = 'views_reader'
else:
book = Book.create(slug='test', text=SAMPLE_XML, creator=user)
self.client.post(
- '/cover/quick-import/1/',
+ f'/cover/quick-import/{book.pk}/',
{
'url': 'https://cyfrowe.mnw.art.pl/pl/zbiory/447973'
}
self.assertEqual(len(response.context['object_list']), 1)
def test_image(self):
- response = self.client.get('/cover/image/1/')
+ response = self.client.get(f'/cover/image/{self.img.pk}/')
self.assertEqual(response.context['object'].title, 'Angelus Novus')
def test_edit_image(self):
self.client.force_login(self.user)
- response = self.client.post('/cover/image/1/', {
+ response = self.client.post(f'/cover/image/{self.img.pk}/', {
'author': 'author',
'title': 'changed title',
'license_name': 'domena',
'cut_right': 1,
})
- response = self.client.get('/cover/image/1/')
+ response = self.client.get(f'/cover/image/{self.img.pk}/')
self.assertEqual(response.context['object'].title, 'changed title')
def test_image_file(self):
- response = self.client.get('/cover/image/1/file/')
+ response = self.client.get(f'/cover/image/{self.img.pk}/file/')
self.assertRegex(response['Location'], r'^/media/cover/image/')
except OSError:
pass
fname = os.path.join(cover_dir, "%s.%s" % (coverid, cover.ext()))
- img = cover.image().resize(PREVIEW_SIZE, PIL.Image.ANTIALIAS)
+ img = cover.image().resize(PREVIEW_SIZE, PIL.Image.Resampling.LANCZOS)
img.save(os.path.join(settings.MEDIA_ROOT, fname))
return HttpResponse(os.path.join(settings.MEDIA_URL, fname))
class PriceLevelInline(OrderableAdmin, admin.TabularInline):
model = models.PriceLevel
extra = 0
+ ordering_field = 'price'
@admin.register(models.Site)
if max_len is not None:
qs = qs[:max_len]
if day is not None:
- next_day = day + timedelta(1)
- qs = qs.filter(created_at__gte=day, created_at__lt=next_day)
+ qs = qs.filter(created_at__date=day)
for item in qs:
tag = 'stage' if item.tags.count() else 'change'
chunk = item.tree
if max_len is not None:
qs = qs[:max_len]
if day is not None:
- next_day = day + timedelta(1)
- qs = qs.filter(created_at__gte=day, created_at__lt=next_day)
+ qs = qs.filter(created_at__date=day)
for item in qs:
tag = 'stage' if item.tags.count() else 'change'
image = item.tree
if max_len is not None:
qs = qs[:max_len]
if day is not None:
- next_day = day + timedelta(1)
- qs = qs.filter(timestamp__gte=day, timestamp__lt=next_day)
+ qs = qs.filter(timestamp__date=day)
for item in qs:
w = WallItem('publish')
w.header = _('Publication')
if max_len is not None:
qs = qs[:max_len]
if day is not None:
- next_day = day + timedelta(1)
- qs = qs.filter(timestamp__gte=day, timestamp__lt=next_day)
+ qs = qs.filter(timestamp__date=day)
for item in qs:
w = WallItem('publish')
w.header = _('Publication')
# This file is part of FNP-Redakcja, licensed under GNU Affero GPLv3 or later.
# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
#
-import datetime
import os.path
from django.conf import settings
import django.core.files.storage
from django.db import migrations, models
import django.db.models.deletion
+import django.utils.timezone
import dvcs.models
('author_email', models.CharField(blank=True, help_text='Used if author is not set.', max_length=128, null=True, verbose_name='author email')),
('revision', models.IntegerField(db_index=True, verbose_name='revision')),
('description', models.TextField(blank=True, default=b'', verbose_name='description')),
- ('created_at', models.DateTimeField(db_index=True, default=datetime.datetime.now, editable=False)),
+ ('created_at', models.DateTimeField(db_index=True, default=django.utils.timezone, editable=False)),
('publishable', models.BooleanField(default=False, verbose_name='publishable')),
('data', models.FileField(storage=django.core.files.storage.FileSystemStorage(location=os.path.join(settings.MEDIA_ROOT, 'dvcs')), upload_to=dvcs.models.data_upload_to, verbose_name='data')),
('author', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, verbose_name='author')),
--- /dev/null
+import pickle
+from django.core.signing import JSONSerializer
+
+
+class JSONWithPickleFallbackSerializer(JSONSerializer):
+ """Transitional until the sessions are replaced."""
+ def loads(self, data):
+ if data[:1] == b"\x80":
+ data = pickle.loads(data)
+ for k in list(data.get('wiki_last_books', {}).keys()):
+ if not isinstance(k, str):
+ del data['wiki_last_books'][k]
+ return data
+ return super().loads(data)
if DEBUG:
INSTALLED_APPS += ('debug_toolbar',)
+FORMS_URLFIELD_ASSUME_HTTPS = True
+
LOCALE_PATHS = [
PROJECT_ROOT + "/locale-contrib",
]
'pipeline.finders.PipelineFinder',
)
-STATICFILES_STORAGE = 'pipeline.storage.PipelineManifestStorage'
+STORAGES = {
+ 'default': {
+ 'BACKEND': 'django.core.files.storage.FileSystemStorage'
+ },
+ 'staticfiles': {
+ 'BACKEND': 'pipeline.storage.PipelineManifestStorage',
+ },
+}
PIPELINE = {
'JS_COMPRESSOR': 'pipeline.compressors.jsmin.JSMinCompressor',
DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'
-SESSION_SERIALIZER = 'django.contrib.sessions.serializers.PickleSerializer'
+SESSION_SERIALIZER = 'redakcja.serializer.JSONWithPickleFallbackSerializer'
REST_FRAMEWORK = {
DATABASES = {
'default': {
- 'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
- 'NAME': '', # Or path to database file if using sqlite3.
- 'USER': '', # Not used with sqlite3.
- 'PASSWORD': '', # Not used with sqlite3.
- 'HOST': '', # Set to empty string for localhost. Not used with sqlite3.
- 'PORT': '', # Set to empty string for default. Not used with sqlite3.
+ 'ENGINE': 'django.db.backends.postgresql',
+ 'HOST': 'db',
+ 'USER': os.environ.get('POSTGRES_USER'),
+ 'PASSWORD': os.environ.get('POSTGRES_PASSWORD'),
+ 'NAME': os.environ.get('POSTGRES_USER'),
}
}
LITERARY_DIRECTOR_USERNAME = 'Kaowiec'
MIN_COVER_SIZE = (1, 1)
-
-
-class DisableMigrations(object):
-
- def __contains__(self, item):
- return True
-
- def __getitem__(self, item):
- return None
-
-MIGRATION_MODULES = DisableMigrations()
from .test import *
TEST_INTEGRATION = True
-
-MIGRATION_MODULES = {}
migrations.AddField(
model_name="presence",
name="until",
- field=models.DateTimeField(db_index=True, default="1970-01-01"),
+ field=models.DateTimeField(db_index=True, default="1970-01-01 0:00Z"),
preserve_default=False,
),
migrations.AlterField(