If you call controller function and return something from this function, it 
will allways create new page (if you return string, it will be returned 
directly, if dictionary, it will be returned through the templating engine).

You can

1) test privileges before (when you create the page at first) and
a) immediately hide the button
--or-- b) have a hidden element <div style="display: none;">no 
privileges</div> and show it using javascript when user clicks

--or-- (if you don't want test privileges before, but after the click)

2) use ajax call (see ajax chapter of the book), which can return
a) script
--or-- b) innerHTML for some element






Dne čtvrtek 19. února 2015 9:15:09 UTC+1 Yebach napsal(a):
>
> Hello
>
> I have a button for user to export some data from db. If he does not have 
> the right privileges (that is checked on server) I would like to return an 
> alert (possible modal or smth) without redirection after he clicks ok
>
> So far I have an alert but user is redirected to an empty page afterwards
>
>
> This is my button in html
>
> <div class="btn-group" style="margin-bottom: 20px; margin-top: 10px;">
>     <!--      <button onclick="" class="btn btn-primary"><span 
> class="glyphicon glyphicon-export"></span>&nbsp;&nbsp;{{ =T('Export EXCEL') 
> }}</button> -->
>         {{=A(T('iCal export'), _class='btn btn-primary', 
> _href=URL('script','iCalDownload',  args = request.args[0]))}}
>     </div>
>
> and my controler
>
> def iCalDownoload():
>      if user has privilages:
>          blah blah blah
>      else:
>          return SCRIPT("alert('You do not have the right privileges to 
> download. Please contact administrator: in...@algit.si <javascript:>')")
>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to