Merge pull request #269 from eReuse/bugfix/allocate-bugs

Bugfix/allocate bugs
This commit is contained in:
cayop 2022-05-12 17:38:37 +02:00 committed by GitHub
commit 5026768eb5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 2 deletions

View file

@ -684,6 +684,7 @@ class NewActionForm(ActionFormMix):
class AllocateForm(ActionFormMix):
date = HiddenField('')
start_time = DateField('Start time')
end_time = DateField('End time', [validators.Optional()])
final_user_code = StringField(
@ -692,7 +693,7 @@ class AllocateForm(ActionFormMix):
transaction = StringField(
'Transaction', [validators.Optional(), validators.length(max=50)]
)
end_users = IntegerField('End users', [validators.Optional()])
end_users = IntegerField('Number of end users', [validators.Optional()])
def validate(self, extra_validators=None):
if not super().validate(extra_validators):

View file

@ -326,7 +326,8 @@ class NewAllocateView(NewActionView, DeviceListMix):
messages.error('Action {} error!'.format(self.form.type.data))
for k, v in self.form.errors.items():
value = ';'.join(v)
messages.error('Action Error {key}: {value}!'.format(key=k, value=value))
key = self.form[k].label.text
messages.error('Action Error {key}: {value}!'.format(key=key, value=value))
next_url = self.get_next_url()
return flask.redirect(next_url)

View file

@ -29,6 +29,9 @@
{% else %}
<div class="col-12">
{{ field.label(class_="form-label") }}
{% if field == form_new_allocate.start_time %}
<span class="text-danger">*</span>
{% endif %}
{{ field(class_="form-control") }}
{% if field.errors %}
<p class="text-danger">