Skip to content
Snippets Groups Projects
Commit 5eae9d7c authored by Jiří Kalvoda's avatar Jiří Kalvoda
Browse files

Fields: FormAddRole

parent f9d98c05
Branches
No related tags found
1 merge request!92Používání mo.web.fields
This commit is part of merge request !92. Comments created here will be created in the context of that merge request.
...@@ -300,7 +300,7 @@ def org_orgs(): ...@@ -300,7 +300,7 @@ def org_orgs():
class FormAddRole(FlaskForm): class FormAddRole(FlaskForm):
role = wtforms.SelectField('Role', choices=db.RoleType.choices(), coerce=db.RoleType.coerce, render_kw={'autofocus': True}) role = wtforms.SelectField('Role', choices=db.RoleType.choices(), coerce=db.RoleType.coerce, render_kw={'autofocus': True})
place_code = wtforms.StringField('Oblast') place = mo_fields.Place()
year = wtforms.IntegerField('Ročník', validators=[validators.Optional()]) year = wtforms.IntegerField('Ročník', validators=[validators.Optional()])
category = wtforms.StringField("Kategorie", validators=[validators.Length(max=2)], filters=[lambda x: x or None]) category = wtforms.StringField("Kategorie", validators=[validators.Length(max=2)], filters=[lambda x: x or None])
seq = wtforms.IntegerField("Kolo", validators=[validators.Optional()]) seq = wtforms.IntegerField("Kolo", validators=[validators.Optional()])
...@@ -360,14 +360,7 @@ def org_org(id: int): ...@@ -360,14 +360,7 @@ def org_org(id: int):
new_role.assigned_by = g.user.user_id new_role.assigned_by = g.user.user_id
ok = True ok = True
place_code = form_add_role.place_code.data new_role.place = form_add_role.place.place
if place_code:
place = db.get_place_by_code(place_code)
if not place:
role_errors.append("Nepovedlo se nalézt místo podle kódu")
ok = False
else:
new_role.place = place
if not g.gatekeeper.can_set_role(new_role): if not g.gatekeeper.can_set_role(new_role):
role_errors.append(f'Roli "{new_role}" nelze přidělit, není podmnožinou žádné vaší role') role_errors.append(f'Roli "{new_role}" nelze přidělit, není podmnožinou žádné vaší role')
......
...@@ -54,7 +54,7 @@ ...@@ -54,7 +54,7 @@
<form action="" method="POST" class="form form-inline" role="form"> <form action="" method="POST" class="form form-inline" role="form">
{{ form_add_role.csrf_token() }} {{ form_add_role.csrf_token() }}
{{ wtf.form_field(form_add_role.role) }} {{ wtf.form_field(form_add_role.role) }}
{{ wtf.form_field(form_add_role.place_code, placeholder='Kód', size=8) }} {{ wtf.form_field(form_add_role.place, size=8) }}
{{ wtf.form_field(form_add_role.year, type='number', size=3, maxlength=2) }} {{ wtf.form_field(form_add_role.year, type='number', size=3, maxlength=2) }}
{{ wtf.form_field(form_add_role.category, size=2, maxlength=2) }} {{ wtf.form_field(form_add_role.category, size=2, maxlength=2) }}
{{ wtf.form_field(form_add_role.seq, type='number', size=3, maxlength=2) }} {{ wtf.form_field(form_add_role.seq, type='number', size=3, maxlength=2) }}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment