From: Radek Czajka Date: Mon, 5 Aug 2019 11:21:30 +0000 (+0200) Subject: Update Celery to 4.3 X-Git-Url: https://git.mdrn.pl/wolnelektury.git/commitdiff_plain/eaf0711613bea8181528d8911b30ef7976b7bb42 Update Celery to 4.3 --- diff --git a/README.md b/README.md index 45c7e4e23..13c0ed2b8 100644 --- a/README.md +++ b/README.md @@ -59,26 +59,23 @@ Bundled software ================ * django-chunks - in `apps/chunks` + in `src/chunks` based on [django-chunks](http://code.google.com/p/django-chunks/) by Clint Ecker , [New BSD License](http://www.opensource.org/licenses/bsd-license.php) * [django-newtagging](http://www.bitbucket.org/zuber/django-newtagging/) - in `apps/newtagging` + in `src/newtagging` by Marek Stępniowski , [MIT License](http://www.opensource.org/licenses/mit-license.php), based on [django-tagging](http://code.google.com/p/django-tagging/), also under [MIT License](http://www.opensource.org/licenses/mit-license.php) * [jPlayer](http://jplayer.org/) - in `apps/catalogue/static/jplayer` + in `src/catalogue/static/jplayer` by Happyworm, [MIT License](http://opensource.org/licenses/MIT) * [Switch template tag](http://djangosnippets.org/snippets/967/) - in `apps/wolnelektury_core/templatetags/switch_tag.py` + in `src/wolnelektury/templatetags/switch_tag.py` by adurdin -* [Cropping engine for sorl-thumbnail](http://timmyomahony.com/blog/custom-cropping-engine-sorl-thumbnail/) - in `apps/picture/engine.py` - by Timmy O'Mahony -* Javascript in `apps/wolnelektury_core/static/js/contrib` +* Javascript in `src/wolnelektury/static/js/contrib` with relevant attribution and licensing diff --git a/requirements/requirements.txt b/requirements/requirements.txt index 2f877e9bf..a5f04677f 100644 --- a/requirements/requirements.txt +++ b/requirements/requirements.txt @@ -44,8 +44,7 @@ sorl-thumbnail==12.5.0 librarian==1.7.4 # celery tasks -celery>=3.1.12,<3.2 -kombu>=3.0.23,<3.1 +celery[redis]==4.3.0 # spell checking pyenchant diff --git a/src/api/tests/res/responses/books-grandchild.json b/src/api/tests/res/responses/books-grandchild.json index b7dd9daaf..6638317b0 100644 --- a/src/api/tests/res/responses/books-grandchild.json +++ b/src/api/tests/res/responses/books-grandchild.json @@ -4,9 +4,9 @@ "html": "Fragment", "title": "Parent, Child" }, - "txt": "http://testserver/katalog/pobierz/grandchild.txt", + "txt": "http://testserver/media/txt/grandchild.txt", "children": [], - "xml": "http://testserver/katalog/pobierz/grandchild.xml", + "xml": "http://testserver/media/xml/grandchild.xml", "genres": [ { "url": "http://testserver/katalog/gatunek/sonet/", @@ -17,9 +17,9 @@ ], "title": "Grandchild", "media": [], - "html": "http://testserver/katalog/pobierz/grandchild.html", - "preview": true, - "fb2": "http://testserver/katalog/pobierz/grandchild.fb2", + "html": "http://testserver/media/html/grandchild.html", + "preview": false, + "fb2": "http://testserver/media/fb2/grandchild.fb2", "kinds": [], "parent": { "kind": "", @@ -42,11 +42,11 @@ "simple_cover": "", "authors": [], "audio_length": "", - "epub": "http://testserver/katalog/pobierz/grandchild.epub", + "epub": "http://testserver/media/epub/grandchild.epub", "cover_thumb": "", - "mobi": "http://testserver/katalog/pobierz/grandchild.mobi", + "mobi": "http://testserver/media/mobi/grandchild.mobi", "url": "http://testserver/katalog/lektura/grandchild/", "cover": "", - "pdf": "http://testserver/katalog/pobierz/grandchild.pdf", + "pdf": "http://testserver/media/pdf/grandchild.pdf", "simple_thumb": "" } diff --git a/src/api/tests/res/responses/ebooks.json b/src/api/tests/res/responses/ebooks.json index 719faac17..d01f1fa27 100644 --- a/src/api/tests/res/responses/ebooks.json +++ b/src/api/tests/res/responses/ebooks.json @@ -12,16 +12,16 @@ "epub": "" }, { - "fb2": "http://testserver/katalog/pobierz/grandchild.fb2", - "mobi": "http://testserver/katalog/pobierz/grandchild.mobi", + "fb2": "http://testserver/media/fb2/grandchild.fb2", + "mobi": "http://testserver/media/mobi/grandchild.mobi", "title": "Grandchild", "author": "", "cover": "", "href": "http://testserver/api/books/grandchild/", - "pdf": "http://testserver/katalog/pobierz/grandchild.pdf", - "txt": "http://testserver/katalog/pobierz/grandchild.txt", + "pdf": "http://testserver/media/pdf/grandchild.pdf", + "txt": "http://testserver/media/txt/grandchild.txt", "slug": "grandchild", - "epub": "http://testserver/katalog/pobierz/grandchild.epub" + "epub": "http://testserver/media/epub/grandchild.epub" }, { "fb2": "", diff --git a/src/api/tests/tests.py b/src/api/tests/tests.py index c37fef33b..993a52409 100644 --- a/src/api/tests/tests.py +++ b/src/api/tests/tests.py @@ -177,12 +177,15 @@ class BooksTests(ApiTest): '/api/filter-books/?lektura=true', []) - self.assert_slugs( - '/api/filter-books/?preview=true', - ['grandchild']) + Book.objects.filter(slug='grandchild').update(preview=True) + # Skipping: we don't allow previewed books in filtered list. + #self.assert_slugs( + # '/api/filter-books/?preview=true', + # ['grandchild']) self.assert_slugs( '/api/filter-books/?preview=false', ['child', 'parent']) + Book.objects.filter(slug='grandchild').update(preview=False) self.assert_slugs( '/api/filter-books/?audiobook=true', @@ -231,11 +234,6 @@ class BlogTests(ApiTest): self.assertEqual(self.load_json('/api/blog'), []) -class PreviewTests(ApiTest): - def unauth(self): - self.assert_json_response('/api/preview/', 'preview.json') - - class OAuth1Tests(ApiTest): @classmethod def setUpClass(cls): @@ -436,6 +434,8 @@ class AuthorizedTests(ApiTest): ['parent']) def test_subscription(self): + Book.objects.filter(slug='grandchild').update(preview=True) + self.assert_slugs('/api/preview/', ['grandchild']) self.assertEqual( self.signed_json('/api/username/'), @@ -454,6 +454,8 @@ class AuthorizedTests(ApiTest): self.signed('/api/epub/grandchild/').content, b"") + Book.objects.filter(slug='grandchild').update(preview=False) + def test_publish(self): response = self.signed('/api/books/', method='POST', diff --git a/src/catalogue/fixtures/test-books.yaml b/src/catalogue/fixtures/test-books.yaml index 42eefd761..fcb3617c5 100644 --- a/src/catalogue/fixtures/test-books.yaml +++ b/src/catalogue/fixtures/test-books.yaml @@ -32,16 +32,15 @@ fields: slug: grandchild title: Grandchild - preview: true sort_key: grandchild parent: 2 - xml_file: secret/grandchild.xml - txt_file: secret/grandchild.txt - html_file: secret/grandchild.html - epub_file: secret/grandchild.epub - mobi_file: secret/grandchild.mobi - pdf_file: secret/grandchild.pdf - fb2_file: secret/grandchild.fb2 + xml_file: xml/grandchild.xml + txt_file: txt/grandchild.txt + html_file: html/grandchild.html + epub_file: epub/grandchild.epub + mobi_file: mobi/grandchild.mobi + pdf_file: pdf/grandchild.pdf + fb2_file: fb2/grandchild.fb2 created_at: "1970-01-01 0:0Z" changed_at: "1970-01-01 0:0Z" diff --git a/src/catalogue/models/book.py b/src/catalogue/models/book.py index d47cb1520..af4c9410a 100644 --- a/src/catalogue/models/book.py +++ b/src/catalogue/models/book.py @@ -502,6 +502,7 @@ class Book(models.Model): tag.save() book.tags = set(meta_tags + book_shelves) + book.save() # update sort_key_author cover_changed = old_cover != book.cover_info() obsolete_children = set(b for b in book.children.all() @@ -553,7 +554,6 @@ class Book(models.Model): for child in notify_cover_changed: child.parent_cover_changed() - book.save() # update sort_key_author book.update_popularity() cls.published.send(sender=cls, instance=book) return book diff --git a/src/catalogue/test_utils.py b/src/catalogue/test_utils.py index dd5647a7d..ad3e49199 100644 --- a/src/catalogue/test_utils.py +++ b/src/catalogue/test_utils.py @@ -16,7 +16,7 @@ from django.conf import settings MEDIA_ROOT=tempfile.mkdtemp(prefix='djangotest_'), CATALOGUE_DONT_BUILD={'pdf', 'mobi', 'epub', 'txt', 'fb2', 'cover'}, NO_SEARCH_INDEX=True, - CELERY_ALWAYS_EAGER=True, + CELERY_TASK_ALWAYS_EAGER=True, CACHES={ 'default': {'BACKEND': 'django.core.cache.backends.dummy.DummyCache'}, }, diff --git a/src/catalogue/tests/test_book_import.py b/src/catalogue/tests/test_book_import.py index da5e58621..9fdb29889 100644 --- a/src/catalogue/tests/test_book_import.py +++ b/src/catalogue/tests/test_book_import.py @@ -36,6 +36,7 @@ class BookImportLogicTests(WLTestCase): def test_empty_book(self): book_text = "" book = models.Book.from_text_and_meta(ContentFile(book_text), self.book_info) + book.refresh_from_db() self.assertEqual(book.title, "Default Book") self.assertEqual(book.slug, "default-book") @@ -68,6 +69,7 @@ class BookImportLogicTests(WLTestCase): """ book = models.Book.from_text_and_meta(ContentFile(book_text), self.book_info) + book.refresh_from_db() self.assertTrue(book.has_html_file()) def test_book_with_fragment(self): @@ -78,6 +80,7 @@ class BookImportLogicTests(WLTestCase): """ book = models.Book.from_text_and_meta(ContentFile(book_text), self.book_info) + book.refresh_from_db() self.assertTrue(book.has_html_file()) self.assertEqual(book.fragments.count(), 1) diff --git a/src/wolnelektury/celery.py b/src/wolnelektury/celery.py index d1e18d7d6..23bf6dcb3 100644 --- a/src/wolnelektury/celery.py +++ b/src/wolnelektury/celery.py @@ -13,5 +13,5 @@ os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'wolnelektury.settings') app = Celery('wolnelektury') -app.config_from_object('django.conf:settings') +app.config_from_object('django.conf:settings', namespace='CELERY') app.autodiscover_tasks(lambda: settings.INSTALLED_APPS) diff --git a/src/wolnelektury/settings/apps.py b/src/wolnelektury/settings/apps.py index ba313f5c3..76ffa6f45 100644 --- a/src/wolnelektury/settings/apps.py +++ b/src/wolnelektury/settings/apps.py @@ -53,7 +53,6 @@ INSTALLED_APPS_CONTRIB = [ 'pipeline', 'piwik', 'sorl.thumbnail', - 'kombu.transport.django', 'honeypot', 'fnpdjango', 'getpaid', diff --git a/src/wolnelektury/settings/celery.py b/src/wolnelektury/settings/celery.py index e5c265c2e..1552bc0e0 100644 --- a/src/wolnelektury/settings/celery.py +++ b/src/wolnelektury/settings/celery.py @@ -1,9 +1,9 @@ -# -*- coding: utf-8 -*- # This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later. # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. # -BROKER_URL = 'django://' +CELERY_BROKER_URL = 'redis://' CELERY_EAGER_PROPAGATES_EXCEPTIONS = True CELERY_SEND_TASK_ERROR_EMAILS = True CELERY_ACCEPT_CONTENT = ['pickle'] +CELERY_TASK_SERIALIZER = 'pickle'