def get_schools(): try: res = ctrl_school.get_schools_public(get_db()) except ValueError as e: return general.create_error_message(str(e)) return general.convert_json(res)
def get_school(school_id): try: _school_id = int(school_id) res = ctrl_school.get_school_public(get_db(), _school_id) except ValueError as e: return general.create_error_message(str(e)) return general.convert_json(res)
def unregister_device(): try: _uuid = request.args.get('uuid', None) except ValueError: return general.create_error_message("Unable to convert given parameter!"); try: res = ctrl_user.del_user_uuid(get_db(), _uuid) except ValueError as e: return general.create_error_message(str(e)) return general.convert_json(res)
def get_subscription(): try: _uuid = request.args.get('uuid', None) except ValueError: return general.create_error_message("Unable to convert given parameter!"); try: res = ctrl_subscription.get_subscriptions_uuid(get_db(), _uuid) except ValueError as e: return general.create_error_message(str(e)) return general.convert_json(res)
def get_notifications(school_id): try: _school_id = int(school_id) _days = int(request.args.get('days', ctrl_schedule.DEFAULT_DAYS)) except ValueError: return general.create_error_message("Unable to convert given parameter!"); try: res = ctrl_notification.get_notifications(get_db(), _school_id, _days) except ValueError as e: return general.create_error_message(str(e)) return general.convert_json(res)
def update_device(): try: _uuid = request.args.get('uuid', None) _new_reg_id = request.args.get('new_reg_id', None) except ValueError: return general.create_error_message("Unable to convert given parameter!"); try: res = ctrl_user.update_user_reg_id(get_db(), _uuid, _new_reg_id) except (ValueError, IntegrityError) as e: return general.create_error_message(str(e)) return general.convert_json(res)
def get_schedule(school_id): try: _school_id = int(school_id) _days = int(request.args.get('days', ctrl_schedule.DEFAULT_DAYS)) _class = request.args.get('class', ctrl_schedule.DEFAULT_CLASS) except ValueError: return general.create_error_message("Unable to convert given parameter!"); try: res = ctrl_schedule.get_schedule_for_date(get_db(), _school_id, _days, _class) except ValueError as e: return general.create_error_message(str(e)) return general.convert_json(res)
def delete_subscription(school_id): try: _uuid = request.args.get('uuid', None) _class = request.args.get('class', None) except ValueError: return general.create_error_message("Unable to convert given parameter!"); try: res1 = ctrl_user.get_user_id_by_uuid(get_db(), _uuid) if res1: res2 = ctrl_subscription.del_subscription(get_db(), res1['_id'], school_id, _class) except ValueError as e: return general.create_error_message(str(e)) return general.convert_json(res2)