fnp
/
redakcja.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
87bd94a
)
Audience and thema editing.
author
Radek Czajka
<rczajka@rczajka.pl>
Fri, 28 Jul 2023 11:56:41 +0000
(13:56 +0200)
committer
Radek Czajka
<rczajka@rczajka.pl>
Fri, 28 Jul 2023 11:56:41 +0000
(13:56 +0200)
requirements/requirements.txt
patch
|
blob
|
history
src/catalogue/urls.py
patch
|
blob
|
history
src/catalogue/views.py
patch
|
blob
|
history
src/depot/legimi.py
patch
|
blob
|
history
src/documents/templates/documents/book_detail.html
patch
|
blob
|
history
src/documents/views.py
patch
|
blob
|
history
src/redakcja/static/js/wiki/view_properties.js
patch
|
blob
|
history
src/wlxml/views.py
patch
|
blob
|
history
diff --git
a/requirements/requirements.txt
b/requirements/requirements.txt
index
cc6b09d
..
921bc06
100644
(file)
--- a/
requirements/requirements.txt
+++ b/
requirements/requirements.txt
@@
-10,7
+10,7
@@
python-slugify==8.0.1
python-docx==0.8.11
Wikidata==0.7
python-docx==0.8.11
Wikidata==0.7
-librarian==2
.6
+librarian==2
3.07
## Django
Django==4.1.9
## Django
Django==4.1.9
diff --git
a/src/catalogue/urls.py
b/src/catalogue/urls.py
index
ac9cede
..
d512eea
100644
(file)
--- a/
src/catalogue/urls.py
+++ b/
src/catalogue/urls.py
@@
-11,6
+11,7
@@
urlpatterns = [
path("book/<slug:slug>/", views.BookView.as_view(), name="catalogue_book"),
path("book/<slug:slug>.json", views.BookAPIView.as_view(), name="catalogue_book_api"),
path("book/<slug:slug>/", views.BookView.as_view(), name="catalogue_book"),
path("book/<slug:slug>.json", views.BookAPIView.as_view(), name="catalogue_book_api"),
+ path('terms/audience/', views.AudienceTerms.as_view()),
path('terms/epoch/', views.EpochTerms.as_view()),
path('terms/kind/', views.KindTerms.as_view()),
path('terms/genre/', views.GenreTerms.as_view()),
path('terms/epoch/', views.EpochTerms.as_view()),
path('terms/kind/', views.KindTerms.as_view()),
path('terms/genre/', views.GenreTerms.as_view()),
@@
-18,6
+19,7
@@
urlpatterns = [
path('terms/book_title/', views.BookTitleTerms.as_view()),
path('terms/author/', views.AuthorTerms.as_view()),
path('terms/thema/', views.ThemaTerms.as_view()),
path('terms/book_title/', views.BookTitleTerms.as_view()),
path('terms/author/', views.AuthorTerms.as_view()),
path('terms/thema/', views.ThemaTerms.as_view()),
+ path('terms/thema-main/', views.MainThemaTerms.as_view()),
path('terms/editor/', views.EditorTerms.as_view()),
path('terms/editor/', views.EditorTerms.as_view()),
diff --git
a/src/catalogue/views.py
b/src/catalogue/views.py
index
6eb6e63
..
44ad305
100644
(file)
--- a/
src/catalogue/views.py
+++ b/
src/catalogue/views.py
@@
-106,6
+106,15
@@
class Terms(ListAPIView):
label = serializers.CharField(source='name')
label = serializers.CharField(source='name')
+class AudienceTerms(Terms):
+ queryset = models.Audience.objects.all()
+ search_fields = ['code', 'name', 'description']
+
+ class serializer_class(serializers.Serializer):
+ label = serializers.CharField(source='code')
+ name = serializers.CharField()
+ description = serializers.CharField()
+
class EpochTerms(Terms):
queryset = models.Epoch.objects.all()
class KindTerms(Terms):
class EpochTerms(Terms):
queryset = models.Epoch.objects.all()
class KindTerms(Terms):
@@
-150,6
+159,9
@@
class ThemaTerms(Terms):
name = serializers.CharField()
description = serializers.CharField()
name = serializers.CharField()
description = serializers.CharField()
+class MainThemaTerms(ThemaTerms):
+ queryset = models.Thema.objects.filter(usable=True, hidden=False, usable_as_main=True)
+
class WikidataView(APIView):
permission_classes = [IsAdminUser]
class WikidataView(APIView):
permission_classes = [IsAdminUser]
diff --git
a/src/depot/legimi.py
b/src/depot/legimi.py
index
f61bbfd
..
464eeca
100644
(file)
--- a/
src/depot/legimi.py
+++ b/
src/depot/legimi.py
@@
-184,13
+184,18
@@
class Legimi:
base_url='file://' + book.gallery_path() + '/'
).build(wlbook).get_file()
base_url='file://' + book.gallery_path() + '/'
).build(wlbook).get_file()
+ thema = []
+ if meta.thema_main:
+ thema.append(meta.thema_main)
+ thema.extend(meta.thema)
+
book_data = {
"Title": meta.title,
"Author": ", ".join(p.readable() for p in meta.authors),
"Year": str(date.today().year),
'GenreId': str(self.get_genre(wlbook)),
book_data = {
"Title": meta.title,
"Author": ", ".join(p.readable() for p in meta.authors),
"Year": str(date.today().year),
'GenreId': str(self.get_genre(wlbook)),
- 'themaCategories': ';'.join(
meta.
thema),
+ 'themaCategories': ';'.join(thema),
'thema-search': '',
'Isbn': '',
'LanguageLocale': lang_code_3to2(meta.language),
'thema-search': '',
'Isbn': '',
'LanguageLocale': lang_code_3to2(meta.language),
@@
-289,12
+294,13
@@
class Legimi:
for p in wlbook.meta.genres
) + '</p>'
for p in wlbook.meta.genres
) + '</p>'
- if wlbook.meta.audience:
+ # TODO: Move away from using audiences for this.
+ if wlbook.meta.audience in ('L', 'SP1', 'SP2', 'SP3', 'SP4'):
description += '<p><em>{}</em> to lektura szkolna.'.format(wlbook.meta.title)
if wlbook.tree.find('//pe') is not None:
description += '<br>Ebook <em>{title}</em> zawiera przypisy opracowane specjalnie dla uczennic i uczniów {school}.'.format(
title=wlbook.meta.title,
description += '<p><em>{}</em> to lektura szkolna.'.format(wlbook.meta.title)
if wlbook.tree.find('//pe') is not None:
description += '<br>Ebook <em>{title}</em> zawiera przypisy opracowane specjalnie dla uczennic i uczniów {school}.'.format(
title=wlbook.meta.title,
- school='szkoły podstawowej' if wlbook.meta.audience
== 'SP'
else 'liceum i technikum'
+ school='szkoły podstawowej' if wlbook.meta.audience
.startswith('SP')
else 'liceum i technikum'
)
description += '</p>'
return description
)
description += '</p>'
return description
diff --git
a/src/documents/templates/documents/book_detail.html
b/src/documents/templates/documents/book_detail.html
index
ee053d5
..
caa3de5
100644
(file)
--- a/
src/documents/templates/documents/book_detail.html
+++ b/
src/documents/templates/documents/book_detail.html
@@
-141,16
+141,23
@@
{% if perms.depot.add_legimibookpublish %}
<hr>
{% if perms.depot.add_legimibookpublish %}
<hr>
- {% with thema=doc.book_info.thema %}
- {% if thema %}
+ {% with thema
_main=doc.book_info.thema_main thema
=doc.book_info.thema %}
+ {% if thema
_main or thema
%}
<form method="post" action="{% url 'depot_legimi_publish' book.pk %}">
{% csrf_token %}
<button class="btn btn-primary" type="submit">
Opublikuj na Legimi<br><small>w kategorii:
<form method="post" action="{% url 'depot_legimi_publish' book.pk %}">
{% csrf_token %}
<button class="btn btn-primary" type="submit">
Opublikuj na Legimi<br><small>w kategorii:
+ {% if thema_main %}
+ <tt>{{ thema_main }}</tt>
+ {% endif %}
{% for t in thema %}
{% for t in thema %}
+ {% if forloop.first and thema_main %}oraz: {% endif %}
<tt>{{ t }}</tt>
{% if not forloop.last %}, {% endif %}
{% endfor %}
<tt>{{ t }}</tt>
{% if not forloop.last %}, {% endif %}
{% endfor %}
+ {% if not thema_main %}
+ <span class="badge badge-secondary" title="Nie ustalono głównej kategorii Thema"> * </small>
+ {% endif %}
</small></button>
{% with llp=book.last_legimi_publish %}
{% if llp %}
</small></button>
{% with llp=book.last_legimi_publish %}
{% if llp %}
@@
-163,7
+170,7
@@
{% endwith %}
</form>
{% else %}
{% endwith %}
</form>
{% else %}
- <div class="alert alert-warning">Nie można opublikować na Legimi, ponieważ nie usta
i
ono kategorii Thema.</div>
+ <div class="alert alert-warning">Nie można opublikować na Legimi, ponieważ nie usta
l
ono kategorii Thema.</div>
{% endif %}
{% endwith %}
{% endif %}
{% endif %}
{% endwith %}
{% endif %}
diff --git
a/src/documents/views.py
b/src/documents/views.py
index
a930b8d
..
225ad55
100644
(file)
--- a/
src/documents/views.py
+++ b/
src/documents/views.py
@@
-295,11
+295,13
@@
def book_epub(request, slug):
return HttpResponseForbidden("Not authorized.")
# TODO: move to celery
return HttpResponseForbidden("Not authorized.")
# TODO: move to celery
- doc = book.wldocument()
+ doc = book.wldocument(
librarian2=True
)
# TODO: error handling
# TODO: error handling
- #### Problemas: images in children.
- epub = doc.as_epub(base_url='file://' + book.gallery_path() + '/').get_bytes()
+ from librarian.builders import EpubBuilder
+ epub = EpubBuilder(
+ base_url='file://' + book.gallery_path() + '/'
+ ).build(doc).get_bytes()
response = HttpResponse(content_type='application/epub+zip')
response['Content-Disposition'] = 'attachment; filename=%s' % book.slug + '.epub'
response.write(epub)
response = HttpResponse(content_type='application/epub+zip')
response['Content-Disposition'] = 'attachment; filename=%s' % book.slug + '.epub'
response.write(epub)
@@
-314,9
+316,12
@@
def book_mobi(request, slug):
return HttpResponseForbidden("Not authorized.")
# TODO: move to celery
return HttpResponseForbidden("Not authorized.")
# TODO: move to celery
- doc = book.wldocument()
+ doc = book.wldocument(
librarian2=True
)
# TODO: error handling
# TODO: error handling
- mobi = doc.as_mobi(base_url='file://' + book.gallery_path() + '/').get_bytes()
+ from librarian.builders import MobiBuilder
+ mobi = MobiBuilder(
+ base_url='file://' + book.gallery_path() + '/'
+ ).build(doc).get_bytes()
response = HttpResponse(content_type='application/x-mobipocket-ebook')
response['Content-Disposition'] = 'attachment; filename=%s' % book.slug + '.mobi'
response.write(mobi)
response = HttpResponse(content_type='application/x-mobipocket-ebook')
response['Content-Disposition'] = 'attachment; filename=%s' % book.slug + '.mobi'
response.write(mobi)
diff --git
a/src/redakcja/static/js/wiki/view_properties.js
b/src/redakcja/static/js/wiki/view_properties.js
index
a3fe432
..
9fa1c9d
100644
(file)
--- a/
src/redakcja/static/js/wiki/view_properties.js
+++ b/
src/redakcja/static/js/wiki/view_properties.js
@@
-149,7
+149,8
@@
self.$pane.on('click', '.meta-delete', function() {
let $fg = $(this).closest('.form-group');
self.$pane.on('click', '.meta-delete', function() {
let $fg = $(this).closest('.form-group');
- $('input', $fg).data('edited').remove();
+ let $ig = $(this).closest('.input-group');
+ $('input', $ig).data('edited').remove();
self.displayMetaProperty($fg);
$.wiki.perspectives.VisualPerspective.flush();
return false;
self.displayMetaProperty($fg);
$.wiki.perspectives.VisualPerspective.flush();
return false;
diff --git
a/src/wlxml/views.py
b/src/wlxml/views.py
index
f1f5dae
..
2039569
100644
(file)
--- a/
src/wlxml/views.py
+++ b/
src/wlxml/views.py
@@
-7,7
+7,7
@@
from librarian.dcparser import BookInfo
from librarian.document import WLDocument
from librarian.builders import StandaloneHtmlBuilder
from librarian.meta.types.wluri import WLURI
from librarian.document import WLDocument
from librarian.builders import StandaloneHtmlBuilder
from librarian.meta.types.wluri import WLURI
-from librarian.meta.types.text import LegimiCategory, Epoch, Kind, Genre, Audience, ThemaCategory
+from librarian.meta.types.text import LegimiCategory, Epoch, Kind, Genre, Audience, ThemaCategory
, MainThemaCategory
from depot.legimi import legimi
from depot.legimi import legimi
@@
-50,11
+50,21
@@
VALUE_TYPES = {
'widget': 'select',
'options': [''] + list(legimi.CATEGORIES.keys()),
},
'widget': 'select',
'options': [''] + list(legimi.CATEGORIES.keys()),
},
+ Audience: {
+ 'autocomplete': {
+ 'source': '/catalogue/terms/audience/',
+ }
+ },
ThemaCategory: {
'autocomplete': {
'source': '/catalogue/terms/thema/',
}
},
ThemaCategory: {
'autocomplete': {
'source': '/catalogue/terms/thema/',
}
},
+ ThemaCategory: {
+ 'autocomplete': {
+ 'source': '/catalogue/terms/thema-main/',
+ }
+ },
Epoch: {
'autocomplete': {
'source': '/catalogue/terms/epoch/',
Epoch: {
'autocomplete': {
'source': '/catalogue/terms/epoch/',