From c3bcc0703d6255b78c2a6813bbea03e9581609e0 Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Thu, 13 Oct 2011 17:16:28 +0200 Subject: [PATCH 1/1] some usability changes --- apps/catalogue/forms.py | 28 ++- .../catalogue/locale/pl/LC_MESSAGES/django.mo | Bin 6005 -> 5618 bytes .../catalogue/locale/pl/LC_MESSAGES/django.po | 164 +++++++++--------- apps/catalogue/models/book.py | 6 +- apps/catalogue/models/chunk.py | 6 +- .../templates/catalogue/book_detail.html | 108 +++++------- .../templates/catalogue/book_list/book.html | 5 +- .../templates/catalogue/book_list/chunk.html | 2 +- .../templates/catalogue/chunk_add.html | 9 +- .../templates/catalogue/chunk_edit.html | 16 +- apps/catalogue/templatetags/book_list.py | 2 +- apps/catalogue/urls.py | 2 - apps/catalogue/views.py | 110 ++---------- redakcja/static/css/filelist.css | 46 ++--- redakcja/static/js/catalogue/catalogue.js | 33 ++-- 15 files changed, 236 insertions(+), 301 deletions(-) diff --git a/apps/catalogue/forms.py b/apps/catalogue/forms.py index 657a1b04..8cd00c2d 100644 --- a/apps/catalogue/forms.py +++ b/apps/catalogue/forms.py @@ -68,12 +68,18 @@ class ChunkForm(forms.ModelForm): user = forms.ModelChoiceField(queryset= User.objects.annotate(count=Count('chunk')). order_by('-count', 'last_name', 'first_name'), required=False, - label=_('Assigned to')) + label=_('Assigned to')) class Meta: model = Chunk + fields = ['title', 'slug', 'user', 'stage'] exclude = ['number'] + def __init__(self, *args, **kwargs): + super(ChunkForm, self).__init__(*args, **kwargs) + self.fields['slug'].widget.attrs={'class': 'autoslug'} + self.fields['title'].widget.attrs={'class': 'autoslug-source'} + def clean_slug(self): slug = self.cleaned_data['slug'] try: @@ -114,13 +120,27 @@ class BookAppendForm(forms.Form): class BookForm(forms.ModelForm): - """ - Form used for editing a Book. - """ + """Form used for editing a Book.""" class Meta: model = Book + def __init__(self, *args, **kwargs): + ret = super(BookForm, self).__init__(*args, **kwargs) + self.fields['slug'].widget.attrs.update({"class": "autoslug"}) + self.fields['title'].widget.attrs.update({"class": "autoslug-source"}) + return ret + + +class ReadonlyBookForm(BookForm): + """Form used for not editing a Book.""" + + def __init__(self, *args, **kwargs): + ret = super(ReadonlyBookForm, self).__init__(*args, **kwargs) + for field in self.fields.values(): + field.widget.attrs.update({"readonly": True}) + return ret + class ChooseMasterForm(forms.Form): """ diff --git a/apps/catalogue/locale/pl/LC_MESSAGES/django.mo b/apps/catalogue/locale/pl/LC_MESSAGES/django.mo index daf9fc1c45fa3e13f8dfbd4bf2a27aabe4b46c39..ff6d31c668e32fc19dbb952c4a7340093baa0a79 100644 GIT binary patch delta 2149 zcmY+_eN0t#9LMpWaCu4)!N3%iV-YDBk1Cy3LH7lx4Sjx|^h zTQSf416yr9&DCbJuFYC9djML?xz@`5X=Q(8R&$Y?w#C|df4IN9>g;~+>vw+VoZs*J zdpP%AFS}M6{XW-s%y4uNYl!nn#zgT*3SS(D(~QZ-5lqKPOvWk9z?V?Bp0M>NaVh8T z*z41HGv}Y#`tQ)k`4!AkS63|~HM|Qy#%lZv`Is`Y&cqsAp`kWXP{#XF3G`qtMo=A3pb~r@)#2-?899w5_=T;% zff{M*O(cZ{sCFk%?Ht7wcpR0$+vw9&e@H=N;I!2Xo2I=U5b*P4lP#Krn`fAjDwWvg!QTO#& zL#XEmP>CN#bu?kGKW9B^uTLR;n-iJLKeJ|HR4m77)C^oeHE;>l@K2}?f3x-1Z2h08 zhW@to8T9_g5@rF*sn>exdIhSTI@Ao+qY`b+X8x7Hqf}^0f~W_c!~%TA-uMPCCW@Mg zY1AhB3iaGP7NL((XsS1&?yo{t&(xth-i>@r2VbSw8>OI;d8h`CV=Azfy>k**;T-C@OIU#msDz@MXhkF1j!$6=s>82QBlrQ; zz%R%%CYj+X;XKsu#Ts0RwMed}71v=GR^b?`z01LhA-h(feOXK_ja{ZMwaS z7ue;fhTHA+M^KxlAC>SEs1BY+KIT=v^!)qQY1H$d*z?cr`32NWeS=H2MwcnDY0YLr z8S2+;m3K9zAi9B4GNB39Zn&M$Pmdl*BPx@or)dp%gVwIyC-fLR&U*Y`2A- z*k;SS6Bm*HfhyBZf%!AH+6xb0lPxFEn6(pj5O;VVq!vaWq@=aiEB6plOtcW1Jstbv zn7w$vEo;yG_t2ivsw9qD3S|V_$E;6OS}U!0#*La93fkq3L<4azp||5cViUpJYBmzv zh$2G&6I%$qk}QUKm|(yE@93~+S}}*v+fz-H6MExz5%I&jnAV#ei3EGYfgWejHTA9= z^4iin^ZSOvp@?a4`}+go!Gw|6yXnW0y~)hYsoj14aBsl-J#(j5n>CqnXsGM)V5Be5 zmXuxTYx*oEe`z8}fT^F7IF4 zFgi0e`(k&{G`Z^2KQQ`lDG)2nd2dNsb1)DZ{4_QYaJucyPB<8FA~WMouRG`tt5s() ym5{&tU~D1xK$3SRugN#sAM|_W`R(4b`KMMpZu|~+m^94L?AejQkUJa>hRi>1%JY=~ delta 2538 zcmZA2TWl0n9LMoPffi_&ODP4B!f=t=R-i2)w<;I8RG|n0mP-xU?heaz+nKT#%dXLV zfI?!T(Tq)KAo0yactFyiF;odj8xvoQ5fhA5pNy9nr6w4>q2J$jXc{N|@8|59bNQb$ zXSTo9++CjgrgTD&;c6k~5q}pLlf&B+`QW-$WK21Jg_H0Oj>kW6GX8^VTEtD&hp-rD zpzc>-8CC}M4S|gq(p38?%%VXnPQ{bB7|$YOn@dPT(}&aWMsWXgoWS?HSb=}yTAahI zD{(JUWxBBhU&onv9+lu_oT{Z>qfko4r>F^sPzim9n(!~w4irx@rWzNa>YGq2djZ=p zff{%SHO`Ny35QV$Oys5#E=7$$8)s;%mr>9PH{u*@LJN-}f95P7jp$=F-o`>KVpQ$e zRMaD=z`3{>welxXk8}rW0Z~-KFQF2719Qr-C%Ex0YM_r%D;z*gbThdBHELydQ0?vo z_4iRLn#n5Ez6v!#ZSZ|Hs(l0UXSVR6`+Gv{zd9VCLbe1ABB+(0Kz84}jMMQf&cJi1 z0WP8jzKrUBHK^|o>TjUN`6TcQRR3>L{f9&B|L{0tey3su6+f_Sb(q6!8h8n6i>r|) zW*sV_9jKk#i)wGh&rU#QT>K+2@dBdXuxvPQb!A^GApnKH=$P6 zj_Q!arFafE;&tSFnSW72L_)QZ;fq5Hd0JJO8W;#W`$xqwRWgW&rO)FZkb)ZfFIdjAV} zHKmHtEe;MqjsVfb;vFS_3xqDzaQNH2zCC< zXB4!;A=E@aA<3Bu?3)Id8@K>9z>?s5P4K-I)qf3Yi?<@XZVsTHwS$~-ZFhb_Pa#$L z%YSQPS#Bvs{dQ~8&4hk_wG&Se+lT{%u17~Ot5An;7qO5~((4EvsOJc6^Mgx|QrFW& zbG~HE&OpJxn|gDQ0_V(FL?fZ=*%9)eO?>8e0-q!v@edU)$nB$4OK8)dC-i>oC-ma! z+A@OKfV+dTj^x-&C-2ahiZzrUBeZXNU&dbgf!IUTj8x{#Y6{DV9mIBGFQFs2m8d58 zF)@|IT4E9LII)tbBJ_X`6FMpDiA}^2qJ_}K8OXmUdI#%>WrQB`GsMW{zgQG2@9b>P zSjU``cG7H4CY_jTN3E3S|6Fva(Cg^1-BjO^Nj>8m!_lbK8csS9E9ynks<)DvFAwO}k9m?M%0}JIUjAl=5g6%wwNS`IADeMRitP{rZ(_{1c&t zBjr`KeZ8TQf_crExaWr3tZau9b~9#ABAe-Sl3~{-7r%d6$K;)!mKIKA`?gQNILvKrz8Kn<)1FwwJe>?#=U6Pb2FnO zn*3tI!X7-$w#6UppntP$f1w@Cq|$AE<*X|kvM!6xZz1cjywR1own^FXWXfu_v!gj@ MOnR_CqXd=Ke^3Wx{{R30 diff --git a/apps/catalogue/locale/pl/LC_MESSAGES/django.po b/apps/catalogue/locale/pl/LC_MESSAGES/django.po index 9050300d..7439ee2f 100644 --- a/apps/catalogue/locale/pl/LC_MESSAGES/django.po +++ b/apps/catalogue/locale/pl/LC_MESSAGES/django.po @@ -7,8 +7,8 @@ msgid "" msgstr "" "Project-Id-Version: Platforma Redakcyjna\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2011-10-11 12:37+0200\n" -"PO-Revision-Date: 2011-10-11 12:40+0100\n" +"POT-Creation-Date: 2011-10-13 17:15+0200\n" +"PO-Revision-Date: 2011-10-13 17:16+0100\n" "Last-Translator: Radek Czajka \n" "Language-Team: Fundacja Nowoczesna Polska \n" "Language: pl\n" @@ -25,29 +25,29 @@ msgstr "Plik ZIP" msgid "Directories are documents in chunks" msgstr "Katalogi zawierają dokumenty w częściach" -#: forms.py:71 +#: forms.py:74 msgid "Assigned to" msgstr "Przypisane do" -#: forms.py:85 -#: forms.py:99 +#: forms.py:94 +#: forms.py:108 msgid "Chunk with this slug already exists" msgstr "Część z tym slugiem już istnieje" -#: forms.py:109 +#: forms.py:117 msgid "Append to" msgstr "Dołącz do" -#: views.py:138 +#: views.py:143 #, python-format msgid "Slug already used for %s" msgstr "Slug taki sam jak dla pliku %s" -#: views.py:140 +#: views.py:145 msgid "Slug already used in repository." msgstr "Dokument o tym slugu już istnieje w repozytorium." -#: views.py:146 +#: views.py:151 msgid "File should be UTF-8 encoded." msgstr "Plik powinien mieć kodowanie UTF-8." @@ -57,7 +57,7 @@ msgid "title" msgstr "tytuł" #: models/book.py:26 -#: models/chunk.py:23 +#: models/chunk.py:25 msgid "slug" msgstr "slug" @@ -74,7 +74,7 @@ msgid "parent number" msgstr "numeracja rodzica" #: models/book.py:48 -#: models/chunk.py:21 +#: models/chunk.py:22 #: models/publish_log.py:17 msgid "book" msgstr "książka" @@ -83,43 +83,43 @@ msgstr "książka" msgid "books" msgstr "książki" -#: models/book.py:195 +#: models/book.py:197 msgid "No chunks in the book." msgstr "Książka nie ma części." -#: models/book.py:199 +#: models/book.py:201 msgid "Not all chunks have publishable revisions." -msgstr "W książce są niepublikowalne części." +msgstr "Niektóre części nie są gotowe do publikacji." -#: models/book.py:205 +#: models/book.py:207 msgid "Invalid XML" msgstr "Nieprawidłowy XML" -#: models/book.py:207 +#: models/book.py:209 msgid "No Dublin Core found." msgstr "Brak sekcji Dublin Core." -#: models/book.py:209 +#: models/book.py:211 msgid "Invalid Dublin Core" msgstr "Nieprawidłowy Dublin Core" -#: models/book.py:212 +#: models/book.py:214 msgid "rdf:about is not" msgstr "rdf:about jest różny od" -#: models/chunk.py:22 +#: models/chunk.py:23 msgid "number" msgstr "numer" -#: models/chunk.py:25 +#: models/chunk.py:26 msgid "gallery start" msgstr "początek galerii" -#: models/chunk.py:40 +#: models/chunk.py:41 msgid "chunk" msgstr "część" -#: models/chunk.py:41 +#: models/chunk.py:42 msgid "chunks" msgstr "części" @@ -160,84 +160,72 @@ msgstr "Platforma Redakcyjna" msgid "Append book" msgstr "Dołącz książkę" -#: templates/catalogue/book_detail.html:6 -#: templates/catalogue/book_detail.html:46 -msgid "edit" -msgstr "edytuj" - -#: templates/catalogue/book_detail.html:16 -msgid "add basic document structure" -msgstr "dodaj podstawową strukturę dokumentu" - -#: templates/catalogue/book_detail.html:20 -msgid "change master tag to" -msgstr "zmień tak master na" - -#: templates/catalogue/book_detail.html:24 -msgid "add begin trimming tag" -msgstr "dodaj początkowy ogranicznik" - -#: templates/catalogue/book_detail.html:28 -msgid "add end trimming tag" -msgstr "dodaj końcowy ogranicznik" +#: templates/catalogue/book_detail.html:14 +#: templates/catalogue/book_edit.html:9 +#: templates/catalogue/chunk_edit.html:12 +msgid "Save" +msgstr "Zapisz" -#: templates/catalogue/book_detail.html:34 -msgid "unstructured text" -msgstr "tekst bez struktury" +#: templates/catalogue/book_detail.html:21 +msgid "Append to other book" +msgstr "Dołącz do innej książki" -#: templates/catalogue/book_detail.html:38 -msgid "unknown XML" -msgstr "nieznany XML" +#: templates/catalogue/book_detail.html:27 +msgid "Chunks" +msgstr "Części" #: templates/catalogue/book_detail.html:42 -msgid "broken document" -msgstr "uszkodzony dokument" - -#: templates/catalogue/book_detail.html:61 -msgid "Apply fixes" -msgstr "Wykonaj zmiany" - -#: templates/catalogue/book_detail.html:67 -msgid "Append to other book" -msgstr "Dołącz do innej książki" +#: templatetags/wall.py:67 +msgid "Publication" +msgstr "Publikacja" -#: templates/catalogue/book_detail.html:69 +#: templates/catalogue/book_detail.html:44 msgid "Last published" msgstr "Ostatnio opublikowano" -#: templates/catalogue/book_detail.html:73 +#: templates/catalogue/book_detail.html:54 msgid "Full XML" msgstr "Pełny XML" -#: templates/catalogue/book_detail.html:74 +#: templates/catalogue/book_detail.html:55 msgid "HTML version" msgstr "Wersja HTML" -#: templates/catalogue/book_detail.html:75 +#: templates/catalogue/book_detail.html:56 msgid "TXT version" msgstr "Wersja TXT" -#: templates/catalogue/book_detail.html:93 +#: templates/catalogue/book_detail.html:74 msgid "Publish" msgstr "Opublikuj" -#: templates/catalogue/book_detail.html:97 +#: templates/catalogue/book_detail.html:78 msgid "Log in to publish." msgstr "Zaloguj się, aby opublikować." -#: templates/catalogue/book_detail.html:100 +#: templates/catalogue/book_detail.html:81 msgid "This book can't be published yet, because:" msgstr "Ta książka nie może jeszcze zostać opublikowana. Powód:" -#: templates/catalogue/book_edit.html:9 -#: templates/catalogue/chunk_edit.html:9 -msgid "Save" -msgstr "Zapisz" +#: templates/catalogue/book_detail.html:90 +msgid "Comments" +msgstr "Komentarze" -#: templates/catalogue/chunk_add.html:9 +#: templates/catalogue/chunk_add.html:5 +#: templates/catalogue/chunk_add.html:11 msgid "Add chunk" msgstr "Dodaj część" +#: templates/catalogue/chunk_edit.html:5 +#: templates/catalogue/book_list/book.html:7 +#: templates/catalogue/book_list/chunk.html:5 +msgid "Chunk settings" +msgstr "Ustawienia części" + +#: templates/catalogue/chunk_edit.html:10 +msgid "Book" +msgstr "Książka" + #: templates/catalogue/document_create_missing.html:9 msgid "Create document" msgstr "Utwórz dokument" @@ -302,11 +290,6 @@ msgstr "Użytkownicy" msgid "Book settings" msgstr "Ustawienia książki" -#: templates/catalogue/book_list/book.html:7 -#: templates/catalogue/book_list/chunk.html:5 -msgid "Chunk settings" -msgstr "Ustawienia części" - #: templates/catalogue/book_list/book_list.html:19 msgid "Show hidden books" msgstr "Pokaż ukryte książki" @@ -392,14 +375,37 @@ msgstr "Powiązana zmiana" msgid "Edit" msgstr "Zmiana" -#: templatetags/wall.py:67 -msgid "Publication" -msgstr "Publikacja" - #: templatetags/wall.py:84 msgid "Comment" msgstr "Komentarz" +#~ msgid "edit" +#~ msgstr "edytuj" + +#~ msgid "add basic document structure" +#~ msgstr "dodaj podstawową strukturę dokumentu" + +#~ msgid "change master tag to" +#~ msgstr "zmień tak master na" + +#~ msgid "add begin trimming tag" +#~ msgstr "dodaj początkowy ogranicznik" + +#~ msgid "add end trimming tag" +#~ msgstr "dodaj końcowy ogranicznik" + +#~ msgid "unstructured text" +#~ msgstr "tekst bez struktury" + +#~ msgid "unknown XML" +#~ msgstr "nieznany XML" + +#~ msgid "broken document" +#~ msgstr "uszkodzony dokument" + +#~ msgid "Apply fixes" +#~ msgstr "Wykonaj zmiany" + #~ msgid "Can mark for publishing" #~ msgstr "Oznacza do publikacji" diff --git a/apps/catalogue/models/book.py b/apps/catalogue/models/book.py index d60a3b67..1a141fcb 100755 --- a/apps/catalogue/models/book.py +++ b/apps/catalogue/models/book.py @@ -27,8 +27,8 @@ class Book(models.Model): gallery = models.CharField(_('scan gallery name'), max_length=255, blank=True) #wl_slug = models.CharField(_('title'), max_length=255, null=True, db_index=True, editable=False) - parent = models.ForeignKey('self', null=True, blank=True, verbose_name=_('parent'), related_name="children") - parent_number = models.IntegerField(_('parent number'), null=True, blank=True, db_index=True) + parent = models.ForeignKey('self', null=True, blank=True, verbose_name=_('parent'), related_name="children", editable=False) + parent_number = models.IntegerField(_('parent number'), null=True, blank=True, db_index=True, editable=False) # Cache _short_html = models.TextField(null=True, blank=True, editable=False) @@ -44,7 +44,7 @@ class Book(models.Model): class Meta: app_label = 'catalogue' - ordering = ['parent_number', 'title'] + ordering = ['title'] verbose_name = _('book') verbose_name_plural = _('books') diff --git a/apps/catalogue/models/chunk.py b/apps/catalogue/models/chunk.py index 8b8f56b3..9b1dcbae 100755 --- a/apps/catalogue/models/chunk.py +++ b/apps/catalogue/models/chunk.py @@ -11,6 +11,7 @@ from django.utils.translation import ugettext_lazy as _ from catalogue.helpers import cached_in_field from catalogue.managers import VisibleManager from catalogue.tasks import refresh_instance +from catalogue.xml_tools import GradedText from dvcs import models as dvcs_models @@ -20,8 +21,8 @@ class Chunk(dvcs_models.Document): book = models.ForeignKey('Book', editable=False, verbose_name=_('book')) number = models.IntegerField(_('number')) - slug = models.SlugField(_('slug')) title = models.CharField(_('title'), max_length=255, blank=True) + slug = models.SlugField(_('slug')) gallery_start = models.IntegerField(_('gallery start'), null=True, blank=True) # cache @@ -123,3 +124,6 @@ class Chunk(dvcs_models.Document): self.changed self.hidden self.short_html + + def graded(self, master=None): + return GradedText(self.materialize(), master) diff --git a/apps/catalogue/templates/catalogue/book_detail.html b/apps/catalogue/templates/catalogue/book_detail.html index 19e673c5..b32177d9 100755 --- a/apps/catalogue/templates/catalogue/book_detail.html +++ b/apps/catalogue/templates/catalogue/book_detail.html @@ -1,72 +1,53 @@ {% extends "catalogue/base.html" %} -{% load comments i18n %} +{% load book_list comments i18n %} -{% block leftcolumn %} +{% block content %} -{% trans "edit" %} -

{{ book.title }}

- - {% for c in chunks %} - - - - - - - - +
{{ c.chunk.title }}{% for fix in c.fix %} +

{{ book.title }}

- {% ifequal fix "wl" %}</>{% endifequal %} - {% ifequal fix "bad-master" %}master{% endifequal %} - - {% ifequal fix "trim-begin" %}{% endifequal %} +{% if editable %}
{% csrf_token %}{% endif %} + + {{ form.as_table }} + {% if editable %} + + {% endif %} +
+{% if editable %}
{% endif %} - {% ifequal fix "trim-end" %}{% endifequal %} - {% endfor %} +{% if editable %} +

{% trans "Append to other book" %}

+{% endif %} - {% ifequal c.grade "plain" %} - {% trans "unstructured text" %} - {% endifequal %} - {% ifequal c.grade "xml" %} - {% trans "unknown XML" %} - {% endifequal %} +
- {% ifequal c.grade "wl-broken" %} - {% trans "broken document" %} - {% endifequal %} +

{% trans "Chunks" %}

-
[{% trans "edit" %}]{% if c.chunk.publishable %}P{% endif %}{% if c.chunk.user.is_authenticated %} - {{ c.chunk.user }} - {% endif %}[+]
+ {% for chunk in book %} + {{ chunk.short_html|safe }} {% endfor %} - {% if need_fixing %} - - {% endif %} -
-
- {% csrf_token %} - {% if choose_master %} - {{ form.master }} - {% endif %} - -
-
+ + + + + -

{% trans "Append to other book" %}

+
-

{% trans "Last published" %}: {{ book.last_published }}

+ +

{% trans "Publication" %}

+ +

{% trans "Last published" %}: + {% if book.last_published %} + {{ book.last_published }} + {% else %} + — + {% endif %} +

{% if publishable %}

@@ -100,12 +81,17 @@

  • {{ publishable_error }}
{% endif %} -{% endblock leftcolumn %} +
+ + + +
+

{% trans "Comments" %}

-{% block rightcolumn %} -{% render_comment_list for book %} -{% with book.get_absolute_url as next %} - {% render_comment_form for book %} -{% endwith %} + {% render_comment_list for book %} + {% with book.get_absolute_url as next %} + {% render_comment_form for book %} + {% endwith %} +
-{% endblock rightcolumn %} +{% endblock content %} diff --git a/apps/catalogue/templates/catalogue/book_list/book.html b/apps/catalogue/templates/catalogue/book_list/book.html index 00f2f1c1..46d5ae12 100755 --- a/apps/catalogue/templates/catalogue/book_list/book.html +++ b/apps/catalogue/templates/catalogue/book_list/book.html @@ -22,10 +22,11 @@ {% endwith %} {% else %} - [B] + [B] {{ book.title }} - + + {% if book.published %}P{% endif %} {% if book.new_publishable %}p{% endif %} diff --git a/apps/catalogue/templates/catalogue/book_list/chunk.html b/apps/catalogue/templates/catalogue/book_list/chunk.html index 3897d78b..14599428 100755 --- a/apps/catalogue/templates/catalogue/book_list/chunk.html +++ b/apps/catalogue/templates/catalogue/book_list/chunk.html @@ -1,7 +1,7 @@ {% load i18n %} - + [c] {{ chunk.number }}. diff --git a/apps/catalogue/templates/catalogue/chunk_add.html b/apps/catalogue/templates/catalogue/chunk_add.html index 800a7e45..558fc9f1 100755 --- a/apps/catalogue/templates/catalogue/chunk_add.html +++ b/apps/catalogue/templates/catalogue/chunk_add.html @@ -1,14 +1,13 @@ {% extends "catalogue/base.html" %} {% load i18n %} -{% block leftcolumn %} +{% block content %} +

{% trans "Add chunk" %}

+
{% csrf_token %} {{ form.as_p }}

-{% endblock leftcolumn %} - -{% block rightcolumn %} -{% endblock rightcolumn %} +{% endblock content %} diff --git a/apps/catalogue/templates/catalogue/chunk_edit.html b/apps/catalogue/templates/catalogue/chunk_edit.html index 94fe12bc..20e8657f 100755 --- a/apps/catalogue/templates/catalogue/chunk_edit.html +++ b/apps/catalogue/templates/catalogue/chunk_edit.html @@ -1,14 +1,16 @@ {% extends "catalogue/base.html" %} {% load i18n %} -{% block leftcolumn %} +{% block content %} +

{% trans "Chunk settings" %}

+
{% csrf_token %} - {{ form.as_p }} + + + {{ form.as_table}} + +
{% trans "Book" %}{{ chunk.book }} ({{ chunk.number }}/{{ chunk.book|length }})
-

-{% endblock leftcolumn %} - -{% block rightcolumn %} -{% endblock rightcolumn %} +{% endblock content %} diff --git a/apps/catalogue/templatetags/book_list.py b/apps/catalogue/templatetags/book_list.py index f5b7e647..aee33210 100755 --- a/apps/catalogue/templatetags/book_list.py +++ b/apps/catalogue/templatetags/book_list.py @@ -127,6 +127,7 @@ def book_list(context, user=None): '-count', 'last_name', 'first_name')} new_context.update({ + "filters": True, "request": request, "books": ChunksList(document_list_filter(request, **filters)), "stages": Chunk.tag_model.objects.all(), @@ -134,4 +135,3 @@ def book_list(context, user=None): }) return new_context - diff --git a/apps/catalogue/urls.py b/apps/catalogue/urls.py index 73fd3ee6..9fbc587d 100644 --- a/apps/catalogue/urls.py +++ b/apps/catalogue/urls.py @@ -35,7 +35,5 @@ urlpatterns = patterns('catalogue.views', 'chunk_edit', name="catalogue_chunk_edit"), url(r'^book_append/(?P[^/]+)/$', 'book_append', name="catalogue_book_append"), - url(r'^book_edit/(?P[^/]+)/$', - 'book_edit', name="catalogue_book_edit"), ) diff --git a/apps/catalogue/views.py b/apps/catalogue/views.py index cac1bd2b..fad8a692 100644 --- a/apps/catalogue/views.py +++ b/apps/catalogue/views.py @@ -219,86 +219,19 @@ def revision(request, slug, chunk=None): def book(request, slug): book = get_object_or_404(Book, slug=slug) - # TODO: most of this should go somewhere else - - # do we need some automation? - first_master = None - chunks = [] - need_fixing = False - choose_master = False - - length = book.chunk_set.count() - for i, chunk in enumerate(book): - chunk_dict = { - "chunk": chunk, - "fix": [], - "grade": "" - } - graded = xml_tools.GradedText(chunk.materialize()) - if graded.is_wl(): - master = graded.master() - if first_master is None: - first_master = master - elif master != first_master: - chunk_dict['fix'].append('bad-master') - - if i > 0 and not graded.has_trim_begin(): - chunk_dict['fix'].append('trim-begin') - if i < length - 1 and not graded.has_trim_end(): - chunk_dict['fix'].append('trim-end') - - if chunk_dict['fix']: - chunk_dict['grade'] = 'wl-fix' - else: - chunk_dict['grade'] = 'wl' - - elif graded.is_broken_wl(): - chunk_dict['grade'] = 'wl-broken' - elif graded.is_xml(): - chunk_dict['grade'] = 'xml' + if request.user.has_perm('catalogue.change_book'): + if request.method == "POST": + form = forms.BookForm(request.POST, instance=book) + if form.is_valid(): + form.save() + return http.HttpResponseRedirect(book.get_absolute_url()) else: - chunk_dict['grade'] = 'plain' - chunk_dict['fix'].append('wl') - choose_master = True - - if chunk_dict['fix']: - need_fixing = True - chunks.append(chunk_dict) - - if first_master or not need_fixing: - choose_master = False - - if request.method == "POST": - form = forms.ChooseMasterForm(request.POST) - if not choose_master or form.is_valid(): - if choose_master: - first_master = form.cleaned_data['master'] - - # do the actual fixing - for c in chunks: - if not c['fix']: - continue - - text = c['chunk'].materialize() - for fix in c['fix']: - if fix == 'bad-master': - text = xml_tools.change_master(text, first_master) - elif fix == 'trim-begin': - text = xml_tools.add_trim_begin(text) - elif fix == 'trim-end': - text = xml_tools.add_trim_end(text) - elif fix == 'wl': - text = xml_tools.basic_structure(text, first_master) - author = request.user if request.user.is_authenticated() else None - description = "auto-fix: " + ", ".join(c['fix']) - c['chunk'].commit(text=text, author=author, - description=description) - - return http.HttpResponseRedirect(book.get_absolute_url()) - elif choose_master: - form = forms.ChooseMasterForm() + form = forms.BookForm(instance=book) + editable = True else: - form = None + form = forms.ReadonlyBookForm(instance=book) + editable = False + try: book.assert_publishable() @@ -313,11 +246,8 @@ def book(request, slug): "book": book, "publishable": publishable, "publishable_error": publishable_error, - "chunks": chunks, - "need_fixing": need_fixing, - "choose_master": choose_master, - "first_master": first_master, "form": form, + "editable": editable, }) @@ -399,22 +329,6 @@ def book_append(request, slug): }) -@permission_required('catalogue.change_book') -def book_edit(request, slug): - book = get_object_or_404(Book, slug=slug) - if request.method == "POST": - form = forms.BookForm(request.POST, instance=book) - if form.is_valid(): - form.save() - return http.HttpResponseRedirect(book.get_absolute_url()) - else: - form = forms.BookForm(instance=book) - return direct_to_template(request, "catalogue/book_edit.html", extra_context={ - "book": book, - "form": form, - }) - - @require_POST @login_required def publish(request, slug): diff --git a/redakcja/static/css/filelist.css b/redakcja/static/css/filelist.css index e20296c9..23198945 100644 --- a/redakcja/static/css/filelist.css +++ b/redakcja/static/css/filelist.css @@ -12,7 +12,18 @@ body { font-size: 10px; } +img { + border: 0; +} + +th { + text-align: left; +} +td { + vertical-align: top; + padding: 0 3px; +} .clr { clear: both; } @@ -43,6 +54,19 @@ body { border-color: #ff8000 #ff8000 white #ff8000; } +.section { + border-top: 1px solid #ffdfbf; + margin-top: 2em; + padding-top: 1em; +} + +.editable td { + padding: 1px; +} +.editable input, .editable select { + width: 30em; +} + #login-box { float: right; } @@ -119,28 +143,6 @@ a:hover { padding-left: 2em; } -td { - vertical-align: top; -} - - -.fix { - border: 1px solid gray; - font-size: 0.7em; - padding: 3px; -} - -.fix-info { - font-size: 0.7em; - font-style: italic; -} - -.chunk-plain a {color: gray;} -.chunk-xml a {color: gray; font-style: italic;} -.chunk-wl-broken a {color: red;} -.chunk-wl a {color: green;} -.chunk-wl-fix a {color: black;} - /* Big cheesy publish button */ #publish-button { diff --git a/redakcja/static/js/catalogue/catalogue.js b/redakcja/static/js/catalogue/catalogue.js index e8ef5e95..e6a210e3 100755 --- a/redakcja/static/js/catalogue/catalogue.js +++ b/redakcja/static/js/catalogue/catalogue.js @@ -2,25 +2,28 @@ $(function() { - $(function() { - $('.filter').change(function() { - document.filter[this.name].value = this.value; - document.filter.submit(); - }); + $('.filter').change(function() { + document.filter[this.name].value = this.value; + document.filter.submit(); + }); + + $('.check-filter').change(function() { + document.filter[this.name].value = this.checked ? '1' : ''; + document.filter.submit(); + }); - $('.check-filter').change(function() { - document.filter[this.name].value = this.checked ? '1' : ''; + $('.text-filter').each(function() { + var inp = this; + $(inp).parent().submit(function() { + document.filter[inp.name].value = inp.value; document.filter.submit(); + return false; }); + }); - $('.text-filter').each(function() { - var inp = this; - $(inp).parent().submit(function() { - document.filter[inp.name].value = inp.value; - document.filter.submit(); - return false; - }); - }); + + $('.autoslug-source').change(function() { + $('.autoslug').attr('value', slugify(this.value)); }); -- 2.20.1