Skip to content

Commit

Permalink
Atom feed
Browse files Browse the repository at this point in the history
see bug cryptoparty#26

Still needs us to:

 - link to the feed from the rest of the site (both human-readable and for autodiscovery)
 - work out the ordering. most-recently-added seems most useful, but requires us to collect that info
 - decide the content of the feed items -- cf. issue cryptoparty#32

Also: this is Atom only, not RSS -- but I think one feed format is enough?
  • Loading branch information
danohu committed Nov 22, 2014
1 parent df910bf commit 5591efb
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions cryptoparty/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
from flask import render_template, g, request
from wtforms import Form, TextField, FileField, DateTimeField, validators
from flask.ext.mail import Message
from werkzeug.contrib.atom import AtomFeed


EMAIL_REGEX = re.compile("[^@]+@[^@]+\.[^@]+")

Expand Down Expand Up @@ -58,6 +60,21 @@ def get_all_parties_as_json():
return json.dumps(parties_serialized)


@app.route('/feeds/atom')
def feed():
feed = AtomFeed('Upcoming Cryptoparties',
feed_url=request.url, url=request.url_root)
parties = g.db.query(Party).filter(Party.time > datetime.now()).\
filter(Party.confirmed).all()
for party in parties:
text_content = '<h4>' + party.name + '</h4></p>' + '<p><b>Street Address: </b>' + party.street_address + '</p>' + '<p><b>Date: </b>' + party.time.strftime("%a %b %d %Y %H:%I") + '</p>' + '<p><b>Additional Info: </b><a href="' + party.additional_info + '">[link]</a></p>' + '<p><b>Event Organizer: </b>' + party.organizer_email + '</p>'
feed.add(
party.name, text_content,
url=party.additional_info,
updated = party.time, # this should be the datetime the event was added, but we don't store that
)
return feed.get_response()

@app.route('/json/subscription/add', methods=['POST'])
def json_subscription_add():
# load and unpack form data
Expand Down

0 comments on commit 5591efb

Please sign in to comment.