From e977f7187b10b1bc0a30794cd585c6b840568996 Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Sun, 22 Mar 2020 18:22:20 +0100 Subject: [PATCH] Rename catalogue to documents. --- src/catalogue/urls.py | 66 ------------------ src/cover/templates/cover/add_image.html | 2 +- src/cover/templates/cover/image_detail.html | 2 +- src/cover/templates/cover/image_list.html | 2 +- src/cover/views.py | 4 +- src/{catalogue => documents}/__init__.py | 0 src/{catalogue => documents}/admin.py | 3 +- src/{catalogue => documents}/constants.py | 0 src/{catalogue => documents}/ebook_utils.py | 2 +- src/{catalogue => documents}/feeds.py | 2 +- .../fixtures/stages.json | 18 ++--- src/{catalogue => documents}/forms.py | 5 +- src/{catalogue => documents}/helpers.py | 2 +- .../locale/pl/LC_MESSAGES/django.mo | Bin .../locale/pl/LC_MESSAGES/django.po | 0 .../management/__init__.py | 2 +- .../management/commands/__init__.py | 2 +- .../management/commands/add_parent.py | 2 +- .../management/commands/fixdc.py | 4 +- .../management/commands/import_wl.py | 2 +- .../management/commands/insert_isbn.py | 2 +- .../management/commands/mark_final.py | 2 +- .../management/commands/merge_books.py | 2 +- .../management/commands/prune_audience.py | 2 +- src/{catalogue => documents}/managers.py | 0 .../models/__init__.py | 13 ++-- src/{catalogue => documents}/models/book.py | 14 ++-- src/{catalogue => documents}/models/chunk.py | 6 +- src/{catalogue => documents}/models/image.py | 10 +-- .../models/listeners.py | 4 +- .../models/project.py | 2 +- .../models/publish_log.py | 8 +-- src/{catalogue => documents}/signals.py | 0 .../documents}/active_users_list.html | 2 +- .../templates/documents}/activity.html | 6 +- .../templates/documents}/base.html | 8 +-- .../templates/documents}/book_append_to.html | 2 +- .../templates/documents}/book_detail.html | 24 +++---- .../templates/documents}/book_edit.html | 2 +- .../templates/documents}/book_html.html | 0 .../templates/documents}/book_list/book.html | 8 +-- .../documents}/book_list/book_list.html | 6 +- .../templates/documents}/book_list/chunk.html | 4 +- .../templates/documents}/book_text.html | 0 .../templates/documents}/chunk_add.html | 2 +- .../templates/documents}/chunk_edit.html | 4 +- .../documents}/document_create_missing.html | 2 +- .../templates/documents}/document_list.html | 4 +- .../templates/documents}/document_upload.html | 2 +- .../templates/documents}/image_detail.html | 4 +- .../templates/documents}/image_list.html | 4 +- .../templates/documents}/image_short.html | 4 +- .../templates/documents}/image_table.html | 4 +- .../templates/documents}/main_tabs.html | 0 .../templates/documents}/mark_final.html | 4 +- .../documents}/mark_final_completed.html | 4 +- .../templates/documents}/my_page.html | 4 +- .../templates/documents}/upload_pdf.html | 2 +- .../templates/documents}/user_list.html | 4 +- .../templates/documents}/user_page.html | 4 +- .../templates/documents}/wall.html | 2 +- .../templatetags/__init__.py | 0 .../templatetags/book_list.py | 6 +- .../templatetags/common_tags.py | 0 .../templatetags/documents.py} | 20 +++--- .../templatetags/set_get_parameter.py | 0 .../templatetags/wall.py | 6 +- src/{catalogue => documents}/test_utils.py | 0 .../tests/__init__.py | 0 .../tests/files/chunk1.xml | 0 .../tests/files/chunk2.xml | 0 .../tests/files/expected.xml | 0 .../tests/test_book.py | 2 +- .../tests/test_gallery.py | 2 +- .../tests/test_publish.py | 4 +- .../tests/test_xml_updater.py | 6 +- src/documents/urls.py | 66 ++++++++++++++++++ src/{catalogue => documents}/views.py | 64 ++++++++--------- src/{catalogue => documents}/xml_tools.py | 2 +- .../templates/fileupload/picture_form.html | 2 +- src/redakcja/settings/__init__.py | 13 ++-- .../js/{catalogue => documents}/book_list.js | 0 .../catalogue.js => documents/documents.js} | 0 src/redakcja/templates/404.html | 4 +- .../templates/registration/login.html | 2 +- src/redakcja/urls.py | 2 +- src/wiki/forms.py | 2 +- .../templates/wiki/document_details_base.html | 2 +- src/wiki/views.py | 10 +-- src/wiki_img/forms.py | 2 +- .../wiki_img/document_details_base.html | 2 +- src/wiki_img/views.py | 8 +-- 92 files changed, 264 insertions(+), 264 deletions(-) delete mode 100644 src/catalogue/urls.py rename src/{catalogue => documents}/__init__.py (100%) rename src/{catalogue => documents}/admin.py (95%) rename src/{catalogue => documents}/constants.py (100%) rename src/{catalogue => documents}/ebook_utils.py (96%) rename src/{catalogue => documents}/feeds.py (96%) rename src/{catalogue => documents}/fixtures/stages.json (81%) rename src/{catalogue => documents}/forms.py (98%) rename src/{catalogue => documents}/helpers.py (98%) rename src/{catalogue => documents}/locale/pl/LC_MESSAGES/django.mo (100%) rename src/{catalogue => documents}/locale/pl/LC_MESSAGES/django.po (100%) rename src/{catalogue => documents}/management/__init__.py (98%) rename src/{catalogue => documents}/management/commands/__init__.py (97%) rename src/{catalogue => documents}/management/commands/add_parent.py (98%) rename src/{catalogue => documents}/management/commands/fixdc.py (94%) rename src/{catalogue => documents}/management/commands/import_wl.py (98%) rename src/{catalogue => documents}/management/commands/insert_isbn.py (99%) rename src/{catalogue => documents}/management/commands/mark_final.py (97%) rename src/{catalogue => documents}/management/commands/merge_books.py (99%) rename src/{catalogue => documents}/management/commands/prune_audience.py (98%) rename src/{catalogue => documents}/managers.py (100%) rename src/{catalogue => documents}/models/__init__.py (59%) rename src/{catalogue => documents}/models/book.py (97%) rename src/{catalogue => documents}/models/chunk.py (96%) rename src/{catalogue => documents}/models/image.py (95%) rename src/{catalogue => documents}/models/listeners.py (93%) rename src/{catalogue => documents}/models/project.py (95%) rename src/{catalogue => documents}/models/publish_log.py (93%) rename src/{catalogue => documents}/signals.py (100%) rename src/{catalogue/templates/catalogue => documents/templates/documents}/active_users_list.html (91%) rename src/{catalogue/templates/catalogue => documents/templates/documents}/activity.html (70%) rename src/{catalogue/templates/catalogue => documents/templates/documents}/base.html (92%) rename src/{catalogue/templates/catalogue => documents/templates/documents}/book_append_to.html (92%) rename src/{catalogue/templates/catalogue => documents/templates/documents}/book_detail.html (81%) rename src/{catalogue/templates/catalogue => documents/templates/documents}/book_edit.html (90%) rename src/{catalogue/templates/catalogue => documents/templates/documents}/book_html.html (100%) rename src/{catalogue/templates/catalogue => documents/templates/documents}/book_list/book.html (82%) rename src/{catalogue/templates/catalogue => documents/templates/documents}/book_list/book_list.html (96%) rename src/{catalogue/templates/catalogue => documents/templates/documents}/book_list/chunk.html (87%) rename src/{catalogue/templates/catalogue => documents/templates/documents}/book_text.html (100%) rename src/{catalogue/templates/catalogue => documents/templates/documents}/chunk_add.html (94%) rename src/{catalogue/templates/catalogue => documents/templates/documents}/chunk_edit.html (88%) rename src/{catalogue/templates/catalogue => documents/templates/documents}/document_create_missing.html (93%) rename src/{catalogue/templates/catalogue => documents/templates/documents}/document_list.html (88%) rename src/{catalogue/templates/catalogue => documents/templates/documents}/document_upload.html (98%) rename src/{catalogue/templates/catalogue => documents/templates/documents}/image_detail.html (95%) rename src/{catalogue/templates/catalogue => documents/templates/documents}/image_list.html (88%) rename src/{catalogue/templates/catalogue => documents/templates/documents}/image_short.html (89%) rename src/{catalogue/templates/catalogue => documents/templates/documents}/image_table.html (97%) rename src/{catalogue/templates/catalogue => documents/templates/documents}/main_tabs.html (100%) rename src/{catalogue/templates/catalogue => documents/templates/documents}/mark_final.html (78%) rename src/{catalogue/templates/catalogue => documents/templates/documents}/mark_final_completed.html (70%) rename src/{catalogue/templates/catalogue => documents/templates/documents}/my_page.html (95%) rename src/{catalogue/templates/catalogue => documents/templates/documents}/upload_pdf.html (90%) rename src/{catalogue/templates/catalogue => documents/templates/documents}/user_list.html (82%) rename src/{catalogue/templates/catalogue => documents/templates/documents}/user_page.html (86%) rename src/{catalogue/templates/catalogue => documents/templates/documents}/wall.html (94%) rename src/{catalogue => documents}/templatetags/__init__.py (100%) rename src/{catalogue => documents}/templatetags/book_list.py (97%) rename src/{catalogue => documents}/templatetags/common_tags.py (100%) rename src/{catalogue/templatetags/catalogue.py => documents/templatetags/documents.py} (56%) rename src/{catalogue => documents}/templatetags/set_get_parameter.py (100%) rename src/{catalogue => documents}/templatetags/wall.py (96%) rename src/{catalogue => documents}/test_utils.py (100%) rename src/{catalogue => documents}/tests/__init__.py (100%) rename src/{catalogue => documents}/tests/files/chunk1.xml (100%) rename src/{catalogue => documents}/tests/files/chunk2.xml (100%) rename src/{catalogue => documents}/tests/files/expected.xml (100%) rename src/{catalogue => documents}/tests/test_book.py (98%) rename src/{catalogue => documents}/tests/test_gallery.py (99%) rename src/{catalogue => documents}/tests/test_publish.py (94%) rename src/{catalogue => documents}/tests/test_xml_updater.py (89%) create mode 100644 src/documents/urls.py rename src/{catalogue => documents}/views.py (91%) rename src/{catalogue => documents}/xml_tools.py (98%) rename src/redakcja/static/js/{catalogue => documents}/book_list.js (100%) rename src/redakcja/static/js/{catalogue/catalogue.js => documents/documents.js} (100%) diff --git a/src/catalogue/urls.py b/src/catalogue/urls.py deleted file mode 100644 index 2cebacf0..00000000 --- a/src/catalogue/urls.py +++ /dev/null @@ -1,66 +0,0 @@ -# This file is part of FNP-Redakcja, licensed under GNU Affero GPLv3 or later. -# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. -# -from django.conf.urls import url -from django.contrib.auth.decorators import permission_required -from django.views.generic import RedirectView -from catalogue.feeds import PublishTrackFeed -from . import views - - -urlpatterns = [ - url(r'^$', RedirectView.as_view(url='catalogue/', permanent=False)), - - url(r'^images/$', views.image_list, name='catalogue_image_list'), - url(r'^image/(?P[^/]+)/$', views.image, name="catalogue_image"), - url(r'^image/(?P[^/]+)/publish$', views.publish_image, - name="catalogue_publish_image"), - - url(r'^catalogue/$', views.document_list, name='catalogue_document_list'), - url(r'^user/$', views.my, name='catalogue_user'), - url(r'^user/(?P[^/]+)/$', views.user, name='catalogue_user'), - url(r'^users/$', views.users, name='catalogue_users'), - url(r'^activity/$', views.activity, name='catalogue_activity'), - url(r'^activity/(?P\d{4}-\d{2}-\d{2})/$', - views.activity, name='catalogue_activity'), - - url(r'^upload/$', - views.upload, name='catalogue_upload'), - - url(r'^create/(?P[^/]*)/', - views.create_missing, name='catalogue_create_missing'), - url(r'^create/', - views.create_missing, name='catalogue_create_missing'), - - url(r'^book/(?P[^/]+)/publish$', views.publish, name="catalogue_publish"), - - url(r'^book/(?P[^/]+)/$', views.book, name="catalogue_book"), - url(r'^book/(?P[^/]+)/gallery/$', - permission_required('catalogue.change_book')(views.GalleryView.as_view()), - name="catalogue_book_gallery"), - url(r'^book/(?P[^/]+)/xml$', views.book_xml, name="catalogue_book_xml"), - url(r'^book/dc/(?P[^/]+)/xml$', views.book_xml_dc, name="catalogue_book_xml_dc"), - url(r'^book/(?P[^/]+)/txt$', views.book_txt, name="catalogue_book_txt"), - url(r'^book/(?P[^/]+)/html$', views.book_html, name="catalogue_book_html"), - url(r'^book/(?P[^/]+)/epub$', views.book_epub, name="catalogue_book_epub"), - url(r'^book/(?P[^/]+)/mobi$', views.book_mobi, name="catalogue_book_mobi"), - url(r'^book/(?P[^/]+)/pdf$', views.book_pdf, name="catalogue_book_pdf"), - url(r'^book/(?P[^/]+)/pdf-mobile$', views.book_pdf, kwargs={'mobile': True}, name="catalogue_book_pdf_mobile"), - - url(r'^chunk_add/(?P[^/]+)/(?P[^/]+)/$', - views.chunk_add, name="catalogue_chunk_add"), - url(r'^chunk_edit/(?P[^/]+)/(?P[^/]+)/$', - views.chunk_edit, name="catalogue_chunk_edit"), - url(r'^book_append/(?P[^/]+)/$', - views.book_append, name="catalogue_book_append"), - url(r'^chunk_mass_edit', - views.chunk_mass_edit, name='catalogue_chunk_mass_edit'), - url(r'^image_mass_edit', - views.image_mass_edit, name='catalogue_image_mass_edit'), - - url(r'^track/(?P[^/]*)/$', PublishTrackFeed()), - url(r'^active/$', views.active_users_list, name='active_users_list'), - - url(r'^mark-final/$', views.mark_final, name='mark_final'), - url(r'^mark-final-completed/$', views.mark_final_completed, name='mark_final_completed'), -] diff --git a/src/cover/templates/cover/add_image.html b/src/cover/templates/cover/add_image.html index ba981844..56f5665e 100644 --- a/src/cover/templates/cover/add_image.html +++ b/src/cover/templates/cover/add_image.html @@ -1,4 +1,4 @@ -{% extends "catalogue/base.html" %} +{% extends "documents/base.html" %} {% load i18n %} {% load bootstrap4 %} diff --git a/src/cover/templates/cover/image_detail.html b/src/cover/templates/cover/image_detail.html index db9b176f..670b3ce5 100644 --- a/src/cover/templates/cover/image_detail.html +++ b/src/cover/templates/cover/image_detail.html @@ -1,4 +1,4 @@ -{% extends "catalogue/base.html" %} +{% extends "documents/base.html" %} {% load i18n %} {% load thumbnail %} {% load build_absolute_uri from fnp_common %} diff --git a/src/cover/templates/cover/image_list.html b/src/cover/templates/cover/image_list.html index 87971df2..2d5608c0 100644 --- a/src/cover/templates/cover/image_list.html +++ b/src/cover/templates/cover/image_list.html @@ -1,4 +1,4 @@ -{% extends "catalogue/base.html" %} +{% extends "documents/base.html" %} {% load i18n %} {% load thumbnail pagination_tags %} diff --git a/src/cover/views.py b/src/cover/views.py index b1261e6d..bfc3ee33 100644 --- a/src/cover/views.py +++ b/src/cover/views.py @@ -8,8 +8,8 @@ from django.http import HttpResponse, HttpResponseRedirect, Http404 from django.shortcuts import get_object_or_404, render from django.views.decorators.csrf import csrf_exempt from django.views.decorators.http import require_POST -from catalogue.helpers import active_tab -from catalogue.models import Chunk +from documents.helpers import active_tab +from documents.models import Chunk from cover.models import Image from cover import forms diff --git a/src/catalogue/__init__.py b/src/documents/__init__.py similarity index 100% rename from src/catalogue/__init__.py rename to src/documents/__init__.py diff --git a/src/catalogue/admin.py b/src/documents/admin.py similarity index 95% rename from src/catalogue/admin.py rename to src/documents/admin.py index 8daad6e0..b793303d 100644 --- a/src/catalogue/admin.py +++ b/src/documents/admin.py @@ -2,8 +2,7 @@ # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. # from django.contrib import admin - -from catalogue import models +from . import models class BookAdmin(admin.ModelAdmin): list_display = ['title', 'public', '_published', '_new_publishable', 'project'] diff --git a/src/catalogue/constants.py b/src/documents/constants.py similarity index 100% rename from src/catalogue/constants.py rename to src/documents/constants.py diff --git a/src/catalogue/ebook_utils.py b/src/documents/ebook_utils.py similarity index 96% rename from src/catalogue/ebook_utils.py rename to src/documents/ebook_utils.py index f9bd6d37..e75ed777 100644 --- a/src/catalogue/ebook_utils.py +++ b/src/documents/ebook_utils.py @@ -2,7 +2,7 @@ # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. # from io import BytesIO -from catalogue.models import Book +from .models import Book from librarian import DocProvider from django.http import HttpResponse diff --git a/src/catalogue/feeds.py b/src/documents/feeds.py similarity index 96% rename from src/catalogue/feeds.py rename to src/documents/feeds.py index 99808bc6..bf9f2dbf 100644 --- a/src/catalogue/feeds.py +++ b/src/documents/feeds.py @@ -3,7 +3,7 @@ # from django.contrib.syndication.views import Feed from django.shortcuts import get_object_or_404 -from catalogue.models import Book, Chunk +from .models import Book, Chunk class PublishTrackFeed(Feed): diff --git a/src/catalogue/fixtures/stages.json b/src/documents/fixtures/stages.json similarity index 81% rename from src/catalogue/fixtures/stages.json rename to src/documents/fixtures/stages.json index 5a46ec04..11456691 100644 --- a/src/catalogue/fixtures/stages.json +++ b/src/documents/fixtures/stages.json @@ -1,7 +1,7 @@ [ { "pk": 1, - "model": "catalogue.chunktag", + "model": "documents.chunktag", "fields": { "ordering": 1, "name": "Autokorekta", @@ -10,7 +10,7 @@ }, { "pk": 2, - "model": "catalogue.chunktag", + "model": "documents.chunktag", "fields": { "ordering": 2, "name": "Tagowanie", @@ -19,7 +19,7 @@ }, { "pk": 3, - "model": "catalogue.chunktag", + "model": "documents.chunktag", "fields": { "ordering": 3, "name": "Korekta", @@ -28,7 +28,7 @@ }, { "pk": 4, - "model": "catalogue.chunktag", + "model": "documents.chunktag", "fields": { "ordering": 4, "name": "Sprawdzenie przypis\u00f3w \u017ar\u00f3d\u0142a", @@ -37,7 +37,7 @@ }, { "pk": 5, - "model": "catalogue.chunktag", + "model": "documents.chunktag", "fields": { "ordering": 5, "name": "Uwsp\u00f3\u0142cze\u015bnienie", @@ -46,7 +46,7 @@ }, { "pk": 6, - "model": "catalogue.chunktag", + "model": "documents.chunktag", "fields": { "ordering": 6, "name": "Przypisy", @@ -55,7 +55,7 @@ }, { "pk": 7, - "model": "catalogue.chunktag", + "model": "documents.chunktag", "fields": { "ordering": 7, "name": "Motywy", @@ -64,7 +64,7 @@ }, { "pk": 8, - "model": "catalogue.chunktag", + "model": "documents.chunktag", "fields": { "ordering": 8, "name": "Ostateczna redakcja literacka", @@ -73,7 +73,7 @@ }, { "pk": 9, - "model": "catalogue.chunktag", + "model": "documents.chunktag", "fields": { "ordering": 9, "name": "Ostateczna redakcja techniczna", diff --git a/src/catalogue/forms.py b/src/documents/forms.py similarity index 98% rename from src/catalogue/forms.py rename to src/documents/forms.py index e61a1b71..f5f2901d 100644 --- a/src/catalogue/forms.py +++ b/src/documents/forms.py @@ -1,14 +1,13 @@ # This file is part of FNP-Redakcja, licensed under GNU Affero GPLv3 or later. # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. # -from catalogue.models import User from django.db.models import Count from django import forms from django.utils.translation import ugettext_lazy as _ from django.conf import settings -from catalogue.constants import MASTERS -from catalogue.models import Book, Chunk, Image +from .constants import MASTERS +from .models import Book, Chunk, Image, User class DocumentCreateForm(forms.ModelForm): """ diff --git a/src/catalogue/helpers.py b/src/documents/helpers.py similarity index 98% rename from src/catalogue/helpers.py rename to src/documents/helpers.py index 59545031..df15b91d 100644 --- a/src/catalogue/helpers.py +++ b/src/documents/helpers.py @@ -20,7 +20,7 @@ def active_tab(tab): def wrapper(f): @wraps(f) def wrapped(request, *args, **kwargs): - request.catalogue_active_tab = tab + request.documents_active_tab = tab return f(request, *args, **kwargs) return wrapped return wrapper diff --git a/src/catalogue/locale/pl/LC_MESSAGES/django.mo b/src/documents/locale/pl/LC_MESSAGES/django.mo similarity index 100% rename from src/catalogue/locale/pl/LC_MESSAGES/django.mo rename to src/documents/locale/pl/LC_MESSAGES/django.mo diff --git a/src/catalogue/locale/pl/LC_MESSAGES/django.po b/src/documents/locale/pl/LC_MESSAGES/django.po similarity index 100% rename from src/catalogue/locale/pl/LC_MESSAGES/django.po rename to src/documents/locale/pl/LC_MESSAGES/django.po diff --git a/src/catalogue/management/__init__.py b/src/documents/management/__init__.py similarity index 98% rename from src/catalogue/management/__init__.py rename to src/documents/management/__init__.py index 6f6f6b6e..8c38828d 100644 --- a/src/catalogue/management/__init__.py +++ b/src/documents/management/__init__.py @@ -94,7 +94,7 @@ class XmlUpdater(object): def run(self, user, verbose=0, dry_run=False, books=None): """Runs the actual update.""" if books is None: - from catalogue.models import Book + from documents.models import Book books = Book.objects.all() # Start transaction management. diff --git a/src/catalogue/management/commands/__init__.py b/src/documents/management/commands/__init__.py similarity index 97% rename from src/catalogue/management/commands/__init__.py rename to src/documents/management/commands/__init__.py index 6e450663..22469b98 100644 --- a/src/catalogue/management/commands/__init__.py +++ b/src/documents/management/commands/__init__.py @@ -4,7 +4,7 @@ import sys from django.contrib.auth.models import User from django.core.management.base import BaseCommand -from catalogue.models import Book +from documents.models import Book class XmlUpdaterCommand(BaseCommand): diff --git a/src/catalogue/management/commands/add_parent.py b/src/documents/management/commands/add_parent.py similarity index 98% rename from src/catalogue/management/commands/add_parent.py rename to src/documents/management/commands/add_parent.py index 49dff284..59767bf6 100644 --- a/src/catalogue/management/commands/add_parent.py +++ b/src/documents/management/commands/add_parent.py @@ -8,7 +8,7 @@ from lxml import etree from django.core.management import BaseCommand -from catalogue.models import Book +from documents.models import Book from librarian import RDFNS, DCNS TEMPLATE = ''' diff --git a/src/catalogue/management/commands/fixdc.py b/src/documents/management/commands/fixdc.py similarity index 94% rename from src/catalogue/management/commands/fixdc.py rename to src/documents/management/commands/fixdc.py index cd691723..3f4a848e 100644 --- a/src/catalogue/management/commands/fixdc.py +++ b/src/documents/management/commands/fixdc.py @@ -3,8 +3,8 @@ # from librarian import RDFNS, WLURI, ValidationError from librarian.dcparser import BookInfo -from catalogue.management import XmlUpdater -from catalogue.management.commands import XmlUpdaterCommand +from documents.management import XmlUpdater +from documents.management.commands import XmlUpdaterCommand class FixDC(XmlUpdater): diff --git a/src/catalogue/management/commands/import_wl.py b/src/documents/management/commands/import_wl.py similarity index 98% rename from src/catalogue/management/commands/import_wl.py rename to src/documents/management/commands/import_wl.py index bb891edd..299d4c54 100644 --- a/src/catalogue/management/commands/import_wl.py +++ b/src/documents/management/commands/import_wl.py @@ -11,7 +11,7 @@ from django.db import transaction from librarian.dcparser import BookInfo from librarian import ParseError, ValidationError -from catalogue.models import Book +from documents.models import Book WL_API = 'http://www.wolnelektury.pl/api/books/' diff --git a/src/catalogue/management/commands/insert_isbn.py b/src/documents/management/commands/insert_isbn.py similarity index 99% rename from src/catalogue/management/commands/insert_isbn.py rename to src/documents/management/commands/insert_isbn.py index 5bacb4bd..536d30ff 100644 --- a/src/catalogue/management/commands/insert_isbn.py +++ b/src/documents/management/commands/insert_isbn.py @@ -9,7 +9,7 @@ from lxml import etree from collections import defaultdict from django.core.management import BaseCommand -from catalogue.models import Book +from documents.models import Book from librarian import RDFNS, DCNS CONTENT_TYPES = { diff --git a/src/catalogue/management/commands/mark_final.py b/src/documents/management/commands/mark_final.py similarity index 97% rename from src/catalogue/management/commands/mark_final.py rename to src/documents/management/commands/mark_final.py index 11d63a3c..b2c316c9 100644 --- a/src/catalogue/management/commands/mark_final.py +++ b/src/documents/management/commands/mark_final.py @@ -5,7 +5,7 @@ import sys from django.contrib.auth.models import User from django.core.management import BaseCommand -from catalogue.models import Book, Chunk +from documents.models import Book, Chunk class Command(BaseCommand): diff --git a/src/catalogue/management/commands/merge_books.py b/src/documents/management/commands/merge_books.py similarity index 99% rename from src/catalogue/management/commands/merge_books.py rename to src/documents/management/commands/merge_books.py index cebf73bc..5dc6cb01 100644 --- a/src/catalogue/management/commands/merge_books.py +++ b/src/documents/management/commands/merge_books.py @@ -8,7 +8,7 @@ from django.core.management.base import BaseCommand from django.core.management.color import color_style from django.db import transaction -from catalogue.models import Book +from documents.models import Book def common_prefix(texts): diff --git a/src/catalogue/management/commands/prune_audience.py b/src/documents/management/commands/prune_audience.py similarity index 98% rename from src/catalogue/management/commands/prune_audience.py rename to src/documents/management/commands/prune_audience.py index a271e329..743a58a9 100644 --- a/src/catalogue/management/commands/prune_audience.py +++ b/src/documents/management/commands/prune_audience.py @@ -7,7 +7,7 @@ from lxml import etree from django.core.management import BaseCommand -from catalogue.models import Book +from documents.models import Book from librarian import DCNS diff --git a/src/catalogue/managers.py b/src/documents/managers.py similarity index 100% rename from src/catalogue/managers.py rename to src/documents/managers.py diff --git a/src/catalogue/models/__init__.py b/src/documents/models/__init__.py similarity index 59% rename from src/catalogue/models/__init__.py rename to src/documents/models/__init__.py index 86be6bc6..48b6d070 100644 --- a/src/catalogue/models/__init__.py +++ b/src/documents/models/__init__.py @@ -1,16 +1,17 @@ # This file is part of FNP-Redakcja, licensed under GNU Affero GPLv3 or later. # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. # -from catalogue.models.project import Project -from catalogue.models.chunk import Chunk -from catalogue.models.image import Image -from catalogue.models.publish_log import (BookPublishRecord, +from .project import Project +from .chunk import Chunk +from .image import Image +from .publish_log import (BookPublishRecord, ChunkPublishRecord, ImagePublishRecord) -from catalogue.models.book import Book -from catalogue.models.listeners import * +from .book import Book +from .listeners import * from django.contrib.auth.models import User as AuthUser + class User(AuthUser): class Meta: proxy = True diff --git a/src/catalogue/models/book.py b/src/documents/models/book.py similarity index 97% rename from src/catalogue/models/book.py rename to src/documents/models/book.py index fc0e18f6..e7c34814 100644 --- a/src/catalogue/models/book.py +++ b/src/documents/models/book.py @@ -11,10 +11,10 @@ from slugify import slugify import apiclient -from catalogue.helpers import cached_in_field, GalleryMerger -from catalogue.models import BookPublishRecord, ChunkPublishRecord, Project -from catalogue.signals import post_publish -from catalogue.xml_tools import compile_text, split_xml +from documents.helpers import cached_in_field, GalleryMerger +from documents.models import BookPublishRecord, ChunkPublishRecord, Project +from documents.signals import post_publish +from documents.xml_tools import compile_text, split_xml from cover.models import Image import os import shutil @@ -47,7 +47,7 @@ class Book(models.Model): pass class Meta: - app_label = 'catalogue' + app_label = 'documents' ordering = ['title', 'slug'] verbose_name = _('book') verbose_name_plural = _('books') @@ -75,7 +75,7 @@ class Book(models.Model): return self.title def get_absolute_url(self): - return reverse("catalogue_book", args=[self.slug]) + return reverse("documents_book", args=[self.slug]) def correct_about(self): return "http://%s%s" % ( @@ -394,7 +394,7 @@ class Book(models.Model): def wldocument(self, publishable=True, changes=None, parse_dublincore=True, strict=False): - from catalogue.ebook_utils import RedakcjaDocProvider + from documents.ebook_utils import RedakcjaDocProvider from librarian.parser import WLDocument return WLDocument.from_bytes( diff --git a/src/catalogue/models/chunk.py b/src/documents/models/chunk.py similarity index 96% rename from src/catalogue/models/chunk.py rename to src/documents/models/chunk.py index b3e6acaa..39a20871 100644 --- a/src/catalogue/models/chunk.py +++ b/src/documents/models/chunk.py @@ -7,8 +7,8 @@ from django.db.utils import IntegrityError from django.template.loader import render_to_string from django.urls import reverse from django.utils.translation import ugettext_lazy as _ -from catalogue.helpers import cached_in_field -from catalogue.managers import VisibleManager +from documents.helpers import cached_in_field +from documents.managers import VisibleManager from dvcs import models as dvcs_models @@ -32,7 +32,7 @@ class Chunk(dvcs_models.Document): visible_objects = VisibleManager() class Meta: - app_label = 'catalogue' + app_label = 'documents' unique_together = [['book', 'number'], ['book', 'slug']] ordering = ['number'] verbose_name = _('chunk') diff --git a/src/catalogue/models/image.py b/src/documents/models/image.py similarity index 95% rename from src/catalogue/models/image.py rename to src/documents/models/image.py index becc308b..10782dcf 100644 --- a/src/catalogue/models/image.py +++ b/src/documents/models/image.py @@ -7,8 +7,8 @@ from django.db import models from django.template.loader import render_to_string from django.urls import reverse from django.utils.translation import ugettext_lazy as _ -from catalogue.helpers import cached_in_field -from catalogue.models import Project +from documents.helpers import cached_in_field +from documents.models import Project from dvcs import models as dvcs_models @@ -28,7 +28,7 @@ class Image(dvcs_models.Document): _changed = models.NullBooleanField(editable=False) class Meta: - app_label = 'catalogue' + app_label = 'documents' ordering = ['title'] verbose_name = _('image') verbose_name_plural = _('images') @@ -41,7 +41,7 @@ class Image(dvcs_models.Document): return self.title def get_absolute_url(self): - return reverse("catalogue_image", args=[self.slug]) + return reverse("documents_image", args=[self.slug]) def correct_about(self): return ["http://%s%s" % ( @@ -133,7 +133,7 @@ class Image(dvcs_models.Document): """Publishes the picture on behalf of a (local) user.""" from base64 import b64encode import apiclient - from catalogue.signals import post_publish + from documents.signals import post_publish self.assert_publishable() change = self.publishable() diff --git a/src/catalogue/models/listeners.py b/src/documents/models/listeners.py similarity index 93% rename from src/catalogue/models/listeners.py rename to src/documents/models/listeners.py index 0c0663c9..d306e4e9 100644 --- a/src/catalogue/models/listeners.py +++ b/src/documents/models/listeners.py @@ -3,9 +3,9 @@ # from django.contrib.auth.models import User from django.db import models -from catalogue.models import (Book, Chunk, Image, BookPublishRecord, +from documents.models import (Book, Chunk, Image, BookPublishRecord, ImagePublishRecord) -from catalogue.signals import post_publish +from documents.signals import post_publish from dvcs.signals import post_publishable diff --git a/src/catalogue/models/project.py b/src/documents/models/project.py similarity index 95% rename from src/catalogue/models/project.py rename to src/documents/models/project.py index caea8b80..f0ac752f 100644 --- a/src/catalogue/models/project.py +++ b/src/documents/models/project.py @@ -12,7 +12,7 @@ class Project(models.Model): notes = models.TextField(_('notes'), blank=True, null=True) class Meta: - app_label = 'catalogue' + app_label = 'documents' ordering = ['name'] verbose_name = _('project') verbose_name_plural = _('projects') diff --git a/src/catalogue/models/publish_log.py b/src/documents/models/publish_log.py similarity index 93% rename from src/catalogue/models/publish_log.py rename to src/documents/models/publish_log.py index eeec055e..5322bb62 100644 --- a/src/catalogue/models/publish_log.py +++ b/src/documents/models/publish_log.py @@ -4,7 +4,7 @@ from django.contrib.auth.models import User from django.db import models from django.utils.translation import ugettext_lazy as _ -from catalogue.models import Chunk, Image +from documents.models import Chunk, Image class BookPublishRecord(models.Model): @@ -17,7 +17,7 @@ class BookPublishRecord(models.Model): user = models.ForeignKey(User, models.CASCADE, verbose_name=_('user')) class Meta: - app_label = 'catalogue' + app_label = 'documents' ordering = ['-timestamp'] verbose_name = _('book publish record') verbose_name_plural = _('book publish records') @@ -32,7 +32,7 @@ class ChunkPublishRecord(models.Model): change = models.ForeignKey(Chunk.change_model, models.CASCADE, related_name='publish_log', verbose_name=_('change')) class Meta: - app_label = 'catalogue' + app_label = 'documents' verbose_name = _('chunk publish record') verbose_name_plural = _('chunk publish records') @@ -46,7 +46,7 @@ class ImagePublishRecord(models.Model): change = models.ForeignKey(Image.change_model, models.CASCADE, related_name='publish_log', verbose_name=_('change')) class Meta: - app_label = 'catalogue' + app_label = 'documents' ordering = ['-timestamp'] verbose_name = _('image publish record') verbose_name_plural = _('image publish records') diff --git a/src/catalogue/signals.py b/src/documents/signals.py similarity index 100% rename from src/catalogue/signals.py rename to src/documents/signals.py diff --git a/src/catalogue/templates/catalogue/active_users_list.html b/src/documents/templates/documents/active_users_list.html similarity index 91% rename from src/catalogue/templates/catalogue/active_users_list.html rename to src/documents/templates/documents/active_users_list.html index 3741b412..ef9532fc 100644 --- a/src/catalogue/templates/catalogue/active_users_list.html +++ b/src/documents/templates/documents/active_users_list.html @@ -1,4 +1,4 @@ -{% extends "catalogue/base.html" %} +{% extends "documents/base.html" %} {% load i18n %} diff --git a/src/catalogue/templates/catalogue/activity.html b/src/documents/templates/documents/activity.html similarity index 70% rename from src/catalogue/templates/catalogue/activity.html rename to src/documents/templates/documents/activity.html index 0ab5c0de..e99ee189 100644 --- a/src/catalogue/templates/catalogue/activity.html +++ b/src/documents/templates/documents/activity.html @@ -1,4 +1,4 @@ -{% extends "catalogue/base.html" %} +{% extends "documents/base.html" %} {% load i18n %} {% load wall %} @@ -11,10 +11,10 @@

- < + < {% trans "Activity" %}: {{ day }} {% if next_day %} - > + > {% endif %}

diff --git a/src/catalogue/templates/catalogue/base.html b/src/documents/templates/documents/base.html similarity index 92% rename from src/catalogue/templates/catalogue/base.html rename to src/documents/templates/documents/base.html index c35e5395..81af8933 100644 --- a/src/catalogue/templates/catalogue/base.html +++ b/src/documents/templates/documents/base.html @@ -1,14 +1,14 @@ {% load pipeline i18n %} {% load static %} -{% load catalogue %} +{% load documents %} - {% stylesheet 'catalogue' %} + {% stylesheet 'documents' %} {% block title %}{% block titleextra %}{% endblock %} :: {% trans "Platforma Redakcyjna" %}{% endblock title %} {% block add_css %}{% endblock %} @@ -18,7 +18,7 @@
@@ -43,7 +43,7 @@ {% for chunk in book %} - {% include 'catalogue/book_list/chunk.html' %} + {% include 'documents/book_list/chunk.html' %} {% endfor %}
@@ -83,13 +83,13 @@ Okładka w rozmiarze {% if publishable %}

- {% trans "Full XML" %}
- {% trans "HTML version" %}
- {% trans "TXT version" %}
- {% trans "PDF version" %}
- {% trans "PDF version for mobiles" %}
- {% trans "EPUB version" %}
- {% trans "MOBI version" %}
+ {% trans "Full XML" %}
+ {% trans "HTML version" %}
+ {% trans "TXT version" %}
+ {% trans "PDF version" %}
+ {% trans "PDF version for mobiles" %}
+ {% trans "EPUB version" %}
+ {% trans "MOBI version" %}

{% if user.is_authenticated %} @@ -99,7 +99,7 @@ Okładka w rozmiarze mira66 (http://www.flickr.com/photos/21804434@N02/) / CC BY 2.0 (http://creativecommons.org/licenses/by/2.0/) --> -
{% csrf_token %} + {% csrf_token %} {{ publish_options_form.as_p }}
diff --git a/src/catalogue/templates/catalogue/image_list.html b/src/documents/templates/documents/image_list.html similarity index 88% rename from src/catalogue/templates/catalogue/image_list.html rename to src/documents/templates/documents/image_list.html index d1c0d951..a33921a7 100644 --- a/src/catalogue/templates/catalogue/image_list.html +++ b/src/documents/templates/documents/image_list.html @@ -1,7 +1,7 @@ -{% extends "catalogue/base.html" %} +{% extends "documents/base.html" %} {% load i18n %} -{% load catalogue book_list %} +{% load documents book_list %} {% load pipeline %} diff --git a/src/catalogue/templates/catalogue/image_short.html b/src/documents/templates/documents/image_short.html similarity index 89% rename from src/catalogue/templates/catalogue/image_short.html rename to src/documents/templates/documents/image_short.html index c00481ec..c10c7f0a 100644 --- a/src/catalogue/templates/catalogue/image_short.html +++ b/src/documents/templates/documents/image_short.html @@ -3,7 +3,7 @@ - 🖼 + 🖼 {{ image.title }} @@ -11,7 +11,7 @@ {{ image.stage }} {% else %}– {% endif %} - {% if image.user %}{{ image.user|username }}{% endif %} + {% if image.user %}{{ image.user|username }}{% endif %} {% if image.published %} opubl. diff --git a/src/catalogue/templates/catalogue/image_table.html b/src/documents/templates/documents/image_table.html similarity index 97% rename from src/catalogue/templates/catalogue/image_table.html rename to src/documents/templates/documents/image_table.html index 4f0a4250..77a71883 100644 --- a/src/catalogue/templates/catalogue/image_table.html +++ b/src/documents/templates/documents/image_table.html @@ -71,7 +71,7 @@ {% autopaginate objects 100 as objects_page %} {% for image in objects_page %} - {% include 'catalogue/image_short.html' %} + {% include 'documents/image_short.html' %} {% endfor %} @@ -81,7 +81,7 @@

{% trans "No images found." %}

{% endif %} - + {% csrf_token %} diff --git a/src/catalogue/templates/catalogue/main_tabs.html b/src/documents/templates/documents/main_tabs.html similarity index 100% rename from src/catalogue/templates/catalogue/main_tabs.html rename to src/documents/templates/documents/main_tabs.html diff --git a/src/catalogue/templates/catalogue/mark_final.html b/src/documents/templates/documents/mark_final.html similarity index 78% rename from src/catalogue/templates/catalogue/mark_final.html rename to src/documents/templates/documents/mark_final.html index 9ed740c0..3e71978c 100644 --- a/src/catalogue/templates/catalogue/mark_final.html +++ b/src/documents/templates/documents/mark_final.html @@ -1,4 +1,4 @@ -{% extends "catalogue/base.html" %} +{% extends "documents/base.html" %} {% block titleextra %}Oznacz książki{% endblock %} @@ -13,4 +13,4 @@ -{% endblock leftcolumn %} \ No newline at end of file +{% endblock leftcolumn %} diff --git a/src/catalogue/templates/catalogue/mark_final_completed.html b/src/documents/templates/documents/mark_final_completed.html similarity index 70% rename from src/catalogue/templates/catalogue/mark_final_completed.html rename to src/documents/templates/documents/mark_final_completed.html index 1b37c836..b05637ab 100644 --- a/src/catalogue/templates/catalogue/mark_final_completed.html +++ b/src/documents/templates/documents/mark_final_completed.html @@ -1,4 +1,4 @@ -{% extends "catalogue/base.html" %} +{% extends "documents/base.html" %} {% block titleextra %}Oznaczono książki{% endblock %} @@ -9,4 +9,4 @@

Książki zostały oznaczone.

-{% endblock leftcolumn %} \ No newline at end of file +{% endblock leftcolumn %} diff --git a/src/catalogue/templates/catalogue/my_page.html b/src/documents/templates/documents/my_page.html similarity index 95% rename from src/catalogue/templates/catalogue/my_page.html rename to src/documents/templates/documents/my_page.html index 2fec0a34..6828706a 100644 --- a/src/catalogue/templates/catalogue/my_page.html +++ b/src/documents/templates/documents/my_page.html @@ -1,7 +1,7 @@ -{% extends "catalogue/base.html" %} +{% extends "documents/base.html" %} {% load i18n %} -{% load catalogue book_list wall %} +{% load documents book_list wall %} {% load pipeline %} {% block add_js %} diff --git a/src/catalogue/templates/catalogue/upload_pdf.html b/src/documents/templates/documents/upload_pdf.html similarity index 90% rename from src/catalogue/templates/catalogue/upload_pdf.html rename to src/documents/templates/documents/upload_pdf.html index 265b84ad..ea74e922 100644 --- a/src/catalogue/templates/catalogue/upload_pdf.html +++ b/src/documents/templates/documents/upload_pdf.html @@ -1,4 +1,4 @@ -{% extends "catalogue/base.html" %} +{% extends "documents/base.html" %} {% load i18n %} diff --git a/src/catalogue/templates/catalogue/user_list.html b/src/documents/templates/documents/user_list.html similarity index 82% rename from src/catalogue/templates/catalogue/user_list.html rename to src/documents/templates/documents/user_list.html index b0607fa4..f0e9ab25 100644 --- a/src/catalogue/templates/catalogue/user_list.html +++ b/src/documents/templates/documents/user_list.html @@ -1,4 +1,4 @@ -{% extends "catalogue/base.html" %} +{% extends "documents/base.html" %} {% load i18n %} {% load username from common_tags %} @@ -17,7 +17,7 @@
    {% for user in users %} -
  • +
  • {{ forloop.counter }}. {{ user|username }} ({{ user.count }})
  • diff --git a/src/catalogue/templates/catalogue/user_page.html b/src/documents/templates/documents/user_page.html similarity index 86% rename from src/catalogue/templates/catalogue/user_page.html rename to src/documents/templates/documents/user_page.html index 85f30617..3be2c57c 100644 --- a/src/catalogue/templates/catalogue/user_page.html +++ b/src/documents/templates/documents/user_page.html @@ -1,7 +1,7 @@ -{% extends "catalogue/base.html" %} +{% extends "documents/base.html" %} {% load i18n %} -{% load catalogue book_list wall %} +{% load documents book_list wall %} {% block titleextra %}{{ viewed_user|nice_name }}{% endblock %} diff --git a/src/catalogue/templates/catalogue/wall.html b/src/documents/templates/documents/wall.html similarity index 94% rename from src/catalogue/templates/catalogue/wall.html rename to src/documents/templates/documents/wall.html index a107dfa8..5e2ed9a0 100644 --- a/src/catalogue/templates/catalogue/wall.html +++ b/src/documents/templates/documents/wall.html @@ -19,7 +19,7 @@ {{ item.title }}
    {% trans "user" %}: {% if item.user %} - + {{ item.user|username }} <{{ item.user.email|email_link }}> {% else %} diff --git a/src/catalogue/templatetags/__init__.py b/src/documents/templatetags/__init__.py similarity index 100% rename from src/catalogue/templatetags/__init__.py rename to src/documents/templatetags/__init__.py diff --git a/src/catalogue/templatetags/book_list.py b/src/documents/templatetags/book_list.py similarity index 97% rename from src/catalogue/templatetags/book_list.py rename to src/documents/templatetags/book_list.py index db24c695..acd22083 100644 --- a/src/catalogue/templatetags/book_list.py +++ b/src/documents/templatetags/book_list.py @@ -6,7 +6,7 @@ from django.db.models import Q, Count from django import template from django.utils.translation import ugettext_lazy as _ from django.contrib.auth.models import User -from catalogue.models import Chunk, Image, Project +from documents.models import Chunk, Image, Project register = template.Library() @@ -113,7 +113,7 @@ def document_list_filter(request, **kwargs): return chunks -@register.inclusion_tag('catalogue/book_list/book_list.html', takes_context=True) +@register.inclusion_tag('documents/book_list/book_list.html', takes_context=True) def book_list(context, user=None): request = context['request'] @@ -175,7 +175,7 @@ def image_list_filter(request, **kwargs): return images -@register.inclusion_tag('catalogue/image_table.html', takes_context=True) +@register.inclusion_tag('documents/image_table.html', takes_context=True) def image_list(context, user=None): request = context['request'] diff --git a/src/catalogue/templatetags/common_tags.py b/src/documents/templatetags/common_tags.py similarity index 100% rename from src/catalogue/templatetags/common_tags.py rename to src/documents/templatetags/common_tags.py diff --git a/src/catalogue/templatetags/catalogue.py b/src/documents/templatetags/documents.py similarity index 56% rename from src/catalogue/templatetags/catalogue.py rename to src/documents/templatetags/documents.py index 0bfd95ab..5c3b1eb8 100644 --- a/src/catalogue/templatetags/catalogue.py +++ b/src/documents/templatetags/documents.py @@ -19,22 +19,22 @@ class Tab(object): self.url = url -@register.inclusion_tag("catalogue/main_tabs.html", takes_context=True) +@register.inclusion_tag("documents/main_tabs.html", takes_context=True) def main_tabs(context): - active = getattr(context['request'], 'catalogue_active_tab', None) + active = getattr(context['request'], 'documents_active_tab', None) tabs = [] user = context['user'] - tabs.append(Tab('my', _('My page'), reverse("catalogue_user"))) + tabs.append(Tab('my', _('My page'), reverse("documents_user"))) - tabs.append(Tab('activity', _('Activity'), reverse("catalogue_activity"))) - tabs.append(Tab('all', _('All'), reverse("catalogue_document_list"))) - tabs.append(Tab('images', _('Images'), reverse("catalogue_image_list"))) - tabs.append(Tab('users', _('Users'), reverse("catalogue_users"))) + tabs.append(Tab('activity', _('Activity'), reverse("documents_activity"))) + tabs.append(Tab('all', _('All'), reverse("documents_document_list"))) + tabs.append(Tab('images', _('Images'), reverse("documents_image_list"))) + tabs.append(Tab('users', _('Users'), reverse("documents_users"))) - if user.has_perm('catalogue.add_book'): - tabs.append(Tab('create', _('Add'), reverse("catalogue_create_missing"))) - tabs.append(Tab('upload', _('Upload'), reverse("catalogue_upload"))) + if user.has_perm('documents.add_book'): + tabs.append(Tab('create', _('Add'), reverse("documents_create_missing"))) + tabs.append(Tab('upload', _('Upload'), reverse("documents_upload"))) tabs.append(Tab('cover', _('Covers'), reverse("cover_image_list"))) diff --git a/src/catalogue/templatetags/set_get_parameter.py b/src/documents/templatetags/set_get_parameter.py similarity index 100% rename from src/catalogue/templatetags/set_get_parameter.py rename to src/documents/templatetags/set_get_parameter.py diff --git a/src/catalogue/templatetags/wall.py b/src/documents/templatetags/wall.py similarity index 96% rename from src/catalogue/templatetags/wall.py rename to src/documents/templatetags/wall.py index 7543616a..4a6795be 100644 --- a/src/catalogue/templatetags/wall.py +++ b/src/documents/templatetags/wall.py @@ -7,7 +7,7 @@ from django.urls import reverse from django import template from django.utils.translation import ugettext as _ -from catalogue.models import Chunk, BookPublishRecord, Image, ImagePublishRecord +from documents.models import Chunk, BookPublishRecord, Image, ImagePublishRecord register = template.Library() @@ -159,7 +159,7 @@ def big_wall(walls, max_len=None): del subwalls[i] -@register.inclusion_tag("catalogue/wall.html", takes_context=True) +@register.inclusion_tag("documents/wall.html", takes_context=True) def wall(context, user=None, max_len=100): return { "request": context['request'], @@ -171,7 +171,7 @@ def wall(context, user=None, max_len=100): image_published_wall(user, max_len), ], max_len)} -@register.inclusion_tag("catalogue/wall.html", takes_context=True) +@register.inclusion_tag("documents/wall.html", takes_context=True) def day_wall(context, day): return { "request": context['request'], diff --git a/src/catalogue/test_utils.py b/src/documents/test_utils.py similarity index 100% rename from src/catalogue/test_utils.py rename to src/documents/test_utils.py diff --git a/src/catalogue/tests/__init__.py b/src/documents/tests/__init__.py similarity index 100% rename from src/catalogue/tests/__init__.py rename to src/documents/tests/__init__.py diff --git a/src/catalogue/tests/files/chunk1.xml b/src/documents/tests/files/chunk1.xml similarity index 100% rename from src/catalogue/tests/files/chunk1.xml rename to src/documents/tests/files/chunk1.xml diff --git a/src/catalogue/tests/files/chunk2.xml b/src/documents/tests/files/chunk2.xml similarity index 100% rename from src/catalogue/tests/files/chunk2.xml rename to src/documents/tests/files/chunk2.xml diff --git a/src/catalogue/tests/files/expected.xml b/src/documents/tests/files/expected.xml similarity index 100% rename from src/catalogue/tests/files/expected.xml rename to src/documents/tests/files/expected.xml diff --git a/src/catalogue/tests/test_book.py b/src/documents/tests/test_book.py similarity index 98% rename from src/catalogue/tests/test_book.py rename to src/documents/tests/test_book.py index 1d26e4d3..c423d9e4 100644 --- a/src/catalogue/tests/test_book.py +++ b/src/documents/tests/test_book.py @@ -5,7 +5,7 @@ from django.test import TestCase from django.contrib.auth.models import User -from catalogue.models import Book +from documents.models import Book class ManipulationTests(TestCase): diff --git a/src/catalogue/tests/test_gallery.py b/src/documents/tests/test_gallery.py similarity index 99% rename from src/catalogue/tests/test_gallery.py rename to src/documents/tests/test_gallery.py index 32c0e0ac..ba75b95b 100644 --- a/src/catalogue/tests/test_gallery.py +++ b/src/documents/tests/test_gallery.py @@ -7,7 +7,7 @@ from os.path import join, basename, exists from os import makedirs, listdir from django.test import TestCase from django.contrib.auth.models import User -from catalogue.models import Book +from documents.models import Book from tempfile import mkdtemp from django.conf import settings diff --git a/src/catalogue/tests/test_publish.py b/src/documents/tests/test_publish.py similarity index 94% rename from src/catalogue/tests/test_publish.py rename to src/documents/tests/test_publish.py index 930d88a1..b59136a1 100644 --- a/src/catalogue/tests/test_publish.py +++ b/src/documents/tests/test_publish.py @@ -3,12 +3,12 @@ # """Tests for the publishing process.""" -from catalogue.test_utils import get_fixture +from documents.test_utils import get_fixture from mock import patch from django.test import TestCase from django.contrib.auth.models import User -from catalogue.models import Book +from documents.models import Book class PublishTests(TestCase): diff --git a/src/catalogue/tests/test_xml_updater.py b/src/documents/tests/test_xml_updater.py similarity index 89% rename from src/catalogue/tests/test_xml_updater.py rename to src/documents/tests/test_xml_updater.py index a5ce5671..ef0c8734 100644 --- a/src/catalogue/tests/test_xml_updater.py +++ b/src/documents/tests/test_xml_updater.py @@ -3,11 +3,11 @@ # """XmlUpdater tests.""" -from catalogue.test_utils import get_fixture +from documents.test_utils import get_fixture from django.test import TestCase from django.contrib.auth.models import User -from catalogue.models import Book -from catalogue.management import XmlUpdater +from documents.models import Book +from documents.management import XmlUpdater from librarian import DCNS diff --git a/src/documents/urls.py b/src/documents/urls.py new file mode 100644 index 00000000..602d4f22 --- /dev/null +++ b/src/documents/urls.py @@ -0,0 +1,66 @@ +# This file is part of FNP-Redakcja, licensed under GNU Affero GPLv3 or later. +# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. +# +from django.conf.urls import url +from django.contrib.auth.decorators import permission_required +from django.views.generic import RedirectView +from .feeds import PublishTrackFeed +from . import views + + +urlpatterns = [ + url(r'^$', RedirectView.as_view(url='catalogue/', permanent=False)), + + url(r'^images/$', views.image_list, name='documents_image_list'), + url(r'^image/(?P[^/]+)/$', views.image, name="documents_image"), + url(r'^image/(?P[^/]+)/publish$', views.publish_image, + name="documents_publish_image"), + + url(r'^catalogue/$', views.document_list, name='documents_document_list'), + url(r'^user/$', views.my, name='documents_user'), + url(r'^user/(?P[^/]+)/$', views.user, name='documents_user'), + url(r'^users/$', views.users, name='documents_users'), + url(r'^activity/$', views.activity, name='documents_activity'), + url(r'^activity/(?P\d{4}-\d{2}-\d{2})/$', + views.activity, name='documents_activity'), + + url(r'^upload/$', + views.upload, name='documents_upload'), + + url(r'^create/(?P[^/]*)/', + views.create_missing, name='documents_create_missing'), + url(r'^create/', + views.create_missing, name='documents_create_missing'), + + url(r'^book/(?P[^/]+)/publish$', views.publish, name="documents_publish"), + + url(r'^book/(?P[^/]+)/$', views.book, name="documents_book"), + url(r'^book/(?P[^/]+)/gallery/$', + permission_required('documents.change_book')(views.GalleryView.as_view()), + name="documents_book_gallery"), + url(r'^book/(?P[^/]+)/xml$', views.book_xml, name="documents_book_xml"), + url(r'^book/dc/(?P[^/]+)/xml$', views.book_xml_dc, name="documents_book_xml_dc"), + url(r'^book/(?P[^/]+)/txt$', views.book_txt, name="documents_book_txt"), + url(r'^book/(?P[^/]+)/html$', views.book_html, name="documents_book_html"), + url(r'^book/(?P[^/]+)/epub$', views.book_epub, name="documents_book_epub"), + url(r'^book/(?P[^/]+)/mobi$', views.book_mobi, name="documents_book_mobi"), + url(r'^book/(?P[^/]+)/pdf$', views.book_pdf, name="documents_book_pdf"), + url(r'^book/(?P[^/]+)/pdf-mobile$', views.book_pdf, kwargs={'mobile': True}, name="documents_book_pdf_mobile"), + + url(r'^chunk_add/(?P[^/]+)/(?P[^/]+)/$', + views.chunk_add, name="documents_chunk_add"), + url(r'^chunk_edit/(?P[^/]+)/(?P[^/]+)/$', + views.chunk_edit, name="documents_chunk_edit"), + url(r'^book_append/(?P[^/]+)/$', + views.book_append, name="documents_book_append"), + url(r'^chunk_mass_edit', + views.chunk_mass_edit, name='documents_chunk_mass_edit'), + url(r'^image_mass_edit', + views.image_mass_edit, name='documents_image_mass_edit'), + + url(r'^track/(?P[^/]*)/$', PublishTrackFeed()), + url(r'^active/$', views.active_users_list, name='active_users_list'), + + url(r'^mark-final/$', views.mark_final, name='mark_final'), + url(r'^mark-final-completed/$', views.mark_final_completed, name='mark_final_completed'), +] diff --git a/src/catalogue/views.py b/src/documents/views.py similarity index 91% rename from src/catalogue/views.py rename to src/documents/views.py index 019d25a7..397d78bd 100644 --- a/src/catalogue/views.py +++ b/src/documents/views.py @@ -25,10 +25,10 @@ from django.views.decorators.http import require_POST from django_cas_ng.decorators import user_passes_test from apiclient import NotAuthorizedError -from catalogue import forms -from catalogue import helpers -from catalogue.helpers import active_tab -from catalogue.models import (Book, Chunk, Image, BookPublishRecord, +from . import forms +from . import helpers +from .helpers import active_tab +from .models import (Book, Chunk, Image, BookPublishRecord, ChunkPublishRecord, ImagePublishRecord, Project) from fileupload.views import UploadView @@ -37,25 +37,25 @@ from fileupload.views import UploadView # from django.views.decorators.cache import never_cache -logger = logging.getLogger("fnp.catalogue") +logger = logging.getLogger("fnp.documents") @active_tab('all') @never_cache def document_list(request): - return render(request, 'catalogue/document_list.html') + return render(request, 'documents/document_list.html') @active_tab('images') @never_cache def image_list(request, user=None): - return render(request, 'catalogue/image_list.html') + return render(request, 'documents/image_list.html') @never_cache def user(request, username): user = get_object_or_404(User, username=username) - return render(request, 'catalogue/user_page.html', {"viewed_user": user}) + return render(request, 'documents/user_page.html', {"viewed_user": user}) @login_required @@ -66,7 +66,7 @@ def my(request): key=lambda x: x[1]['time'], reverse=True) for k, v in last_books: v['time'] = datetime.fromtimestamp(v['time']) - return render(request, 'catalogue/my_page.html', { + return render(request, 'documents/my_page.html', { 'last_books': last_books, "logout_to": '/', }) @@ -74,7 +74,7 @@ def my(request): @active_tab('users') def users(request): - return render(request, 'catalogue/user_list.html', { + return render(request, 'documents/user_list.html', { 'users': User.objects.all().annotate(count=Count('chunk')).order_by( '-count', 'last_name', 'first_name'), }) @@ -94,7 +94,7 @@ def activity(request, isodate=None): next_day = day + timedelta(1) prev_day = day - timedelta(1) - return render(request, 'catalogue/activity.html', locals()) + return render(request, 'documents/activity.html', locals()) @never_cache @@ -103,7 +103,7 @@ def logout_then_redirect(request): return http.HttpResponseRedirect(urlquote_plus(request.GET.get('next', '/'), safe='/?=')) -@permission_required('catalogue.add_book') +@permission_required('documents.add_book') @active_tab('create') def create_missing(request, slug=None): if slug is None: @@ -126,7 +126,7 @@ def create_missing(request, slug=None): gallery=form.cleaned_data['gallery'], ) - return http.HttpResponseRedirect(reverse("catalogue_book", args=[book.slug])) + return http.HttpResponseRedirect(reverse("documents_book", args=[book.slug])) else: form = forms.DocumentCreateForm(initial={ "slug": slug, @@ -134,7 +134,7 @@ def create_missing(request, slug=None): "gallery": slug, }) - return render(request, "catalogue/document_create_missing.html", { + return render(request, "documents/document_create_missing.html", { "slug": slug, "form": form, @@ -142,7 +142,7 @@ def create_missing(request, slug=None): }) -@permission_required('catalogue.add_book') +@permission_required('documents.add_book') @active_tab('upload') def upload(request): if request.method == "POST": @@ -189,7 +189,7 @@ def upload(request): title=title, ) - return render(request, "catalogue/document_upload.html", { + return render(request, "documents/document_upload.html", { "form": form, "ok_list": ok_list, "skipped_list": skipped_list, @@ -200,7 +200,7 @@ def upload(request): else: form = forms.DocumentsUploadForm() - return render(request, "catalogue/document_upload.html", { + return render(request, "documents/document_upload.html", { "form": form, "logout_to": '/', @@ -260,7 +260,7 @@ def book_html(request, slug): # book_themes = book_themes.items() # book_themes.sort(key=lambda s: s[0].sort_key) - return render(request, 'catalogue/book_text.html', locals()) + return render(request, 'documents/book_text.html', locals()) @never_cache @@ -274,7 +274,7 @@ def book_pdf(request, slug, mobile=False): # TODO: error handling customizations = ['26pt', 'nothemes', 'nomargins', 'notoc'] if mobile else None pdf_file = doc.as_pdf(cover=True, ilustr_path=book.gallery_path(), customizations=customizations) - from catalogue.ebook_utils import serve_file + from .ebook_utils import serve_file return serve_file(pdf_file.get_filename(), book.slug + '.pdf', 'application/pdf') @@ -327,7 +327,7 @@ def book(request, slug): if not book.accessible(request): return HttpResponseForbidden("Not authorized.") - if request.user.has_perm('catalogue.change_book'): + if request.user.has_perm('documents.change_book'): if request.method == "POST": form = forms.BookForm(request.POST, instance=book) if form.is_valid(): @@ -345,7 +345,7 @@ def book(request, slug): publish_error = book.publishable_error() publishable = publish_error is None - return render(request, "catalogue/book_detail.html", { + return render(request, "documents/book_detail.html", { "book": book, "publishable": publishable, "publishable_error": publish_error, @@ -360,7 +360,7 @@ def image(request, slug): if not image.accessible(request): return HttpResponseForbidden("Not authorized.") - if request.user.has_perm('catalogue.change_image'): + if request.user.has_perm('documents.change_image'): if request.method == "POST": form = forms.ImageForm(request.POST, instance=image) if form.is_valid(): @@ -376,7 +376,7 @@ def image(request, slug): publish_error = image.publishable_error() publishable = publish_error is None - return render(request, "catalogue/image_detail.html", { + return render(request, "documents/image_detail.html", { "object": image, "publishable": publishable, "publishable_error": publish_error, @@ -385,7 +385,7 @@ def image(request, slug): }) -@permission_required('catalogue.add_chunk') +@permission_required('documents.add_chunk') def chunk_add(request, slug, chunk): try: doc = Chunk.get(slug, chunk) @@ -416,7 +416,7 @@ def chunk_add(request, slug, chunk): "title": "cz. %d" % (doc.number + 1, ), }) - return render(request, "catalogue/chunk_add.html", { + return render(request, "documents/chunk_add.html", { "chunk": doc, "form": form, }) @@ -452,7 +452,7 @@ def chunk_edit(request, slug, chunk): else: go_next = '' - return render(request, "catalogue/chunk_edit.html", { + return render(request, "documents/chunk_edit.html", { "chunk": doc, "form": form, "go_next": go_next, @@ -543,7 +543,7 @@ def image_mass_edit(request): return HttpResponse("", content_type="text/plain") -@permission_required('catalogue.change_book') +@permission_required('documents.change_book') def book_append(request, slug): book = get_object_or_404(Book, slug=slug) if not book.accessible(request): @@ -557,7 +557,7 @@ def book_append(request, slug): return http.HttpResponseRedirect(append_to.get_absolute_url()) else: form = forms.BookAppendForm(book) - return render(request, "catalogue/book_append_to.html", { + return render(request, "documents/book_append_to.html", { "book": book, "form": form, @@ -616,7 +616,7 @@ class GalleryView(UploadView): def breadcrumbs(self): return [ - (_('books'), reverse('catalogue_document_list')), + (_('books'), reverse('documents_document_list')), (self.object.title, self.object.get_absolute_url()), (_('scan gallery'),), ] @@ -650,7 +650,7 @@ def active_users_list(request): for email, count in by_email.items(): active_users.append((email, names_by_email[email], count)) active_users.sort(key=lambda x: -x[2]) - return render(request, 'catalogue/active_users_list.html', { + return render(request, 'documents/active_users_list.html', { 'users': active_users, 'year': year, }) @@ -665,8 +665,8 @@ def mark_final(request): return HttpResponseRedirect(reverse('mark_final_completed')) else: form = forms.MarkFinalForm() - return render(request, 'catalogue/mark_final.html', {'form': form}) + return render(request, 'documents/mark_final.html', {'form': form}) def mark_final_completed(request): - return render(request, 'catalogue/mark_final_completed.html') + return render(request, 'documents/mark_final_completed.html') diff --git a/src/catalogue/xml_tools.py b/src/documents/xml_tools.py similarity index 98% rename from src/catalogue/xml_tools.py rename to src/documents/xml_tools.py index 917e62ac..f2c885d9 100644 --- a/src/catalogue/xml_tools.py +++ b/src/documents/xml_tools.py @@ -5,7 +5,7 @@ from copy import deepcopy import re from lxml import etree -from catalogue.constants import TRIM_BEGIN, TRIM_END, MASTERS +from .constants import TRIM_BEGIN, TRIM_END, MASTERS RE_TRIM_BEGIN = re.compile("^$" % TRIM_BEGIN, re.M) RE_TRIM_END = re.compile("^$" % TRIM_END, re.M) diff --git a/src/fileupload/templates/fileupload/picture_form.html b/src/fileupload/templates/fileupload/picture_form.html index 44c37db7..dc49f9c9 100644 --- a/src/fileupload/templates/fileupload/picture_form.html +++ b/src/fileupload/templates/fileupload/picture_form.html @@ -1,4 +1,4 @@ -{% extends "catalogue/base.html" %} +{% extends "documents/base.html" %} {% load i18n %} {% load upload_tags %} diff --git a/src/redakcja/settings/__init__.py b/src/redakcja/settings/__init__.py index 51dec4da..8b7b9c4b 100644 --- a/src/redakcja/settings/__init__.py +++ b/src/redakcja/settings/__init__.py @@ -89,6 +89,7 @@ INSTALLED_APPS = ( 'bootstrap4', 'catalogue', + 'documents', 'cover', 'dvcs', 'wiki', @@ -138,11 +139,11 @@ PIPELINE = { ), 'output_filename': 'compressed/detail_styles.css', }, - 'catalogue': { + 'documents': { 'source_filenames': ( 'css/filelist.css', ), - 'output_filename': 'compressed/catalogue_styles.css', + 'output_filename': 'compressed/documents_styles.css', }, 'book': { 'source_filenames': ( @@ -226,13 +227,13 @@ PIPELINE = { ), 'output_filename': 'compressed/detail_img_scripts.js', }, - 'catalogue': { + 'documents': { 'source_filenames': ( - 'js/catalogue/catalogue.js', + 'js/documents/documents.js', 'js/slugify.js', 'email_mangler/email_mangler.js', ), - 'output_filename': 'compressed/catalogue_scripts.js', + 'output_filename': 'compressed/documents_scripts.js', }, 'book': { 'source_filenames': ( @@ -246,7 +247,7 @@ PIPELINE = { }, 'book_list': { 'source_filenames': ( - 'js/catalogue/book_list.js', + 'js/documents/book_list.js', ), 'output_filename': 'compressed/book_list.js', } diff --git a/src/redakcja/static/js/catalogue/book_list.js b/src/redakcja/static/js/documents/book_list.js similarity index 100% rename from src/redakcja/static/js/catalogue/book_list.js rename to src/redakcja/static/js/documents/book_list.js diff --git a/src/redakcja/static/js/catalogue/catalogue.js b/src/redakcja/static/js/documents/documents.js similarity index 100% rename from src/redakcja/static/js/catalogue/catalogue.js rename to src/redakcja/static/js/documents/documents.js diff --git a/src/redakcja/templates/404.html b/src/redakcja/templates/404.html index 11edc9d5..a4fd20de 100644 --- a/src/redakcja/templates/404.html +++ b/src/redakcja/templates/404.html @@ -1,4 +1,4 @@ -{% extends "catalogue/base.html" %} +{% extends "documents/base.html" %} {% load i18n %} {% block titleextra %}{% trans "Page not found" %}{% endblock %} @@ -17,7 +17,7 @@ still can't find what you're looking for, please contact the administrator.{% endblocktrans %}

    -{% url "catalogue_user" as m %} +{% url "documents_user" as m %}

    {% blocktrans %}If you're coming from Redmine, please note that work is no longer managed there. diff --git a/src/redakcja/templates/registration/login.html b/src/redakcja/templates/registration/login.html index 6ba9f759..7bef2eb8 100644 --- a/src/redakcja/templates/registration/login.html +++ b/src/redakcja/templates/registration/login.html @@ -1,4 +1,4 @@ -{% extends "catalogue/base.html" %} +{% extends "documents/base.html" %} {% block titleextra %}Logowanie{% endblock %} {% block subtitle %} - Logowanie {% endblock subtitle %} diff --git a/src/redakcja/urls.py b/src/redakcja/urls.py index 9f5d6e03..af8b4f26 100644 --- a/src/redakcja/urls.py +++ b/src/redakcja/urls.py @@ -20,7 +20,7 @@ urlpatterns = [ url(r'^admin/', admin.site.urls), url(r'^$', RedirectView.as_view(url='/documents/', permanent=False)), - url(r'^documents/', include('catalogue.urls')), + url(r'^documents/', include('documents.urls')), url(r'^apiclient/', include('apiclient.urls')), url(r'^editor/', include('wiki.urls')), url(r'^images/', include('wiki_img.urls')), diff --git a/src/wiki/forms.py b/src/wiki/forms.py index 6f6defc6..084ae46d 100644 --- a/src/wiki/forms.py +++ b/src/wiki/forms.py @@ -4,7 +4,7 @@ from django import forms from django.utils.translation import ugettext_lazy as _ -from catalogue.models import Chunk +from documents.models import Chunk class DocumentPubmarkForm(forms.Form): diff --git a/src/wiki/templates/wiki/document_details_base.html b/src/wiki/templates/wiki/document_details_base.html index 8b79d9aa..6cf25432 100644 --- a/src/wiki/templates/wiki/document_details_base.html +++ b/src/wiki/templates/wiki/document_details_base.html @@ -33,7 +33,7 @@