Browse Source

Merge branch 'pseudo_master' into test

middleware_test
Pavel "LEdoian" Turinsky 4 years ago
parent
commit
0824df7359
  1. 10
      .gitignore
  2. 3
      MIGRATIONS
  3. 112
      Makefile
  4. 14
      README.md
  5. BIN
      Schema_new.dia
  6. 17
      convert_spaces_to_tabs.sh
  7. 332
      flat.json
  8. 64
      galerie/admin.py
  9. 6
      galerie/autocomplete_light_registry.py.old
  10. 6
      galerie/forms.py
  11. 6
      galerie/migrations/0001_initial.py
  12. 2
      galerie/migrations/0004_nepovinna_galerie_u_obrazku.py
  13. 71
      galerie/migrations/0008_auto_20190430_2340.py
  14. 31
      galerie/migrations/0009_auto_20190610_2358.py
  15. 8
      galerie/migrations/0010_auto_20200819_0947.py
  16. 181
      galerie/models.py
  17. BIN
      galerie/static/galerie/prvky/dalsi.png
  18. 65
      galerie/static/galerie/prvky/dalsi.svg
  19. BIN
      galerie/static/galerie/prvky/nahoru.png
  20. BIN
      galerie/static/galerie/prvky/predchozi.png
  21. 65
      galerie/static/galerie/prvky/predchozi.svg
  22. 12
      galerie/urls.py
  23. 413
      galerie/views.py
  24. 16
      init_local.sh
  25. 28
      korektury/admin.py
  26. 18
      korektury/forms.py
  27. 2
      korektury/migrations/0001_initial.py
  28. 2
      korektury/migrations/0002_auto_20151202_2351.py
  29. 2
      korektury/migrations/0006_oprava_pdf.py
  30. 4
      korektury/migrations/0010_Pridani_odkazu_na_organizatora.py
  31. 8
      korektury/migrations/0011_prevod_autora_z_charField_na_Organizator.py
  32. 10
      korektury/migrations/0014_add_org_to_pdf.py
  33. 2
      korektury/migrations/0015_auto_20161004_2005.py
  34. 77
      korektury/migrations/0016_auto_20190430_2340.py
  35. 36
      korektury/migrations/0017_auto_20190610_2358.py
  36. 323
      korektury/models.py
  37. 87
      korektury/static/korektury/opraf.css
  38. 68
      korektury/static/korektury/opraf.js
  39. 38
      korektury/templates/korektury/opraf.html
  40. 9
      korektury/templates/korektury/seznam.html
  41. 11
      korektury/urls.py
  42. 369
      korektury/views.py
  43. 43
      mamweb/settings_common.py
  44. 13
      mamweb/settings_debug.py
  45. 48
      mamweb/settings_local.py
  46. 2
      mamweb/settings_prod.py
  47. 2
      mamweb/settings_test.py
  48. 984
      mamweb/static/css/mamweb.css
  49. BIN
      mamweb/static/favicon.ico
  50. 201
      mamweb/static/fonts/OpenSans/Apache License.txt
  51. BIN
      mamweb/static/fonts/OpenSans/OpenSans-Bold.ttf
  52. BIN
      mamweb/static/fonts/OpenSans/OpenSans-BoldItalic.ttf
  53. BIN
      mamweb/static/fonts/OpenSans/OpenSans-ExtraBold.ttf
  54. BIN
      mamweb/static/fonts/OpenSans/OpenSans-ExtraBoldItalic.ttf
  55. BIN
      mamweb/static/fonts/OpenSans/OpenSans-Italic.ttf
  56. BIN
      mamweb/static/fonts/OpenSans/OpenSans-Light.ttf
  57. BIN
      mamweb/static/fonts/OpenSans/OpenSans-LightItalic.ttf
  58. BIN
      mamweb/static/fonts/OpenSans/OpenSans-Regular.ttf
  59. BIN
      mamweb/static/fonts/OpenSans/OpenSans-Semibold.ttf
  60. BIN
      mamweb/static/fonts/OpenSans/OpenSans-SemiboldItalic.ttf
  61. 120
      mamweb/static/images/MATFYZ_MM_barevne.svg
  62. BIN
      mamweb/static/images/footer-bg-bottom.png
  63. BIN
      mamweb/static/images/footer-bg-top.png
  64. BIN
      mamweb/static/images/graf/adrenalinove.jpeg
  65. BIN
      mamweb/static/images/graf/behaci.jpeg
  66. BIN
      mamweb/static/images/graf/ceny.jpeg
  67. BIN
      mamweb/static/images/graf/deskovky.jpeg
  68. BIN
      mamweb/static/images/graf/dort.jpeg
  69. BIN
      mamweb/static/images/graf/hry.jpeg
  70. BIN
      mamweb/static/images/graf/jidlo.jpeg
  71. BIN
      mamweb/static/images/graf/konfery.jpeg
  72. BIN
      mamweb/static/images/graf/legenda.jpeg
  73. BIN
      mamweb/static/images/graf/prednasky.jpeg
  74. BIN
      mamweb/static/images/graf/strategicke.jpeg
  75. BIN
      mamweb/static/images/graf/vylet.jpeg
  76. BIN
      mamweb/static/images/graph.png
  77. BIN
      mamweb/static/images/header-bg-archiv-NOC.jpg
  78. BIN
      mamweb/static/images/header-bg-archiv.jpg
  79. BIN
      mamweb/static/images/header-bg-clanek-NOC.jpg
  80. BIN
      mamweb/static/images/header-bg-clanek.jpg
  81. BIN
      mamweb/static/images/header-bg-odevzdat-NOC.jpg
  82. BIN
      mamweb/static/images/header-bg-soustredeni-NOC.jpg
  83. BIN
      mamweb/static/images/header-bg-soustredeni.jpg
  84. BIN
      mamweb/static/images/header-bg-uvod-NOC.jpg
  85. BIN
      mamweb/static/images/header-bg-uvod.jpg
  86. BIN
      mamweb/static/images/header-bg-zadani-NOC.jpg
  87. BIN
      mamweb/static/images/header-bg-zadani.jpg
  88. BIN
      mamweb/static/images/header-bg.jpg
  89. BIN
      mamweb/static/images/header/baliky.jpg
  90. BIN
      mamweb/static/images/header/beh.jpg
  91. BIN
      mamweb/static/images/header/kryptografie.jpg
  92. BIN
      mamweb/static/images/header/mam_cernobile.jpg
  93. BIN
      mamweb/static/images/header/noc.jpg
  94. BIN
      mamweb/static/images/header/ohen.jpg
  95. BIN
      mamweb/static/images/header/snih.jpg
  96. BIN
      mamweb/static/images/header/spolecna.jpg
  97. BIN
      mamweb/static/images/header/stiny.jpg
  98. BIN
      mamweb/static/images/header/vikendovka.jpg
  99. BIN
      mamweb/static/images/header/vylet.jpg
  100. BIN
      mamweb/static/images/logo-jcmf.png

10
.gitignore

@ -1,11 +1,5 @@
# virtual env # virtual env
/bin/ /env/
/include/
/lib/
/local/
/share/
/virtualenv/
/pip-selfcheck.json
# transient files # transient files
/db-test.sqlite3* /db-test.sqlite3*
@ -16,7 +10,7 @@
# aux files # aux files
*.pyc *.pyc
*.swp *.sw[mnop]
# secrets # secrets
/django.secret /django.secret

3
MIGRATIONS

@ -0,0 +1,3 @@
Jak zvládnout migrace na nový model:
- V mojí verzi databáze mají úlohy-Problémy typ "b'uloha'"

112
Makefile

@ -1,68 +1,69 @@
.PHONY: clean_env init_env clean_virtualenv install_packages clean install run all schema_seminar.pdf schema_all.pdf sync_test_media sync_test_db sync_test sync_local_media sync_local_db sync_local PYTHON ?= python3
PYTHON=python2.7 VENV ?= ${PYTHON} -m venv
VE_VER=16.0.0 # Všechny flagy, které se s venvem/virtualenvem/... mají volat patří sem. Volá se "${VENV} cesta"
LOCAL_PYTHON=bin/python VENV_PATH ?= env
# Musí být definovaná, i kdyby to měla být "."
all: install
.PHONY: all venv_check clean install install_web install_venv clean_venv clean_schema run test deploy_test deploy_prod sync_test_media sync_test_db sync_test sync_local_media sync_local_db sync_local
clean: clean_env
# activate by mělo být předpokladem ke všemu, co volá webový python (i.e. python nasazený do ${VENV}u kvůli webu, např. manage.py)
veryclean: clean clean_virtualenv all:
@# Just echo:
install: virtualenv bin/python install_packages # Install je trochu magický:
# Spusť následující posloupnost příkazů:
# make install_venv
# phony, but depends on file # . ${VENV_PATH}/bin/activate
make_env: ${LOCAL_PYTHON} # make install_web
#
# phony, but fast repeated execution # Pokud install_web říká Error: pg_config executable not found. nainstaluj si libpq-dev
install_packages: make_env # Pokud chybová hláška obsahuje #include <Python.h>, nainstaluj si python3-dev
bin/pip install -r requirements.txt --upgrade #
# Až skončíš s vývojem webu, spusť "deactivate". Tím zmizí '(${VENV_PATH})' ze začátku promptu.
# phony
clean_env: venv_check:
rm -rf bin/ include/ lib/ local/ share/ @# Pokud org nemá zapnutý venv, poradíme mu, aby si ho zapnul a spadneme. Jinak nic.
@expr $$PATH : ".*:*$(shell pwd)/${VENV_PATH}/bin" > /dev/null && exit 0 || echo 'Není zapnutý venv, spusť ". ${VENV_PATH}/bin/activate".\nPokud není venv nainstalovaný, spusť "make install_venv"' && false
clean: clean_venv clean_schema
install: install_web
install_web: venv_check
@# venv může být příšerně starý, takže nejdříve upgradujeme venvové věci
pip install --upgrade pip
pip install --upgrade setuptools
# Instalace závislostí webu
pip install -r requirements.txt --upgrade
install_venv:
${VENV} ${VENV_PATH}
clean_venv:
# Možná není 100% foolproof...
@test ! ${VENV_PATH} = . || ! echo "Smaž si prosím venv sám, nebudu mazat celý web"
rm -rfv ${VENV_PATH}
rm -f pip-selfcheck.json rm -f pip-selfcheck.json
clean_schema:
rm -f schema_seminar.pdf schema_all.pdf rm -f schema_seminar.pdf schema_all.pdf
# binary name representing set-up env run: venv_check
${LOCAL_PYTHON}: virtualenv
${PYTHON} virtualenv/virtualenv.py .
# directory name
virtualenv:
# I could not find a link without hash anymore. This will probably break in
# the future.
curl -O https://files.pythonhosted.org/packages/33/bc/fa0b5347139cd9564f0d44ebd2b147ac97c36b2403943dbee8a25fd74012/virtualenv-16.0.0.tar.gz
tar xvfz virtualenv-${VE_VER}.tar.gz
mv -T virtualenv-${VE_VER} virtualenv
rm virtualenv-${VE_VER}.tar.gz
# phony
clean_virtualenv:
rm -rf virtualenv/
rm -rf virtualenv-*.tar.gz
run:
./manage.py runserver ./manage.py runserver
test: test: venv_check
./manage.py test -v2 seminar mamweb ./manage.py test -v2 seminar mamweb
# DB schemata # DB schemata
schema: schema_seminar.pdf schema_all.pdf schema: schema_seminar.pdf schema_all.pdf
schema_seminar.pdf: schema_seminar.pdf: venv_check
./manage.py graph_models seminar | dot -Tpdf > schema_seminar.pdf ./manage.py graph_models seminar | dot -Tpdf > schema_seminar.pdf
schema_all.pdf: schema_all.pdf: venv_check
./manage.py graph_models -a -g | dot -Tpdf > schema_all.pdf ./manage.py graph_models -a -g | dot -Tpdf > schema_all.pdf
# Deploy to current *mamweb-test* directory # Deploy to current *mamweb-test* directory
deploy_test: deploy_test: venv_check
@if [ ${USER} != "mam-web" ]; then echo "Only possible by user mam-web"; exit 1; fi @if [ ${USER} != "mam-web" ]; then echo "Only possible by user mam-web"; exit 1; fi
@if [ `readlink -f .` != "/aux/akce/mam/www/mamweb-test" ]; then echo "Only possible in directory mamweb-test"; exit 1; fi @if [ `readlink -f .` != "/aux/akce/mam/www/mamweb-test" ]; then echo "Only possible in directory mamweb-test"; exit 1; fi
@echo "Installing version from origin/test ..." @echo "Installing version from origin/test ..."
@ -78,7 +79,7 @@ deploy_test:
@echo Done. @echo Done.
# Deploy to current *mamweb-prod* directory # Deploy to current *mamweb-prod* directory
deploy_prod: deploy_prod: venv_check
@if [ ${USER} != "mam-web" ]; then echo "Only possible by user mam-web"; exit 1; fi @if [ ${USER} != "mam-web" ]; then echo "Only possible by user mam-web"; exit 1; fi
@if [ `readlink -f .` != "/aux/akce/mam/www/mamweb-prod" ]; then echo "Only possible in directory mamweb-prod"; exit 1; fi @if [ `readlink -f .` != "/aux/akce/mam/www/mamweb-prod" ]; then echo "Only possible in directory mamweb-prod"; exit 1; fi
@echo "Backing up production DB ..." @echo "Backing up production DB ..."
@ -96,6 +97,15 @@ deploy_prod:
@echo Done. @echo Done.
sync_prod_flatpages: venv_check
@echo Downloading current version of flatpages from mamweb-prod.
ssh mam-web@gimli.ms.mff.cuni.cz \
"cd /akce/mam/www/mamweb-prod; ./manage.py dumpdata flatpages --indent=2 > flat.json"
rsync -ave ssh mam-web@gimli.ms.mff.cuni.cz:/akce/mam/www/mamweb-prod/flat.json ./flat.json
@echo "Applying downloaded flatpages."
./manage.py loaddata flat.json
@echo "Done."
# Sync test media directory with production # Sync test media directory with production
sync_test_media: sync_test_media:
@if [ ${USER} != "mam-web" ]; then echo "Only possible by user mam-web"; exit 1; fi @if [ ${USER} != "mam-web" ]; then echo "Only possible by user mam-web"; exit 1; fi
@ -128,4 +138,4 @@ sync_local_db:
pg_restore -c -d mam-prod last.pgdump pg_restore -c -d mam-prod last.pgdump
# Sync database and media. See above lines # Sync database and media. See above lines
sync_local: sync_media sync_db sync_local: sync_local_media sync_local_db

14
README.md

@ -13,12 +13,12 @@ Use git :-)
Quickstart Quickstart
---------- ----------
Run the following commands:
make install_venv
. env/bin/activate
make install_web
Install the following packages in Debian/Ubuntu: `libpq-dev python-dev python-setuptools python2.7 libjpeg-dev libpng12-dev`. Then run: After finishing development, run "deactivate".
make
./manage.py testdata
make run
Make commands Make commands
------------- -------------
@ -41,6 +41,8 @@ Make commands
* `make schema` - generates graph of seminar and all schemas as PDF. Supercool! * `make schema` - generates graph of seminar and all schemas as PDF. Supercool!
* `make sync_prod_flatpages` - downloads and applies static/flat pages from mamweb-prod
./manage.py commands ./manage.py commands
-------------------- --------------------
@ -56,6 +58,8 @@ Make commands
* `./manage.py test` - run the tests. * `./manage.py test` - run the tests.
* `./manage.py shell` - run commands, list elemements of database, check syntax
by importing files, etc.
Configurations Configurations
-------------- --------------

BIN
Schema_new.dia

Binary file not shown.

17
convert_spaces_to_tabs.sh

@ -0,0 +1,17 @@
#!/bin/sh
if test "$#" -lt 1
then
echo "Usage: $0 file ..."
exit 2
fi
for file in "$@"
do
# Do the sed magic: keep replacing 4 spaces at the begining of line
sed -i -re '
: loop
s/^( *) /\1 /
t loop
' "$file"
done

332
flat.json

File diff suppressed because one or more lines are too long

64
galerie/admin.py

@ -5,50 +5,50 @@ from django.contrib import admin
from django.http import HttpResponseRedirect from django.http import HttpResponseRedirect
from django import forms from django import forms
from django.db import models from django.db import models
from autocomplete_light import shortcuts as autocomplete_light
# akction # akction
def zverejnit_fotogalerii(modeladmin, request, queryset): def zverejnit_fotogalerii(modeladmin, request, queryset):
'''zverejni vybranou fotogalerii i jeji vsechny podgalerie''' '''zverejni vybranou fotogalerii i jeji vsechny podgalerie'''
for galerie in queryset: for galerie in queryset:
galerie.zobrazit = 0 galerie.zobrazit = 0
galerie.save() galerie.save()
zverejnit_fotogalerii(modeladmin, request, zverejnit_fotogalerii(modeladmin, request,
Galerie.objects.filter(galerie_up = galerie)) Galerie.objects.filter(galerie_up = galerie))
zverejnit_fotogalerii.short_description = 'Zveřejnit fotogalerie' zverejnit_fotogalerii.short_description = 'Zveřejnit fotogalerie'
def prepnout_fotogalerii_do_org_rezimu(modeladmin, request, queryset): def prepnout_fotogalerii_do_org_rezimu(modeladmin, request, queryset):
'''zneverjni vybranou fotogalerii i jeji vsechny podgalerie''' '''zneverjni vybranou fotogalerii i jeji vsechny podgalerie'''
for galerie in queryset: for galerie in queryset:
galerie.zobrazit = 1 galerie.zobrazit = 1
galerie.save() galerie.save()
prepnout_fotogalerii_do_org_rezimu(modeladmin, request, prepnout_fotogalerii_do_org_rezimu(modeladmin, request,
Galerie.objects.filter(galerie_up = galerie)) Galerie.objects.filter(galerie_up = galerie))
prepnout_fotogalerii_do_org_rezimu.short_description = \ prepnout_fotogalerii_do_org_rezimu.short_description = \
'Přepnout do režimu úprav (zneveřejní galerii)' 'Přepnout do režimu úprav (zneveřejní galerii)'
class GalerieInline(admin.TabularInline): class GalerieInline(admin.TabularInline):
model = Obrazek model = Obrazek
fields = ['obrazek_velky', 'nazev', 'popis', 'obrazek_maly_tag', 'poradi'] fields = ['obrazek_velky', 'nazev', 'popis', 'obrazek_maly_tag', 'poradi']
readonly_fields = ['nazev', 'obrazek_maly_tag'] readonly_fields = ['nazev', 'obrazek_maly_tag']
formfield_overrides = { formfield_overrides = {
models.TextField: {'widget': forms.TextInput}, models.TextField: {'widget': forms.TextInput},
} }
class ObrazekAdmin(admin.ModelAdmin): class ObrazekAdmin(admin.ModelAdmin):
list_display = ('obrazek_velky', 'nazev', 'popis', 'obrazek_maly_tag', 'poradi') list_display = ('obrazek_velky', 'nazev', 'popis', 'obrazek_maly_tag', 'poradi')
search_fields = ['nazev','popis']
class GalerieAdmin(admin.ModelAdmin): class GalerieAdmin(admin.ModelAdmin):
form = autocomplete_light.modelform_factory(Galerie, autocomplete_fields=['titulni_obrazek'], fields=['titulni_obrazek']) model = Galerie
model = Galerie fields = ('zobrazit', 'nazev', 'titulni_obrazek', 'popis', 'galerie_up', 'soustredeni', 'poradi')
fields = ('zobrazit', 'nazev', 'titulni_obrazek', 'popis', 'galerie_up', 'soustredeni', 'poradi') autocomplete_fields = ['titulni_obrazek']
list_display = ('nazev', 'soustredeni', 'galerie_up', 'poradi', 'zobrazit', 'datum_zmeny') list_display = ('nazev', 'soustredeni', 'galerie_up', 'poradi', 'zobrazit', 'datum_zmeny')
inlines = [GalerieInline] inlines = [GalerieInline]
actions = [zverejnit_fotogalerii, prepnout_fotogalerii_do_org_rezimu] actions = [zverejnit_fotogalerii, prepnout_fotogalerii_do_org_rezimu]
save_on_top = True save_on_top = True
ordering = ['galerie_up__nazev', 'poradi'] ordering = ['galerie_up__nazev', 'poradi']
admin.site.register(Obrazek, ObrazekAdmin) admin.site.register(Obrazek, ObrazekAdmin)
admin.site.register(Galerie, GalerieAdmin) admin.site.register(Galerie, GalerieAdmin)

6
galerie/autocomplete_light_registry.py → galerie/autocomplete_light_registry.py.old

@ -1,11 +1,9 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from __future__ import unicode_literals
from autocomplete_light import shortcuts as autocomplete_light from autocomplete_light import shortcuts as autocomplete_light
from models import Obrazek, Galerie from .models import Obrazek, Galerie
from views import cesta_od_korene from .views import cesta_od_korene
class ObrazekAutocomplete(autocomplete_light.AutocompleteModelBase): class ObrazekAutocomplete(autocomplete_light.AutocompleteModelBase):

6
galerie/forms.py

@ -4,8 +4,8 @@ from django import forms
from seminar.models import Soustredeni from seminar.models import Soustredeni
class KomentarForm(forms.Form): class KomentarForm(forms.Form):
komentar = forms.CharField(label = "Komentář:", max_length = 300, required=False) komentar = forms.CharField(label = "Komentář:", max_length = 300, required=False)
class NewGalerieForm(forms.Form): class NewGalerieForm(forms.Form):
nazev = forms.CharField(label = "Název galerie", max_length = 100) nazev = forms.CharField(label = "Název galerie", max_length = 100)
#popis = forms.CharField(label = "Popis", required = False, max_length = 2000, widget = forms.Textarea) #popis = forms.CharField(label = "Popis", required = False, max_length = 2000, widget = forms.Textarea)

6
galerie/migrations/0001_initial.py

@ -21,8 +21,8 @@ class Migration(migrations.Migration):
('datum_zmeny', models.DateTimeField(auto_now=True, verbose_name=b'Datum posledn\xc3\xad zm\xc4\x9bny')), ('datum_zmeny', models.DateTimeField(auto_now=True, verbose_name=b'Datum posledn\xc3\xad zm\xc4\x9bny')),
('popis', models.TextField(null=True, verbose_name=b'Popis', blank=True)), ('popis', models.TextField(null=True, verbose_name=b'Popis', blank=True)),
('zobrazit', models.IntegerField(default=1, verbose_name=b'Zobrazit?', choices=[(0, b'V\xc5\xbedy'), (1, b'Organiz\xc3\xa1tor\xc5\xafm'), (2, b'Nikdy')])), ('zobrazit', models.IntegerField(default=1, verbose_name=b'Zobrazit?', choices=[(0, b'V\xc5\xbedy'), (1, b'Organiz\xc3\xa1tor\xc5\xafm'), (2, b'Nikdy')])),
('galerie_up', models.ForeignKey(blank=True, to='galerie.Galerie', null=True)), ('galerie_up', models.ForeignKey(blank=True, to='galerie.Galerie', null=True, on_delete=models.CASCADE)),
('soustredeni', models.ForeignKey(blank=True, to='seminar.Soustredeni', null=True)), ('soustredeni', models.ForeignKey(blank=True, to='seminar.Soustredeni', null=True, on_delete=models.CASCADE)),
], ],
options={ options={
'verbose_name': 'Galerie', 'verbose_name': 'Galerie',
@ -42,7 +42,7 @@ class Migration(migrations.Migration):
('datum_vlozeni', models.DateTimeField(auto_now_add=True, verbose_name=b'Datum vlo\xc5\xbeen\xc3\xad')), ('datum_vlozeni', models.DateTimeField(auto_now_add=True, verbose_name=b'Datum vlo\xc5\xbeen\xc3\xad')),
('datum', models.DateTimeField(verbose_name=b'Datum po\xc5\x99\xc3\xadzen\xc3\xad fotografie')), ('datum', models.DateTimeField(verbose_name=b'Datum po\xc5\x99\xc3\xadzen\xc3\xad fotografie')),
('poradi', models.IntegerField(null=True, verbose_name=b'Po\xc5\x99ad\xc3\xad', blank=True)), ('poradi', models.IntegerField(null=True, verbose_name=b'Po\xc5\x99ad\xc3\xad', blank=True)),
('galerie', models.ForeignKey(to='galerie.Galerie')), ('galerie', models.ForeignKey(to='galerie.Galerie', on_delete=models.CASCADE)),
], ],
options={ options={
'verbose_name': 'Obr\xe1zek', 'verbose_name': 'Obr\xe1zek',

2
galerie/migrations/0004_nepovinna_galerie_u_obrazku.py

@ -14,7 +14,7 @@ class Migration(migrations.Migration):
migrations.AlterField( migrations.AlterField(
model_name='obrazek', model_name='obrazek',
name='galerie', name='galerie',
field=models.ForeignKey(blank=True, to='galerie.Galerie', null=True), field=models.ForeignKey(blank=True, to='galerie.Galerie', null=True, on_delete=models.CASCADE),
preserve_default=True, preserve_default=True,
), ),
] ]

71
galerie/migrations/0008_auto_20190430_2340.py

@ -0,0 +1,71 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.20 on 2019-04-30 21:40
from __future__ import unicode_literals
from django.db import migrations, models
import galerie.models
class Migration(migrations.Migration):
dependencies = [
('galerie', '0007_obrazek_odstranen_datum'),
]
operations = [
migrations.AlterField(
model_name='galerie',
name='datum_vytvoreni',
field=models.DateTimeField(auto_now_add=True, verbose_name='Datum vytvoření'),
),
migrations.AlterField(
model_name='galerie',
name='datum_zmeny',
field=models.DateTimeField(auto_now=True, verbose_name='Datum poslední změny'),
),
migrations.AlterField(
model_name='galerie',
name='nazev',
field=models.CharField(max_length=100, verbose_name='Název'),
),
migrations.AlterField(
model_name='galerie',
name='popis',
field=models.TextField(blank=True, null=True, verbose_name='Popis'),
),
migrations.AlterField(
model_name='galerie',
name='poradi',
field=models.IntegerField(blank=True, null=True, verbose_name='Pořadí'),
),
migrations.AlterField(
model_name='galerie',
name='zobrazit',
field=models.IntegerField(choices=[(0, 'Vždy'), (1, 'Organizátorům'), (2, 'Nikdy')], default=1, verbose_name='Zobrazit?'),
),
migrations.AlterField(
model_name='obrazek',
name='datum_vlozeni',
field=models.DateTimeField(auto_now_add=True, verbose_name='Datum vložení'),
),
migrations.AlterField(
model_name='obrazek',
name='nazev',
field=models.CharField(blank=True, max_length=50, null=True, verbose_name='Název'),
),
migrations.AlterField(
model_name='obrazek',
name='obrazek_velky',
field=models.ImageField(help_text='Lze vložit libovolně velký obrázek. Ideální je, aby alespoň jeden rozměr měl alespoň 500px.', upload_to=galerie.models.obrazek_filename),
),
migrations.AlterField(
model_name='obrazek',
name='popis',
field=models.TextField(blank=True, null=True, verbose_name='Popis'),
),
migrations.AlterField(
model_name='obrazek',
name='poradi',
field=models.IntegerField(blank=True, null=True, verbose_name='Pořadí'),
),
]

31
galerie/migrations/0009_auto_20190610_2358.py

@ -0,0 +1,31 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.21 on 2019-06-10 21:58
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('galerie', '0008_auto_20190430_2340'),
]
operations = [
migrations.AlterField(
model_name='galerie',
name='galerie_up',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='galerie.Galerie'),
),
migrations.AlterField(
model_name='galerie',
name='soustredeni',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, to='seminar.Soustredeni'),
),
migrations.AlterField(
model_name='obrazek',
name='galerie',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='galerie.Galerie'),
),
]

8
galerie/migrations/0008_auto_20191209_2326.py → galerie/migrations/0010_auto_20200819_0947.py

@ -1,6 +1,4 @@
# -*- coding: utf-8 -*- # Generated by Django 2.2.15 on 2020-08-19 07:47
# Generated by Django 1.11.26 on 2019-12-09 22:26
from __future__ import unicode_literals
from django.db import migrations, models from django.db import migrations, models
@ -8,13 +6,13 @@ from django.db import migrations, models
class Migration(migrations.Migration): class Migration(migrations.Migration):
dependencies = [ dependencies = [
('galerie', '0007_obrazek_odstranen_datum'), ('galerie', '0009_auto_20190610_2358'),
] ]
operations = [ operations = [
migrations.AlterField( migrations.AlterField(
model_name='galerie', model_name='galerie',
name='poradi', name='poradi',
field=models.IntegerField(blank=True, default=0, verbose_name=b'Po\xc5\x99ad\xc3\xad'), field=models.IntegerField(blank=True, default=0, verbose_name='Pořadí'),
), ),
] ]

181
galerie/models.py

@ -2,7 +2,7 @@
from django.db import models from django.db import models
#from django.db.models import Q #from django.db.models import Q
from django.utils.encoding import force_unicode from django.utils.encoding import force_text
from imagekit.models import ImageSpecField from imagekit.models import ImageSpecField
from imagekit.processors import ResizeToFit, Transpose from imagekit.processors import ResizeToFit, Transpose
@ -14,109 +14,112 @@ VZDY=0
ORG=1 ORG=1
NIKDY=2 NIKDY=2
VIDITELNOST = ( VIDITELNOST = (
(VZDY, 'Vždy'), (VZDY, 'Vždy'),
(ORG, 'Organizátorům'), (ORG, 'Organizátorům'),
(NIKDY, 'Nikdy'), (NIKDY, 'Nikdy'),
) )
# tyhle funkce jsou tady jen kvůli starým migracím, které se na ně odkazují # tyhle funkce jsou tady jen kvůli starým migracím, které se na ně odkazují
# až se ty migrace někdy squashnou, tak by mělo být možné funkce smazat # až se ty migrace někdy squashnou, tak by mělo být možné funkce smazat
def obrazek_filename_maly(): def obrazek_filename_maly():
pass pass
def obrazek_filename_stredni(): def obrazek_filename_stredni():
pass pass
def obrazek_filename_velky(): def obrazek_filename_velky():
pass pass
def obrazek_filename(self, filename): def obrazek_filename(self, filename):
gal = self.galerie gal = self.galerie
cislo_gal = force_unicode(gal.pk) cislo_gal = gal.pk
# najdi kořenovou galerii # najdi kořenovou galerii
while (gal.galerie_up): while (gal.galerie_up):
gal = gal.galerie_up gal = gal.galerie_up
# soustředění je v cestě jen pokud galerie pod nějaké patří # soustředění je v cestě jen pokud galerie pod nějaké patří
cesta = ( cesta = (
['Galerie'] + ['Galerie'] +
(["soustredeni_" + force_unicode(gal.soustredeni.pk)] if gal.soustredeni else []) + (["soustredeni_{}".format(gal.soustredeni.pk)] if gal.soustredeni else []) +
["galerie_" + cislo_gal, force_unicode(self.nazev)] ["galerie_{}".format(cislo_gal), self.nazev]
) )
return os.path.join(*cesta) return os.path.join(*cesta)
class Obrazek(models.Model): class Obrazek(models.Model):
obrazek_velky = models.ImageField(upload_to=obrazek_filename, obrazek_velky = models.ImageField(upload_to=obrazek_filename,
help_text = "Lze vložit libovolně velký obrázek. Ideální je, aby alespoň jeden rozměr měl alespoň 500px.") help_text = "Lze vložit libovolně velký obrázek. Ideální je, aby alespoň jeden rozměr měl alespoň 500px.")
obrazek_stredni = ImageSpecField(source='obrazek_velky', obrazek_stredni = ImageSpecField(source='obrazek_velky',
processors=[Transpose(Transpose.AUTO), ResizeToFit(900, 675, upscale=False)], processors=[Transpose(Transpose.AUTO), ResizeToFit(900, 675, upscale=False)],
options={'quality': 95}) options={'quality': 95})
obrazek_maly = ImageSpecField(source='obrazek_velky', obrazek_maly = ImageSpecField(source='obrazek_velky',
processors=[Transpose(Transpose.AUTO), ResizeToFit(167, 167, upscale=False)], processors=[Transpose(Transpose.AUTO), ResizeToFit(167, 167, upscale=False)],
options={'quality': 95}) options={'quality': 95})
nazev = models.CharField('Název', max_length=50, blank=True, null=True) nazev = models.CharField('Název', max_length=50, blank=True, null=True)
popis = models.TextField('Popis', blank=True, null=True) popis = models.TextField('Popis', blank=True, null=True)
datum_vlozeni = models.DateTimeField('Datum vložení', auto_now_add=True) datum_vlozeni = models.DateTimeField('Datum vložení', auto_now_add=True)
galerie = models.ForeignKey('Galerie', blank=True, null=True) galerie = models.ForeignKey('Galerie', blank=True, null=True, on_delete=models.SET_NULL)
poradi = models.IntegerField('Pořadí', blank=True, null=True) poradi = models.IntegerField('Pořadí', blank=True, null=True)
def __unicode__(self): def __str__(self):
return unicode(self.obrazek_velky.name) return self.obrazek_velky.name
class Meta: class Meta:
verbose_name = 'Obrázek' verbose_name = 'Obrázek'
verbose_name_plural = 'Obrázky' verbose_name_plural = 'Obrázky'
ordering = ['nazev'] ordering = ['nazev']
def obrazek_maly_tag(self): def obrazek_maly_tag(self):
return u'<img src="{}">'.format(self.obrazek_maly.url) if not self.obrazek_maly:
obrazek_maly_tag.short_description = "Náhled" return ''
obrazek_maly_tag.allow_tags = True return u'<img src="{}">'.format(self.obrazek_maly.url)
obrazek_maly_tag.short_description = "Náhled"
def save(self, *args, **kwargs): obrazek_maly_tag.allow_tags = True
# obrázek potřebuje název, protože se z něj generuje cesta pro jeho uložení
# (a pak se podle něj taky řadí) def save(self, *args, **kwargs):
if self.nazev is None: # obrázek potřebuje název, protože se z něj generuje cesta pro jeho uložení
self.nazev = os.path.basename(self.obrazek_velky.name) # (a pak se podle něj taky řadí)
super(Obrazek, self).save(*args, **kwargs) if self.nazev is None:
self.nazev = os.path.basename(self.obrazek_velky.name)
super(Obrazek, self).save(*args, **kwargs)
class Galerie(models.Model): class Galerie(models.Model):
nazev = models.CharField('Název', max_length=100) nazev = models.CharField('Název', max_length=100)
datum_vytvoreni = models.DateTimeField('Datum vytvoření', auto_now_add = True) datum_vytvoreni = models.DateTimeField('Datum vytvoření', auto_now_add = True)
datum_zmeny = models.DateTimeField('Datum poslední změny', auto_now = True) datum_zmeny = models.DateTimeField('Datum poslední změny', auto_now = True)
popis = models.TextField('Popis', blank = True, null = True) popis = models.TextField('Popis', blank = True, null = True)
titulni_obrazek = models.ForeignKey(Obrazek, blank = True, null = True, related_name = "+", on_delete = models.SET_NULL) titulni_obrazek = models.ForeignKey(Obrazek, blank = True, null = True, related_name = "+", on_delete = models.SET_NULL)
zobrazit = models.IntegerField('Zobrazit?', default = ORG, choices = VIDITELNOST) zobrazit = models.IntegerField('Zobrazit?', default = ORG, choices = VIDITELNOST)
galerie_up = models.ForeignKey('Galerie', blank = True, null = True) galerie_up = models.ForeignKey('Galerie', blank = True, null = True,
soustredeni = models.ForeignKey(Soustredeni, blank = True, null = True) on_delete=models.SET_NULL)
poradi = models.IntegerField('Pořadí', blank = True, null = False, default = 0) soustredeni = models.ForeignKey(Soustredeni, blank = True, null = True,
on_delete=models.PROTECT)
def __unicode__(self): poradi = models.IntegerField('Pořadí', blank = True, null = False, default = 0)
return self.nazev
class Meta: def __str__(self):
verbose_name = 'Galerie' return self.nazev
verbose_name_plural = 'Galerie' class Meta:
verbose_name = 'Galerie'
#def link_na_preview(self): verbose_name_plural = 'Galerie'
#"""Odkaz na galerii, používá se v admin rozhranní. """
#return '<a href="/fotogalerie/galerie/%s/">Preview</a>' % self.id #def link_na_preview(self):
#link_na_preview.allow_tags = True #"""Odkaz na galerii, používá se v admin rozhranní. """
#link_na_preview.short_description = 'Zobrazit galerii' #return '<a href="/fotogalerie/galerie/%s/">Preview</a>' % self.id
#link_na_preview.allow_tags = True
#link_na_preview.short_description = 'Zobrazit galerii'
# #
#def je_publikovano(self): #def je_publikovano(self):
#"""Vraci True, pokud je tato galerie publikovana. """ #"""Vraci True, pokud je tato galerie publikovana. """
#if self.zobrazit == VZDY: #if self.zobrazit == VZDY:
#return True #return True
#if self.zobrazit == PODLE_CLANKU: #if self.zobrazit == PODLE_CLANKU:
#for clanek in self.clanek_set.all(): #for clanek in self.clanek_set.all():
#if clanek.je_publikovano(): #if clanek.je_publikovano():
#return True #return True
#return False #return False
# #
#@staticmethod #@staticmethod
#def publikovane_galerie(): #def publikovane_galerie():
#"""Vraci galerie, ktere uz maji byt publikovane.""" #"""Vraci galerie, ktere uz maji byt publikovane."""
#clanky = Blog.models.Clanek.publikovane_clanky() #clanky = Blog.models.Clanek.publikovane_clanky()
#return Galerie.objects.filter(Q(zobrazit=VZDY) | (Q(clanek__in=clanky) & Q(zobrazit=PODLE_CLANKU))).distinct() #return Galerie.objects.filter(Q(zobrazit=VZDY) | (Q(clanek__in=clanky) & Q(zobrazit=PODLE_CLANKU))).distinct()

BIN
galerie/static/galerie/prvky/dalsi.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

65
galerie/static/galerie/prvky/dalsi.svg

@ -0,0 +1,65 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="25.135418mm"
height="42.333332mm"
viewBox="0 0 25.135418 42.333331"
version="1.1"
id="svg851"
sodipodi:docname="dalsi.svg"
inkscape:version="0.92.4 (5da689c313, 2019-01-14)">
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1850"
inkscape:window-height="1136"
id="namedview7"
showgrid="true"
inkscape:zoom="23.600001"
inkscape:cx="18.587131"
inkscape:cy="74.924864"
inkscape:window-x="70"
inkscape:window-y="27"
inkscape:window-maximized="1"
inkscape:current-layer="svg851">
<inkscape:grid
type="xygrid"
id="grid833" />
</sodipodi:namedview>
<defs
id="defs845" />
<metadata
id="metadata848">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
id="layer1"
transform="matrix(-1.0282842,0,0,1,111.4545,-88.415317)">
<path
d="m 98.096584,101.64448 1.286528,1.32292 -5.660724,5.82083 h 13.379892 v 1.5875 H 93.722388 l 5.660724,5.82083 -1.286528,1.32292 -7.719171,-7.9375 z"
style="fill:#e84e10;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.23177969"
id="path44-3"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cccccccccc" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.0 KiB

BIN
galerie/static/galerie/prvky/nahoru.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

BIN
galerie/static/galerie/prvky/predchozi.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

65
galerie/static/galerie/prvky/predchozi.svg

@ -0,0 +1,65 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="25.135418mm"
height="42.333332mm"
viewBox="0 0 25.135418 42.333331"
version="1.1"
id="svg851"
sodipodi:docname="predchozi.svg"
inkscape:version="0.92.4 (5da689c313, 2019-01-14)">
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1850"
inkscape:window-height="1136"
id="namedview7"
showgrid="true"
inkscape:zoom="4.1719301"
inkscape:cx="124.03002"
inkscape:cy="97.874031"
inkscape:window-x="70"
inkscape:window-y="27"
inkscape:window-maximized="1"
inkscape:current-layer="svg851">
<inkscape:grid
type="xygrid"
id="grid833" />
</sodipodi:namedview>
<defs
id="defs845" />
<metadata
id="metadata848">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
id="layer1"
transform="matrix(1.0282842,0,0,1,-86.319083,-88.415315)">
<path
d="m 98.096584,101.64448 1.286528,1.32292 -5.660724,5.82083 h 13.379892 v 1.5875 H 93.722388 l 5.660724,5.82083 -1.286528,1.32292 -7.719171,-7.9375 z"
style="fill:#e84e10;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.23177969"
id="path44-3"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cccccccccc" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.0 KiB

12
galerie/urls.py

@ -1,13 +1,13 @@
# coding: utf-8 # coding: utf-8
from django.conf.urls import include, url from django.urls import path
from . import views from . import views
urlpatterns = [ urlpatterns = [
url(r'^(?P<pk>\d+)/$', views.nahled), path('<int:pk>/', views.nahled),
url(r'^(?P<pk>\d+)/(?P<fotka>\d+)/$', views.detail), path('<int:pk>/<int:fotka>/', views.detail),
url(r'^(?P<galerie>\d+)/new/$', views.new_galerie), path('<int:galerie>/new/', views.new_galerie),
url(r'^(?P<galerie>\d+)/plus/(?P<subgalerie>\d+)/$', views.plus_galerie), path('<int:galerie>/plus/<int:subgalerie>/', views.plus_galerie),
url(r'^(?P<galerie>\d+)/minus/(?P<subgalerie>\d+)/$', views.minus_galerie), path('<int:galerie>/minus/<int:subgalerie>/', views.minus_galerie),
] ]

413
galerie/views.py

@ -12,226 +12,225 @@ from seminar.models import Soustredeni
from galerie.forms import KomentarForm, NewGalerieForm from galerie.forms import KomentarForm, NewGalerieForm
def zobrazit(galerie, request): def zobrazit(galerie, request):
preview = False preview = False
if galerie.zobrazit >= 1: if galerie.zobrazit >= 1:
if request.user.is_staff: if request.user.is_staff:
preview = True; preview = True;
else: else:
raise Http404 raise Http404
return preview return preview
def cesta_od_korene(g): def cesta_od_korene(g):
"""Vrátí seznam galerií od kořene ke g""" """Vrátí seznam galerií od kořene ke g"""
cesta = [] cesta = []
while g != None: while g != None:
cesta.append(g) cesta.append(g)
g = g.galerie_up g = g.galerie_up
return reversed(cesta) return reversed(cesta)
def nahled(request, pk, soustredeni): def nahled(request, pk, soustredeni):
"""Zobrazeni nahledu vsech fotek ve skupine.""" """Zobrazeni nahledu vsech fotek ve skupine."""
galerie = get_object_or_404(Galerie, pk=pk) galerie = get_object_or_404(Galerie, pk=pk)
podgalerie = Galerie.objects.filter(galerie_up = galerie).order_by('poradi') podgalerie = Galerie.objects.filter(galerie_up = galerie).order_by('poradi')
if not request.user.is_staff: if not request.user.is_staff:
podgalerie = podgalerie.filter(zobrazit__lt=1) podgalerie = podgalerie.filter(zobrazit__lt=1)
obrazky = Obrazek.objects.filter(galerie = galerie).order_by('poradi', 'nazev') obrazky = Obrazek.objects.filter(galerie = galerie).order_by('poradi', 'nazev')
preview = zobrazit(galerie, request) preview = zobrazit(galerie, request)
sourozenci = [] sourozenci = []
if galerie.galerie_up: if galerie.galerie_up:
sourozenci = galerie.galerie_up.galerie_set.all().order_by('poradi') sourozenci = galerie.galerie_up.galerie_set.all().order_by('poradi')
if not request.user.is_staff: if not request.user.is_staff:
sourozenci = sourozenci.filter(zobrazit__lt=1) sourozenci = sourozenci.filter(zobrazit__lt=1)
predchozi = None predchozi = None
nasledujici = None nasledujici = None
minuly = None minuly = None
for g in sourozenci: for g in sourozenci:
if g.pk == galerie.pk: if g.pk == galerie.pk:
predchozi = minuly predchozi = minuly
if minuly != None and minuly.pk == galerie.pk: if minuly != None and minuly.pk == galerie.pk:
nasledujici = g nasledujici = g
break break
minuly = g minuly = g
cesta = cesta_od_korene(galerie) cesta = cesta_od_korene(galerie)
return render(request, 'galerie/GalerieNahled.html', return render(request, 'galerie/GalerieNahled.html',
{'galerie' : galerie, {'galerie' : galerie,
'podgalerie' : podgalerie, 'podgalerie' : podgalerie,
'obrazky' : obrazky, 'obrazky' : obrazky,
'preview' : preview, 'preview' : preview,
'cesta': cesta, 'cesta': cesta,
'sourozenci': sourozenci, 'sourozenci': sourozenci,
'predchozi': predchozi, 'predchozi': predchozi,
'nasledujici': nasledujici, 'nasledujici': nasledujici,
}) })
def detail(request, pk, fotka, soustredeni): def detail(request, pk, fotka, soustredeni):
"""Zobrazeni nahledu fotky s id 'fotka'.""" """Zobrazeni nahledu fotky s id 'fotka'."""
MAX_VYSKA = 900 MAX_VYSKA = 900
MAX_SIRKA = 900 MAX_SIRKA = 900
MAX_VYSKA_MALA = 100 MAX_VYSKA_MALA = 100
MAX_SIRKA_MALA = 200 MAX_SIRKA_MALA = 200
NAHLEDU = 1 NAHLEDU = 1
galerie = get_object_or_404(Galerie, pk=pk) galerie = get_object_or_404(Galerie, pk=pk)
preview = zobrazit(galerie, request) preview = zobrazit(galerie, request)
obrazek = get_object_or_404(Obrazek, pk=fotka) obrazek = get_object_or_404(Obrazek, pk=fotka)
obrazky = galerie.obrazek_set.all().order_by('poradi', 'nazev') obrazky = galerie.obrazek_set.all().order_by('poradi', 'nazev')
# vytvoreni a obslouzeni formulare # vytvoreni a obslouzeni formulare
if request.method == 'POST': if request.method == 'POST':
form = KomentarForm(request.POST) form = KomentarForm(request.POST)
if form.is_valid(): if form.is_valid():
obrazek.popis = form.cleaned_data['komentar'] obrazek.popis = form.cleaned_data['komentar']
obrazek.save() obrazek.save()
else: else:
form = KomentarForm({'komentar': obrazek.popis}) form = KomentarForm({'komentar': obrazek.popis})
# Poradi aktualniho obrazku v galerii/stitku. # Poradi aktualniho obrazku v galerii/stitku.
for i in range(len(obrazky)): for i in range(len(obrazky)):
if obrazky[i] == obrazek: if obrazky[i] == obrazek:
poradi = i poradi = i
break break
else: else:
# Obrazek neni v galerii/stitku. # Obrazek neni v galerii/stitku.
raise Http404 raise Http404
# Nacteni okolnich obrazku a galerii # Nacteni okolnich obrazku a galerii
# TODO vyjmout zjisteni predchozich a nasledujicich galerii # TODO vyjmout zjisteni predchozich a nasledujicich galerii
# a udelat z toho funkci, ktera se pouzije u nahledu # a udelat z toho funkci, ktera se pouzije u nahledu
predchozi_galerie = None predchozi_galerie = None
nasledujici_galerie = None nasledujici_galerie = None
obrazky_dalsi = obrazky[poradi+1:poradi+NAHLEDU+1] obrazky_dalsi = obrazky[poradi+1:poradi+NAHLEDU+1]
if (poradi+1) > NAHLEDU: if (poradi+1) > NAHLEDU:
obrazky_predchozi = obrazky[poradi-NAHLEDU:poradi] obrazky_predchozi = obrazky[poradi-NAHLEDU:poradi]
else: else:
obrazky_predchozi = obrazky[0:poradi] obrazky_predchozi = obrazky[0:poradi]
if galerie.poradi > 1: if galerie.poradi > 1:
predchozi_galerie = Galerie.objects.\ predchozi_galerie = Galerie.objects.\
filter(galerie_up=galerie.galerie_up).\ filter(galerie_up=galerie.galerie_up).\
filter(poradi=(galerie.poradi-1)) filter(poradi=(galerie.poradi-1))
if predchozi_galerie: if predchozi_galerie:
predchozi_galerie = predchozi_galerie[0] predchozi_galerie = predchozi_galerie[0]
else: else:
predchozi_galerie = None predchozi_galerie = None
if (poradi+1) == len(obrazky): # Tohle je poslední obrázek if (poradi+1) == len(obrazky): # Tohle je poslední obrázek
if (galerie.poradi is not None if (galerie.poradi is not None
and galerie.galerie_up is not None): and galerie.galerie_up is not None):
nasledujici_galerie = Galerie.objects.\ nasledujici_galerie = Galerie.objects.\
filter(galerie_up=galerie.galerie_up).\ filter(galerie_up=galerie.galerie_up).\
filter(poradi=(galerie.poradi+1)) filter(poradi=(galerie.poradi+1))
else: else:
nasledujici_galerie = None nasledujici_galerie = None
if nasledujici_galerie: if nasledujici_galerie:
nasledujici_galerie = nasledujici_galerie[0] nasledujici_galerie = nasledujici_galerie[0]
else: else:
nasledujici_galerie = None nasledujici_galerie = None
# Preskalovani obrazku do vybraneho prostoru. # Preskalovani obrazku do vybraneho prostoru.
vyska = obrazek.obrazek_stredni.height vyska = obrazek.obrazek_stredni.height
sirka = obrazek.obrazek_stredni.width sirka = obrazek.obrazek_stredni.width
if vyska > MAX_VYSKA: if vyska > MAX_VYSKA:
sirka = sirka * MAX_VYSKA / vyska sirka = sirka * MAX_VYSKA / vyska
vyska = MAX_VYSKA vyska = MAX_VYSKA
if sirka > MAX_SIRKA: if sirka > MAX_SIRKA:
vyska = vyska * MAX_SIRKA / sirka vyska = vyska * MAX_SIRKA / sirka
sirka = MAX_SIRKA sirka = MAX_SIRKA
return render(request, 'galerie/Galerie.html', return render(request, 'galerie/Galerie.html',
{'galerie' : galerie, {'galerie' : galerie,
'predchozi_galerie' : predchozi_galerie, 'predchozi_galerie' : predchozi_galerie,
'nasledujici_galerie' : nasledujici_galerie, 'nasledujici_galerie' : nasledujici_galerie,
'obrazek' : obrazek, 'obrazek' : obrazek,
'vyska' : vyska, 'vyska' : vyska,
'sirka' : sirka, 'sirka' : sirka,
'obrazky_predchozi' : obrazky_predchozi, 'obrazky_predchozi' : obrazky_predchozi,
'obrazky_dalsi' : obrazky_dalsi, 'obrazky_dalsi' : obrazky_dalsi,
'preview' : preview, 'preview' : preview,
'form' : form, 'form' : form,
'cesta': cesta_od_korene(galerie), 'cesta': cesta_od_korene(galerie),
}) })
def new_galerie(request, galerie, soustredeni): def new_galerie(request, galerie, soustredeni):
# zjistime k jakemu soustredeni se vaze nove vytvarena galerie # zjistime k jakemu soustredeni se vaze nove vytvarena galerie
soustredeni = get_object_or_404(Soustredeni, pk = soustredeni) soustredeni = get_object_or_404(Soustredeni, pk = soustredeni)
# pokud je parametr galerie 0, pak jde o hlavni galerii # pokud je parametr galerie 0, pak jde o hlavni galerii
# kdyz je nejaky jiny, pak je pk galerie pod kterou tu dalsi vytvarim # kdyz je nejaky jiny, pak je pk galerie pod kterou tu dalsi vytvarim
if int(galerie) == 0: if int(galerie) == 0:
galerie_up = False galerie_up = False
galerie_text = "Hlavní fotogalerie soustředění" galerie_text = "Hlavní fotogalerie soustředění"
else: else:
galerie_up = get_object_or_404(Galerie, pk = int(galerie)) galerie_up = get_object_or_404(Galerie, pk = int(galerie))
galerie_text = "podgalerii ke galerii " + str(galerie_up) galerie_text = "podgalerii ke galerii " + str(galerie_up)
# obsluha formulare umoznujiciho multiple nahravani fotek # obsluha formulare umoznujiciho multiple nahravani fotek
if request.method == 'POST': if request.method == 'POST':
form = NewGalerieForm(request.POST, request.FILES) form = NewGalerieForm(request.POST, request.FILES)
if form.is_valid(): if form.is_valid():
# vytvoreni nove galerie # vytvoreni nove galerie
gal = Galerie() gal = Galerie()
gal.nazev = form.cleaned_data['nazev'] gal.nazev = form.cleaned_data['nazev']
#gal.popis = form.cleaned_data['popis'] # popis nepouzivame #gal.popis = form.cleaned_data['popis'] # popis nepouzivame
gal.zobrazit = 1 # galerie je v procesu vytvareni gal.zobrazit = 1 # galerie je v procesu vytvareni
''' pokud je to podgalerie pridej nadrazenou galerii ''' pokud je to podgalerie pridej nadrazenou galerii
a nadrazene soustredeni nechej volne, a nadrazene soustredeni nechej volne,
pokud je to hlavni galerie, tak nadrazena galerie neexistuje, pokud je to hlavni galerie, tak nadrazena galerie neexistuje,
ale v takovem pripade musi byt nadrazene soustredeni a ne jinak ''' ale v takovem pripade musi byt nadrazene soustredeni a ne jinak '''
if galerie_up: if galerie_up:
gal.galerie_up = galerie_up gal.galerie_up = galerie_up
else: else:
gal.soustredeni = soustredeni gal.soustredeni = soustredeni
if gal.galerie_up: if gal.galerie_up:
gal.poradi = int(len(gal.galerie_up.galerie_set.all())) + 1 gal.poradi = int(len(gal.galerie_up.galerie_set.all())) + 1
gal.save() gal.save()
# zpracovani obrazku v galerii # zpracovani obrazku v galerii
for obr in request.FILES.getlist('obr'): for obr in request.FILES.getlist('obr'):
o = Obrazek() o = Obrazek()
o.obrazek_velky = obr o.obrazek_velky = obr
o.nazev = str(obr) o.nazev = str(obr)
o.galerie = gal o.galerie = gal
o.save() o.save()
# presmerovani na prave vzniklou galerii # presmerovani na prave vzniklou galerii
return HttpResponseRedirect('../../' + str(gal.pk)) return HttpResponseRedirect('../../' + str(gal.pk))
else: else:
form = NewGalerieForm() form = NewGalerieForm()
return render(request, 'galerie/GalerieNew.html', return render(request, 'galerie/GalerieNew.html',
{ {
'form' : form, 'form' : form,
'soustredeni' : soustredeni, 'soustredeni' : soustredeni,
'galerie_text' : galerie_text, 'galerie_text' : galerie_text,
}) })
def plus_galerie(request, galerie, soustredeni, subgalerie): def plus_galerie(request, galerie, soustredeni, subgalerie):
galerie = get_object_or_404(Galerie, pk=subgalerie) galerie = get_object_or_404(Galerie, pk=subgalerie)
if galerie.poradi: if galerie.poradi:
galerie.poradi += 1 galerie.poradi += 1
else: else:
galerie.poradi = int(len(galerie.galerie_up.galerie_set.all())) galerie.poradi = int(len(galerie.galerie_up.galerie_set.all()))
galerie.save() galerie.save()
return HttpResponseRedirect('../../') return HttpResponseRedirect('../../')
def minus_galerie(request, galerie, soustredeni, subgalerie): def minus_galerie(request, galerie, soustredeni, subgalerie):
galerie = get_object_or_404(Galerie, pk=subgalerie) galerie = get_object_or_404(Galerie, pk=subgalerie)
if galerie.poradi: if galerie.poradi:
galerie.poradi -= 1 galerie.poradi -= 1
else: else:
galerie.poradi = 1 galerie.poradi = 1
galerie.save() galerie.save()
return HttpResponseRedirect('../../') return HttpResponseRedirect('../../')

16
init_local.sh

@ -0,0 +1,16 @@
#!/bin/sh
set -e # Spadni pokud něco spadne
# Check venvu
# NOTE: zkontroluje i správnou složku -- existencí Makefilu
make venv_check
# Vygenerujeme testdata
./manage.py testdata
# Nahrajeme statický obsah modelů
./manage.py loaddata flat.json sitetree_new.json
# Posbíráme statické soubory
./manage.py collectstatic

28
korektury/admin.py

@ -6,21 +6,21 @@ from korektury.models import KorekturovanePDF
# Register your models here. # Register your models here.
class KorekturovanePDFAdmin(VersionAdmin): class KorekturovanePDFAdmin(VersionAdmin):
readonly_fields = ['cas', 'stran'] readonly_fields = ['cas', 'stran']
def get_readonly_fields(self, request, obj=None): def get_readonly_fields(self, request, obj=None):
if obj: if obj:
return self.readonly_fields + ['pdf'] return self.readonly_fields + ['pdf']
return self.readonly_fields return self.readonly_fields
fieldsets = [ fieldsets = [
(None, (None,
{'fields': {'fields':
['pdf', 'cas', 'org', 'stran', 'nazev', 'komentar']}), ['pdf', 'cas', 'org', 'stran', 'nazev', 'komentar']}),
# (u'PDF', {'fields': ['pdf']}), # (u'PDF', {'fields': ['pdf']}),
] ]
list_display = ['nazev', 'cas', 'stran', 'org'] list_display = ['nazev', 'cas', 'stran', 'org']
list_filter = [] list_filter = []
search_fields = [] search_fields = []
admin.site.register(KorekturovanePDF, KorekturovanePDFAdmin) admin.site.register(KorekturovanePDF, KorekturovanePDFAdmin)

18
korektury/forms.py

@ -1,13 +1,13 @@
from django import forms from django import forms
class OpravaForm(forms.Form): class OpravaForm(forms.Form):
text = forms.CharField(max_length=256) text = forms.CharField(max_length=256)
autor = forms.CharField(max_length=20) autor = forms.CharField(max_length=20)
x = forms.IntegerField() x = forms.IntegerField()
y = forms.IntegerField() y = forms.IntegerField()
scroll = forms.CharField(max_length=256) scroll = forms.CharField(max_length=256)
pdf = forms.CharField(max_length=256) pdf = forms.CharField(max_length=256)
img_id = forms.CharField(max_length=256) img_id = forms.CharField(max_length=256)
id = forms.CharField(max_length=256) id = forms.CharField(max_length=256)
action = forms.CharField(max_length=256) action = forms.CharField(max_length=256)

2
korektury/migrations/0001_initial.py

@ -50,7 +50,7 @@ class Migration(migrations.Migration):
('cas', models.DateTimeField(help_text=b'\xc4\x8cas zad\xc3\xa1n\xc3\xad koment\xc3\xa1\xc5\x99e', verbose_name='\u010das koment\xe1\u0159e')), ('cas', models.DateTimeField(help_text=b'\xc4\x8cas zad\xc3\xa1n\xc3\xad koment\xc3\xa1\xc5\x99e', verbose_name='\u010das koment\xe1\u0159e')),
('autor', models.TextField(help_text=b'Autor koment\xc3\xa1\xc5\x99e', verbose_name='autor koment\xe1\u0159e', blank=True)), ('autor', models.TextField(help_text=b'Autor koment\xc3\xa1\xc5\x99e', verbose_name='autor koment\xe1\u0159e', blank=True)),
('text', models.TextField(help_text=b'Text koment\xc3\xa1\xc5\x99e', verbose_name='text koment\xe1\u0159e', blank=True)), ('text', models.TextField(help_text=b'Text koment\xc3\xa1\xc5\x99e', verbose_name='text koment\xe1\u0159e', blank=True)),
('oprava', models.ForeignKey(to='korektury.Oprava')), ('oprava', models.ForeignKey(to='korektury.Oprava', on_delete=models.CASCADE)),
], ],
options={ options={
'ordering': ['cas'], 'ordering': ['cas'],

2
korektury/migrations/0002_auto_20151202_2351.py

@ -19,7 +19,7 @@ class Migration(migrations.Migration):
('cas', models.DateTimeField(default=django.utils.timezone.now, help_text=b'\xc4\x8cas zad\xc3\xa1n\xc3\xad koment\xc3\xa1\xc5\x99e', verbose_name='\u010das koment\xe1\u0159e')), ('cas', models.DateTimeField(default=django.utils.timezone.now, help_text=b'\xc4\x8cas zad\xc3\xa1n\xc3\xad koment\xc3\xa1\xc5\x99e', verbose_name='\u010das koment\xe1\u0159e')),
('autor', models.TextField(help_text=b'Autor koment\xc3\xa1\xc5\x99e', verbose_name='autor koment\xe1\u0159e', blank=True)), ('autor', models.TextField(help_text=b'Autor koment\xc3\xa1\xc5\x99e', verbose_name='autor koment\xe1\u0159e', blank=True)),
('text', models.TextField(help_text=b'Text koment\xc3\xa1\xc5\x99e', verbose_name='text koment\xe1\u0159e', blank=True)), ('text', models.TextField(help_text=b'Text koment\xc3\xa1\xc5\x99e', verbose_name='text koment\xe1\u0159e', blank=True)),
('oprava', models.ForeignKey(to='korektury.Oprava')), ('oprava', models.ForeignKey(to='korektury.Oprava', on_delete=models.CASCADE)),
], ],
options={ options={
'ordering': ['cas'], 'ordering': ['cas'],

2
korektury/migrations/0006_oprava_pdf.py

@ -14,7 +14,7 @@ class Migration(migrations.Migration):
migrations.AddField( migrations.AddField(
model_name='oprava', model_name='oprava',
name='pdf', name='pdf',
field=models.ForeignKey(default=-1, to='korektury.KorekturovanePDF'), field=models.ForeignKey(default=-1, to='korektury.KorekturovanePDF', on_delete=models.CASCADE),
preserve_default=True, preserve_default=True,
), ),
] ]

4
korektury/migrations/0010_Pridani_odkazu_na_organizatora.py

@ -15,11 +15,11 @@ class Migration(migrations.Migration):
migrations.AddField( migrations.AddField(
model_name='komentar', model_name='komentar',
name='autor_org', name='autor_org',
field=models.ForeignKey(blank=True, to='seminar.Organizator', help_text='Autor koment\xe1\u0159e', null=True), field=models.ForeignKey(blank=True, to='seminar.Organizator', help_text='Autor koment\xe1\u0159e', null=True, on_delete=models.CASCADE),
), ),
migrations.AddField( migrations.AddField(
model_name='oprava', model_name='oprava',
name='autor_org', name='autor_org',
field=models.ForeignKey(blank=True, to='seminar.Organizator', help_text=b'Autor opravy', null=True), field=models.ForeignKey(blank=True, to='seminar.Organizator', help_text=b'Autor opravy', null=True, on_delete=models.CASCADE),
), ),
] ]

8
korektury/migrations/0011_prevod_autora_z_charField_na_Organizator.py

@ -18,10 +18,10 @@ def transform_autor(apps, schema_editor):
oprava.autor_org = org oprava.autor_org = org
oprava.save() oprava.save()
except: except:
print "Org nenalezen -- mažu korekturu" print("Org nenalezen -- mažu korekturu")
# oprava.delete() # oprava.delete()
else: else:
print "Org nenalezen -- mažu korekturu" print("Org nenalezen -- mažu korekturu")
oprava.delete() oprava.delete()
# preorgovani komentaru # preorgovani komentaru
@ -35,10 +35,10 @@ def transform_autor(apps, schema_editor):
komentar.autor_org = org komentar.autor_org = org
komentar.save() komentar.save()
except: except:
print "Org nenalezen -- mažu korekturu" print("Org nenalezen -- mažu korekturu")
# oprava.delete() # oprava.delete()
else: else:
print "Org nenalezen -- mažu korekturu" print("Org nenalezen -- mažu korekturu")
komentar.delete() komentar.delete()
def back(apps, schema_editor): def back(apps, schema_editor):

10
korektury/migrations/0014_add_org_to_pdf.py

@ -16,10 +16,10 @@ class Migration(migrations.Migration):
model_name='korekturovanepdf', model_name='korekturovanepdf',
name='org', name='org',
field=models.ForeignKey(default=None, field=models.ForeignKey(default=None,
blank=True, blank=True,
to='seminar.Organizator', to='seminar.Organizator',
help_text=b'Zodpov\xc4\x9bdn\xc3\xbd\ help_text=b'Zodpov\xc4\x9bdn\xc3\xbd\
organiz\xc3\xa1tor za obsah', organiz\xc3\xa1tor za obsah',
null=True), null=True, on_delete=models.CASCADE),
), ),
] ]

2
korektury/migrations/0015_auto_20161004_2005.py

@ -14,6 +14,6 @@ class Migration(migrations.Migration):
migrations.AlterField( migrations.AlterField(
model_name='korekturovanepdf', model_name='korekturovanepdf',
name='org', name='org',
field=models.ForeignKey(default=None, blank=True, to='seminar.Organizator', help_text=b'Zodpov\xc4\x9bdn\xc3\xbd organiz\xc3\xa1tor za obsah', null=True), field=models.ForeignKey(default=None, blank=True, to='seminar.Organizator', help_text=b'Zodpov\xc4\x9bdn\xc3\xbd organiz\xc3\xa1tor za obsah', null=True, on_delete=models.CASCADE),
), ),
] ]

77
korektury/migrations/0016_auto_20190430_2340.py

@ -0,0 +1,77 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.20 on 2019-04-30 21:40
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone
class Migration(migrations.Migration):
dependencies = [
('korektury', '0015_auto_20161004_2005'),
]
operations = [
migrations.AlterField(
model_name='komentar',
name='cas',
field=models.DateTimeField(default=django.utils.timezone.now, help_text='Čas zadání komentáře', verbose_name='čas komentáře'),
),
migrations.AlterField(
model_name='komentar',
name='text',
field=models.TextField(blank=True, help_text='Text komentáře', verbose_name='text komentáře'),
),
migrations.AlterField(
model_name='korekturovanepdf',
name='cas',
field=models.DateTimeField(default=django.utils.timezone.now, help_text='Čas vložení PDF', verbose_name='čas vložení PDF'),
),
migrations.AlterField(
model_name='korekturovanepdf',
name='komentar',
field=models.TextField(blank=True, help_text='Komentář ke korekturovanému PDF (např. na co se zaměřit)', verbose_name='komentář k PDF'),
),
migrations.AlterField(
model_name='korekturovanepdf',
name='nazev',
field=models.CharField(blank=True, help_text='Název (např. 22.1 verze 4) korekturovaného PDF', max_length=50, verbose_name='název PDF'),
),
migrations.AlterField(
model_name='korekturovanepdf',
name='org',
field=models.ForeignKey(blank=True, default=None, help_text='Zodpovědný organizátor za obsah', null=True, on_delete=django.db.models.deletion.CASCADE, to='seminar.Organizator'),
),
migrations.AlterField(
model_name='korekturovanepdf',
name='status',
field=models.CharField(choices=[('pridavani', 'Přidávání korektur'), ('zanaseni', 'Korektury jsou zanášeny'), ('zastarale', 'Stará verze, nekorigovat')], default='pridavani', max_length=16, verbose_name='stav PDF'),
),
migrations.AlterField(
model_name='korekturovanepdf',
name='stran',
field=models.IntegerField(default=0, help_text='Počet stran PDF', verbose_name='počet stran'),
),
migrations.AlterField(
model_name='oprava',
name='autor',
field=models.ForeignKey(blank=True, help_text='Autor opravy', null=True, on_delete=django.db.models.deletion.CASCADE, to='seminar.Organizator'),
),
migrations.AlterField(
model_name='oprava',
name='status',
field=models.CharField(choices=[('k_oprave', 'K opravě'), ('opraveno', 'Opraveno'), ('neni_chyba', 'Není chyba'), ('k_zaneseni', 'K zanesení do TeXu')], default='k_oprave', max_length=16, verbose_name='stav opravy'),
),
migrations.AlterField(
model_name='oprava',
name='strana',
field=models.IntegerField(help_text='Strana s opravou (od 0)', verbose_name='strana s opravou'),
),
migrations.AlterField(
model_name='oprava',
name='text',
field=models.TextField(blank=True, help_text='Text opravy', verbose_name='text opravy'),
),
]

36
korektury/migrations/0017_auto_20190610_2358.py

@ -0,0 +1,36 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.21 on 2019-06-10 21:58
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('korektury', '0016_auto_20190430_2340'),
]
operations = [
migrations.AlterField(
model_name='komentar',
name='autor',
field=models.ForeignKey(blank=True, help_text='Autor komentáře', null=True, on_delete=django.db.models.deletion.SET_NULL, to='seminar.Organizator'),
),
migrations.AlterField(
model_name='korekturovanepdf',
name='org',
field=models.ForeignKey(blank=True, default=None, help_text='Zodpovědný organizátor za obsah', null=True, on_delete=django.db.models.deletion.SET_NULL, to='seminar.Organizator'),
),
migrations.AlterField(
model_name='oprava',
name='autor',
field=models.ForeignKey(blank=True, help_text='Autor opravy', null=True, on_delete=django.db.models.deletion.SET_NULL, to='seminar.Organizator'),
),
migrations.AlterField(
model_name='oprava',
name='pdf',
field=models.ForeignKey(default=-1, on_delete=django.db.models.deletion.PROTECT, to='korektury.KorekturovanePDF'),
),
]

323
korektury/models.py

@ -3,8 +3,7 @@ import os
from django.db import models from django.db import models
from django.utils import timezone from django.utils import timezone
from django.conf import settings from django.conf import settings
from django.utils.encoding import python_2_unicode_compatible from django.utils.encoding import force_text
from django.utils.encoding import force_unicode
from django.core.exceptions import ObjectDoesNotExist from django.core.exceptions import ObjectDoesNotExist
from django.utils.text import get_valid_filename from django.utils.text import get_valid_filename
@ -17,180 +16,176 @@ from unidecode import unidecode
def generate_filename(self, filename): def generate_filename(self, filename):
clean = get_valid_filename( clean = get_valid_filename(
unidecode( unidecode(
filename.replace('/', '-').replace('\0', '').replace(":", "_") filename.replace('/', '-').replace('\0', '').replace(":", "_")
) )
) )
fname = "%s_%s" % ( fname = "%s_%s" % (
timezone.now().strftime('%Y-%m-%d-%H_%M'), timezone.now().strftime('%Y-%m-%d-%H_%M'),
clean) clean)
return os.path.join(settings.KOREKTURY_PDF_DIR, fname) return os.path.join(settings.KOREKTURY_PDF_DIR, fname)
#@reversion.register(ignore_duplicates=True) #@reversion.register(ignore_duplicates=True)
#@python_2_unicode_compatible
class KorekturovanePDF(models.Model): class KorekturovanePDF(models.Model):
class Meta: class Meta:
ordering = ['-cas'] ordering = ['-cas']
db_table = 'korekturovane_cislo' db_table = 'korekturovane_cislo'
verbose_name = u'PDF k opravám' verbose_name = u'PDF k opravám'
verbose_name_plural = u'PDF k opravám' verbose_name_plural = u'PDF k opravám'
#Interní ID #Interní ID
id = models.AutoField(primary_key = True) id = models.AutoField(primary_key = True)
cas = models.DateTimeField(u'čas vložení PDF',default=timezone.now,help_text = 'Čas vložení PDF') cas = models.DateTimeField(u'čas vložení PDF',default=timezone.now,help_text = 'Čas vložení PDF')
nazev = models.CharField(u'název PDF',blank = True,max_length=50, help_text='Název (např. 22.1 verze 4) korekturovaného PDF') nazev = models.CharField(u'název PDF',blank = True,max_length=50, help_text='Název (např. 22.1 verze 4) korekturovaného PDF')
komentar = models.TextField(u'komentář k PDF',blank = True, help_text='Komentář ke korekturovanému PDF (např. na co se zaměřit)') komentar = models.TextField(u'komentář k PDF',blank = True, help_text='Komentář ke korekturovanému PDF (např. na co se zaměřit)')
pdf = models.FileField(u'PDF', upload_to = generate_filename) pdf = models.FileField(u'PDF', upload_to = generate_filename)
org = models.ForeignKey(Organizator, blank=True, org = models.ForeignKey(Organizator, blank=True,
help_text='Zodpovědný organizátor za obsah', help_text='Zodpovědný organizátor za obsah',
null=True, null=True, default=None, on_delete=models.SET_NULL)
default=None)
stran = models.IntegerField(u'počet stran', help_text='Počet stran PDF',
stran = models.IntegerField(u'počet stran', help_text='Počet stran PDF', default=0)
default=0) STATUS_PRIDAVANI = 'pridavani'
STATUS_PRIDAVANI = 'pridavani' STATUS_ZANASENI = 'zanaseni'
STATUS_ZANASENI = 'zanaseni' STATUS_ZASTARALE = 'zastarale'
STATUS_ZASTARALE = 'zastarale' STATUS_CHOICES = (
STATUS_CHOICES = ( (STATUS_PRIDAVANI, u'Přidávání korektur'),
(STATUS_PRIDAVANI, u'Přidávání korektur'), (STATUS_ZANASENI, u'Korektury jsou zanášeny'),
(STATUS_ZANASENI, u'Korektury jsou zanášeny'), (STATUS_ZASTARALE, u'Stará verze, nekorigovat'),
(STATUS_ZASTARALE, u'Stará verze, nekorigovat'), )
) status = models.CharField(u'stav PDF',max_length=16, choices=STATUS_CHOICES, blank=False,
status = models.CharField(u'stav PDF',max_length=16, choices=STATUS_CHOICES, blank=False, default = STATUS_PRIDAVANI)
default = STATUS_PRIDAVANI)
#TODO Nepovinný foreign key k číslu
#TODO Nepovinný foreign key k číslu
def get_prefix(self):
def get_prefix(self): """Vrať řetězec, ke kterému se připojí číslo a .png"""
"""Vrať řetězec, ke kterému se připojí číslo a .png""" # vrátíme jméno souboru bez cesty
# vrátíme jméno souboru bez cesty return os.path.basename(self.pdf.file.name)
return os.path.basename(self.pdf.file.name)
def convert(self):
def convert(self): """Vytvoří jedno png za každou stranu pdf a uloží se"""
"""Vytvoří jedno png za každou stranu pdf a uloží se""" dirname = os.path.join(settings.MEDIA_ROOT, settings.KOREKTURY_IMG_DIR)
dirname = os.path.join(settings.MEDIA_ROOT, settings.KOREKTURY_IMG_DIR) if not os.path.exists(dirname):
if not os.path.exists(dirname): os.mkdir(dirname)
os.mkdir(dirname) self.stran = 0
self.stran = 0 while True:
while True: res = subprocess.call([
res = subprocess.call([ #Parametry inspirovány chybovou hláškou imagemagicku
#Parametry inspirovány chybovou hláškou imagemagicku "gs",
"gs", "-sstdout=%stderr",
"-sstdout=%stderr", "-dSAFER",
"-dSAFER", "-dNOPAUSE",
"-dNOPAUSE", "-dBATCH",
"-dBATCH", "-dNOPROMPT",
"-dNOPROMPT", "-sDEVICE=pngalpha",
"-sDEVICE=pngalpha", "-r180x180",
"-r180x180", "-dFirstPage=%d" % (self.stran+1),
"-dFirstPage=%d" % (self.stran+1), "-dLastPage=%d" % (self.stran+1),
"-dLastPage=%d" % (self.stran+1), "-sOutputFile="+os.path.join(
"-sOutputFile="+os.path.join( dirname,
dirname, "%s-%d.png" % (self.get_prefix(), self.stran)),
"%s-%d.png" % (self.get_prefix(), self.stran)), "-f%s" % (self.pdf.path)
"-f%s" % (self.pdf.path) ])
]) if not os.path.exists(os.path.join(
if not os.path.exists(os.path.join( dirname,
dirname, "%s-%d.png" % (self.get_prefix(), self.stran))):
"%s-%d.png" % (self.get_prefix(), self.stran))): break
break self.stran += 1
self.stran += 1 # Změnil se počet stran, ukládáme
# Změnil se počet stran, ukládáme super(KorekturovanePDF, self).save()
super(KorekturovanePDF, self).save()
def save(self):
def save(self): # Pokud se nezmenilo PDF, tak nepregenerovavej nahledy
# Pokud se nezmenilo PDF, tak nepregenerovavej nahledy try:
try: original = KorekturovanePDF.objects.get(pk=self.pk)
original = KorekturovanePDF.objects.get(pk=self.pk) if original.pdf == self.pdf:
if original.pdf == self.pdf: super(KorekturovanePDF, self).save()
super(KorekturovanePDF, self).save() return
return except ObjectDoesNotExist:
except ObjectDoesNotExist: pass
pass # uložíme nahrávané pdf
# uložíme nahrávané pdf super(KorekturovanePDF, self).save()
super(KorekturovanePDF, self).save()
# uložíme png a změněný počet stran
# uložíme png a změněný počet stran self.convert()
self.convert()
@reversion.register(ignore_duplicates=True) @reversion.register(ignore_duplicates=True)
@python_2_unicode_compatible
class Oprava(models.Model): class Oprava(models.Model):
class Meta: class Meta:
db_table = 'opravy' db_table = 'opravy'
verbose_name = u'Oprava' verbose_name = u'Oprava'
verbose_name_plural = u'Opravy' verbose_name_plural = u'Opravy'
ordering = ['y','x'] ordering = ['y','x']
#Interní ID #Interní ID
id = models.AutoField(primary_key = True) id = models.AutoField(primary_key = True)
pdf = models.ForeignKey(KorekturovanePDF, default=-1) pdf = models.ForeignKey(KorekturovanePDF, default=-1, on_delete=models.PROTECT)
strana = models.IntegerField(u'strana s opravou', help_text='Strana s opravou (od 0)') strana = models.IntegerField(u'strana s opravou', help_text='Strana s opravou (od 0)')
x = models.IntegerField(u'x-ová souřadnice bugu') x = models.IntegerField(u'x-ová souřadnice bugu')
y = models.IntegerField(u'y-ová souřadnice bugu') y = models.IntegerField(u'y-ová souřadnice bugu')
STATUS_K_OPRAVE = 'k_oprave' STATUS_K_OPRAVE = 'k_oprave'
STATUS_OPRAVENO = 'opraveno' STATUS_OPRAVENO = 'opraveno'
STATUS_NENI_CHYBA = 'neni_chyba' STATUS_NENI_CHYBA = 'neni_chyba'
STATUS_K_ZANESENI = 'k_zaneseni' STATUS_K_ZANESENI = 'k_zaneseni'
STATUS_CHOICES = ( STATUS_CHOICES = (
(STATUS_K_OPRAVE, u'K opravě'), (STATUS_K_OPRAVE, u'K opravě'),
(STATUS_OPRAVENO, u'Opraveno'), (STATUS_OPRAVENO, u'Opraveno'),
(STATUS_NENI_CHYBA, u'Není chyba'), (STATUS_NENI_CHYBA, u'Není chyba'),
(STATUS_K_ZANESENI, u'K zanesení do TeXu'), (STATUS_K_ZANESENI, u'K zanesení do TeXu'),
) )
status = models.CharField(u'stav opravy',max_length=16, choices=STATUS_CHOICES, blank=False, status = models.CharField(u'stav opravy',max_length=16, choices=STATUS_CHOICES, blank=False,
default = STATUS_K_OPRAVE) default = STATUS_K_OPRAVE)
autor = models.ForeignKey(Organizator, blank = True, autor = models.ForeignKey(Organizator, blank = True,
help_text='Autor opravy', help_text='Autor opravy',
null = True) null = True, on_delete=models.SET_NULL)
text = models.TextField(u'text opravy',blank = True, help_text='Text opravy') text = models.TextField(u'text opravy',blank = True, help_text='Text opravy')
# def __init__(self,dictionary): # def __init__(self,dictionary):
# for k,v in dictionary.items(): # for k,v in dictionary.items():
# setattr(self,k,v) # setattr(self,k,v)
def __str__(self): def __str__(self):
return force_unicode(u'%s od %s: %s'%(self.status,self.autor,self.text)) return '{} od {}: {}'.format(self.status,self.autor,self.text)
@reversion.register(ignore_duplicates=True) @reversion.register(ignore_duplicates=True)
@python_2_unicode_compatible
class Komentar(models.Model): class Komentar(models.Model):
class Meta: class Meta:
db_table = 'komentare' db_table = 'komentare'
verbose_name = u'Komentář k opravě' verbose_name = u'Komentář k opravě'
verbose_name_plural = u'Komentáře k opravě' verbose_name_plural = u'Komentáře k opravě'
ordering = ['cas'] ordering = ['cas']
#Interní ID #Interní ID
id = models.AutoField(primary_key = True) id = models.AutoField(primary_key = True)
cas = models.DateTimeField(u'čas komentáře',default=timezone.now,help_text = 'Čas zadání komentáře') cas = models.DateTimeField(u'čas komentáře',default=timezone.now,help_text = 'Čas zadání komentáře')
oprava = models.ForeignKey(Oprava) oprava = models.ForeignKey(Oprava, on_delete=models.CASCADE)
autor = models.ForeignKey(Organizator, blank = True, autor = models.ForeignKey(Organizator, blank = True,
help_text = u'Autor komentáře', help_text = u'Autor komentáře',
null = True) null = True, on_delete=models.SET_NULL)
text = models.TextField(u'text komentáře',blank = True, help_text='Text komentáře') text = models.TextField(u'text komentáře',blank = True, help_text='Text komentáře')
def __str__(self): def __str__(self):
return force_unicode(u'%s od %s: %s'%(self.cas,self.autor,self.text)) return '{} od {}: {}'.format(self.cas,self.autor,self.text)

87
korektury/static/korektury/opraf.css

@ -13,72 +13,46 @@ body,
img{background:white;} img{background:white;}
/* Barvy korektur */
.k_oprave {
--rgb: 255, 0, 0;
}
.opraveno {
--rgb: 0, 0, 255;
}
.neni_chyba {
--rgb: 128, 128, 128;
}
.k_zaneseni {
--rgb: 0, 255, 0;
}
.pointer-hi, .pointer-hi,
.pointer, .pointer{
.pointer-wontfix,
.pointer-wontfix-hi,
.pointer-ready,
.pointer-ready-hi,
.pointer-done,
.pointer-done-hi {
position:absolute; position:absolute;
/*border-bottom-left-radius: 10px; */ /*border-bottom-left-radius: 10px; */
border-left: 2px solid yellow; border-left: 2px solid yellow;
border-bottom: 2px solid yellow; border-bottom: 2px solid yellow;
border-color: rgb(var(--rgb),var(--alpha));
} }
.pointer-done-hi, .pointer {
.pointer-wontfix-hi, border-width: 1px;
.pointer-ready-hi, --alpha: 0.35;
.pointer-hi {
border-width: 3px;
} }
.pointer {
border-color: #F00; /*IE*/
border-color: rgba(255, 0, 0, 0.35);
}
.pointer-hi { .pointer-hi {
border-color: #F00; /*IE*/ border-width: 3px;
border-color: rgba(255, 0, 0, 1); --alpha: 1;
}
.pointer-done {
border-color: #00F; /*IE*/
border-color: rgba(0, 0, 255, 0.2);
}
.pointer-done-hi {
border-color: #00F; /*IE*/
border-color: rgba(0, 0, 255, 1);
}
.pointer-wontfix {
border-color: #000; /*IE*/
border-color: rgba(128, 128, 128, 0.2);
}
.pointer-wontfix-hi {
border-color: #000; /*IE*/
border-color: rgba(128, 128, 128, 1);
}
.pointer-ready {
border-color: #0F0; /*IE*/
border-color: rgba(0, 255, 0, 0.2);
}
.pointer-ready-hi {
border-color: #0F0; /*IE*/
border-color: rgba(0, 255, 0, 1);
} }
.box:hover,
.box-done:hover, .box:hover{
.box-ready:hover,
.box-wontfix:hover{
border-width:3px; border-width:3px;
margin: 0px; margin: 0px;
} }
.box, .box {
.box-done,
.box-ready,
.box-wontfix {
margin: 1px; margin: 1px;
background-color: white; background-color: white;
width:300px; width:300px;
@ -86,18 +60,7 @@ img{background:white;}
padding: 3px; padding: 3px;
border: 2px solid black; border: 2px solid black;
border-radius: 10px; border-radius: 10px;
} border-color: rgb(var(--rgb));
.box {
border-color: red;
}
.box-done {
border-color: blue;
}
.box-ready {
border-color: rgba(0,255,0,1);
}
.box-wontfix {
border-color: grey;
} }
form { form {
display:inline; display:inline;

68
korektury/static/korektury/opraf.js

@ -65,6 +65,12 @@ function place_comments_one_div(img_id, comments)
} }
} }
function place_comments() {
for (var i=0; i < comments.length-1; i++) {
place_comments_one_div(comments[i][0], comments[i][1])
}
}
// ctrl-enter submits form // ctrl-enter submits form
function textarea_onkey(ev) function textarea_onkey(ev)
{ {
@ -212,45 +218,22 @@ function show_form(img_id, dx, dy, id, text, action) {
textarea.focus(); textarea.focus();
return true; return true;
} }
function box_onmouseover(box, stat) function box_onmouseover(box)
{ {
var id = box.id; var id = box.id;
var pointer = document.getElementById(box.id + '-pointer'); var pointer = document.getElementById(box.id + '-pointer');
switch (stat){ pointer.classList.remove('pointer');
case 'done': pointer.classList.add('pointer-hi');
pointer.className = 'pointer-done-hi';
break;
case 'wontfix':
pointer.className = 'pointer-wontfix-hi';
break;
case 'ready':
pointer.className = 'pointer-ready-hi';
break;
default:
pointer.className = 'pointer-hi';
}
} }
function box_onmouseout(box, stat) function box_onmouseout(box)
{ {
var id = box.id; var id = box.id;
var pointer = document.getElementById(box.id + '-pointer'); var pointer = document.getElementById(box.id + '-pointer');
switch (stat){ pointer.classList.remove('pointer-hi');
case 'done': pointer.classList.add('pointer');
pointer.className = 'pointer-done';
break;
case 'wontfix':
pointer.className = 'pointer-wontfix';
break;
case 'ready':
pointer.className = 'pointer-ready';
break;
default:
pointer.className = 'pointer';
}
} }
function save_scroll(form) function save_scroll(form)
@ -261,6 +244,33 @@ function save_scroll(form)
return true; return true;
} }
function toggle_corrections(aclass)
{
var stylesheets = document.styleSheets;
var ssheet = null;
for (var i=0;i<stylesheets.length; i++){
if (stylesheets[i].title === "opraf-css"){
ssheet = stylesheets[i];
break;
}
}
if (! ssheet){
return;
}
for (var i=0;i<ssheet.cssRules.length;i++){
var rule = ssheet.cssRules[i];
if (rule.selectorText === '.'+aclass){
if (rule.style.display === ""){
rule.style.display = "none";
} else {
rule.style.display = "";
}
}
}
place_comments();
}
String.prototype.unescapeHTML = function () { String.prototype.unescapeHTML = function () {
return( return(

38
korektury/templates/korektury/opraf.html

@ -3,7 +3,7 @@
<html> <html>
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css" media="screen, projection" href="{% static "korektury/opraf.css"%}" /> <link rel="stylesheet" title="opraf-css" type="text/css" media="screen, projection" href="{% static "korektury/opraf.css"%}" />
<script src="{% static "korektury/opraf.js"%}"></script> <script src="{% static "korektury/opraf.js"%}"></script>
<title>Korektury {{pdf.nazev}}</title> <title>Korektury {{pdf.nazev}}</title>
</head> </head>
@ -20,6 +20,29 @@
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|
<a href="/">hlavní stránka</a> | <a href="/">hlavní stránka</a> |
<a href="https://mam.mff.cuni.cz/wiki">wiki</a> | <a href="https://mam.mff.cuni.cz/wiki">wiki</a> |
<hr />
Zobrazit:
<input type="checkbox"
id="k_oprave_checkbox"
name="k_oprave_checkbox"
onchange="toggle_corrections('k_oprave')" checked>
<label for="k_oprave_checkbox">K opravě ({{k_oprave_cnt}})</label>
<input type="checkbox"
id="opraveno_checkbox"
name="opraveno_checkbox"
onchange="toggle_corrections('opraveno')" checked>
<label for="opraveno_checkbox">Opraveno ({{opraveno_cnt}})</label>
<input type="checkbox"
id="neni_chyba_checkbox"
name="neni_chyba_checkbox"
onchange="toggle_corrections('neni_chyba')" checked>
<label for="neni_chyba_checkbox">Není chyba ({{neni_chyba_cnt}})</labe>
<input type="checkbox"
id="k_zaneseni_checkbox"
name="k_zaneseni_checkbox"
onchange="toggle_corrections('k_zaneseni')" checked>
<label for="k_zaneseni_checkbox">K zanesení ({{k_zaneseni_cnt}})</labe>
<hr/> <hr/>
<div id="commform-div"> <div id="commform-div">
@ -81,12 +104,12 @@
{% for o in opravy %} {% for o in opravy %}
<div onclick='img_click(this,event)' <div onclick='img_click(this,event)'
id='op{{o.id}}-pointer' id='op{{o.id}}-pointer'
class='pointer{%if o.status == 'opraveno' %}-done{% elif o.status == 'neni_chyba' %}-wontfix{% elif o.status == 'k_zaneseni' %}-ready{% endif %}'> class='pointer {{o.status}}'>
</div> </div>
<div name='op{{o.id}}' id='op{{o.id}}' <div name='op{{o.id}}' id='op{{o.id}}'
class='box{%if o.status == 'opraveno' %}-done{% elif o.status == 'neni_chyba' %}-wontfix{% elif o.status == 'k_zaneseni' %}-ready{% endif %}' class='box {{o.status}}'
onmouseover='box_onmouseover(this,{% if o.status == 'opraveno' %}"done"{% elif o.status == 'neni_chyba' %}"wontfix"{% elif o.status == 'k_zaneseni' %}"ready"{% else %}""{% endif %})' onmouseover='box_onmouseover(this)'
onmouseout='box_onmouseout(this, {% if o.status == 'opraveno' %}"done"{% elif o.status == 'neni_chyba' %}"wontfix"{% elif o.status == 'k_zaneseni' %}"ready"{% else %}""{% endif %})'> onmouseout='box_onmouseout(this)'>
<div class='corr-header'> <div class='corr-header'>
<span class='author' id='op{{o.id}}-autor'>{{o.autor}}</span> <span class='author' id='op{{o.id}}-autor'>{{o.autor}}</span>
@ -211,11 +234,6 @@
["img-{{s.strana}}", [{% for o in s.op_id %}["op{{o.id}}",{{o.x}},{{o.y}}],{% endfor %}[]]], ["img-{{s.strana}}", [{% for o in s.op_id %}["op{{o.id}}",{{o.x}},{{o.y}}],{% endfor %}[]]],
{% endfor %} {% endfor %}
[]] []]
function place_comments() {
for (var i=0; i < comments.length-1; i++) {
place_comments_one_div(comments[i][0], comments[i][1])
}
}
{% if scroll %} {% if scroll %}
window.scrollTo(0,{{scroll}}); window.scrollTo(0,{{scroll}});
{% endif %} {% endif %}

9
korektury/templates/korektury/seznam.html

@ -21,7 +21,14 @@
<ul> <ul>
{% for pdf in object_list %} {% for pdf in object_list %}
<li><span {% if pdf.status == 'zanaseni'%} class="comitting-text" {% elif pdf.status == 'zastarale' %} class="deprecated-text" {% endif %}> <b>{{ pdf.nazev }}</b> <i>{{pdf.komentar}}</i> <a href="/korektury/{{pdf.id}}">{{pdf.pdf.name}}</a> </span> </li> <li><span {% if pdf.status == 'zanaseni'%} class="comitting-text" {% elif pdf.status == 'zastarale' %} class="deprecated-text" {% endif %}>
<b>{{ pdf.nazev }}</b>
<i>{{pdf.komentar}}</i>
<a href="/korektury/{{pdf.id}}">{{pdf.pdf.name}}</a>
(k opravě: {{pdf.k_oprave_cnt}},
opraveno: {{pdf.opraveno_cnt}},
není chyba: {{pdf.neni_chyba_cnt}},
k zanesení: {{pdf.k_zaneseni_cnt}}) </span> </li>
{% empty %} {% empty %}
<li> Nejsou žádné dokumenty ke korekturování. <li> Nejsou žádné dokumenty ke korekturování.
{% endfor %} {% endfor %}

11
korektury/urls.py

@ -1,13 +1,12 @@
from django.conf.urls import * # NOQA from django.urls import path
from django.conf.urls import url
from django.contrib.auth.decorators import user_passes_test from django.contrib.auth.decorators import user_passes_test
from . import views from . import views
staff_member_required = user_passes_test(lambda u: u.is_staff) staff_member_required = user_passes_test(lambda u: u.is_staff)
urlpatterns = [ urlpatterns = [
url(r'^korektury/$', staff_member_required(views.KorekturyAktualniListView.as_view()), name='korektury-list'), path('korektury/', staff_member_required(views.KorekturyAktualniListView.as_view()), name='korektury-list'),
url(r'^korektury/zastarale/$', staff_member_required(views.KorekturyZastaraleListView.as_view()), name='korektury-list-zastarale'), path('korektury/zastarale/', staff_member_required(views.KorekturyZastaraleListView.as_view()), name='korektury-list'),
url(r'^korektury/(?P<pdf>\d+)/$', staff_member_required(views.KorekturyView.as_view()), name='korektury'), path('korektury/<int:pdf>/', staff_member_required(views.KorekturyView.as_view()), name='korektury'),
url(r'^korektury/help/', staff_member_required(views.KorekturyHelpView.as_view()), name='korektury-help'), path('korektury/help/', staff_member_required(views.KorekturyHelpView.as_view()), name='korektury-help'),
] ]

369
korektury/views.py

@ -5,6 +5,7 @@ from django.utils.translation import ugettext as _
from django.conf import settings from django.conf import settings
from django.http import HttpResponseForbidden from django.http import HttpResponseForbidden
from django.core.mail import send_mail from django.core.mail import send_mail
from django.db.models import Count,Q
from .models import Oprava,Komentar,KorekturovanePDF, Organizator from .models import Oprava,Komentar,KorekturovanePDF, Organizator
from .forms import OpravaForm from .forms import OpravaForm
@ -12,14 +13,21 @@ from .forms import OpravaForm
import subprocess import subprocess
import shutil import shutil
import os import os
import unicodedata
class KorekturyHelpView(generic.TemplateView): class KorekturyHelpView(generic.TemplateView):
template_name = 'korektury/help.html' template_name = 'korektury/help.html'
class KorekturyListView(generic.ListView): class KorekturyListView(generic.ListView):
model = KorekturovanePDF model = KorekturovanePDF
template_name = 'korektury/seznam.html' # Nefunguje, filtry se vubec nepouziji
queryset = KorekturovanePDF.objects.annotate(
k_oprave_cnt=Count('oprava',distinct=True,filter=Q(oprava__status='k_oprave')),
opraveno_cnt=Count('oprava',distinct=True,filter=Q(oprava__status='opraveno')),
neni_chyba_cnt=Count('oprava',distinct=True,filter=Q(oprava__status='neni_chyba')),
k_zaneseni_cnt=Count('oprava',distinct=True,filter=Q(oprava__status='k_zaneseni')),
)
template_name = 'korektury/seznam.html'
class KorekturyAktualniListView(KorekturyListView): class KorekturyAktualniListView(KorekturyListView):
def get_queryset(self, *args, **kwargs): def get_queryset(self, *args, **kwargs):
@ -45,178 +53,183 @@ class KorekturyZastaraleListView(KorekturyListView):
### Korektury ### Korektury
class KorekturyView(generic.TemplateView): class KorekturyView(generic.TemplateView):
model = Oprava model = Oprava
template_name = 'korektury/opraf.html' template_name = 'korektury/opraf.html'
form_class = OpravaForm form_class = OpravaForm
def post(self, request, *args, **kwargs): def post(self, request, *args, **kwargs):
form = self.form_class(request.POST) form = self.form_class(request.POST)
q = request.POST q = request.POST
scroll = q.get('scroll') scroll = q.get('scroll')
# prirazeni autora podle prihlaseni # prirazeni autora podle prihlaseni
autor_user = request.user autor_user = request.user
# pokud existuje ucet (user), ale neni to organizator = 403 # pokud existuje ucet (user), ale neni to organizator = 403
autor = Organizator.objects.filter(user=autor_user).first() autor = Organizator.objects.filter(osoba__user=autor_user).first()
if not autor: if not autor:
return HttpResponseForbidden() return HttpResponseForbidden()
if not scroll: if not scroll:
scroll = 0 scroll = 0
action = q.get('action') action = q.get('action')
if (action == u''): # Přidej if (action == ''): # Přidej
x = int(q.get('x')) x = int(q.get('x'))
y = int(q.get('y')) y = int(q.get('y'))
text = q.get('txt') text = q.get('txt')
strana = int(q.get('img-id')[4:]) strana = int(q.get('img-id')[4:])
pdf = KorekturovanePDF.objects.get(id=q.get('pdf')) pdf = KorekturovanePDF.objects.get(id=q.get('pdf'))
op = Oprava(x=x,y=y, autor=autor, text=text, strana=strana,pdf = pdf) op = Oprava(x=x,y=y, autor=autor, text=text, strana=strana,pdf = pdf)
op.save() op.save()
self.send_email_notification_komentar(op, autor, text) self.send_email_notification_komentar(op, autor, text)
elif (action == u'del'): elif (action == 'del'):
id = int(q.get('id')) id = int(q.get('id'))
op = Oprava.objects.get(id=id) op = Oprava.objects.get(id=id)
op.delete() op.delete()
elif (action == u'update'): elif (action == 'update'):
id = int(q.get('id')) id = int(q.get('id'))
op = Oprava.objects.get(id=id) op = Oprava.objects.get(id=id)
text = q.get('txt') text = q.get('txt')
op.autor = autor op.autor = autor
op.text = text op.text = text
op.save() op.save()
elif (action == u'undone'): elif (action == 'undone'):
id = int(q.get('id')) id = int(q.get('id'))
op = Oprava.objects.get(id=id) op = Oprava.objects.get(id=id)
op.status = op.STATUS_K_OPRAVE op.status = op.STATUS_K_OPRAVE
op.save() op.save()
elif (action == u'done'): elif (action == 'done'):
id = int(q.get('id')) id = int(q.get('id'))
op = Oprava.objects.get(id=id) op = Oprava.objects.get(id=id)
op.status = op.STATUS_OPRAVENO op.status = op.STATUS_OPRAVENO
op.save() op.save()
elif (action == u'ready'): elif (action == 'ready'):
id = int(q.get('id')) id = int(q.get('id'))
op = Oprava.objects.get(id=id) op = Oprava.objects.get(id=id)
op.status = op.STATUS_K_ZANESENI op.status = op.STATUS_K_ZANESENI
op.save() op.save()
elif (action == u'wontfix'): elif (action == 'wontfix'):
id = int(q.get('id')) id = int(q.get('id'))
op = Oprava.objects.get(id=id) op = Oprava.objects.get(id=id)
op.status = op.STATUS_NENI_CHYBA op.status = op.STATUS_NENI_CHYBA
op.save() op.save()
elif (action == u'comment'): elif (action == 'comment'):
id = int(q.get('id')) id = int(q.get('id'))
op = Oprava.objects.get(id=id) op = Oprava.objects.get(id=id)
text = q.get('txt') text = q.get('txt')
kom = Komentar(oprava=op,autor=autor,text=text) kom = Komentar(oprava=op,autor=autor,text=text)
kom.save() kom.save()
self.send_email_notification_komentar(op, autor, text) self.send_email_notification_komentar(op, autor, text)
elif (action == u'update-comment'): elif (action == 'update-comment'):
id = int(q.get('id')) id = int(q.get('id'))
kom = Komentar.objects.get(id=id) kom = Komentar.objects.get(id=id)
text = q.get('txt') text = q.get('txt')
kom.text = text kom.text = text
kom.autor = autor kom.autor = autor
kom.save() kom.save()
elif (action == u'del-comment'): elif (action == 'del-comment'):
id = int(q.get('id')) id = int(q.get('id'))
kom = Komentar.objects.get(id=id) kom = Komentar.objects.get(id=id)
kom.delete() kom.delete()
elif (action == u'set-state'): elif (action == 'set-state'):
pdf = KorekturovanePDF.objects.get(id=q.get('pdf')) pdf = KorekturovanePDF.objects.get(id=q.get('pdf'))
if (q.get('state') == u'adding'): if (q.get('state') == 'adding'):
pdf.status = pdf.STATUS_PRIDAVANI pdf.status = pdf.STATUS_PRIDAVANI
elif (q.get('state') == u'comitting'): elif (q.get('state') == 'comitting'):
pdf.status = pdf.STATUS_ZANASENI pdf.status = pdf.STATUS_ZANASENI
elif (q.get('state') == u'deprecated'): elif (q.get('state') == 'deprecated'):
pdf.status = pdf.STATUS_ZASTARALE pdf.status = pdf.STATUS_ZASTARALE
pdf.save() pdf.save()
context = self.get_context_data() context = self.get_context_data()
context['scroll'] = scroll context['scroll'] = scroll
context['autor'] = autor context['autor'] = autor
return render(request, 'korektury/opraf.html',context) return render(request, 'korektury/opraf.html',context)
def send_email_notification_komentar(self, oprava, autor, text): def send_email_notification_komentar(self, oprava, autor, text):
''' Rozesle e-mail pri pridani komentare, ''' Rozesle e-mail pri pridani komentare,
ktery obsahuje text komentare. ktery obsahuje text komentare.
''' '''
# parametry e-mailu # parametry e-mailu
odkaz = "https://mam.mff.cuni.cz/korektury/{}/".format(oprava.pdf.pk) odkaz = "https://mam.mff.cuni.cz/korektury/{}/".format(oprava.pdf.pk)
from_email = 'korekturovatko@mam.mff.cuni.cz' from_email = 'korekturovatko@mam.mff.cuni.cz'
subject = u'Nová korektura od {} v {}'.format(autor, subject = 'Nová korektura od {} v {}'.format(autor,
oprava.pdf.nazev) oprava.pdf.nazev)
text = u"Text komentáře:\n\n{}\n\n=== Konec textu komentáře ===\n\ text = u"Text komentáře:\n\n{}\n\n=== Konec textu komentáře ===\n\
\nodkaz do korekturovátka: {}\n\ \nodkaz do korekturovátka: {}\n\
\nVaše korekturovátko\n".format(text, odkaz) \nVaše korekturovátko\n".format(text, odkaz)
# Prijemci e-mailu # Prijemci e-mailu
emails = set() emails = set()
# e-mail autora korektury # e-mail autora korektury
email = oprava.autor.user.email email = oprava.autor.osoba.email
if email: if email:
emails.add(email) emails.add(email)
# nalezeni e-mailu na autory komentaru # nalezeni e-mailu na autory komentaru
for komentar in oprava.komentar_set.all(): for komentar in oprava.komentar_set.all():
email_komentujiciho = komentar.autor.user.email email_komentujiciho = komentar.autor.osoba.email
if email_komentujiciho: if email_komentujiciho:
emails.add(email_komentujiciho) emails.add(email_komentujiciho)
# zodpovedny org # zodpovedny org
if oprava.pdf.org: if oprava.pdf.org:
email_zobpovedny = oprava.pdf.org.user.email email_zobpovedny = oprava.pdf.org.osoba.email
if email_zobpovedny: if email_zobpovedny:
emails.add(email_zobpovedny) emails.add(email_zobpovedny)
# odstran e-mail autora opravy # odstran e-mail autora opravy
email = autor.user.email email = autor.osoba.email
if email: if email:
emails.discard(email) emails.discard(email)
if not settings.SEND_EMAIL_NOTIFICATIONS: if not settings.SEND_EMAIL_NOTIFICATIONS:
print "Poslal bych upozornění na tyto adresy: ", " ".join(emails) print("Poslal bych upozornění na tyto adresy: ", " ".join(emails))
return return
send_mail(subject, text, from_email, list(emails)) send_mail(subject, text, from_email, list(emails))
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
context = super(KorekturyView,self).get_context_data(**kwargs) context = super(KorekturyView,self).get_context_data(**kwargs)
pdf = get_object_or_404(KorekturovanePDF, id=self.kwargs['pdf']) pdf = get_object_or_404(KorekturovanePDF, id=self.kwargs['pdf'])
context['pdf'] = pdf context['pdf'] = pdf
context['img_prefix'] = pdf.get_prefix() context['img_prefix'] = pdf.get_prefix()
context['img_path'] = settings.KOREKTURY_IMG_DIR context['img_path'] = settings.KOREKTURY_IMG_DIR
context['img_indexes'] = range(pdf.stran) context['img_indexes'] = range(pdf.stran)
context['form_oprava'] = OpravaForm() context['form_oprava'] = OpravaForm()
opravy = Oprava.objects.filter(pdf=self.kwargs['pdf']) opravy = Oprava.objects.filter(pdf=self.kwargs['pdf'])
zasluhy = {} zasluhy = {}
for o in opravy: for o in opravy:
if o.autor in zasluhy: if o.autor in zasluhy:
zasluhy[o.autor]+=1 zasluhy[o.autor]+=1
else: else:
zasluhy[o.autor]=1 zasluhy[o.autor]=1
o.komentare = o.komentar_set.all() o.komentare = o.komentar_set.all()
for k in o.komentare: for k in o.komentare:
if k.autor in zasluhy: if k.autor in zasluhy:
zasluhy[k.autor] += 1 zasluhy[k.autor] += 1
else: else:
zasluhy[k.autor] = 1 zasluhy[k.autor] = 1
zasluhy = [ zasluhy = [
{'autor': jmeno, 'pocet': pocet} {'autor': jmeno, 'pocet': pocet}
for (jmeno, pocet) in zasluhy.items() for (jmeno, pocet) in zasluhy.items()
] ]
zasluhy.sort(key=lambda z: z['pocet'], reverse=True) zasluhy.sort(key=lambda z: z['pocet'], reverse=True)
strany = set(o.strana for o in opravy) strany = set(o.strana for o in opravy)
opravy_na_stranu = [{'strana': s, 'op_id': opravy.filter(strana=s)} for s in strany] opravy_na_stranu = [{'strana': s, 'op_id': opravy.filter(strana=s)} for s in strany]
context['opravy_strany'] = opravy_na_stranu context['opravy_strany'] = opravy_na_stranu
context['opravy'] = opravy context['k_oprave_cnt'] = opravy.filter(status='k_oprave').count()
context['zasluhy'] = zasluhy context['opraveno_cnt'] = opravy.filter(status='opraveno').count()
return context context['neni_chyba_cnt'] = opravy.filter(status='neni_chyba').count()
context['k_zaneseni_cnt'] = opravy.filter(status='k_zaneseni').count()
def form_valid(self,form):
return super(KorekturyView,self).form_valid(form) context['opravy'] = opravy
context['zasluhy'] = zasluhy
return context
def form_valid(self,form):
return super(KorekturyView,self).form_valid(form)

43
mamweb/settings_common.py

@ -52,14 +52,15 @@ AUTHENTICATION_BACKENDS = (
) )
MIDDLEWARE_CLASSES = ( MIDDLEWARE = (
'reversion.middleware.RevisionMiddleware', # 'reversion.middleware.RevisionMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware', 'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware', 'django.middleware.csrf.CsrfViewMiddleware',
'mamweb.middleware.LoggedInHintCookieMiddleware', # FIXME: rozbilo se při přechodu na Django 2.0, nevím, jestli
# se to dá zahodit bez náhrady
# 'mamweb.middleware.LoggedInHintCookieMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware', 'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware', 'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',
@ -73,6 +74,7 @@ TEMPLATES = [
'OPTIONS': { 'OPTIONS': {
'context_processors': ( 'context_processors': (
'django.contrib.auth.context_processors.auth', 'django.contrib.auth.context_processors.auth',
'django.template.context_processors.request',
'django.contrib.messages.context_processors.messages', 'django.contrib.messages.context_processors.messages',
'sekizai.context_processors.sekizai', 'sekizai.context_processors.sekizai',
'mamweb.context_processors.vzhled', 'mamweb.context_processors.vzhled',
@ -102,7 +104,8 @@ INSTALLED_APPS = (
'ckeditor', 'ckeditor',
'ckeditor_uploader', 'ckeditor_uploader',
'taggit', 'taggit',
'autocomplete_light', 'dal',
'dal_select2',
'fluent_comments', 'fluent_comments',
'crispy_forms', 'crispy_forms',
@ -112,8 +115,12 @@ INSTALLED_APPS = (
'django.contrib.flatpages', 'django.contrib.flatpages',
'django.contrib.humanize', 'django.contrib.humanize',
'sitetree',
'imagekit', 'imagekit',
'polymorphic',
# MaMweb # MaMweb
'mamweb', 'mamweb',
'seminar', 'seminar',
@ -211,6 +218,14 @@ LOGGING = {
'handlers': ['console'], 'handlers': ['console'],
'level': 'DEBUG', 'level': 'DEBUG',
}, },
'seminar.prihlaska.form':{
'handlers': ['console','registration_logfile'],
'level': 'INFO'
},
'seminar.prihlaska.problem':{
'handlers': ['console','mail_registration','registration_error_log'],
'level': 'INFO'
},
# Catch-all logger # Catch-all logger
'': { '': {
@ -233,6 +248,24 @@ LOGGING = {
'class': 'django.utils.log.AdminEmailHandler', 'class': 'django.utils.log.AdminEmailHandler',
'formatter': 'verbose', 'formatter': 'verbose',
}, },
'mail_registration': {
'level': 'WARN',
'class': 'django.utils.log.AdminEmailHandler',
'formatter': 'verbose',
},
'registration_logfile':{
'level': 'INFO',
'class': 'logging.FileHandler',
# filename declared in specific configuration files
'formatter': 'verbose',
},
'registration_error_log':{
'level': 'INFO',
'class': 'logging.FileHandler',
# filename declared in specific configuration files
'formatter': 'verbose',
},
}, },
} }

13
mamweb/settings_debug.py

@ -0,0 +1,13 @@
# Debugovaci nastaveni settings.py
# Pro vyber tohoto nastaveni muzete pouzit tez:
# DJANGO_SETTINGS_MODULE=mamweb.settings_debug ./manage.py ...
# Import local settings
from .settings_local import *
# Vypisovani databazovych dotazu do konzole
LOGGING['loggers']['django.db.backends'] = {
'level': 'DEBUG',
'handlers': ['console'],
'propagate': False,
}

48
mamweb/settings_local.py

@ -10,7 +10,7 @@ import os.path
# Import common settings # Import common settings
from .settings_common import * from .settings_common import *
MIDDLEWARE_CLASSES += ( MIDDLEWARE += (
'debug_toolbar.middleware.DebugToolbarMiddleware', 'debug_toolbar.middleware.DebugToolbarMiddleware',
) )
@ -24,6 +24,7 @@ INSTALLED_APPS += (
# SECURITY WARNING: don't run with debug turned on in production! # SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True DEBUG = True
INTERNAL_IPS = ['127.0.0.1']
TEMPLATES[0]['OPTIONS']['debug'] = True TEMPLATES[0]['OPTIONS']['debug'] = True
@ -47,7 +48,50 @@ DATABASES = {
#} #}
# LOGGING # LOGGING
LOGGING = {
'version': 1,
'disable_existing_loggers': True,
'filters': {
'require_debug_false': {
'()': 'django.utils.log.RequireDebugFalse'
}
},
'formatters': {
'simple': {
'format': '%(asctime)s - %(name)s - %(levelname)-8s - %(message)s',
},
},
'handlers': {
'dummy': {
'class': 'logging.NullHandler',
},
'console': {
'level': 'DEBUG',
'class': 'logging.StreamHandler',
'formatter': 'simple',
},
},
'loggers': {
# Vypisovani databazovych dotazu do konzole
#'django.db.backends': {
# 'level': 'DEBUG',
# 'handlers': ['console'],
# 'propagate': False,
#},
'werkzeug': {
'handlers': ['console'],
'level': 'DEBUG',
'propagate': True,
},
'': {
'handlers': ['console'],
'level': 'DEBUG',
'propagate': False,
},
},
}
# set to 'DEBUG' for EXTRA verbose output # set to 'DEBUG' for EXTRA verbose output
LOGGING['handlers']['console']['level'] = 'INFO' # LOGGING['handlers']['console']['level'] = 'INFO'
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'

2
mamweb/settings_prod.py

@ -61,6 +61,8 @@ CSRF_COOKIE_SECURE = True
LOGGING['loggers']['']['handlers'] = ['console', 'mail_admins'] LOGGING['loggers']['']['handlers'] = ['console', 'mail_admins']
LOGGING['loggers']['django']['handlers'] = ['console', 'mail_admins'] LOGGING['loggers']['django']['handlers'] = ['console', 'mail_admins']
LOGGING['handlers']['registration_logfile']['filename'] = '/home/mam-web/logs/prod/registration.log'
LOGGING['handlers']['registration_error_log']['filename'] = '/home/mam-web/logs/prod/registration_errors.log'
# E-MAIL NOTIFICATIONS # E-MAIL NOTIFICATIONS

2
mamweb/settings_test.py

@ -65,3 +65,5 @@ CSRF_COOKIE_SECURE = True
LOGGING['loggers']['']['handlers'] = ['console', 'mail_admins'] LOGGING['loggers']['']['handlers'] = ['console', 'mail_admins']
LOGGING['loggers']['django']['handlers'] = ['console', 'mail_admins'] LOGGING['loggers']['django']['handlers'] = ['console', 'mail_admins']
LOGGING['handlers']['registration_logfile']['filename'] = '/home/mam-web/logs/test/registration.log'
LOGGING['handlers']['registration_error_log']['filename'] = '/home/mam-web/logs/test/registration_errors.log'

984
mamweb/static/css/mamweb.css

File diff suppressed because it is too large

BIN
mamweb/static/favicon.ico

Binary file not shown.

Before

Width:  |  Height:  |  Size: 218 B

201
mamweb/static/fonts/OpenSans/Apache License.txt

@ -0,0 +1,201 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

BIN
mamweb/static/fonts/OpenSans/OpenSans-Bold.ttf

Binary file not shown.

BIN
mamweb/static/fonts/OpenSans/OpenSans-BoldItalic.ttf

Binary file not shown.

BIN
mamweb/static/fonts/OpenSans/OpenSans-ExtraBold.ttf

Binary file not shown.

BIN
mamweb/static/fonts/OpenSans/OpenSans-ExtraBoldItalic.ttf

Binary file not shown.

BIN
mamweb/static/fonts/OpenSans/OpenSans-Italic.ttf

Binary file not shown.

BIN
mamweb/static/fonts/OpenSans/OpenSans-Light.ttf

Binary file not shown.

BIN
mamweb/static/fonts/OpenSans/OpenSans-LightItalic.ttf

Binary file not shown.

BIN
mamweb/static/fonts/OpenSans/OpenSans-Regular.ttf

Binary file not shown.

BIN
mamweb/static/fonts/OpenSans/OpenSans-Semibold.ttf

Binary file not shown.

BIN
mamweb/static/fonts/OpenSans/OpenSans-SemiboldItalic.ttf

Binary file not shown.

120
mamweb/static/images/MATFYZ_MM_barevne.svg

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
version="1.1"
id="svg2"
xml:space="preserve"
width="873.38959"
height="697.76959"
viewBox="0 0 873.38957 697.7696"
sodipodi:docname="MATFYZ_MM_barevne.svg"
inkscape:version="0.92.3 (2405546, 2018-03-11)"><metadata
id="metadata8"><rdf:RDF><cc:Work
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
id="defs6" /><sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1853"
inkscape:window-height="1025"
id="namedview4"
showgrid="false"
inkscape:zoom="0.29733907"
inkscape:cx="436.69495"
inkscape:cy="348.92161"
inkscape:window-x="67"
inkscape:window-y="27"
inkscape:window-maximized="1"
inkscape:current-layer="g10" /><g
id="g10"
inkscape:groupmode="layer"
inkscape:label="ink_ext_XXXXXX"
transform="matrix(1.3333333,0,0,-1.3333333,-124.56506,745.70131)"><g
id="g12"
transform="scale(0.1)"><path
d="M 7483.93,3086.74 6136.77,1739.57 h -1324.9 l 1347.41,1347.17 h 1324.65"
style="fill:#e94e0f;fill-opacity:1;fill-rule:nonzero;stroke:none"
id="path14"
inkscape:connector-curvature="0" /><path
d="m 7210.43,1001.61 v -88.579 h -308.59 v 91.489 l 179.35,190.24 H 6909.1 v 88.58 h 294.07 v -91.49 l -179.35,-190.24 h 186.61"
style="fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none"
id="path16"
inkscape:connector-curvature="0" /><path
d="M 6847.38,1283.34 6704.34,793.219 h -100.93 l 34.85,119.812 H 6578 l -108.19,370.309 h 114.72 l 73.34,-298.43 74.06,298.43 h 115.45"
style="fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none"
id="path18"
inkscape:connector-curvature="0" /><path
d="m 6437.13,1415.49 -5.08,-72.61 c -21.06,2.18 -37.76,2.9 -50.1,2.9 -52.28,0 -60.99,-6.53 -62.45,-63.17 h 94.4 v -87.85 h -94.4 V 913.031 h -108.91 v 387.009 c 0,96.57 32.67,128.52 129.24,128.52 36.31,0 74.07,-5.81 97.3,-13.07"
style="fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none"
id="path20"
inkscape:connector-curvature="0" /><path
d="M 6151.29,3087.46 C 5702.07,2638.25 5252.62,2188.79 4803.4,1739.57 h -3.15 l -0.72,0.73 1347.4,1347.16 h 4.36"
style="fill:#e94e0f;fill-opacity:1;fill-rule:nonzero;stroke:none"
id="path22"
inkscape:connector-curvature="0" /><path
d="m 6116.92,998.711 5.81,-78.422 c -24.69,-7.988 -67.53,-14.519 -99.48,-14.519 -80.59,0 -119.8,25.41 -119.8,124.16 v 321.66 l 108.91,30.5 v -98.75 h 87.13 v -88.58 h -87.13 V 1056.8 c 0,-54.46 6.54,-62.448 48.65,-62.448 15.98,0 37.76,1.449 55.91,4.359"
style="fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none"
id="path24"
inkscape:connector-curvature="0" /><path
d="m 5685.62,1068.41 c -26.14,1.45 -52.28,2.91 -68.26,2.91 -38.48,-0.73 -53,-15.98 -53,-44.3 0,-26.86 18.87,-44.29 56.63,-44.29 24.69,0 46.47,8.719 64.63,21.06 z m 0,67.53 v 3.63 c 0,55.91 -17.43,65.35 -74.07,65.35 -38.48,0 -80.59,-2.9 -122.71,-6.53 l -5.08,77.69 c 43.56,7.99 104.56,14.52 147.4,14.52 124.16,0 163.37,-31.95 163.37,-148.13 V 913.031 h -72.61 l -22.51,37.75 c -31.22,-27.59 -69.7,-45.011 -116.9,-45.011 -79.15,0 -124.16,47.921 -124.16,119.8 0,84.96 47.92,113.28 153.2,113.28 23.24,0.72 49.38,-0.73 74.07,-2.91"
style="fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none"
id="path26"
inkscape:connector-curvature="0" /><path
d="m 5424.22,522.629 -17.19,-154.66 h -50.58 l 31.71,231.859 h 50.1 l 51.31,-134.078 50.58,134.078 h 51.56 l 30.49,-231.859 h -50.82 l -16.7,156.351 -45.27,-119.082 h -41.62 l -43.57,117.391"
style="fill:#e94e0f;fill-opacity:1;fill-rule:nonzero;stroke:none"
id="path28"
inkscape:connector-curvature="0" /><path
d="m 5204.69,402.09 c 9.93,0 18.64,2.91 26.87,8.23 l -54.7,56.399 c -8.47,-7.02 -12.83,-16.457 -12.83,-28.559 0,-21.789 17.43,-36.07 40.66,-36.07 z m -88.58,30.98 c 0,25.168 13.31,48.172 35.58,61.239 -13.07,16.461 -19.61,31.953 -19.61,47.203 0,19.84 6.78,35.57 20.33,47.918 13.8,12.582 31.71,18.879 53.98,18.879 52.04,0 77.93,-20.817 81.81,-65.11 h -53.74 c -1.45,16.942 -11.13,25.903 -28.07,25.903 -13.56,0 -23.96,-8.481 -23.96,-23.243 0,-11.859 4.6,-19.847 20.09,-35.82 l 56.39,-58.09 c 3.87,13.563 5.81,27.84 5.81,43.813 h 50.83 c 0,-28.563 -7.51,-54.942 -22.76,-79.153 l 47.2,-48.64 h -67.04 l -13.07,13.07 c -17.19,-12.109 -36.07,-18.16 -57.36,-18.16 -24.21,0 -45.02,6.051 -61.72,18.402 -16.7,12.578 -24.69,29.77 -24.69,51.789"
style="fill:#e94e0f;fill-opacity:1;fill-rule:nonzero;stroke:none"
id="path30"
inkscape:connector-curvature="0" /><path
d="m 5130.87,1248.49 c 39.94,25.41 89.31,42.11 127.8,42.11 72.61,0 109.64,-39.94 109.64,-121.98 V 913.031 h -108.92 v 212.019 c 0,67.53 -7.26,76.97 -53,76.97 -17.43,0 -38.49,-2.18 -58.09,-6.54 0.73,-8.71 1.45,-17.43 1.45,-26.86 V 913.031 h -108.91 v 212.019 c 0,67.53 -7.26,76.97 -53.01,76.97 -17.43,0 -38.48,-2.18 -58.09,-6.54 V 913.031 h -108.91 v 370.309 h 72.61 l 19.6,-34.13 c 39.21,24.69 88.59,41.39 127.07,41.39 42.84,0 73.34,-13.79 90.76,-42.11"
style="fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none"
id="path32"
inkscape:connector-curvature="0" /><path
d="m 5019.05,524.32 -45.26,-119.082 h -41.63 l -43.56,117.391 -17.43,-154.66 h -50.34 l 31.7,231.859 h 50.1 l 51.07,-134.078 50.83,134.078 h 51.55 l 30.5,-231.859 h -50.83 l -16.7,156.351"
style="fill:#e94e0f;fill-opacity:1;fill-rule:nonzero;stroke:none"
id="path34"
inkscape:connector-curvature="0" /><path
d="M 6159.28,3086.74 4811.87,1739.57 h -8.47 c 449.22,449.22 898.67,898.68 1347.89,1347.89 h 1333.37 l -0.73,-0.72 H 6159.28"
style="fill:#e94e0f;fill-opacity:1;fill-rule:nonzero;stroke:none"
id="path36"
inkscape:connector-curvature="0" /><path
d="m 4800.25,1739.57 h -1.45 l 0.73,0.73 z"
style="fill:#e94e0f;fill-opacity:1;fill-rule:nonzero;stroke:none"
id="path38"
inkscape:connector-curvature="0" /><path
d="m 4782.34,1740.3 -0.24,-0.24 H 2883.34 v 1899 l 1899,-1898.76"
style="fill:#e94e0f;fill-opacity:1;fill-rule:nonzero;stroke:none"
id="path40"
inkscape:connector-curvature="0" /><path
d="M 4481.01,1707.38 V 359.488 H 3133.12 V 1707.38 h 1347.89"
style="fill:#e94e0f;fill-opacity:1;fill-rule:nonzero;stroke:none"
id="path42"
inkscape:connector-curvature="0" /><path
d="M 2850.67,5592.76 V 3710.7 l -941.27,941.03 z"
style="fill:#e94e0f;fill-opacity:1;fill-rule:nonzero;stroke:none"
id="path44"
inkscape:connector-curvature="0" /><path
d="m 2845.59,3672.94 -953.14,-953.13 -953.126,953.13 953.126,953.14 953.14,-953.14"
style="fill:#e94e0f;fill-opacity:1;fill-rule:nonzero;stroke:none"
id="path46"
inkscape:connector-curvature="0" /><path
d="M 1875.27,4651.73 934.238,3710.7 v 1882.06 z"
style="fill:#e94e0f;fill-opacity:1;fill-rule:nonzero;stroke:none"
id="path48"
inkscape:connector-curvature="0" /></g></g></svg>

After

Width:  |  Height:  |  Size: 7.9 KiB

BIN
mamweb/static/images/footer-bg-bottom.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

BIN
mamweb/static/images/footer-bg-top.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

BIN
mamweb/static/images/graf/adrenalinove.jpeg

Binary file not shown.

After

Width:  |  Height:  |  Size: 568 KiB

BIN
mamweb/static/images/graf/behaci.jpeg

Binary file not shown.

After

Width:  |  Height:  |  Size: 203 KiB

BIN
mamweb/static/images/graf/ceny.jpeg

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 MiB

BIN
mamweb/static/images/graf/deskovky.jpeg

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

BIN
mamweb/static/images/graf/dort.jpeg

Binary file not shown.

After

Width:  |  Height:  |  Size: 323 KiB

BIN
mamweb/static/images/graf/hry.jpeg

Binary file not shown.

After

Width:  |  Height:  |  Size: 394 KiB

BIN
mamweb/static/images/graf/jidlo.jpeg

Binary file not shown.

After

Width:  |  Height:  |  Size: 213 KiB

BIN
mamweb/static/images/graf/konfery.jpeg

Binary file not shown.

After

Width:  |  Height:  |  Size: 170 KiB

BIN
mamweb/static/images/graf/legenda.jpeg

Binary file not shown.

After

Width:  |  Height:  |  Size: 250 KiB

BIN
mamweb/static/images/graf/prednasky.jpeg

Binary file not shown.

After

Width:  |  Height:  |  Size: 72 KiB

BIN
mamweb/static/images/graf/strategicke.jpeg

Binary file not shown.

After

Width:  |  Height:  |  Size: 320 KiB

BIN
mamweb/static/images/graf/vylet.jpeg

Binary file not shown.

After

Width:  |  Height:  |  Size: 209 KiB

BIN
mamweb/static/images/graph.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 62 KiB

BIN
mamweb/static/images/header-bg-archiv-NOC.jpg

Binary file not shown.

Before

Width:  |  Height:  |  Size: 37 KiB

BIN
mamweb/static/images/header-bg-archiv.jpg

Binary file not shown.

Before

Width:  |  Height:  |  Size: 55 KiB

BIN
mamweb/static/images/header-bg-clanek-NOC.jpg

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

BIN
mamweb/static/images/header-bg-clanek.jpg

Binary file not shown.

Before

Width:  |  Height:  |  Size: 86 KiB

BIN
mamweb/static/images/header-bg-odevzdat-NOC.jpg

Binary file not shown.

Before

Width:  |  Height:  |  Size: 64 KiB

BIN
mamweb/static/images/header-bg-soustredeni-NOC.jpg

Binary file not shown.

Before

Width:  |  Height:  |  Size: 53 KiB

BIN
mamweb/static/images/header-bg-soustredeni.jpg

Binary file not shown.

Before

Width:  |  Height:  |  Size: 101 KiB

BIN
mamweb/static/images/header-bg-uvod-NOC.jpg

Binary file not shown.

Before

Width:  |  Height:  |  Size: 42 KiB

BIN
mamweb/static/images/header-bg-uvod.jpg

Binary file not shown.

Before

Width:  |  Height:  |  Size: 88 KiB

BIN
mamweb/static/images/header-bg-zadani-NOC.jpg

Binary file not shown.

Before

Width:  |  Height:  |  Size: 36 KiB

BIN
mamweb/static/images/header-bg-zadani.jpg

Binary file not shown.

Before

Width:  |  Height:  |  Size: 60 KiB

BIN
mamweb/static/images/header-bg.jpg

Binary file not shown.

Before

Width:  |  Height:  |  Size: 122 KiB

BIN
mamweb/static/images/header/baliky.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 351 KiB

BIN
mamweb/static/images/header/beh.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 MiB

BIN
mamweb/static/images/header/kryptografie.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 226 KiB

BIN
mamweb/static/images/header/mam_cernobile.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 MiB

BIN
mamweb/static/images/header/noc.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 262 KiB

BIN
mamweb/static/images/header/ohen.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 363 KiB

BIN
mamweb/static/images/header/snih.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 235 KiB

BIN
mamweb/static/images/header/spolecna.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 338 KiB

BIN
mamweb/static/images/header/stiny.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 443 KiB

BIN
mamweb/static/images/header/vikendovka.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 284 KiB

BIN
mamweb/static/images/header/vylet.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 426 KiB

BIN
mamweb/static/images/logo-jcmf.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save