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
Martin Mareš
Odevzdávací Systém MO
Commits
ffb01f09
Commit
ffb01f09
authored
5 months ago
by
Martin Mareš
Browse files
Options
Downloads
Patches
Plain Diff
User: Zobrazování diplomů
parent
fb9916a9
No related branches found
No related tags found
1 merge request
!137
Sazba diplomů
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
mo/web/templates/user_contest_certs.html
+42
-0
42 additions, 0 deletions
mo/web/templates/user_contest_certs.html
mo/web/user.py
+32
-0
32 additions, 0 deletions
mo/web/user.py
with
74 additions
and
0 deletions
mo/web/templates/user_contest_certs.html
0 → 100644
+
42
−
0
View file @
ffb01f09
{% extends "base.html" %}
{% set round = contest.round %}
{% block title %}Diplomy za {{ round.name|lower }} {{ round.year }}. ročníku kategorie {{ round.category }}: {{ contest.place.name }}{% endblock %}
{% block breadcrumbs %}
<li><a
href=
'{{ url_for('
user_index
')
}}'
>
Soutěže
</a>
<li><a
href=
'{{ url_for('
user_contest
',
id=
contest.contest_id)
}}'
>
{{ round.name }} {{ round.year }}. ročníku kategorie {{ round.category }}: {{ contest.place.name }}
</a>
<li>
Diplomy
{% endblock %}
{% block body %}
{% if cset is none %}
<p>
<em>
Organizátor kola žádné diplomy nevydal.
</em>
</p>
{% elif not cset %}
<p>
<em>
V tomto kole jste nezískal(a) žádné diplomy.
</em>
</p>
{% else %}
<p>
V tomto kole získáváte:
</p>
<table
class=
"table table-bordered table-hover"
>
<thead>
<tr>
<th>
Druh diplomu
<th>
Získán za
<th>
Akce
<tbody>
{% for cert in certs %}
<tr>
<td>
{{ cert.type.friendly_name() }}
<td>
{{ cert.achievement }}
<td><a
class=
'btn btn-xs btn-primary'
href=
'{{ url_for('
user_cert_file
',
ct_id=
contest.contest_id,
cert_type=
cert.type.name,
filename=
cert.type.file_name()
+
'.
pdf
')
}}'
>
Zobrazit
</a>
{% endfor %}
</table>
{% endif %}
{% endblock %}
This diff is collapsed.
Click to expand it.
mo/web/user.py
+
32
−
0
View file @
ffb01f09
...
...
@@ -669,6 +669,38 @@ def send_certificate(ct_id: int, cert_type: str, user_filename: str, user_id: Op
raise
werkzeug
.
exceptions
.
InternalServerError
()
return
send_file
(
open
(
tmp_file
.
name
,
'
rb
'
),
mimetype
=
'
application/pdf
'
)
@app.route
(
'
/user/contest/<int:id>/certificates
'
)
def
user_contest_certificates
(
id
:
int
):
contest
=
get_contest
(
id
)
# Diplomy zobrazíme, jen pokud je soutěž již ukončená
state
=
contest
.
ct_state
()
if
state
not
in
[
db
.
RoundState
.
graded
,
db
.
RoundState
.
closed
]:
raise
werkzeug
.
exceptions
.
NotFound
()
sess
=
db
.
get_session
()
cset
=
sess
.
query
(
db
.
CertSet
).
filter_by
(
contest_id
=
id
).
one_or_none
()
certs
=
(
sess
.
query
(
db
.
Certificate
)
.
filter_by
(
cert_set_id
=
id
,
user
=
g
.
user
)
.
all
())
return
render_template
(
'
user_contest_certs.html
'
,
contest
=
contest
,
cset
=
cset
,
certs
=
certs
,
)
@app.route
(
'
/user/contest/<int:ct_id>/certificates/<cert_type>/<filename>
'
)
def
user_cert_file
(
ct_id
:
int
,
cert_type
:
str
,
filename
:
str
):
_
=
get_contest
(
ct_id
)
return
send_certificate
(
ct_id
,
cert_type
,
filename
,
g
.
user_id
)
@app.route
(
'
/user/history/
'
)
def
user_history
()
->
str
:
sess
=
db
.
get_session
()
...
...
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