korektury¶
Seznam pdf k opravě a opraf v djangu místo PHP.
korektury.admin¶
Soubor sloužící k definici toho, co bude v adminu. Většinou pouhým zavoláním
funkce django.contrib.admin.site.register()
, v případě, že chceme něco
upravit, tak jako třída rozšiřující django.contrib.admin.ModelAdmin
s dekorátorem django.contrib.admin.register()
.
Zde se definuje admin pro:
- class korektury.admin.KorekturovanePDFAdmin(*args, **kwargs)[zdroj]¶
Bases:
VersionAdmin
nastaví čas vložení (
cas
) a počet stran (stran
) jako readonly = neměnitelnýPři prvním uložení pošle e-mail.
- readonly_fields = ['cas', 'stran']¶
- fieldsets = [(None, {'fields': ['pdf', 'cas', 'org', 'stran', 'nazev', 'komentar', 'poslat_mail']})]¶
- list_display = ['nazev', 'cas', 'stran', 'org']¶
- list_filter = []¶
- search_fields = []¶
- save_model(request, obj, form, change)[zdroj]¶
Pokud je soubor nový a má se poslat e-mail, tak pošle e-mail o novém pdf.
- property media¶
korektury.forms¶
Formuláře (django.forms.Form
) umožňují jednoduchou tvorbu formulářů,
které lze pak jednoduše dát do frontendu i zpracovat na backendu.
- Pro přidání políčka do formuláře je potřeba
mít v modelu tu položku, kterou chci upravovat
přidat do views (prihlaskaView, resitelEditView)
přidat do forms
includovat do html
- class korektury.forms.OpravaForm(data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=<class 'django.forms.utils.ErrorList'>, label_suffix=None, empty_permitted=False, field_order=None, use_required_attribute=None, renderer=None)[zdroj]¶
Bases:
Form
formulář k přidání opravy (
korektury.models.Oprava
)- base_fields = {'action': <django.forms.fields.CharField object>, 'autor': <django.forms.fields.CharField object>, 'id': <django.forms.fields.CharField object>, 'img_id': <django.forms.fields.CharField object>, 'pdf': <django.forms.fields.CharField object>, 'scroll': <django.forms.fields.CharField object>, 'text': <django.forms.fields.CharField object>, 'x': <django.forms.fields.IntegerField object>, 'y': <django.forms.fields.IntegerField object>}¶
- declared_fields = {'action': <django.forms.fields.CharField object>, 'autor': <django.forms.fields.CharField object>, 'id': <django.forms.fields.CharField object>, 'img_id': <django.forms.fields.CharField object>, 'pdf': <django.forms.fields.CharField object>, 'scroll': <django.forms.fields.CharField object>, 'text': <django.forms.fields.CharField object>, 'x': <django.forms.fields.IntegerField object>, 'y': <django.forms.fields.IntegerField object>}¶
- property media¶
korektury.models¶
Tento soubor slouží k definici databázového modelu.
Třídy rozšiřují většinou django.db.models.Model
a jejich atributy jsou
většinou sloupce v databázi (tj. nastaví se na hodnotu něčeho z django.db.models
).
Na výběr jsou:
- korektury.models.generate_filename(self, filename)[zdroj]¶
vyrobí jméno souboru podle původního jména a času nahrátí
- class korektury.models.KorekturovanePDF(id, cas, nazev, komentar, pdf, org, stran, status, poslat_mail)[zdroj]¶
Bases:
Model
- id¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- cas¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- nazev¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- komentar¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- pdf¶
The descriptor for the file attribute on the model instance. Return a FieldFile when accessed so you can write code like:
>>> from myapp.models import MyModel >>> instance = MyModel.objects.get(pk=1) >>> instance.file.size
Assign a file object on assignment so you can do:
>>> with open('/path/to/hello.world') as f: ... instance.file = File(f)
- org¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parent
is aForwardManyToOneDescriptor
instance.
- stran¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- STATUS_PRIDAVANI = 'pridavani'¶
- STATUS_ZANASENI = 'zanaseni'¶
- STATUS_ZASTARALE = 'zastarale'¶
- STATUS_CHOICES = (('pridavani', 'Přidávání korektur'), ('zanaseni', 'Korektury jsou zanášeny'), ('zastarale', 'Stará verze, nekorigovat'))¶
- status¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- poslat_mail¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- cislo_a_tema¶
- exception DoesNotExist¶
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned¶
Bases:
MultipleObjectsReturned
- get_next_by_cas(*, field=<django.db.models.fields.DateTimeField: cas>, is_next=True, **kwargs)¶
- get_previous_by_cas(*, field=<django.db.models.fields.DateTimeField: cas>, is_next=False, **kwargs)¶
- get_status_display(*, field=<django.db.models.fields.CharField: status>)¶
- objects = <django.db.models.manager.Manager object>¶
- oprava_set¶
Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Parent.children
is aReverseManyToOneDescriptor
instance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
- org_id¶
- class korektury.models.Oprava(id, pdf, strana, x, y, status, autor, text)[zdroj]¶
Bases:
Model
- id¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- pdf¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parent
is aForwardManyToOneDescriptor
instance.
- strana¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- x¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- y¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- STATUS_K_OPRAVE = 'k_oprave'¶
- STATUS_OPRAVENO = 'opraveno'¶
- STATUS_NENI_CHYBA = 'neni_chyba'¶
- STATUS_K_ZANESENI = 'k_zaneseni'¶
- STATUS_CHOICES = (('k_oprave', 'K opravě'), ('opraveno', 'Opraveno'), ('neni_chyba', 'Není chyba'), ('k_zaneseni', 'K zanesení do TeXu'))¶
- status¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- autor¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parent
is aForwardManyToOneDescriptor
instance.
- text¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- exception DoesNotExist¶
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned¶
Bases:
MultipleObjectsReturned
- autor_id¶
- get_status_display(*, field=<django.db.models.fields.CharField: status>)¶
- komentar_set¶
Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Parent.children
is aReverseManyToOneDescriptor
instance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
- objects = <django.db.models.manager.Manager object>¶
- pdf_id¶
- class korektury.models.Komentar(id, cas, oprava, autor, text)[zdroj]¶
Bases:
Model
- id¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- cas¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- oprava¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parent
is aForwardManyToOneDescriptor
instance.
- autor¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parent
is aForwardManyToOneDescriptor
instance.
- text¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- exception DoesNotExist¶
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned¶
Bases:
MultipleObjectsReturned
- autor_id¶
- get_next_by_cas(*, field=<django.db.models.fields.DateTimeField: cas>, is_next=True, **kwargs)¶
- get_previous_by_cas(*, field=<django.db.models.fields.DateTimeField: cas>, is_next=False, **kwargs)¶
- objects = <django.db.models.manager.Manager object>¶
- oprava_id¶
korektury.tests¶
korektury.testutils¶
Soubor sloužící ke generování testdat.
korektury.urls¶
Soubor sloužící jako „router“, tj. zde se definují url adresy a na co ukazují:
korektury/
(korektury_list)KorekturySeskupeneListView
korektury/neseskupene/
(korektury_neseskupene_list)KorekturyAktualniListView
korektury/zastarale/
(korektury_stare_list)KorekturyZastaraleListView
korektury/<int:pdf>/
(korektury)KorekturyView
korektury.views¶
Soubor sloužící k deklaraci jednotlivých „views“ (nejčastěji funkce beroucí request
a vracející django.shortcuts.render()
respektive nějakou response, nebo
třídy většinou rozšiřující nějakou třídu z django.views.generic
)
- class korektury.views.KorekturyListView(**kwargs)[zdroj]¶
Bases:
ListView
- model¶
alias of
KorekturovanePDF
- queryset¶
- template_name = 'korektury/seznam.html'¶
- class korektury.views.KorekturyAktualniListView(**kwargs)[zdroj]¶
Bases:
KorekturyListView
- class korektury.views.KorekturyZastaraleListView(**kwargs)[zdroj]¶
Bases:
KorekturyListView
- class korektury.views.KorekturySeskupeneListView(**kwargs)[zdroj]¶
Bases:
KorekturyAktualniListView
- template_name = 'korektury/seskupeny_seznam.html'¶
- class korektury.views.KorekturyView(**kwargs)[zdroj]¶
Bases:
TemplateView
- template_name = 'korektury/opraf.html'¶
- form_class¶
alias of
OpravaForm