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
95552430
Commit
95552430
authored
2 years ago
by
Martin Mareš
Browse files
Options
Downloads
Patches
Plain Diff
Web umožňuje adminovi připsat do DB logu poznámku
Hodí se po ručním zásahu do DB.
parent
66cdbbde
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_log.py
+27
-3
27 additions, 3 deletions
mo/web/org_log.py
mo/web/templates/org_log.html
+6
-3
6 additions, 3 deletions
mo/web/templates/org_log.html
with
33 additions
and
6 deletions
mo/web/org_log.py
+
27
−
3
View file @
95552430
from
flask
import
render_template
,
g
from
flask
import
render_template
,
g
,
redirect
,
url_for
,
flash
from
flask_wtf
import
FlaskForm
from
sqlalchemy.orm
import
joinedload
from
sqlalchemy.orm
import
joinedload
import
werkzeug.exceptions
import
werkzeug.exceptions
import
wtforms
import
mo.db
as
db
import
mo.db
as
db
import
mo.util
from
mo.web
import
app
from
mo.web
import
app
@app.route
(
'
/org/log/<typ>/<int:id>/
'
)
class
LogNoteForm
(
FlaskForm
):
note
=
wtforms
.
TextAreaField
(
"
Poznámka
"
)
submit
=
wtforms
.
SubmitField
(
"
Přidat
"
)
@app.route
(
'
/org/log/<typ>/<int:id>/
'
,
methods
=
(
'
GET
'
,
'
POST
'
))
def
org_log
(
typ
:
str
,
id
:
int
):
def
org_log
(
typ
:
str
,
id
:
int
):
if
not
g
.
user
.
is_admin
:
if
not
g
.
user
.
is_admin
:
raise
werkzeug
.
exceptions
.
Forbidden
()
raise
werkzeug
.
exceptions
.
Forbidden
()
...
@@ -16,10 +24,26 @@ def org_log(typ: str, id: int):
...
@@ -16,10 +24,26 @@ def org_log(typ: str, id: int):
log_type
=
getattr
(
db
.
LogType
,
typ
)
log_type
=
getattr
(
db
.
LogType
,
typ
)
sess
=
db
.
get_session
()
sess
=
db
.
get_session
()
note_form
=
LogNoteForm
()
if
note_form
.
validate_on_submit
():
text
=
note_form
.
note
.
data
.
strip
().
replace
(
"
\r
"
,
""
)
mo
.
util
.
log
(
type
=
log_type
,
what
=
id
,
details
=
{
'
action
'
:
'
note
'
,
'
note
'
:
text
,
},
)
sess
.
commit
()
flash
(
'
Zpráva přidána.
'
,
'
success
'
)
redirect
(
url_for
(
'
org_log
'
,
typ
=
typ
,
id
=
id
))
logs
=
(
sess
.
query
(
db
.
Log
)
logs
=
(
sess
.
query
(
db
.
Log
)
.
filter_by
(
type
=
log_type
,
id
=
id
)
.
filter_by
(
type
=
log_type
,
id
=
id
)
.
options
(
joinedload
(
db
.
Log
.
user
))
.
options
(
joinedload
(
db
.
Log
.
user
))
.
order_by
(
db
.
Log
.
changed_at
.
desc
())
.
order_by
(
db
.
Log
.
changed_at
.
desc
())
.
all
())
.
all
())
return
render_template
(
'
org_log.html
'
,
type
=
log_type
,
id
=
id
,
logs
=
logs
)
return
render_template
(
'
org_log.html
'
,
type
=
log_type
,
id
=
id
,
logs
=
logs
,
note_form
=
note_form
)
This diff is collapsed.
Click to expand it.
mo/web/templates/org_log.html
+
6
−
3
View file @
95552430
{% extends "base.html" %}
{% extends "base.html" %}
{% import "bootstrap/wtf.html" as wtf %}
{% block title %}Log: {{ type.name }} #{{ id }}{% endblock %}
{% block title %}Log: {{ type.name }} #{{ id }}{% endblock %}
{% block body %}
{% block body %}
{% if type == 'user' %}
<p><a
class=
'btn btn-default'
href=
'{{ url_for('
org_log
',
typ=
'participant'
,
id=
id)
}}'
>
Participation log
</a>
{% endif %}
<table
class=
'data'
>
<table
class=
'data'
>
{% for log in logs %}
{% for log in logs %}
<tr>
<tr>
...
@@ -11,8 +16,6 @@
...
@@ -11,8 +16,6 @@
{% endfor %}
{% endfor %}
</table>
</table>
{% if type == 'user' %}
{{ wtf.quick_form(note_form, form_type='simple', button_map={'submit': 'primary'}) }}
<p><a
class=
'btn btn-default'
href=
'{{ url_for('
org_log
',
typ=
'participant'
,
id=
id)
}}'
>
Participation log
</a>
{% endif %}
{% endblock %}
{% endblock %}
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