示例#1
0
    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()
示例#2
0
 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
示例#3
0
 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
示例#4
0
 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
示例#5
0
 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
示例#6
0
 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
示例#7
0
 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
示例#8
0
 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
示例#9
0
 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
示例#10
0
    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()
示例#11
0
    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()
示例#12
0
    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()
示例#13
0
 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()
示例#14
0
 def get(self, id):
     result = models.Story.query.get(id)
     return result.watchers or not_found()
示例#15
0
 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()
示例#16
0
 def get(self, id):
     result = models.Event.query.get(id)
     return result or not_found()
示例#17
0
 def get(self, id):
     result = models.Source.query.get(id)
     return result or not_found()
示例#18
0
 def get(self, id):
     result = models.Author.query.get(id)
     return result or not_found()
示例#19
0
 def get(self, id):
     result = models.Article.query.get(id)
     return result or not_found()
示例#20
0
 def get(self, slug):
     result = models.Concept.query.get(slug)
     return result or not_found()
示例#21
0
 def get(self, id):
     result = models.Story.query.get(id)
     return result.watchers or not_found()
示例#22
0
 def get(self, slug):
     result = models.Concept.query.get(slug)
     return result or not_found()
示例#23
0
 def get(self, id):
     result = models.Article.query.get(id)
     return result or not_found()
示例#24
0
 def get(self, id):
     result = models.User.query.get(id)
     return result or not_found()