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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
MO-P
Odevzdávací Systém MO
Commits
9331c29e
Project 'mj/mo-submit' was moved to 'mo-p/osmo'. Please update any links and bookmarks that may still have the old path.
Commit
9331c29e
authored
Aug 23, 2022
by
Martin Mareš
Browse files
Options
Downloads
Patches
Plain Diff
Jinja: Zkratky při inicializaci
parent
ddecb010
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
mo/web/jinja.py
+28
-24
28 additions, 24 deletions
mo/web/jinja.py
with
28 additions
and
24 deletions
mo/web/jinja.py
+
28
−
24
View file @
9331c29e
...
...
@@ -18,43 +18,46 @@ from mo.web.util import user_html_flags
# Konfigurace Jinjy
app
.
jinja_env
.
add_extension
(
'
jinja2.ext.do
'
)
app
.
jinja_env
.
lstrip_blocks
=
True
app
.
jinja_env
.
trim_blocks
=
True
jenv
=
app
.
jinja_env
jenv
.
add_extension
(
'
jinja2.ext.do
'
)
jenv
.
lstrip_blocks
=
True
jenv
.
trim_blocks
=
True
# Filtry definované v mo.util_format
app
.
jinja_env
.
filters
.
update
(
timeformat
=
util_format
.
timeformat
)
app
.
jinja_env
.
filters
.
update
(
timeformat_short
=
util_format
.
timeformat_short
)
app
.
jinja_env
.
filters
.
update
(
inflected
=
util_format
.
inflect_number
)
app
.
jinja_env
.
filters
.
update
(
inflected_by
=
util_format
.
inflect_by_number
)
app
.
jinja_env
.
filters
.
update
(
timedelta
=
util_format
.
timedelta
)
app
.
jinja_env
.
filters
.
update
(
time_and_timedelta
=
util_format
.
time_and_timedelta
)
app
.
jinja_env
.
filters
.
update
(
data_size
=
util_format
.
data_size
)
app
.
jinja_env
.
filters
.
update
(
decimal
=
util_format
.
format_decimal
)
app
.
jinja_env
.
filters
.
update
(
parse_decimal
=
decimal
.
Decimal
)
jf
=
jenv
.
filters
jf
.
update
(
timeformat
=
util_format
.
timeformat
)
jf
.
update
(
timeformat_short
=
util_format
.
timeformat_short
)
jf
.
update
(
inflected
=
util_format
.
inflect_number
)
jf
.
update
(
inflected_by
=
util_format
.
inflect_by_number
)
jf
.
update
(
timedelta
=
util_format
.
timedelta
)
jf
.
update
(
time_and_timedelta
=
util_format
.
time_and_timedelta
)
jf
.
update
(
data_size
=
util_format
.
data_size
)
jf
.
update
(
decimal
=
util_format
.
format_decimal
)
jf
.
update
(
parse_decimal
=
decimal
.
Decimal
)
# Exporty proměnných
app
.
jinja_env
.
globals
.
update
(
web_flavor
=
config
.
WEB_FLAVOR
)
jg
=
jenv
.
globals
jg
.
update
(
web_flavor
=
config
.
WEB_FLAVOR
)
# Export enumů z mo.db:
app
.
jinja_env
.
globals
.
update
(
RoundState
=
db
.
RoundState
)
app
.
jinja_env
.
globals
.
update
(
LogType
=
db
.
LogType
)
app
.
jinja_env
.
globals
.
update
(
PartState
=
db
.
PartState
)
app
.
jinja_env
.
globals
.
update
(
RoleType
=
db
.
RoleType
)
app
.
jinja_env
.
globals
.
update
(
PaperType
=
db
.
PaperType
)
app
.
jinja_env
.
globals
.
update
(
TaskType
=
db
.
TaskType
)
app
.
jinja_env
.
globals
.
update
(
JobType
=
db
.
JobType
)
app
.
jinja_env
.
globals
.
update
(
JobState
=
db
.
JobState
)
jg
.
update
(
RoundState
=
db
.
RoundState
)
jg
.
update
(
LogType
=
db
.
LogType
)
jg
.
update
(
PartState
=
db
.
PartState
)
jg
.
update
(
RoleType
=
db
.
RoleType
)
jg
.
update
(
PaperType
=
db
.
PaperType
)
jg
.
update
(
TaskType
=
db
.
TaskType
)
jg
.
update
(
JobType
=
db
.
JobType
)
jg
.
update
(
JobState
=
db
.
JobState
)
# Další typy:
app
.
jinja_env
.
globals
.
update
(
Markup
=
Markup
)
app
.
jinja_env
.
globals
.
update
(
Right
=
Right
)
jg
.
update
(
Markup
=
Markup
)
jg
.
update
(
Right
=
Right
)
# Vlastní pomocné funkce
app
.
jinja_env
.
globals
.
update
(
place_breadcrumbs
=
place_breadcrumbs
)
jg
.
update
(
place_breadcrumbs
=
place_breadcrumbs
)
# Funkce asset_url se přidává v mo.ext.assets
...
...
@@ -112,6 +115,7 @@ def json_pretty(js: Any) -> str:
def
log_url
(
typ
:
str
,
id
:
int
)
->
str
:
return
url_for
(
'
org_log
'
,
typ
=
typ
,
id
=
id
)
@app.template_filter
()
def
user_flags
(
u
:
db
.
User
)
->
Markup
:
return
user_html_flags
(
u
)
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
sign in
to comment