Jonas Havelka
1 month ago
219 changed files with 499 additions and 809 deletions
@ -1,16 +0,0 @@ |
|||
git hooks |
|||
========= |
|||
|
|||
Kontrola stylu pythoních zdrojáků pomocí flake8. Kontrolujeme jen změny, |
|||
abychom nenutili lidi dělat nesouvisející úpravy, které by rozbíjely historii |
|||
(git blame). |
|||
|
|||
pre-commit |
|||
---------- |
|||
* kontrola změn před commitnutím |
|||
* instalace: lokálně zkopírovat do .git/hooks (musí být spustitelný) |
|||
|
|||
update |
|||
------ |
|||
* kontrola změn přicházejících s pushem |
|||
* instalace: na atreyi zkopírovat do /akce/MaM/MaMweb/mamweb.git/hooks |
@ -1,30 +0,0 @@ |
|||
#!/bin/sh |
|||
# |
|||
# Git hook script to verify what is about to be committed. |
|||
# Checks that the changes don't introduce new flake8 errors. |
|||
|
|||
TMPDIFF=`tempfile` |
|||
FLAKE8="`git rev-parse --show-toplevel`/bin/flake8" |
|||
|
|||
status=0 |
|||
|
|||
# select only changed python files which are not migrations |
|||
changed=`git diff --cached --name-only | grep 'py$' | grep -v 'migrations/[0-9]'` |
|||
if [ -z $changed ] ; then |
|||
# Nothing to check. Note the exit is necessary -- we would not pass any |
|||
# paths to git diff below and it would output the diff unfiltered. |
|||
exit 0 |
|||
fi |
|||
|
|||
git diff --unified=1 --cached HEAD -- $changed > $TMPDIFF |
|||
|
|||
# only do the check when there are some changes to be commited |
|||
# otherwise flake8 would hang waiting for input |
|||
if [ -s $TMPDIFF ] ; then |
|||
cat $TMPDIFF | $FLAKE8 --diff |
|||
status=$? |
|||
fi |
|||
|
|||
rm -f $TMPDIFF |
|||
|
|||
exit $status |
@ -1,61 +0,0 @@ |
|||
#!/bin/sh |
|||
|
|||
# git update hook to check that pushed changes don't introduce new flake8 |
|||
# errors |
|||
|
|||
# --- Command line |
|||
refname="$1" |
|||
oldrev="$2" |
|||
newrev="$3" |
|||
|
|||
# --- Safety check |
|||
if [ -z "$GIT_DIR" ]; then |
|||
echo "Don't run this script from the command line." >&2 |
|||
echo " (if you want, you could supply GIT_DIR then run" >&2 |
|||
echo " $0 <ref> <oldrev> <newrev>)" >&2 |
|||
exit 1 |
|||
fi |
|||
|
|||
if [ -z "$refname" -o -z "$oldrev" -o -z "$newrev" ]; then |
|||
echo "usage: $0 <ref> <oldrev> <newrev>" >&2 |
|||
exit 1 |
|||
fi |
|||
|
|||
|
|||
TMPDIR=`mktemp -d` |
|||
TMPDIFF=`tempfile` |
|||
|
|||
[ $refname != "refs/heads/master" -a $refname != "refs/heads/stable" ] && exit 0 |
|||
|
|||
# select only changed python files which are not migrations |
|||
changed=`git diff --name-only $oldrev $newrev | grep 'py$' | grep -v 'migrations/[0-9]'` |
|||
if [ -z $changed ] ; then |
|||
# Nothing to check. Note the exit is necessary -- we would not pass any |
|||
# paths to git diff below and it would output the diff unfiltered. |
|||
exit 0 |
|||
fi |
|||
|
|||
git diff --unified=1 $oldrev $newrev -- $changed >${TMPDIFF} |
|||
|
|||
# there is no working tree in bare git repository, so we recreate it for flake8 |
|||
git archive $newrev | tar -x -C ${TMPDIR} |
|||
|
|||
cd ${TMPDIR} |
|||
# report only errors on lines in diff |
|||
# (if threre was flake8 installed on atrey, we could just call flake8) |
|||
/akce/MaM/WWW/mamweb-test/bin/flake8 --diff <${TMPDIFF} |
|||
status=$? |
|||
if [ $status != 0 ] ; then |
|||
echo |
|||
echo -n "Změny, které se snažíte pushnout, obsahují kód v pythonu " |
|||
echo -n "nevyhovující flake8 (viz výše). Opravte je a zkuste to znovu. " |
|||
echo -n "Nezapomeňte, že můžete editovat historii (git commit --amend, " |
|||
echo -n "git rebase -i). Pokud byste chybu příště raději odhalili už při " |
|||
echo "commitu, zkopírujte si pre-commit hook z _git_hooks do .git/hooks." |
|||
echo |
|||
fi |
|||
|
|||
rm -rf ${TMPDIR} |
|||
rm -f ${TMPDIFF} |
|||
|
|||
exit $status |
@ -1,8 +1,5 @@ |
|||
""" |
|||
Soubor sloužící k pojmenování a jiným nastavením djangovské aplikace. |
|||
""" |
|||
from django.apps import AppConfig |
|||
|
|||
|
|||
class AesopConfig(AppConfig): |
|||
name = 'aesop' |
|||
verbose_name = 'Export do AESOPa' |
|||
|
@ -1,8 +1,6 @@ |
|||
""" |
|||
Soubor sloužící k pojmenování a jiným nastavením djangovské aplikace. |
|||
""" |
|||
from django.apps import AppConfig |
|||
|
|||
|
|||
class ApiConfig(AppConfig): |
|||
name = 'api' |
|||
verbose_name = 'Různá webová API' |
|||
|
@ -1,7 +1,2 @@ |
|||
""" |
|||
Soubory sloužící k deklaraci jednotlivých „views“ (nejčastěji funkce beroucí request |
|||
a vracející :func:`django.shortcuts.render` respektive nějakou response, nebo |
|||
třídy většinou rozšiřující nějakou třídu z :mod:`django.views.generic`) |
|||
""" |
|||
from .autocomplete import * |
|||
from .exports import * |
|||
|
@ -1,3 +1,4 @@ |
|||
FIXME přepsat do rst, přidat i další věci a případně přesunout na wiki |
|||
Přidání obrázků do odměn: |
|||
admin -> flatpage odměn -> ikona přidat obrázek |
|||
záložka odeslat, vybrat obrázek, odeslat |
@ -1,25 +0,0 @@ |
|||
======== |
|||
| TODO | |
|||
|======| |
|||
|
|||
Aktualni |
|||
* co s titulni fotkou |
|||
* do CSS |
|||
* nahledy |
|||
* nastylovat tabulku s nahledy |
|||
* komentare uz na nahledy? |
|||
* detail |
|||
* nahledy pred a po |
|||
* opravit prechodove sipky |
|||
* vyrobit prechodove sipky ve M&M-stylu |
|||
|
|||
Dlouhodobe |
|||
* sipky na prechazeni mezi fotkami |
|||
* hromadne PRIDANI fotek do jiz existujici galerie |
|||
|
|||
Fylozoficke |
|||
* zvolit velikosti velke a male fotky |
|||
* je potreba i jine razeni nez automaticky podle casu nebo staci podgalerie? |
|||
* napr. dve hry na dvou ruznych mistech ve stejny cas |
|||
* fotky od ucastniku ze hry (skupinky se pohybuji ve stejny cas, ale maji sled fotek) -- nestaci to pripadne vrazit do podgalerii? |
|||
|
@ -1,47 +0,0 @@ |
|||
# -*- coding: utf-8 -*- |
|||
|
|||
from autocomplete_light import shortcuts as autocomplete_light |
|||
|
|||
from .models import Obrazek, Galerie |
|||
from .views import cesta_od_korene |
|||
|
|||
|
|||
class ObrazekAutocomplete(autocomplete_light.AutocompleteModelBase): |
|||
|
|||
model = Obrazek |
|||
search_fields = ['nazev', 'popis'] |
|||
split_words = True |
|||
limit_choices = 15 |
|||
attrs = { |
|||
# This will set the input placeholder attribute: |
|||
'placeholder': u'Obrázek', |
|||
# This will set the yourlabs.Autocomplete.minimumCharacters |
|||
# options, the naming conversion is handled by jQuery |
|||
'data-autocomplete-minimum-characters': 1, |
|||
} |
|||
|
|||
choice_html_format = ''' |
|||
<span class="block" data-value="{}"> |
|||
<span class="block"> |
|||
{} |
|||
<span class="block">{}</span> |
|||
</span> |
|||
</span> |
|||
''' |
|||
|
|||
def choice_label(self, obrazek): |
|||
cesta = "/".join(g.nazev for g in cesta_od_korene(obrazek.galerie)) |
|||
popis = "{}<br>".format(obrazek.popis) if obrazek.popis else "" |
|||
return '{}<br>{}{}'.format(obrazek.nazev, popis, cesta) |
|||
|
|||
def choice_html(self, obrazek): |
|||
"""Vrátí kus html i s obrázkem, které se pak ukazuje v nabídce""" |
|||
return self.choice_html_format.format(self.choice_value(obrazek), |
|||
obrazek.obrazek_maly_tag(), self.choice_label(obrazek)) |
|||
|
|||
widget_attrs={ |
|||
'data-widget-maximum-values': 15, |
|||
'class': 'modern-style', |
|||
} |
|||
|
|||
autocomplete_light.register(ObrazekAutocomplete) |
@ -1,8 +1,6 @@ |
|||
""" |
|||
Soubor sloužící k pojmenování a jiným nastavením djangovské aplikace. |
|||
""" |
|||
from django.apps import AppConfig |
|||
|
|||
|
|||
class HeaderFotkyConfig(AppConfig): |
|||
name = 'header_fotky' |
|||
verbose_name = 'Fotky v záhlaví' |
|||
|
@ -1,11 +0,0 @@ |
|||
- korektura potrebuje reakci |
|||
+ komentáře fixně na username |
|||
- používat skutečné jméno? |
|||
- vyžádat pozornost autora obsahu |
|||
- zvednout upload limit na 5MB |
|||
- sbalit a rozbalit korekturu |
|||
- nahrávání jiných věcí než PDF - kontrolovat? |
|||
- stylování |
|||
- seznam PDF - co zobrazovat? |
|||
|
|||
|
@ -1,3 +0,0 @@ |
|||
from django.test import TestCase |
|||
|
|||
# Create your tests here. |
@ -1,88 +0,0 @@ |
|||
from datetime import datetime, date |
|||
|
|||
from django.conf import settings |
|||
from django.http import HttpResponse, HttpResponseRedirect |
|||
|
|||
|
|||
|
|||
class LoggedInHintCookieMiddleware(object): |
|||
"""Middleware to securely help with 'logged-in' detection for dual HTTP/HTTPS sites. |
|||
|
|||
On insecure requests: Checks for a (non-secure) cookie settings.LOGGED_IN_HINT_COOKIE_NAME |
|||
and if present, redirects to HTTPS (same adress). |
|||
Note this usually breaks non-GET (POST) requests. |
|||
|
|||
On secure requests: Updates cookie settings.LOGGED_IN_HINT_COOKIE_NAME to reflect |
|||
whether an user is logged in in the current session (cookie set to 'True' or cleared). |
|||
The cookie is set to expire at the same time as the sessionid cookie. |
|||
|
|||
By default, LOGGED_IN_HINT_COOKIE_NAME = 'logged_in_hint'. |
|||
""" |
|||
|
|||
def __init__(self): |
|||
if hasattr(settings, 'LOGGED_IN_HINT_COOKIE_NAME'): |
|||
self.cookie_name = settings.LOGGED_IN_HINT_COOKIE_NAME |
|||
else: self.cookie_name = 'logged_in_hint' |
|||
self.cookie_value = 'True' |
|||
|
|||
def cookie_correct(self, request): |
|||
return self.cookie_name in request.COOKIES and request.COOKIES[self.cookie_name] == self.cookie_value |
|||
|
|||
def process_request(self, request): |
|||
if not request.is_secure(): |
|||
if self.cookie_correct(request): |
|||
# redirect insecure (assuming http) requests with hint cookie to https |
|||
url = request.build_absolute_uri() |
|||
assert url[:5] == 'http:' |
|||
return HttpResponseRedirect('https:' + url[5:]) |
|||
return None |
|||
|
|||
def process_response(self, request, response): |
|||
if request.is_secure(): |
|||
# assuming full session info (as the conn. is secure) |
|||
try: |
|||
user = request.user |
|||
except AttributeError: # no user - ajax or other special request |
|||
return response |
|||
if user.is_authenticated(): |
|||
if not self.cookie_correct(request): |
|||
expiry = None if request.session.get_expire_at_browser_close() else request.session.get_expiry_date() |
|||
response.set_cookie(self.cookie_name, value=self.cookie_value, expires=expiry, secure=False) |
|||
else: |
|||
if self.cookie_name in request.COOKIES: |
|||
response.delete_cookie(self.cookie_name) |
|||
return response |
|||
|
|||
|
|||
class vzhled: |
|||
|
|||
def process_request(self, request): |
|||
return None |
|||
|
|||
def process_view(self, request, view_func, view_args, view_kwargs): |
|||
#print "====== process_request ======" |
|||
#print view_func |
|||
#print view_args |
|||
#print view_kwargs |
|||
#print "=============================" |
|||
return None |
|||
|
|||
def process_template_response(self, request, response): |
|||
hodin = datetime.now().hour |
|||
if (hodin <= 6) or (hodin >= 14): # TODO 20 |
|||
response.context_data['noc'] = True |
|||
else: |
|||
response.context_data['noc'] = False |
|||
return response |
|||
|
|||
def process_response(self, request, response): |
|||
#hodin = datetime.now().hour |
|||
#if (hodin <= 6) or (hodin >= 14): # TODO 20 |
|||
#response.context_data['noc'] = True |
|||
#else: |
|||
#response.context_data['noc'] = False |
|||
return response |
|||
|
|||
|
|||
##def process_exception(request, exception): |
|||
#pass |
@ -0,0 +1,5 @@ |
|||
from django.contrib import admin |
|||
|
|||
from .models import Novinky |
|||
|
|||
admin.site.register(Novinky) |
@ -0,0 +1,5 @@ |
|||
from django.apps import AppConfig |
|||
|
|||
class NovinkyConfig(AppConfig): |
|||
name = 'novinky' |
|||
verbose_name = 'Novinky' |
@ -0,0 +1,45 @@ |
|||
# Generated by Django 4.2.13 on 2024-05-13 20:43 |
|||
|
|||
from django.db import migrations, models |
|||
|
|||
def nastav_nove_contenttypes(apps, schema_editor): |
|||
ContentType = apps.get_model('contenttypes', 'ContentType') |
|||
for m in ('novinka'): |
|||
oct = ContentType.objects.filter(app_label='seminar', model=m) |
|||
oct.update(app_label='novinky') |
|||
|
|||
def nastav_stare_contenttypes(apps, schema_editor): |
|||
ContentType = apps.get_model('contenttypes', 'ContentType') |
|||
for m in ('novinka'): |
|||
nct = ContentType.objects.filter(app_label='novinky', model=m) |
|||
nct.update(app_label='seminar') |
|||
|
|||
class Migration(migrations.Migration): |
|||
|
|||
initial = True |
|||
|
|||
dependencies = [ |
|||
('seminar', '0127_unmanage_novinky'), |
|||
] |
|||
|
|||
operations = [ |
|||
migrations.RunPython(nastav_nove_contenttypes, nastav_stare_contenttypes), |
|||
migrations.CreateModel( |
|||
name='Novinky', |
|||
fields=[ |
|||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), |
|||
('datum', models.DateField(auto_now_add=True)), |
|||
('text', models.TextField(blank=True, null=True, verbose_name='Text novinky')), |
|||
('obrazek', models.ImageField(blank=True, null=True, upload_to='image_novinky/%Y/%m/%d/', verbose_name='Obrázek')), |
|||
('autor', models.ForeignKey(to='personalni.organizator', verbose_name='Autor novinky', null=True, on_delete=models.SET_NULL)), |
|||
('zverejneno', models.BooleanField(default=False, verbose_name='Zveřejněno')), |
|||
], |
|||
options={ |
|||
'verbose_name': 'Novinka', |
|||
'verbose_name_plural': 'Novinky', |
|||
'db_table': 'seminar_novinky', |
|||
'ordering': ['-datum'], |
|||
'managed': False, |
|||
}, |
|||
), |
|||
] |
@ -0,0 +1,18 @@ |
|||
# Generated by Django 4.2.13 on 2024-05-13 20:58 |
|||
|
|||
from django.db import migrations |
|||
|
|||
|
|||
class Migration(migrations.Migration): |
|||
|
|||
dependencies = [ |
|||
('novinky', '0001_initial'), |
|||
('seminar', '0128_delete_novinky'), |
|||
] |
|||
|
|||
operations = [ |
|||
migrations.AlterModelOptions( |
|||
name='novinky', |
|||
options={'ordering': ['-datum'], 'verbose_name': 'Novinka', 'verbose_name_plural': 'Novinky'}, |
|||
), |
|||
] |
@ -0,0 +1,13 @@ |
|||
# Generated by Django 4.2.13 on 2024-05-13 21:00 |
|||
|
|||
from django.db import migrations |
|||
|
|||
|
|||
class Migration(migrations.Migration): |
|||
|
|||
dependencies = [ |
|||
('novinky', '0002_manage_novinky'), |
|||
] |
|||
|
|||
operations = [ |
|||
] |
@ -1,8 +1,6 @@ |
|||
""" |
|||
Soubor sloužící k pojmenování a jiným nastavením djangovské aplikace. |
|||
""" |
|||
from django.apps import AppConfig |
|||
|
|||
|
|||
class OdevzdavatkoConfig(AppConfig): |
|||
name = 'odevzdavatko' |
|||
verbose_name = 'Odevzdávátko' |
|||
|
@ -1,8 +1,6 @@ |
|||
""" |
|||
Soubor sloužící k pojmenování a jiným nastavením djangovské aplikace. |
|||
""" |
|||
from django.apps import AppConfig |
|||
|
|||
|
|||
class PersonalniConfig(AppConfig): |
|||
name = 'personalni' |
|||
verbose_name = 'Personální' # Má to nějaký použitelnější název? |
|||
|
@ -0,0 +1,14 @@ |
|||
# Generated by Django 4.2.11 on 2024-04-30 21:53 |
|||
|
|||
from django.db import migrations |
|||
|
|||
|
|||
class Migration(migrations.Migration): |
|||
|
|||
dependencies = [ |
|||
('personalni', '0006_pre_split_soustredeni'), |
|||
('soustredeni', '0003_post_split_soustredeni'), |
|||
] |
|||
|
|||
operations = [ |
|||
] |
@ -0,0 +1,40 @@ |
|||
# Generated by Django 4.2.11 on 2024-04-12 14:03 |
|||
|
|||
from django.db import migrations, models |
|||
|
|||
# V migracích nemáme Osoba.OSLOVENI_*, tak si to sem nakopíruji. |
|||
OSLOVENI_MUZSKE = 'resitel' |
|||
OSLOVENI_ZENSKE = 'resitelka' |
|||
OSLOVENI_ZADNE = '' |
|||
|
|||
def pohlavi_to_osloveni(apps, schema_editor): |
|||
Osoba = apps.get_model('personalni', 'Osoba') |
|||
Osoba.objects.filter(pohlavi_muz=True).update(osloveni=OSLOVENI_MUZSKE) |
|||
Osoba.objects.filter(pohlavi_muz=False).update(osloveni=OSLOVENI_ZENSKE) |
|||
|
|||
def osloveni_to_pohlavi(apps, schema_editor): |
|||
Osoba = apps.get_model('personalni', 'Osoba') |
|||
nebinarni = Osoba.objects.filter(osloveni=OSLOVENI_ZADNE) |
|||
if nebinarni.count() > 0: |
|||
raise Exception("Nelze odmigrovat: v databázi jsou nebinární osoby, které starý model nereprezentuje správně.") |
|||
Osoba.objects.filter(osloveni=OSLOVENI_MUZSKE).update(pohlavi_muz=True) |
|||
Osoba.objects.filter(osloveni=OSLOVENI_MUZSKE).update(pohlavi_muz=False) |
|||
|
|||
class Migration(migrations.Migration): |
|||
|
|||
dependencies = [ |
|||
('personalni', '0007_post_split_soustredeni'), |
|||
] |
|||
|
|||
operations = [ |
|||
migrations.AddField( |
|||
model_name='osoba', |
|||
name='osloveni', |
|||
field=models.CharField(blank=True, choices=[('resitel', 'Řešitel'), ('resitelka', 'Řešitelka')], max_length=32, verbose_name='Oslovení'), |
|||
), |
|||
migrations.RunPython(pohlavi_to_osloveni, osloveni_to_pohlavi), |
|||
migrations.RemoveField( |
|||
model_name='osoba', |
|||
name='pohlavi_muz', |
|||
), |
|||
] |
@ -0,0 +1,13 @@ |
|||
# Generated by Django 4.2.13 on 2024-05-13 20:35 |
|||
|
|||
from django.db import migrations |
|||
|
|||
|
|||
class Migration(migrations.Migration): |
|||
|
|||
dependencies = [ |
|||
('personalni', '0008_reforma_pohlavi'), |
|||
] |
|||
|
|||
operations = [ |
|||
] |
@ -0,0 +1,14 @@ |
|||
# Generated by Django 4.2.13 on 2024-05-13 20:59 |
|||
|
|||
from django.db import migrations |
|||
|
|||
|
|||
class Migration(migrations.Migration): |
|||
|
|||
dependencies = [ |
|||
('personalni', '0009_novinky_pre'), |
|||
('novinky', '0003_novinky_post'), |
|||
] |
|||
|
|||
operations = [ |
|||
] |
@ -0,0 +1,18 @@ |
|||
# Generated by Django 4.2.13 on 2024-06-03 14:31 |
|||
|
|||
from django.db import migrations, models |
|||
|
|||
|
|||
class Migration(migrations.Migration): |
|||
|
|||
dependencies = [ |
|||
('personalni', '0010_novinky_post'), |
|||
] |
|||
|
|||
operations = [ |
|||
migrations.AlterField( |
|||
model_name='osoba', |
|||
name='osloveni', |
|||
field=models.CharField(blank=True, choices=[('resitel', 'Řešitel'), ('resitelka', 'Řešitelka'), ('', 'Cokoliv jiného')], max_length=32, verbose_name='Oslovení'), |
|||
), |
|||
] |
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue