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']
get_readonly_fields(request, obj=None)[zdroj]

Když pdf existuje, tak nedovolím měnit ani pdf.

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 a ForwardManyToOneDescriptor 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.

get_prefix()[zdroj]

Vrať řetězec, ke kterému se připojí číslo a .png

convert()[zdroj]

Vytvoří jedno png za každou stranu pdf a uloží se

save(**kwargs)[zdroj]
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 a ReverseManyToOneDescriptor 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 a ForwardManyToOneDescriptor 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 a ForwardManyToOneDescriptor 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 a ReverseManyToOneDescriptor 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 a ForwardManyToOneDescriptor 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 a ForwardManyToOneDescriptor 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.testutils.create_test_pdf(rnd, organizatori)[zdroj]

Vyrobí testovací pdf ke korekturování. Nevyrábí korektury!

korektury.urls

Soubor sloužící jako „router“, tj. zde se definují url adresy a na co ukazují:

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

get_queryset(*args, **kwargs)[zdroj]
get_context_data(**kwargs)[zdroj]
class korektury.views.KorekturyZastaraleListView(**kwargs)[zdroj]

Bases: KorekturyListView

get_queryset(*args, **kwargs)[zdroj]
get_context_data(**kwargs)[zdroj]
class korektury.views.KorekturySeskupeneListView(**kwargs)[zdroj]

Bases: KorekturyAktualniListView

template_name = 'korektury/seskupeny_seznam.html'
get_queryset(*args, **kwargs)[zdroj]
class korektury.views.KorekturyView(**kwargs)[zdroj]

Bases: TemplateView

model

alias of Oprava

template_name = 'korektury/opraf.html'
form_class

alias of OpravaForm

post(request, *args, **kwargs)[zdroj]
send_email_notification_komentar(oprava, autor)[zdroj]

Rozesle e-mail pri pridani komentare / opravy, ktery obsahuje text vlakna opravy.

get_context_data(**kwargs)[zdroj]
form_valid(form)[zdroj]