@@ -119,7 +119,6 @@ class AOIListChangesetsFeedView(Feed):
119
119
"""
120
120
121
121
def get_object (self , request , pk ):
122
- self .feed_id = pk
123
122
return AreaOfInterest .objects .get (pk = pk )
124
123
125
124
def title (self , obj ):
@@ -131,7 +130,16 @@ def link(self, obj):
131
130
return reverse ('supervise:aoi-detail' , args = [obj .id ])
132
131
133
132
def items (self , obj ):
134
- return obj .changesets ()[:50 ]
133
+ items = obj .changesets ()[:50 ]
134
+ # HACK: we want the <link> for each feed <item> to contain both the
135
+ # changeset ID and the AOI ID, but only the changeset is available in
136
+ # item_link() (passed in as the 'item' argument). As a workaround we'll
137
+ # attach the AOI ID to each changeset object. Storing the AOI ID on
138
+ # 'self' is tempting, but not thread-safe, since a single instance of
139
+ # the Feed class is used to serve all feed requests.
140
+ for item in items :
141
+ item .aoi_id = obj .id
142
+ return items
135
143
136
144
def item_title (self , item ):
137
145
return 'Changeset {} by {}' .format (item .id , item .user )
@@ -140,7 +148,9 @@ def item_geometry(self, item):
140
148
return item .bbox
141
149
142
150
def item_link (self , item ):
143
- return "{}/changesets/{}/?aoi={}" .format (settings .OSMCHA_URL , item .id , self .feed_id )
151
+ # item.aoi_id is obj.id, i.e. the UUID (pk) from the request URL,
152
+ # as set by us in items(self, obj) above.
153
+ return "{}/changesets/{}/?aoi={}" .format (settings .OSMCHA_URL , item .id , item .aoi_id )
144
154
145
155
def item_pubdate (self , item ):
146
156
return item .date
0 commit comments