def save_feed_preview(feed_id): """preview a saved feed""" form = FeedUpdate(request.args) if not form.validate(): return jsonify_error(message="Invalid update data") feed = Feed.get_by_id(feed_id, parent=g.user.key) if not feed: return jsonify_error(message="Can't find that feed") form.populate_obj(feed) feed.preview = True preview_entries = Entry.entry_preview(Entry.latest_published(feed).fetch(3), feed, format=True) return jsonify(status='ok', data=preview_entries)
def feed_change(feed_id): """Get a feed""" form = FeedUpdate(request.form) if not form.validate(): return jsonify_error(message="Invalid update data") feed = Feed.get_by_id(feed_id, parent=g.user.key) if not feed: return jsonify_error(message="Can't find that feed") form.populate_obj(feed) feed.put() feed_data = feed.to_json() entries = [entry.to_dict(include=['title', 'link', 'published', 'published_at']) for entry in Entry.latest_for_feed(feed).fetch(10)] feed_data['entries'] = entries return jsonify(status='ok', data=feed_data)