Table-Plus / Collections / View_permitted....

24 views
Skip to first unread message

Mike

unread,
Oct 1, 2011, 4:55:59 PM10/1/11
to Hobo Users
Hi all,

I'm trying to convert the view of a custom index_action to a table.
It's not working because of complicated view_permissions.

It's strange because:
(1) it works without Table-Plus just fine:
history.dryml: <index-page/>

versus

history.dryml:
<index-page>
<main-nav: current="history" />
<collection: replace>
<div>
<table-plus fields="this,other_var">
</table-plus>
</div>
</collection>
</index-page>

(2) it works with Table-Plus when you're the administrator
(3) The "thing" counter on the page (even with Table-Plus) shows the
right about of entries - I think the scope is capturing the right ones
(4) The permissions work perfectly on the show-pages too

I'm thinking it must be something to do with Table-Plus and the View-
Permitted not getting along. The records just do not show up, it is
not empty (I've checked with an empty message).

The only other person I can find talking about this is here:
http://groups.google.com/group/hobousers/browse_thread/thread/aba4a97ca2bb99d9/defe9568439adc5d?lnk=gst&q=table+permission#defe9568439adc5d

How could I modify history.dryml to do a check if view_permitted? Any
other ideas?? I'm really lost.

Mike


Thing controller:
index_action :history

def history
hobo_index (Thing.owner_id_is(current_user.id))
end

I have also tried current_user.things for the scope.

Thing model:
def view_permitted?(field)
return true if (owner_is?(acting_user))
return true if (acting_user.administrator?)
return true if (other_condition?)
return true if (other_condition2?)
return false

end

kevinpfromnm

unread,
Oct 2, 2011, 12:02:17 PM10/2/11
to hobo...@googlegroups.com
You want to modify your index finder (in the controller) to only grab the right entries anyway.  Otherwise pagination is broken.

def index
  if current_user.administrator?
    hobo_index
  elsif
    hobo_index acting_user.things
  end
end

I can't really speak to the other 2 conditions though but that might at least point you in the right direction.
 

Mike Karp

unread,
Oct 2, 2011, 2:58:16 PM10/2/11
to hobo...@googlegroups.com
Everyone,

I must really be missing something here.  Best I can tell, the scope placed on the custom action after hobo_index is not carrying through to the table-plus object, leaving the table-plus to choke.  Is there something special about the way the standard view is coded to cooperate with the scope placed on "hobo_index"?

 def history
   hobo_index (Thing.owner_is(current_user))
 end

Maybe that scope ^ does not carry through to the replaced collection tag:
<index-page>

   <collection: replace>
       <div>
           <table-plus fields="this,other_var"/>
       </div>
   </collection>
</index-page>

Can I force the table-plus to act on the right scope?  I've done a bunch of searching, and found a lot of different syntax that doesn't make sense to me, that all see to cause errors:
  <table-plus:things fields="this,other_var"/>
  <table-plus with="&@things" fields="this,other_var"/>
What do these mean?

Thanks,

Mike


----
Mike Karp
(m) 650.793.0695
(e) mdk...@gmail.com


 

--
You received this message because you are subscribed to the Google Groups "Hobo Users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/hobousers/-/NQF3qosKt3EJ.
To post to this group, send email to hobo...@googlegroups.com.
To unsubscribe from this group, send email to hobousers+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/hobousers?hl=en.

Reply all
Reply to author
Forward
0 new messages