Added "wr:report" line to feed entry with winterrodeln specific information.
authorphilipp <philipp@7aebc617-e5e2-0310-91dc-80fb5f6d2477>
Sun, 26 Jun 2011 09:37:39 +0000 (09:37 +0000)
committerphilipp <philipp@7aebc617-e5e2-0310-91dc-80fb5f6d2477>
Sun, 26 Jun 2011 09:37:39 +0000 (09:37 +0000)
git-svn-id: http://www.winterrodeln.org/svn/servermediawiki/trunk/wrfeed@833 7aebc617-e5e2-0310-91dc-80fb5f6d2477

setup.py
wrfeed/controllers/berichte.py

index d65a28eaddc172d65dc89024419ebb543e24cf21..4a64a9a2f1ccee1465ecd835591dac1b0d4f5c0c 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -7,7 +7,7 @@ except ImportError:
 
 setup(
     name='wrfeed',
-    version='0.1.5',
+    version='0.1.6',
     description='Provides Atom Feed for Winterrodeln snow reports',
     author='Philipp Spitzer',
     author_email='philipp.spitzer@winterrodeln.org',
index b4b9d922e30108f4febd81255d79af6dddfa249c..01d634c004820d80fcaf679ed27031172351cdec 100644 (file)
@@ -36,7 +36,7 @@ def create_feed(page_title=None, page_ids=None):
     limit = int(config['feedentrylimit'])
     conn = engine.connect()
 
-    select = "select id, wrreport.page_title, date_report, date_entry, `condition`, description, author_name, author_username, position_longitude, position_latitude from wrreport left outer join wrsledruncache on wrreport.page_id=wrsledruncache.page_id "
+    select = "select wrreport.page_id, wrreport.page_title, wrreport.id, date_report, date_entry, `condition`, description, author_name, author_userid, author_username, position_longitude, position_latitude from wrreport left outer join wrsledruncache on wrreport.page_id=wrsledruncache.page_id "
     if not page_title is None:
         # page_title is given
         page_title = page_title.replace('_', ' ')
@@ -58,7 +58,7 @@ def create_feed(page_title=None, page_ids=None):
         result = conn.execute(sql)
 
 
-    feed = Element("feed", xmlns="http://www.w3.org/2005/Atom", attrib={'xmlns:georss': 'http://www.georss.org/georss'})
+    feed = Element("feed", xmlns="http://www.w3.org/2005/Atom", attrib={'xmlns:georss': 'http://www.georss.org/georss', 'xmlns:wr': 'http://www.winterrodeln.org/schema/wrreport'})
     feed_title = SubElement(feed, "title")
     feed_title.text = "Winterrodeln Rodelbahnberichte"
     feed_id = SubElement(feed, "id")
@@ -73,14 +73,14 @@ def create_feed(page_title=None, page_ids=None):
 
     last_updated = None
     for row in result:
-        id, page_title, date_report, date_entry, condition, description, author_name, author_username, lon, lat = row
+        page_id, page_title, report_id, date_report, date_entry, condition, description, author_name, author_userid, author_username, lon, lat = row
         page_title_url = page_title.replace(u' ', u'_')
         entry = SubElement(feed, "entry")
         entry_title = SubElement(entry, "title")
         entry_title.text = page_title
         entry.append(Element("link", rel="alternate", href=u"http://www.winterrodeln.org/wiki/{0}".format(page_title_url), type="text/html", hreflang="de"))
         entry_id = SubElement(entry, "id")
-        entry_id.text = u"http://www.winterrodeln.org/wiki/{0}#{1}".format(page_title_url, id)
+        entry_id.text = u"http://www.winterrodeln.org/wiki/{0}#{1}".format(page_title_url, report_id)
         entry_updated = SubElement(entry, "updated")
         entry_updated.text = date_entry.isoformat() + "+01:00"
         if last_updated is None: last_updated = date_entry
@@ -106,6 +106,16 @@ def create_feed(page_title=None, page_ids=None):
         if not lon is None and not lat is None:
             entry_geo = SubElement(entry, "georss:point")
             entry_geo.text = "{lat} {lon}".format(lat=lat, lon=lon)
+        entry_wrreport = SubElement(entry, "wr:report")
+        entry_wrreport.attrib['report_id'] = str(report_id)
+        entry_wrreport.attrib['page_id'] = str(page_id)
+        entry_wrreport.attrib['page_title'] = page_title
+        entry_wrreport.attrib['date_report'] = str(date_report)
+        entry_wrreport.attrib['date_entry'] = str(date_entry)
+        entry_wrreport.attrib['condition'] = "0" if condition is None else str(condition)
+        entry_wrreport.attrib['author_name'] = author_name
+        entry_wrreport.attrib['author_username'] = "" if author_userid is None else author_username
+        entry_wrreport.text = description
 
     if last_updated is None: last_updated = datetime.datetime.now()
     feed_updated.text = last_updated.isoformat() + "+01:00"