fixes #16: avoid adding empty group/attendees
This commit is contained in:
parent
8b4c739dfe
commit
4f77b3953d
2 changed files with 7 additions and 1 deletions
5
ibt2.py
5
ibt2.py
|
@ -207,6 +207,11 @@ class AttendeesHandler(BaseHandler):
|
||||||
@gen.coroutine
|
@gen.coroutine
|
||||||
def post(self, **kwargs):
|
def post(self, **kwargs):
|
||||||
data = self.clean_body
|
data = self.clean_body
|
||||||
|
for key in 'name', 'group', 'day':
|
||||||
|
value = (data.get(key) or '').strip()
|
||||||
|
if not value:
|
||||||
|
return self.build_error(status=404, message="%s can't be empty" % key)
|
||||||
|
data[key] = value
|
||||||
user_id = self.current_user_info.get('_id')
|
user_id = self.current_user_info.get('_id')
|
||||||
now = datetime.datetime.now()
|
now = datetime.datetime.now()
|
||||||
data['created_by'] = user_id
|
data['created_by'] = user_id
|
||||||
|
|
|
@ -153,7 +153,8 @@ export default {
|
||||||
this.attendeesUrl.save(attendee).then((response) => {
|
this.attendeesUrl.save(attendee).then((response) => {
|
||||||
return response.json();
|
return response.json();
|
||||||
}, (response) => {
|
}, (response) => {
|
||||||
this.$refs.dialogObj.show({text: 'unable to add the attendee'});
|
var msg = (response && response.body && response.body.message) || '';
|
||||||
|
this.$refs.dialogObj.show({text: 'unable to add the attendee: ' + msg});
|
||||||
}).then((json) => {
|
}).then((json) => {
|
||||||
this.reset();
|
this.reset();
|
||||||
this.$emit('updated');
|
this.$emit('updated');
|
||||||
|
|
Loading…
Reference in a new issue