def get(self): page = page_parser.parse_args().get('page') feed_args = feed_parser.parse_args() from_date = feed_args.get('from', None) to_date = feed_args.get('to', None) if from_date and to_date: results = models.Event.query.filter( models.Event.created_at.between(from_date, to_date)).paginate( page, per_page=PER_PAGE).items elif from_date: results = models.Event.query.filter( models.Event.created_at >= from_date).paginate( page, per_page=PER_PAGE).items elif to_date: results = models.Event.query.filter( models.Event.created_at <= to_date).paginate( page, per_page=PER_PAGE).items else: results = models.Event.query.paginate(page, per_page=PER_PAGE).items count = models.Event.query.count() return results, count or not_found()
def delete(self, id): current_user = request.oauth.user event = models.Event.query.get(id) if not event or event not in current_user.bookmarked: return not_found() current_user.bookmarked.remove(event) db.session.commit() return '', 204
def delete(self, id): current_user = request.oauth.user story = models.Story.query.get(id) if not story or story not in current_user.watching: return not_found() current_user.watching.remove(story) db.session.commit() return '', 204
def post(self): current_user = request.oauth.user id = bookmarked_parser.parse_args()['event_id'] event = models.Event.query.get(id) if not event: return not_found() current_user.bookmarked.append(event) db.session.commit() return '', 201
def post(self): current_user = request.oauth.user id = watching_parser.parse_args()['story_id'] story = models.Story.query.get(id) if not story: return not_found() current_user.watching.append(story) db.session.commit() return '', 201
def get(self, raw_query): args = search_parser.parse_args() page = page_parser.parse_args().get('page') raw_types = args.get('types') or 'event,story,concept' types = raw_types.split(',') if raw_query: results, total_count = search(raw_query, page, PER_PAGE, types=types) return results, total_count return not_found()
def get(self): page = page_parser.parse_args().get('page') feed_args = feed_parser.parse_args() from_date = feed_args.get('from', None) to_date = feed_args.get('to', None) if from_date and to_date: results = models.Event.query.filter(models.Event.created_at.between(from_date, to_date)).order_by(models.Event._score.desc()).paginate(page, per_page=PER_PAGE).items elif from_date: results = models.Event.query.filter(models.Event.created_at >= from_date).order_by(models.Event._score.desc()).paginate(page, per_page=PER_PAGE).items elif to_date: results = models.Event.query.filter(models.Event.created_at <= to_date).order_by(models.Event._score.desc()).paginate(page, per_page=PER_PAGE).items else: results = models.Event.query.order_by(models.Event._score.desc()).paginate(page, per_page=PER_PAGE).items count = models.Event.query.count() return results, count or not_found()
def get(self): page = page_parser.parse_args().get('page') results = models.User.query.paginate(page, per_page=PER_PAGE).items count = models.User.query.count() return results, count or not_found()
def get(self, id): result = models.Story.query.get(id) return result.watchers or not_found()
def get(self): page = page_parser.parse_args().get('page') results = models.Event.query.paginate(page, per_page=PER_PAGE).items count = models.Event.query.count() return results, count or not_found()
def get(self, id): result = models.Event.query.get(id) return result or not_found()
def get(self, id): result = models.Source.query.get(id) return result or not_found()
def get(self, id): result = models.Author.query.get(id) return result or not_found()
def get(self, id): result = models.Article.query.get(id) return result or not_found()
def get(self, slug): result = models.Concept.query.get(slug) return result or not_found()
def get(self, id): result = models.User.query.get(id) return result or not_found()