Commit 9adac789d70b8f4e2c32ef66c97798046fc22644
1 parent
7c050bcb
Add Book Document type.
Showing
9 changed files
with
87 additions
and
13 deletions
collector/storage/admin.py
... | ... | @@ -3,7 +3,7 @@ from django.contrib import admin |
3 | 3 | from admin_numeric_filter.admin import RangeNumericFilter |
4 | 4 | |
5 | 5 | from storage.models import Chunk, Document, Keyword, Metadata, Participant, Annotation, Magazine, \ |
6 | - BookWithMultipleAuthors, Article, Chapter | |
6 | + Book, BookWithMultipleAuthors, Article, Chapter | |
7 | 7 | |
8 | 8 | |
9 | 9 | class ChunkInline(admin.StackedInline): |
... | ... | @@ -22,6 +22,10 @@ class MetadataInline(admin.StackedInline): |
22 | 22 | fields = ('id',) |
23 | 23 | |
24 | 24 | |
25 | +class ParticipantAdmin(admin.ModelAdmin): | |
26 | + list_filter = ('role', 'type',) | |
27 | + | |
28 | + | |
25 | 29 | class ParticipantsInline(admin.StackedInline): |
26 | 30 | model = Participant |
27 | 31 | can_delete = False |
... | ... | @@ -51,9 +55,10 @@ class AnnotationAdmin(admin.ModelAdmin): |
51 | 55 | admin.site.register(Chunk, ChunkAdmin) |
52 | 56 | admin.site.register(Document, DocumentAdmin) |
53 | 57 | admin.site.register(Magazine) |
58 | +admin.site.register(Book) | |
54 | 59 | admin.site.register(BookWithMultipleAuthors) |
55 | 60 | admin.site.register(Article) |
56 | 61 | admin.site.register(Chapter) |
57 | 62 | admin.site.register(Keyword) |
58 | -admin.site.register(Participant) | |
63 | +admin.site.register(Participant, ParticipantAdmin) | |
59 | 64 | admin.site.register(Annotation, AnnotationAdmin) |
... | ... |
collector/storage/forms.py
... | ... | @@ -3,7 +3,7 @@ import re |
3 | 3 | from django.forms import ChoiceField, ModelChoiceField, ModelForm, Textarea, CharField, Form |
4 | 4 | from django import forms |
5 | 5 | |
6 | -from .models import Chunk, Document, Participant, Metadata, Keyword, Magazine, BookWithMultipleAuthors | |
6 | +from .models import Chunk, Document, Participant, Metadata, Keyword, Magazine, Book, BookWithMultipleAuthors | |
7 | 7 | from .utils import get_doc_with_type |
8 | 8 | from projects.ppc.models import Utterance |
9 | 9 | from collector import settings |
... | ... | @@ -186,7 +186,8 @@ class AuthorForm(ModelForm): |
186 | 186 | self.fields['name'].widget = Textarea(attrs={'rows': 1}) |
187 | 187 | roles_choices = ( |
188 | 188 | ('author', 'autor'), |
189 | - ('translator', 'tłumacz') | |
189 | + ('translator', 'tłumacz'), | |
190 | + ('editor', 'redaktor') | |
190 | 191 | ) |
191 | 192 | self.fields['role'] = ChoiceField(choices=roles_choices, label="Rola") |
192 | 193 | |
... | ... | @@ -284,6 +285,17 @@ DOC_TYPE_DETAILS_FIELDS = { |
284 | 285 | 'original_lang': 'Język oryginału' |
285 | 286 | } |
286 | 287 | }, |
288 | + Book: { | |
289 | + 'fields': ['title', 'publication_date', 'publication_place', 'publisher', 'channel', 'original_lang'], | |
290 | + 'labels': { | |
291 | + 'title': 'Tytuł', | |
292 | + 'publication_date': 'Data publikacji', | |
293 | + 'publication_place': 'Miejsce publikacji', | |
294 | + 'publisher': 'Wydawca', | |
295 | + 'channel': 'Kanał', | |
296 | + 'original_lang': 'Język oryginału' | |
297 | + } | |
298 | + }, | |
287 | 299 | BookWithMultipleAuthors: { |
288 | 300 | 'fields': ['title', 'publication_date', 'publication_place', 'publisher', 'channel', 'original_lang'], |
289 | 301 | 'labels': { |
... | ... | @@ -345,6 +357,30 @@ class MagazineDetailsForm(ModelForm): |
345 | 357 | } |
346 | 358 | |
347 | 359 | |
360 | +class BookDetailsForm(ModelForm): | |
361 | + def __init__(self, *args, **kwargs): | |
362 | + super(BookDetailsForm, self).__init__(*args, **kwargs) | |
363 | + self.fields['title'].widget = Textarea(attrs={'rows': 1}) | |
364 | + | |
365 | + def save(self, commit=True): | |
366 | + book = super(BookDetailsForm, self).save(commit) | |
367 | + book.changed = True | |
368 | + book.save() | |
369 | + return book | |
370 | + | |
371 | + class Meta: | |
372 | + model = Book | |
373 | + fields = ['title', 'publication_date', 'publication_place', 'publisher', 'channel', 'original_lang'] | |
374 | + labels = { | |
375 | + 'title': 'Tytuł', | |
376 | + 'publication_date': 'Data publikacji', | |
377 | + 'publication_place': 'Miejsce publikacji', | |
378 | + 'publisher': 'Wydawca', | |
379 | + 'channel': 'Kanał', | |
380 | + 'original_lang': 'Język oryginału' | |
381 | + } | |
382 | + | |
383 | + | |
348 | 384 | class BWMADetailsForm(ModelForm): |
349 | 385 | def __init__(self, *args, **kwargs): |
350 | 386 | super(BWMADetailsForm, self).__init__(*args, **kwargs) |
... | ... |
collector/storage/models.py
... | ... | @@ -183,6 +183,20 @@ class BookWithMultipleAuthors(Document): |
183 | 183 | return 'książka o wielu autorach' |
184 | 184 | |
185 | 185 | |
186 | +class Book(Document): | |
187 | + publisher = models.CharField(max_length=100, null=True) | |
188 | + | |
189 | + def check_details_filling(self): | |
190 | + if self.title == '' or self.publication_date is None or self.publication_place == '' or self.publisher == '' \ | |
191 | + or self.original_lang == '': | |
192 | + return False | |
193 | + return True | |
194 | + | |
195 | + @staticmethod | |
196 | + def get_doc_type_display(): | |
197 | + return 'książka' | |
198 | + | |
199 | + | |
186 | 200 | class Article(Document): |
187 | 201 | @staticmethod |
188 | 202 | def get_doc_type_display(): |
... | ... | @@ -258,6 +272,8 @@ class Participant(models.Model): |
258 | 272 | return 'autor' |
259 | 273 | elif self.role == 'translator': |
260 | 274 | return 'tłumacz' |
275 | + elif self.role == 'editor': | |
276 | + return 'redaktor' | |
261 | 277 | return None |
262 | 278 | |
263 | 279 | class Meta: |
... | ... |
collector/storage/templates/storage/annotation.html
... | ... | @@ -116,7 +116,7 @@ |
116 | 116 | {% endif %} |
117 | 117 | |
118 | 118 | {% if document and not document.image and not document.broken_source %} |
119 | - <div class="modal fade" tabindex="-1" role="dialog" id="modal"> | |
119 | + <div class="modal fade" tabindex="-1" role="dialog" id="modal" data-backdrop="static"> | |
120 | 120 | <div class="modal-dialog" role="document"> |
121 | 121 | <div class="modal-content"></div> |
122 | 122 | </div> |
... | ... | @@ -207,6 +207,8 @@ |
207 | 207 | <th>Numer</th> |
208 | 208 | {% elif document|isinst:"storage.models.BookWithMultipleAuthors" %} |
209 | 209 | <th>Wydawca</th> |
210 | + {% elif document|isinst:"storage.models.Book" %} | |
211 | + <th>Wydawca</th> | |
210 | 212 | {% endif %} |
211 | 213 | <th>Kanał</th> |
212 | 214 | <th>Typ</th> |
... | ... | @@ -220,6 +222,9 @@ |
220 | 222 | {% elif document|isinst:"storage.models.BookWithMultipleAuthors" %} |
221 | 223 | <i class="edit-doc-details material-icons button edit" data-id="{% url 'edit_bwma_details' document.pk %}" |
222 | 224 | title="Edytuj">edit</i> |
225 | + {% elif document|isinst:"storage.models.Book" %} | |
226 | + <i class="edit-doc-details material-icons button edit" data-id="{% url 'edit_book_details' document.pk %}" | |
227 | + title="Edytuj">edit</i> | |
223 | 228 | {% elif document|isinst:"storage.models.Document" %} |
224 | 229 | <i class="edit-doc-details material-icons button edit" data-id="{% url 'edit_doc_details' document.pk %}" |
225 | 230 | title="Edytuj">edit</i> |
... | ... | @@ -238,6 +243,8 @@ |
238 | 243 | <td>{{ document.number|default_if_none:'' }}</td> |
239 | 244 | {% elif document|isinst:"storage.models.BookWithMultipleAuthors" %} |
240 | 245 | <td>{{ document.publisher|default_if_none:'' }}</td> |
246 | + {% elif document|isinst:"storage.models.Book" %} | |
247 | + <td>{{ document.publisher|default_if_none:'' }}</td> | |
241 | 248 | {% endif %} |
242 | 249 | <td>{{ document.channel }}</td> |
243 | 250 | <td>{{ document.type }}</td> |
... | ... | @@ -250,7 +257,7 @@ |
250 | 257 | {% endif %} |
251 | 258 | |
252 | 259 | <div class="info"> |
253 | - <p>Autorzy i tłumacze:</p> | |
260 | + <p>Autorzy, tłumacze i redaktorzy:</p> | |
254 | 261 | </div> |
255 | 262 | |
256 | 263 | <table id="authors" class="doc-table"> |
... | ... |
collector/storage/templates/storage/review.html
... | ... | @@ -136,6 +136,8 @@ |
136 | 136 | <th>Numer</th> |
137 | 137 | {% elif document|isinst:BookWithMultipleAuthors %} |
138 | 138 | <th>Wydawca</th> |
139 | + {% elif document|isinst:Book %} | |
140 | + <th>Wydawca</th> | |
139 | 141 | {% endif %} |
140 | 142 | <th>Kanał</th> |
141 | 143 | <th>Typ</th> |
... | ... | @@ -153,6 +155,8 @@ |
153 | 155 | <td>{{ document.number }}</td> |
154 | 156 | {% elif document|isinst:BookWithMultipleAuthors %} |
155 | 157 | <td>{{ document.publisher }}</td> |
158 | + {% elif document|isinst:Book %} | |
159 | + <td>{{ document.publisher }}</td> | |
156 | 160 | {% endif %} |
157 | 161 | <td>{{ document.channel }}</td> |
158 | 162 | <td>{{ document.type }}</td> |
... | ... | @@ -163,7 +167,7 @@ |
163 | 167 | </table> |
164 | 168 | |
165 | 169 | <div class="info"> |
166 | - <p>Autorzy i tłumacze:</p> | |
170 | + <p>Autorzy, tłumacze i redaktorzy:</p> | |
167 | 171 | </div> |
168 | 172 | |
169 | 173 | <table id="authors" class="doc-table"> |
... | ... |
collector/storage/templatetags/filters.py
collector/storage/urls.py
... | ... | @@ -14,6 +14,8 @@ urlpatterns = [ |
14 | 14 | name='edit_magazine_details'), |
15 | 15 | path('document/edit-bwma-details/<int:pk>', login_required(views.BWMADetailsEditView.as_view()), |
16 | 16 | name='edit_bwma_details'), |
17 | + path('document/edit-book-details/<int:pk>', login_required(views.BookDetailsEditView.as_view()), | |
18 | + name='edit_book_details'), | |
17 | 19 | path('document/edit-subdoc-details/<int:pk>', login_required(views.SubDocDetailsEditView.as_view()), |
18 | 20 | name='edit_subdoc_details'), |
19 | 21 | path('chunk/add/<str:doc_id>', login_required(views.ChunkAddBetweenView.as_view()), name='add_chunk_between'), |
... | ... |
collector/storage/utils.py
1 | -from .models import Document, Magazine, BookWithMultipleAuthors, Article, Chapter | |
1 | +from .models import Document, Magazine, Book, BookWithMultipleAuthors, Article, Chapter | |
2 | 2 | |
3 | -DOCUMENT_TYPES_CLASSES = Document, Magazine, BookWithMultipleAuthors | |
3 | +DOCUMENT_TYPES_CLASSES = Document, Magazine, Book, BookWithMultipleAuthors | |
4 | 4 | |
5 | 5 | SUBDOCUMENT_TYPES = { # first subdocument type in tuples are the default ones for this type of the document |
6 | 6 | Document: (Document,), |
7 | 7 | Magazine: (Article,), |
8 | + Book: (Chapter,), | |
8 | 9 | BookWithMultipleAuthors: (Chapter,) |
9 | 10 | } |
10 | 11 | |
... | ... |
collector/storage/views.py
... | ... | @@ -23,8 +23,8 @@ from functools import partial, wraps |
23 | 23 | |
24 | 24 | from .forms import ChunkForm, ParticipantForm, SubchunkForm, MetadataForm, KeywordForm, DocSplitForm, ChunkMoveForm, \ |
25 | 25 | SubDocDetailsForm, AuthorForm, ChunkMergeForm, ChunkSplitForm, DocTypeForm, DocDetailsForm, MagazineDetailsForm, \ |
26 | - BWMADetailsForm | |
27 | -from .models import Chunk, Document, Participant, Metadata, Keyword, Annotation, Magazine, BookWithMultipleAuthors | |
26 | + BookDetailsForm, BWMADetailsForm | |
27 | +from .models import Chunk, Document, Participant, Metadata, Keyword, Annotation, Magazine, Book, BookWithMultipleAuthors | |
28 | 28 | from .utils import get_remaining_doc_types_tuple, get_remaining_subdoc_types_tuple, get_doc_with_type, SUBDOCUMENT_TYPES |
29 | 29 | from projects.ppc.models import Utterance |
30 | 30 | from pipeline.models import ProcessingStatus |
... | ... | @@ -771,6 +771,11 @@ class MagazineDetailsEditView(DocDetailsEditView): |
771 | 771 | form_class = MagazineDetailsForm |
772 | 772 | |
773 | 773 | |
774 | +class BookDetailsEditView(DocDetailsEditView): | |
775 | + model = Book | |
776 | + form_class = BookDetailsForm | |
777 | + | |
778 | + | |
774 | 779 | class BWMADetailsEditView(DocDetailsEditView): |
775 | 780 | model = BookWithMultipleAuthors |
776 | 781 | form_class = BWMADetailsForm |
... | ... |