Browse Source

fixes #16: avoid adding empty group/attendees

Davide Alberani 7 years ago
parent
commit
4f77b3953d
2 changed files with 7 additions and 1 deletions
  1. 5 0
      ibt2.py
  2. 2 1
      src/Group.vue

+ 5 - 0
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

+ 2 - 1
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');