Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Odevzdávací Systém MO
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Martin Mareš
Odevzdávací Systém MO
Commits
b0fda605
Commit
b0fda605
authored
4 years ago
by
Martin Mareš
Browse files
Options
Downloads
Patches
Plain Diff
Export seznamu škol
parent
37f39264
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
mo/web/org.py
+48
-1
48 additions, 1 deletion
mo/web/org.py
mo/web/templates/main.html
+2
-0
2 additions, 0 deletions
mo/web/templates/main.html
with
50 additions
and
1 deletion
mo/web/org.py
+
48
−
1
View file @
b0fda605
from
flask
import
render_template
,
g
,
redirect
,
url_for
from
flask
import
render_template
,
g
,
redirect
,
url_for
,
request
from
sqlalchemy.orm
import
aliased
import
mo.db
as
db
from
mo.web.table
import
Table
,
Column
from
mo.web
import
app
@app.route
(
'
/org/
'
)
def
org_index
():
return
render_template
(
'
org_index.html
'
)
school_export_columns
=
(
Column
(
key
=
'
code
'
,
name
=
'
kod
'
),
Column
(
key
=
'
name
'
,
name
=
'
nazev
'
),
Column
(
key
=
'
town_code
'
,
name
=
'
kod_obce
'
),
Column
(
key
=
'
town
'
,
name
=
'
obec
'
),
Column
(
key
=
'
red_izo
'
,
name
=
'
red_izo
'
),
Column
(
key
=
'
ico
'
,
name
=
'
ico
'
),
Column
(
key
=
'
official_name
'
,
name
=
'
ofic_nazev
'
),
Column
(
key
=
'
address
'
,
name
=
'
adresa
'
),
Column
(
key
=
'
is_zs
'
,
name
=
'
typ_zs
'
),
Column
(
key
=
'
is_ss
'
,
name
=
'
typ_ss
'
),
)
@app.route
(
'
/org/export/skoly
'
)
def
org_export_skoly
():
sess
=
db
.
get_session
()
format
=
request
.
args
.
get
(
'
format
'
,
'
csv
'
)
def
gen_rows
():
town
=
aliased
(
db
.
Place
)
for
p
,
s
,
t
in
(
sess
.
query
(
db
.
Place
,
db
.
School
,
town
)
.
filter
(
db
.
Place
.
type
==
db
.
PlaceType
.
school
)
.
filter
(
db
.
Place
.
place_id
==
db
.
School
.
place_id
)
.
filter
(
db
.
Place
.
parent
==
town
.
place_id
)
.
yield_per
(
100
)):
yield
{
'
code
'
:
p
.
get_code
(),
'
name
'
:
p
.
name
,
'
red_izo
'
:
s
.
red_izo
,
'
ico
'
:
s
.
ico
,
'
official_name
'
:
s
.
official_name
,
'
address
'
:
s
.
address
,
'
is_zs
'
:
int
(
s
.
is_zs
),
'
is_ss
'
:
int
(
s
.
is_ss
),
'
town_code
'
:
t
.
get_code
(),
'
town
'
:
t
.
name
,
}
table
=
Table
(
school_export_columns
,
gen_rows
(),
'
skoly
'
)
return
table
.
send_as
(
format
,
streaming
=
True
)
This diff is collapsed.
Click to expand it.
mo/web/templates/main.html
+
2
−
0
View file @
b0fda605
...
...
@@ -4,6 +4,8 @@
{% if g.user.is_org or g.user.is_admin %}
<p><a
href=
'{{ url_for('
org_place_root
')
}}'
>
Hierarchie míst
</a>
<p>
Export všech škol:
<a
href=
'{{ url_for('
org_export_skoly
',
format=
'csv'
)
}}'
>
CSV
</a>
,
<a
href=
'{{ url_for('
org_export_skoly
',
format=
'tsv'
)
}}'
>
TSV
</a>
{% endif %}
<h3>
Práva
</h3>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment