Bc. Petr Pecha
9 years ago
30 changed files with 4155 additions and 138 deletions
@ -0,0 +1,20 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
from __future__ import unicode_literals |
||||
|
|
||||
|
from django.db import models, migrations |
||||
|
|
||||
|
|
||||
|
class Migration(migrations.Migration): |
||||
|
|
||||
|
dependencies = [ |
||||
|
('galerie', '0003_add_galerie_poradi'), |
||||
|
] |
||||
|
|
||||
|
operations = [ |
||||
|
migrations.AlterField( |
||||
|
model_name='obrazek', |
||||
|
name='galerie', |
||||
|
field=models.ForeignKey(blank=True, to='galerie.Galerie', null=True), |
||||
|
preserve_default=True, |
||||
|
), |
||||
|
] |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 15 KiB |
After Width: | Height: | Size: 18 KiB |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 15 KiB |
@ -1,77 +1,106 @@ |
|||||
{% extends "galerie/Base.html" %} |
{% extends "galerie/Base.html" %} |
||||
|
|
||||
{% block title %}{% block nadpis1a %} |
{% block nadpis1a %} |
||||
{{galerie.nazev}} | Galerie TODO title |
Galerie {{galerie.nazev}} |
||||
{% endblock %}{% endblock %} |
{% endblock %} |
||||
|
|
||||
{% block content %} |
{% block content %} |
||||
<h2>{{galerie.nazev}}</h2> |
|
||||
|
<h2> |
||||
|
{% for g in cesta %} |
||||
|
{% if not forloop.last %} |
||||
|
<a href="../{{ g.pk }}">{{ g.nazev }}</a> > |
||||
|
{% else %} |
||||
|
{{ g.nazev }} |
||||
|
{% endif %} |
||||
|
{% endfor %} |
||||
|
</h2> |
||||
|
|
||||
|
{% if not obrazky %} |
||||
|
<div class="galerie_hlavicka"> |
||||
|
{% if galerie.titulni_obrazek %} |
||||
|
<img src="{{ galerie.titulni_obrazek.obrazek_stredni.url }}" style="border: 1px solid black;"> |
||||
|
{% endif %} |
||||
|
</div> |
||||
|
{% endif %} |
||||
|
|
||||
{# podgalerie #} |
{# podgalerie #} |
||||
{% if podgalerie or galerie.galerie_up %} |
{% if podgalerie or galerie.galerie_up %} |
||||
<h3> PODGALERIE </h3> |
|
||||
<ul> |
{% if sourozenci|length > 1 %} |
||||
{% if galerie.galerie_up %} |
{% for g in sourozenci %} |
||||
<li><a href="../{{galerie.galerie_up.pk}}">..</a> |
{% if g.pk != galerie.pk %} |
||||
|
<a href="../{{ g.pk }}">{{ g.nazev }}</a> |
||||
|
{% else %} |
||||
|
{{ g.nazev }} |
||||
|
{% endif %} |
||||
|
<span style="width: 1em; display: inline-block;"></span> |
||||
|
{% endfor %} |
||||
{% endif %} |
{% endif %} |
||||
{% for galerie in podgalerie %} |
|
||||
{% if galerie.zobrazit < 1 or user.is_staff %} |
{% if podgalerie %} |
||||
<li><a href="../{{galerie.pk}}">{{galerie}}</a> |
<div class="galerie_nahledy"> |
||||
|
{% for galerie in podgalerie %} |
||||
|
<a href="../{{galerie.pk}}" class="podgalerie_nahled"> |
||||
|
{% if galerie.titulni_obrazek %} |
||||
|
{% with galerie.titulni_obrazek.obrazek_maly as obrazek %} |
||||
|
<img src="{{ obrazek.url }}" |
||||
|
width={% widthratio obrazek.width 200 167 %} |
||||
|
height={% widthratio obrazek.height 200 167 %} /> |
||||
|
{% endwith %} |
||||
|
{% endif %} |
||||
|
<div> |
||||
|
{{ galerie }} |
||||
|
</div> |
||||
|
</a> |
||||
{% if user.is_staff and galerie.zobrazit > 0 %} |
{% if user.is_staff and galerie.zobrazit > 0 %} |
||||
({{galerie.poradi}}) |
<div class="mam-org-only-galerie"> |
||||
<span class="plus"><a href="plus/{{galerie.pk}}/">+</a></span> |
({{galerie.poradi}}) |
||||
<span class="minus"><a href="minus/{{galerie.pk}}/">-</a></span> |
<span class="plus"><a href="plus/{{galerie.pk}}/">+</a></span> |
||||
|
<span class="minus"><a href="minus/{{galerie.pk}}/">-</a></span> |
||||
|
</div> |
||||
{% endif %} |
{% endif %} |
||||
{% endif %} |
{% endfor %} |
||||
{% endfor %} |
</div> |
||||
</ul> |
{% endif %} |
||||
{% endif %} |
{% endif %} |
||||
{% if user.is_staff and galerie.zobrazit > 0 %} |
{% if user.is_staff and galerie.zobrazit > 0 %} |
||||
<ul> |
<div class="mam-org-only"> |
||||
<li><a href="./new">VYTVOŘIT NOVOU PODGALERII </a> |
<a href="./new">Vytvořit novou podgalerii </a> |
||||
</ul> |
</div> |
||||
{% endif %} |
{% endif %} |
||||
|
|
||||
{# obrazky v galerii #} |
{# obrazky v galerii #} |
||||
{% if obrazky %} |
{% if obrazky %} |
||||
<table class="galerie_nahled"> |
<div class="galerie_nahledy"> |
||||
{% for obrazek in obrazky %} |
{% for obrazek in obrazky %} |
||||
{% if forloop.counter|add:-1|divisibleby:3 %} |
<a title="Zobrazit tuto fotografii" href="./{{obrazek.pk}}#nahoru" class="galerie_nahled"><span class="vystredeno"></span><img |
||||
<tr> |
|
||||
{% endif %} |
|
||||
<td class="vystredeno"> |
|
||||
<a title="Zobrazit tuto fotografii" href="./{{obrazek.pk}}#popis" |
|
||||
class="jednoducha-galerie"> |
|
||||
<img |
|
||||
src="{{obrazek.obrazek_maly.url}}" |
src="{{obrazek.obrazek_maly.url}}" |
||||
width={% widthratio obrazek.obrazek_maly.width 200 167 %} |
width={% widthratio obrazek.obrazek_maly.width 200 167 %} |
||||
height={% widthratio obrazek.obrazek_maly.height 200 167 %} /> |
height={% widthratio obrazek.obrazek_maly.height 200 167 %} /> |
||||
</a> |
</a> |
||||
<!--<a href="{{obrazek.obrazek_velky.url}}" |
|
||||
class="javascript-galerie" data-lightbox="galerie" data-title="{{obrazek.popis}}" |
|
||||
style="display: none;"> |
|
||||
<img |
|
||||
src="{{obrazek.obrazek_maly.url}}" |
|
||||
width={% widthratio obrazek.obrazek_maly.width 200 167 %} |
|
||||
height={% widthratio obrazek.obrazek_maly.height 200 167 %} /> |
|
||||
</a>--> |
|
||||
</td> |
|
||||
{% if forloop.last %} |
|
||||
{% if not forloop.counter|divisibleby:3 %} |
|
||||
<td></td> |
|
||||
{% endif %} |
|
||||
{% if not forloop.counter|divisibleby:2 %} |
|
||||
<td></td> |
|
||||
{% endif %} |
|
||||
{% endif %} |
|
||||
{% if forloop.counter|divisibleby:3 or forloop.last %} |
|
||||
</tr> |
|
||||
{% endif %} |
|
||||
{% endfor %} |
{% endfor %} |
||||
</table> |
<br> |
||||
|
</div> |
||||
|
|
||||
|
<div class="galerie_predchozi_nasledujici"> |
||||
|
{% if predchozi %} |
||||
|
<div class="predchozi"> |
||||
|
<a href="../{{ predchozi.pk }}">Předchozí: {{ predchozi.nazev }}</a> |
||||
|
</div> |
||||
|
{% endif %} |
||||
|
{% if nasledujici %} |
||||
|
<div class="nasledujici"> |
||||
|
<a href="../{{ nasledujici.pk }}">Následující: {{ nasledujici.nazev }}</a> |
||||
|
</div> |
||||
|
{% endif %} |
||||
|
</div> |
||||
|
|
||||
{% else %} |
{% else %} |
||||
<div class="zadne-vysledky"> |
{% if not podgalerie %} |
||||
V galerii nejsou žádné fotky. |
<div class="zadne-vysledky"> |
||||
</div> |
V galerii nejsou žádné fotky. |
||||
|
</div> |
||||
|
{% endif %} |
||||
{% endif %} |
{% endif %} |
||||
{% endblock content %} |
{% endblock content %} |
||||
|
File diff suppressed because it is too large
@ -0,0 +1,78 @@ |
|||||
|
\input czech.sty |
||||
|
\input epsf |
||||
|
\special{landscape} |
||||
|
\nopagenumbers |
||||
|
\hoffset=-1in |
||||
|
\voffset=-1in |
||||
|
\advance\voffset by 0.9cm |
||||
|
%nove pridano, aby to fungovalo... |
||||
|
\advance\hoffset by 6.5cm |
||||
|
\hsize=22cm |
||||
|
\vsize=16cm |
||||
|
|
||||
|
\font\adrfonta=csssbx10 at 14pt |
||||
|
\font\adrfontb=csssbx10 at 12pt |
||||
|
\font\adrfontc=csss12 |
||||
|
\font\tofont=csr12 at 16pt |
||||
|
|
||||
|
\newdimen\fromskip |
||||
|
\newdimen\toskip |
||||
|
\fromskip=4.35cm |
||||
|
\toskip=13.2cm |
||||
|
|
||||
|
\def\first{\relax} |
||||
|
|
||||
|
\catcode`_=13 |
||||
|
%\catcode`_=12 |
||||
|
|
||||
|
\def_{$\_$} |
||||
|
|
||||
|
\advance\voffset by 2.5cm |
||||
|
|
||||
|
|
||||
|
\def\obalka#1#2#3#4#5#6#7{ |
||||
|
|
||||
|
\def\jmeno{#1} |
||||
|
\def\prijm{#2} |
||||
|
\def\skola{#3} |
||||
|
\def\popis{} |
||||
|
\def\first{} |
||||
|
\def\ulice{#4} |
||||
|
\def\PSC{#5} |
||||
|
\def\mesto{#6} |
||||
|
\def\stat{#7} |
||||
|
\vskip-4mm\vbox to 0pt{\hbox to 0pt{\hskip1.4cm\epsfysize=2.55cm\epsfbox{lisak.eps}\hss}\vss} |
||||
|
|
||||
|
\baselineskip=13pt |
||||
|
\parindent=\fromskip |
||||
|
\line{\indent\adrfonta Časopis M\&M,\hfil} |
||||
|
\vskip3pt |
||||
|
\line{\indent\adrfontb OVVP UK MFF\hfil} |
||||
|
\vskip3pt |
||||
|
\line{\indent\adrfontc Ke Karlovu 3, 121 16 Praha 2\hfil} |
||||
|
\line{\indent\adrfontc Tel.: +420 221 911 235\hss} |
||||
|
\line{\indent\adrfontc mam@atrey.karlin.mff.cuni.cz\hfil} |
||||
|
|
||||
|
\vskip6.15cm |
||||
|
\vbox to 0pt{\parindent=1.4cm\hsize=\toskip\advance\hsize by -1cm |
||||
|
\vbox to 60pt{\vfil} \popis\vss} |
||||
|
\parindent=\toskip |
||||
|
\baselineskip=18pt |
||||
|
\line{\indent\tofont\first\hfil} |
||||
|
\line{\indent\tofont\jmeno\ \prijm\hfil} |
||||
|
\ifx \skola \empty |
||||
|
{} |
||||
|
\else |
||||
|
\line{\indent\tofont\skola\hfil} |
||||
|
\fi |
||||
|
\line{\indent\tofont\ulice\hfil} |
||||
|
\line{\tofont\item{\PSC} \mesto\hfil} |
||||
|
\vskip5pt |
||||
|
\line{\indent\tofont\stat\hfil} |
||||
|
|
||||
|
\vfil\eject |
||||
|
} |
||||
|
|
||||
|
%\obalka{Lenka}{Kopfová}{Leknínová 10}{746 01}{Opava} |
||||
|
|
||||
|
|
@ -0,0 +1,53 @@ |
|||||
|
#!/usr/bin/python |
||||
|
#coding: utf-8 |
||||
|
|
||||
|
import psycopg2 |
||||
|
import sys |
||||
|
import subprocess |
||||
|
import re |
||||
|
|
||||
|
dbname="mam-prod" |
||||
|
user="mam" |
||||
|
|
||||
|
conn = psycopg2.connect("dbname={0} user={1}".format(dbname,user)) |
||||
|
cur = conn.cursor() |
||||
|
|
||||
|
names = [] |
||||
|
|
||||
|
with open("obalky.sql") as qfile, open("obalky-template.tex") as texheader, open("obalky.tex","w") as texout : |
||||
|
texout.write(texheader.read()) |
||||
|
cur.execute(qfile.read()) |
||||
|
for row in cur.fetchall(): |
||||
|
(muz,jmeno,prijmeni,skola,ulice,mesto,psc,stat)=row |
||||
|
if (stat=='CZ'): |
||||
|
stat = "" |
||||
|
elif (stat=='SK'): |
||||
|
stat = "Slovenská republika" |
||||
|
else: |
||||
|
print("Neznamy stat: {}\n".format(stat)) |
||||
|
if (skola==None): |
||||
|
skola="" |
||||
|
psc = psc.replace(" ","") |
||||
|
psc = psc[0:3]+" "+psc[3:] |
||||
|
|
||||
|
texout.write("\\obalka{{{0}}}{{{1}}}{{{2}}}{{{3}}}{{{4}}}{{{5}}}{{{6}}}\n".format(jmeno,prijmeni,skola,ulice,psc,mesto,stat)) |
||||
|
names.append((jmeno,prijmeni)) |
||||
|
texout.write("\\bye\n") |
||||
|
|
||||
|
cur.close() |
||||
|
conn.close() |
||||
|
|
||||
|
print("Spoustim csplain ...") |
||||
|
output = subprocess.check_output(["csplain","obalky.tex"],stderr=subprocess.STDOUT) |
||||
|
page = 0 |
||||
|
for line in output.decode("utf-8").splitlines(): |
||||
|
pmatch = re.search("\[([0-9]+)\]",line) |
||||
|
if pmatch: |
||||
|
page = int(pmatch.group(1)) |
||||
|
errmatch = re.match("Overfull",line) |
||||
|
if errmatch: |
||||
|
print("Preteceni na strane",page,"u osoby",names[page][0],names[page][1]) |
||||
|
|
||||
|
print("Spoustim dvipdf ...") |
||||
|
subprocess.call(["dvipdf","obalky.dvi"]) |
||||
|
print("Hotovo.") |
@ -0,0 +1,26 @@ |
|||||
|
WITH akt_rocnik AS ( |
||||
|
SELECT rocnik FROM seminar_rocniky |
||||
|
WHERE id=(SELECT aktualni_rocnik_id FROM seminar_nastaveni) |
||||
|
), id_rocniku AS ( |
||||
|
SELECT id,prvni_rok FROM seminar_rocniky |
||||
|
WHERE rocnik=(SELECT * FROM akt_rocnik) OR rocnik=(SELECT * FROM akt_rocnik)-1 |
||||
|
), id_cisel AS ( |
||||
|
SELECT seminar_cisla.id FROM seminar_cisla |
||||
|
INNER JOIN id_rocniku ON rocnik_id=id_rocniku.id |
||||
|
), problemy AS ( |
||||
|
SELECT seminar_problemy.id FROM seminar_problemy |
||||
|
INNER JOIN id_cisel ON cislo_zadani_id = id_cisel.id |
||||
|
), resitele AS( |
||||
|
SELECT DISTINCT resitel_id FROM seminar_reseni |
||||
|
INNER JOIN problemy ON problem_id=problemy.id |
||||
|
) |
||||
|
SELECT pohlavi_muz,jmeno,prijmeni,NULL AS skola,ulice,mesto,psc,stat FROM seminar_resitele |
||||
|
INNER JOIN resitele ON seminar_resitele.id=resitel_id |
||||
|
WHERE zasilat='domu' AND rok_maturity > (SELECT MAX(prvni_rok) FROM id_rocniku) |
||||
|
UNION |
||||
|
SELECT res.pohlavi_muz,res.jmeno,res.prijmeni,sk.nazev,sk.ulice,sk.mesto,sk.psc,sk.stat |
||||
|
FROM seminar_resitele AS res |
||||
|
INNER JOIN resitele ON res.id=resitel_id |
||||
|
INNER JOIN seminar_skoly AS sk ON sk.id=skola_id |
||||
|
WHERE zasilat='do_skoly' AND rok_maturity > (SELECT MAX(prvni_rok) FROM id_rocniku) |
||||
|
ORDER BY prijmeni ASC, jmeno ASC |
File diff suppressed because it is too large
@ -0,0 +1,103 @@ |
|||||
|
{% autoescape off %} |
||||
|
{% load staticfiles %} |
||||
|
{% load tex %} |
||||
|
\input czech.sty |
||||
|
\input epsf |
||||
|
\special{landscape} |
||||
|
\nopagenumbers |
||||
|
\hoffset=-1in |
||||
|
\voffset=-1in |
||||
|
\advance\voffset by 0.9cm |
||||
|
%nove pridano, aby to fungovalo... |
||||
|
\advance\hoffset by 6.5cm |
||||
|
\hsize=22cm |
||||
|
\vsize=16cm |
||||
|
|
||||
|
\font\adrfonta=csssbx10 at 14pt |
||||
|
\font\adrfontb=csssbx10 at 12pt |
||||
|
\font\adrfontc=csss12 |
||||
|
\font\tofont=csr12 at 16pt |
||||
|
|
||||
|
\newdimen\fromskip |
||||
|
\newdimen\toskip |
||||
|
\fromskip=4.35cm |
||||
|
\toskip=13.2cm |
||||
|
|
||||
|
\def\first{\relax} |
||||
|
|
||||
|
\catcode`_=13 |
||||
|
%\catcode`_=12 |
||||
|
|
||||
|
\def_{$\_$} |
||||
|
|
||||
|
\advance\voffset by 2.5cm |
||||
|
|
||||
|
|
||||
|
\def\obalka#1#2#3#4#5#6#7{ |
||||
|
|
||||
|
\def\jmeno{#1} |
||||
|
\def\prijm{#2} |
||||
|
\def\skola{#3} |
||||
|
\def\popis{} |
||||
|
\def\first{} |
||||
|
\def\ulice{#4} |
||||
|
\def\PSC{#5} |
||||
|
\def\mesto{#6} |
||||
|
\def\stat{#7} |
||||
|
\vskip-4mm\vbox to 0pt{\hbox to 0pt{\hskip1.4cm\epsfysize=2.55cm\epsfbox{lisak.eps}\hss}\vss} |
||||
|
|
||||
|
\baselineskip=13pt |
||||
|
\parindent=\fromskip |
||||
|
\line{\indent\adrfonta Časopis M\&M,\hfil} |
||||
|
\vskip3pt |
||||
|
\line{\indent\adrfontb OVVP UK MFF\hfil} |
||||
|
\vskip3pt |
||||
|
\line{\indent\adrfontc Ke Karlovu 3, 121 16 Praha 2\hfil} |
||||
|
\line{\indent\adrfontc Tel.: +420 221 911 235\hss} |
||||
|
\line{\indent\adrfontc mam@atrey.karlin.mff.cuni.cz\hfil} |
||||
|
|
||||
|
\vskip6.15cm |
||||
|
\vbox to 0pt{\parindent=1.4cm\hsize=\toskip\advance\hsize by -1cm |
||||
|
\vbox to 60pt{\vfil} \popis\vss} |
||||
|
\parindent=\toskip |
||||
|
\baselineskip=18pt |
||||
|
\line{\indent\tofont\first\hfil} |
||||
|
\line{\indent\tofont\jmeno\ \prijm\hfil} |
||||
|
\ifx \skola \empty |
||||
|
{} |
||||
|
\else |
||||
|
\line{\indent\tofont\skola\hfil} |
||||
|
\fi |
||||
|
\line{\indent\tofont\ulice\hfil} |
||||
|
\line{\tofont\item{\PSC} \mesto\hfil} |
||||
|
\vskip5pt |
||||
|
\line{\indent\tofont\stat\hfil} |
||||
|
|
||||
|
\vfil\eject |
||||
|
} |
||||
|
|
||||
|
|
||||
|
{% for r in resitele %} |
||||
|
{% spaceless %} |
||||
|
{% if r.zasilat == "do_skoly" %} |
||||
|
{% if r.stat == "CZ" %} |
||||
|
\obalka{{r.jmeno|sloz}}{{r.prijmeni|sloz}}{{r.skola.nazev|sloz}}{{r.skola.ulice|sloz}}{{r.skola.psc|sloz}}{{r.skola.mesto|sloz}}{{''|sloz}} |
||||
|
{% else %} |
||||
|
\obalka{{r.jmeno|sloz}}{{r.prijmeni|sloz}}{{r.skola.nazev|sloz}}{{r.skola.ulice|sloz}}{{r.skola.psc|sloz}}{{r.skola.mesto|sloz}}{{r.stat.name|sloz}} |
||||
|
{% endif %} |
||||
|
|
||||
|
{% elif r.zasilat == "domu" %} |
||||
|
{% if r.stat == "CZ" %} |
||||
|
\obalka{{r.jmeno|sloz}}{{r.prijmeni|sloz}}{{''|sloz}}{{r.ulice|sloz}}{{r.psc|sloz}}{{r.mesto|sloz}}{{''|sloz}} |
||||
|
{% else %} |
||||
|
\obalka{{r.jmeno|sloz}}{{r.prijmeni|sloz}}{{''|sloz}}{{r.ulice|sloz}}{{r.psc|sloz}}{{r.mesto|sloz}}{{r.stat.name|sloz}} |
||||
|
{% endif %} |
||||
|
{% else %} |
||||
|
% zasilat: {{r.zasilat}} |
||||
|
%\obalka{{r.jmeno|sloz}}{{r.prijmeni|sloz}}{{''|sloz}}{{r.ulice|sloz}}{{r.psc|sloz}}{{r.mesto|sloz}}{{r.stat.name|sloz}} |
||||
|
{% endif %} |
||||
|
{% endspaceless %} |
||||
|
{% endfor %} |
||||
|
\bye |
||||
|
|
||||
|
{% endautoescape %} |
@ -0,0 +1,9 @@ |
|||||
|
{% autoescape off %} |
||||
|
{% load tex %} |
||||
|
|
||||
|
{% for r in resitele %} |
||||
|
{% spaceless %} |
||||
|
\def\{{r.ascii}}{\titul{{r.titul|sloz}}\relax} |
||||
|
{% endspaceless %} |
||||
|
{% endfor %} |
||||
|
{% endautoescape %} |
@ -0,0 +1,6 @@ |
|||||
|
from django import template |
||||
|
register = template.Library() |
||||
|
|
||||
|
@register.filter(name='sloz') |
||||
|
def sloz(value): |
||||
|
return u"{{{}}}".format(value) |
@ -0,0 +1,82 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
|
||||
|
import logging as log |
||||
|
from .models import Resitel |
||||
|
import reversion |
||||
|
|
||||
|
def merge_props(r1, r2, prop, pretend=True, smaller=False, equal=True): |
||||
|
"""Merge r2.`prop` into r1.`prop`. |
||||
|
|
||||
|
If r1.`prop` unset, use r1.`prop`=r2.`prop`. |
||||
|
If both set and equal=True, warn if not equal. |
||||
|
If both set and smaller=True, use the smaller one. |
||||
|
With pretend=True does not modify r1. |
||||
|
""" |
||||
|
a1 = r1.__getattribute__(prop) |
||||
|
a2 = r2.__getattribute__(prop) |
||||
|
if not a1: |
||||
|
if not pretend: |
||||
|
r1.__setattr__(prop, a2) |
||||
|
elif a2: |
||||
|
if equal and a1 != a2: |
||||
|
log.warn(u"merge: Ruzna %s: %s VS %s", prop, a1, a2) |
||||
|
if smaller: |
||||
|
if not pretend: |
||||
|
r1.__setattr__(prop, min(a1, a2)) |
||||
|
|
||||
|
|
||||
|
def merge_Resitel(rbase, rmerge, pretend=True): |
||||
|
"""Zahrne data a vztahy Resitele rmerge do Resitele rbase, pak smaze rmerge. |
||||
|
|
||||
|
Selze pro uzivatele s user!=NULL. S pretend=True nezmeni databazi. |
||||
|
""" |
||||
|
# Ma relace: skola |
||||
|
# Je v relaci: user, reseni, soustredeni_ucastnici, vysledky_base(VIEW) |
||||
|
|
||||
|
log.info(u"merge: %s <- %s", unicode(rbase), unicode(rmerge)) |
||||
|
|
||||
|
assert not rbase.user |
||||
|
assert not rmerge.user |
||||
|
assert rbase != rmerge |
||||
|
|
||||
|
if (rbase.jmeno != rmerge.jmeno) or (rbase.prijmeni != rmerge.prijmeni): |
||||
|
log.error(u"merge: Ruzna jmena: %s VS %s", rbase, rmerge) |
||||
|
if rbase.rok_maturity != rmerge.rok_maturity: |
||||
|
log.error(u"merge: Ruzne roky maturity: %s VS %s", rbase.rok_maturity, rmerge.rok_maturity) |
||||
|
|
||||
|
with reversion.create_revision(): |
||||
|
reversion.set_comment('Merge duplicitnich Resitelu: %r <- %r' % (rbase.pk, rmerge.pk)) |
||||
|
|
||||
|
merge_props(rbase, rmerge, 'skola', pretend=pretend) |
||||
|
merge_props(rbase, rmerge, 'datum_narozeni', pretend=pretend) |
||||
|
merge_props(rbase, rmerge, 'datum_prihlaseni', pretend=pretend) |
||||
|
merge_props(rbase, rmerge, 'datum_souhlasu_zasilani', pretend=pretend, smaller=True, equal=False) |
||||
|
merge_props(rbase, rmerge, 'datum_souhlasu_udaje', pretend=pretend, smaller=True, equal=False) |
||||
|
merge_props(rbase, rmerge, 'email', pretend=pretend) |
||||
|
if rmerge.import_mamoper_id and not pretend: |
||||
|
rbase.import_mamoper_id += ' ' + rmerge.import_mamoper_id |
||||
|
if rmerge.poznamka and not pretend: |
||||
|
rbase.poznamka += ' ' + rmerge.poznamka |
||||
|
merge_props(rbase, rmerge, 'mesto', pretend=pretend) |
||||
|
merge_props(rbase, rmerge, 'pohlavi_muz', pretend=pretend) |
||||
|
merge_props(rbase, rmerge, 'psc', pretend=pretend) |
||||
|
merge_props(rbase, rmerge, 'stat', pretend=pretend) |
||||
|
merge_props(rbase, rmerge, 'telefon', pretend=pretend) |
||||
|
merge_props(rbase, rmerge, 'ulice', pretend=pretend) |
||||
|
merge_props(rbase, rmerge, 'zasilat', pretend=pretend) |
||||
|
|
||||
|
for res in rmerge.reseni.all(): |
||||
|
if not pretend: |
||||
|
res.resitel = rbase |
||||
|
res.save() |
||||
|
|
||||
|
for uc in rmerge.soustredeni_ucastnici_set.all(): |
||||
|
if not pretend: |
||||
|
uc.resitel = rbase |
||||
|
uc.save() |
||||
|
|
||||
|
if not pretend: |
||||
|
rmerge.delete() |
||||
|
rbase.save() |
||||
|
|
||||
|
|
Loading…
Reference in new issue