Browse Source

Accomp. edit form: difficulty is now a number field

Fixes #15
master
Wojciech Kwolek 5 months ago
parent
commit
721fd58d07
2 changed files with 5 additions and 2 deletions
  1. 5
      app/main.py
  2. 2
      app/templates/main/edit.html

5
app/main.py

@ -1,7 +1,9 @@
from flask import Blueprint, render_template, redirect, url_for, abort, request
from flask_login import current_user, login_required
from flask_wtf import FlaskForm
from wtforms import StringField, SubmitField, IntegerField
from wtforms import StringField, SubmitField
from wtforms.fields.html5 import IntegerField
from wtforms.widgets.html5 import NumberInput
from wtforms.validators import DataRequired, Length, NumberRange
from .db import db, Accomplishment
from datetime import datetime, timedelta
@ -137,6 +139,7 @@ class EditForm(FlaskForm):
)
difficulty = IntegerField(
'Difficulty (XP)',
widget=NumberInput(min=-100, max=100),
validators=[DataRequired(), NumberRange(max=100, min=-100)]
)
submit = SubmitField('Save')

2
app/templates/main/edit.html

@ -14,7 +14,7 @@
{% endif %}>
{{ form.csrf_token }}
{{ render_field(form.text) }}
{{ render_field(form.difficulty, mb="mb-6") }}
{{ render_field(form.difficulty, mb="mb-6", autocomplete="off") }}
<div class="text-center">
{{ render_field(form.submit, False, mb="mb-1", class_="btn btn-blue btn-center btn-wide") }}
<a href="{{ cancel }}" class="text-xs link">cancel</a>

Loading…
Cancel
Save