From 4f77b3953d1b6a80cd393686127a8fda93545edd Mon Sep 17 00:00:00 2001 From: Davide Alberani Date: Thu, 26 Jan 2017 22:38:57 +0100 Subject: [PATCH] fixes #16: avoid adding empty group/attendees --- ibt2.py | 5 +++++ src/Group.vue | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ibt2.py b/ibt2.py index 8bceb95..674bc51 100755 --- a/ibt2.py +++ b/ibt2.py @@ -207,6 +207,11 @@ class AttendeesHandler(BaseHandler): @gen.coroutine def post(self, **kwargs): 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') now = datetime.datetime.now() data['created_by'] = user_id diff --git a/src/Group.vue b/src/Group.vue index 2825405..d2c85e8 100644 --- a/src/Group.vue +++ b/src/Group.vue @@ -153,7 +153,8 @@ export default { this.attendeesUrl.save(attendee).then((response) => { return response.json(); }, (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) => { this.reset(); this.$emit('updated');