Commits

R David Murray  committed 21ee2d7

Fix listing of queries in query edit view; fixes leave in/out.

The problem is that a filter applied to the query list doesn't work. All
queries are returned no matter what the value passed in for private_for is.
So I added conditions instead. Note that the condition I added is more
accurate: we want public queries the user owns to be listed in the first
section where they can make it private if they want to, and we don't want to
list retired queries in either that or the public queries section.

The reason there was a permission error when trying to remove or add a query
is that when the form was submitted it tried to update properties on queries
that the submitting user didn't own, because the form was constructed wrong
(those properties should only have been set on queries the user does own).

  • Participants
  • Parent commits ecbf4fe

Comments (0)

Files changed (1)

File html/query.edit.html

  </tal:block>
 </tr>
 
-<tr tal:define="queries python:db.query.filter(filterspec={'private_for':uid})"
+<!-- RDM20140305: We ought to be able to use a filterspec here and below
+     instead of a condition, but I couldn't get it to work. -->
+<tr tal:define="queries python:db.query.filter()"
      tal:repeat="query queries">
+ <tal:block tal:condition="python:query.creator == uid and not path('query/is_retired')">
  <td><a tal:attributes="href string:${query/klass}?${query/url}"
         tal:content="query/name">query</a></td>
 
   <input type="button" value="Delete" i18n:attributes="value"
   tal:attributes="onClick python:'''retire('%s')'''%query.id">
   </td>
+ </tal:block>
 </tr>
 
-<tr tal:define="queries python:db.query.filter(filterspec={'private_for':None})"
+<tr tal:define="queries python:db.query.filter()"
      tal:repeat="query queries">
+ <tal:block condition="python:query.creator != uid and not path('query/is_retired')">
  <td><a tal:attributes="href string:${query/klass}?${query/url}"
         tal:content="query/name">query</a></td>
 
  <td tal:condition="not:query/is_edit_ok" colspan="3"
     i18n:translate="">[not yours to edit]</td>
 
+ </tal:block>
 </tr>
 
 <tr><td colspan="5">