fix problem in feeds related to URL items.
authorgfawcett <gfawcett@6d9bc8c9-1ec2-4278-b937-99fde70a366f>
Tue, 28 Dec 2010 17:04:00 +0000 (17:04 +0000)
committergfawcett <gfawcett@6d9bc8c9-1ec2-4278-b937-99fde70a366f>
Tue, 28 Dec 2010 17:04:00 +0000 (17:04 +0000)
git-svn-id: svn://svn.open-ils.org/ILS-Contrib/servres/trunk@1126 6d9bc8c9-1ec2-4278-b937-99fde70a366f

conifer/syrup/models.py
conifer/templates/feeds/site_atom.xml

index ca5ff42..5dd63a2 100644 (file)
@@ -343,8 +343,7 @@ class Site(BaseModel):
         # I'm not fond of this being here. I think I'll leave this and
         # item_url non-implemented, and monkey-patch them in views.py.
         req = get_request()
-        prefix = req.META['SCRIPT_NAME']
-        return '%s/site/%d/%s' % (prefix, self.id, suffix)
+        return req.build_absolute_uri('/site/%d/%s' % (self.id, suffix))
 
     def generate_new_passkey(self):
         # todo: have a pluggable passkey algorithm.
@@ -696,19 +695,18 @@ class Item(BaseModel):
             return None
         else:
             req = get_request()
-            prefix = req.META['SCRIPT_NAME']
-            return '%s/site/%d/item/%d/dl/%s' % (
-                prefix, self.site_id, self.id,
-                self.fileobj.name.split('/')[-1])
+            return req.build_absolute_uri(
+                '/site/%d/item/%d/dl/%s' % (
+                    self.site_id, self.id,
+                    self.fileobj.name.split('/')[-1]))
             
-    def item_url(self, suffix=''):
-        req = get_request()
-        prefix = req.META['SCRIPT_NAME']
-        if self.item_type == 'URL' and suffix == '':
+    def item_url(self, suffix='', force_local=False):
+        if self.item_type == 'URL' and suffix == '' and not force_local:
             return self.url
         else:
-            return '%s/site/%d/item/%d/%s' % (
-                prefix, self.site_id, self.id, suffix)
+            req = get_request()
+            return req.build_absolute_uri('/site/%d/item/%d/%s' % (
+                    self.site_id, self.id, suffix))
 
     def parent_url(self, suffix=''):
         if self.parent_heading:
index a0c6182..474c66b 100644 (file)
   <updated>${lastmod.strftime("%Y-%m-%dT%H:%M:%SZ")}</updated>
   <entry py:for="item in items">
     <title>${render_title(item)}</title>
-    <link href="${root}${item.item_url(force_local_url=True)}"
+    <link href="${item.item_url(force_local=True)}"
     rel="alternate"></link>
     <updated>${item.last_modified.strftime("%Y-%m-%dT%H:%M:%SZ")}</updated>
-    <id>${root}${item.item_url('')}</id>
+    <id>${item.item_url(force_local=True)}</id>
     <summary type="html">${item.get_item_type_display()}.
     <div py:if="item.item_type=='HEADING'" py:strip="True">
       Contains ${len(models.Item.objects.filter(parent_heading=item))} items.