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:
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):
"""
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 <radoslaw.czajka@nowoczesnapolska.org.pl>\n"
"Language-Team: Fundacja Nowoczesna Polska <fundacja@nowoczesnapolska.org.pl>\n"
"Language: pl\n"
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."
msgstr "tytuł"
#: models/book.py:26
-#: models/chunk.py:23
+#: models/chunk.py:25
msgid "slug"
msgstr "slug"
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"
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"
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"
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"
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"
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)
class Meta:
app_label = 'catalogue'
- ordering = ['parent_number', 'title']
+ ordering = ['title']
verbose_name = _('book')
verbose_name_plural = _('books')
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
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
self.changed
self.hidden
self.short_html
+
+ def graded(self, master=None):
+ return GradedText(self.materialize(), master)
{% extends "catalogue/base.html" %}
-{% load comments i18n %}
+{% load book_list comments i18n %}
-{% block leftcolumn %}
+{% block content %}
-<a href="{% url catalogue_book_edit book.slug %}">{% trans "edit" %}</a>
- <h1>{{ book.title }}</h1>
-<table>
- {% for c in chunks %}
- <tr class="chunk-{{ c.grade }}">
- <td><a target="_blank" href="{{ c.chunk.get_absolute_url }}">{{ c.chunk.title }}</a></td>
- <td>{% for fix in c.fix %}
+<h1>{{ book.title }}</h1>
- {% ifequal fix "wl" %}<span class="fix"
- title="{% trans "add basic document structure" %}"
- ></></span>{% endifequal %}
- {% ifequal fix "bad-master" %}<span class="fix"
- title='{% trans "change master tag to" %} "{{ first_master }}"'
- >master</span>{% endifequal %}
-
- {% ifequal fix "trim-begin" %}<span class="fix"
- title="{% trans "add begin trimming tag" %}"
- >✁</span>{% endifequal %}
+{% if editable %}<form method='POST'>{% csrf_token %}{% endif %}
+<table class='editable'><tbody>
+ {{ form.as_table }}
+ {% if editable %}
+ <tr><td></td><td><button type="submit">{% trans "Save" %}</button></td></tr>
+ {% endif %}
+</tbody></table>
+{% if editable %}</form>{% endif %}
- {% ifequal fix "trim-end" %}<span class="fix"
- title="{% trans "add end trimming tag" %}"
- >✃</span>{% endifequal %}
- {% endfor %}
+{% if editable %}
+ <p><a href="{% url catalogue_book_append book.slug %}">{% trans "Append to other book" %}</a></p>
+{% endif %}
- {% ifequal c.grade "plain" %}
- <span class="fix-info">{% trans "unstructured text" %}</span>
- {% endifequal %}
- {% ifequal c.grade "xml" %}
- <span class="fix-info">{% trans "unknown XML" %}</span>
- {% endifequal %}
+<div class='section'>
- {% ifequal c.grade "wl-broken" %}
- <span class="fix-info">{% trans "broken document" %}</span>
- {% endifequal %}
+ <h2>{% trans "Chunks" %}</h2>
- </td>
- <td><a href="{% url catalogue_chunk_edit book.slug c.chunk.slug%}">[{% trans "edit" %}]</a></td>
- <td>{% if c.chunk.publishable %}P{% endif %}</td>
- <td>{% if c.chunk.user.is_authenticated %}
- <a href="{% url catalogue_user c.chunk.user.username %}">{{ c.chunk.user }}</a>
- {% endif %}</td>
- <td><a href="{% url catalogue_chunk_add book.slug c.chunk.slug %}">[+]</a></td>
- </tr>
+ <table class='single-book-list'><tbody>
+ {% for chunk in book %}
+ {{ chunk.short_html|safe }}
{% endfor %}
- {% if need_fixing %}
- <tr><td></td><td>
- <form method="POST" action="">
- {% csrf_token %}
- {% if choose_master %}
- {{ form.master }}
- {% endif %}
- <button type="submit">{% trans "Apply fixes" %}</button>
- </form>
- </td></tr>
- {% endif %}
-</table>
+ </tbody></table>
+
+</div>
+
+
-<p><a href="{% url catalogue_book_append book.slug %}">{% trans "Append to other book" %}</a></p>
+<div class='section'>
-<p>{% trans "Last published" %}: {{ book.last_published }}</p>
+
+<h2>{% trans "Publication" %}</h2>
+
+<p>{% trans "Last published" %}:
+ {% if book.last_published %}
+ {{ book.last_published }}
+ {% else %}
+ —
+ {% endif %}
+</p>
{% if publishable %}
<p>
<ul><li>{{ publishable_error }}</li></ul>
{% endif %}
-{% endblock leftcolumn %}
+</div>
+
+
+
+<div class='section'>
+ <h2>{% trans "Comments" %}</h2>
-{% 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 %}
+</div>
-{% endblock rightcolumn %}
+{% endblock content %}
{% endwith %}
{% else %}
<tr>
- <td><a href="{% url catalogue_book book.slug %}" title='{% trans "Book settings" %}'>[B]</a></td>
+ <td class='book-settings-link'><a href="{% url catalogue_book book.slug %}" title='{% trans "Book settings" %}'>[B]</a></td>
<td></td>
<td>{{ book.title }}</td>
- <td></td><td></td>
+ <td></td>
+ <td class='user-column'></td>
<td>
{% if book.published %}P{% endif %}
{% if book.new_publishable %}p{% endif %}
{% load i18n %}
<tr>
- <td></td>
+ <td class='book-settings-column'></td>
<td><a href="{% url catalogue_chunk_edit chunk.book.slug chunk.slug %}" title='{% trans "Chunk settings" %}'>[c]</a></td>
<td><a target="_blank" href="{{ chunk.get_absolute_url }}">
<span class='chunkno'>{{ chunk.number }}.</span>
{% extends "catalogue/base.html" %}
{% load i18n %}
-{% block leftcolumn %}
+{% block content %}
+ <h1>{% trans "Add chunk" %}</h1>
+
<form enctype="multipart/form-data" method="POST" action="">
{% csrf_token %}
{{ form.as_p }}
<p><button type="submit">{% trans "Add chunk" %}</button></p>
</form>
-{% endblock leftcolumn %}
-
-{% block rightcolumn %}
-{% endblock rightcolumn %}
+{% endblock content %}
{% extends "catalogue/base.html" %}
{% load i18n %}
-{% block leftcolumn %}
+{% block content %}
+ <h1>{% trans "Chunk settings" %}</h1>
+
<form enctype="multipart/form-data" method="POST" action="{% if go_next %}?next={{ go_next }}{% endif %}">
{% csrf_token %}
- {{ form.as_p }}
+ <table class='editable'>
+ <tr><th>{% trans "Book" %}</th><td>{{ chunk.book }} ({{ chunk.number }}/{{ chunk.book|length }})</td></tr>
+ {{ form.as_table}}
+ <tr><td></td><td><button type="submit">{% trans "Save" %}</button></td></tr>
+ </table>
- <p><button type="submit">{% trans "Save" %}</button></p>
</form>
-{% endblock leftcolumn %}
-
-{% block rightcolumn %}
-{% endblock rightcolumn %}
+{% endblock content %}
'-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(),
})
return new_context
-
'chunk_edit', name="catalogue_chunk_edit"),
url(r'^book_append/(?P<slug>[^/]+)/$',
'book_append', name="catalogue_book_append"),
- url(r'^book_edit/(?P<slug>[^/]+)/$',
- 'book_edit', name="catalogue_book_edit"),
)
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()
"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,
})
})
-@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):
font-size: 10px;
}
+img {
+ border: 0;
+}
+
+th {
+ text-align: left;
+}
+td {
+ vertical-align: top;
+ padding: 0 3px;
+}
.clr {
clear: both;
}
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;
}
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 {
$(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));
});