[web2py] Re: how to store values into args or vars from loop

2014-12-30 Thread Alex Glaros
for the var list, I get an "invalid syntax" error with an arrow under the 
"=" sign 

are parenthesis symbols supposed to be used instead of brackets?

the arg list works well

-- 
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.


[web2py] Re: how to store values into args or vars from loop

2014-12-30 Thread Dave S


On Tuesday, December 30, 2014 1:59:37 PM UTC-8, Alex Glaros wrote:
>
> but how to keep from overwriting the preceding variable contents within 
> the loop process?
>

arglist=[]
for row in rows:
   arglist.append(row.firstname)
# pass

 or

vardict = {}
for row in rows:
   # use an arbitrary key unless we have a better choice
   vardict[row.id = row.firstname]
# pass


(I'm using row.id as a key just as an example; recall that dictionaries 
create an entry when you assign to a key that isn't already in the 
dictionary)

Unless I'm missing something.  Oh, I wrote the code as for a controller 
function, but if you need it in a view just brace yourself to do the proper 
wrapping.

/dps


-- 
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.


[web2py] Re: how to store values into args or vars from loop

2014-12-30 Thread Alex Glaros
but how to keep from overwriting the preceding variable contents within the 
loop process?

-- 
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.


[web2py] Re: how to store values into args or vars from loop

2014-12-30 Thread Dave S


On Tuesday, December 30, 2014 1:22:23 PM UTC-8, Alex Glaros wrote:
>
> how do I store values from a loop into args or vars?
>
> pseudo code of what I'm trying to do:
>
> for row in rows:
> var1=row.first_name
> pass
>
>
> or
>
> for row in rows:
>arg1=row.first_name
>pass
>
>
> just need syntax to avoid replacing contents of var1 or arg1 with the next 
> value. All the values should be stored in the arg/var list.  E.g., var1 = 
> "Alex", var2 = "Tom", var3 = "Mary"
>
>
>
According to 
http://web2py.com/books/default/chapter/29/04/the-core#URL>,
args are from a list and vars from a dictionary.  
Use your loop to build up a list or a dictionary, and pass that to the 
URL() helper.

/dps


-- 
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.


[web2py] Re: Content Security Policy (CSP) settings and calender.js

2014-12-30 Thread Dave S


On Tuesday, December 30, 2014 12:00:01 PM UTC-8, Niphlod wrote:
>
>
>
> On Tuesday, December 30, 2014 8:35:23 PM UTC+1, Dave S wrote:
>>
>>
>>
>> On Tuesday, December 30, 2014 7:32:15 AM UTC-8, Niphlod wrote:
>>>
>>> I don't get what you're asking for. If you choose to create *your* own 
>>> policy and part of *your* application uses something that *your* own 
>>> policy discards, there's nothing *web2py* can do.
>>>
>>>
>> If it were me, I'd be asking for suggestions that either
>>
>> a) modify the policy in a way that maintains security but allows the 
>> calendar.js to work
>>   (this would likely be a suggestion from someone with experience with 
>> security policies)
>>
>  
> the policy is a single-line header with no possibility to set "per-file" 
> policies, i.e. allow eval for just calendar.js
>

Is there a lesser setting that allows eval without allowing too much of 
other "threats"?  Could changing to that setting
be justified to management (aside from the IE defense:  "The normal user 
has a working visit if we do it that way").
 

>  
>
>> b) suggest a way to remove the dependency on 'eval'
>>  (this would likely be a suggestion from someone with experience swapping 
>> js files under web2py)
>>
>>
> The scaffolding app "adoptes" a calendar widget that is not forced upon 
> anybody (web2py is a python framework to make apps, and the scaffolding app 
> is not a solution for every problem). If "eval" in calendar.js is such a 
> threat that the app (or the coder) can't take, he should evaluate another 
> widget.
>

So the OP  should be able to  strip out calendar.js, and substitute 
another?  Does someone in the community have pointers to a good choice, 
especially one that can be slid in easily?  Are there already examples at 
web2pyslices.com?  (My quick scan only came across an unanswered question at
http://www.web2pyslices.com/slice/show/1525/how-to-get-the-drop-down-date-selector-by-default>)


/dps




-- 
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.


[web2py] how to store values into args or vars from loop

2014-12-30 Thread Alex Glaros
how do I store values from a loop into args or vars?

pseudo code of what I'm trying to do:

for row in rows:
var1=row.first_name
pass


or

for row in rows:
   arg1=row.first_name
   pass


just need syntax to avoid replacing contents of var1 or arg1 with the next 
value. All the values should be stored in the arg/var list.  E.g., var1 = 
"Alex", var2 = "Tom", var3 = "Mary"

thanks

Alex Glaros

-- 
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.


[web2py] Re: Content Security Policy (CSP) settings and calender.js

2014-12-30 Thread Niphlod


On Tuesday, December 30, 2014 8:35:23 PM UTC+1, Dave S wrote:
>
>
>
> On Tuesday, December 30, 2014 7:32:15 AM UTC-8, Niphlod wrote:
>>
>> I don't get what you're asking for. If you choose to create *your* own 
>> policy and part of *your* application uses something that *your* own 
>> policy discards, there's nothing *web2py* can do.
>>
>>
> If it were me, I'd be asking for suggestions that either
>
> a) modify the policy in a way that maintains security but allows the 
> calendar.js to work
>   (this would likely be a suggestion from someone with experience with 
> security policies)
>
 
the policy is a single-line header with no possibility to set "per-file" 
policies, i.e. allow eval for just calendar.js
 

> b) suggest a way to remove the dependency on 'eval'
>  (this would likely be a suggestion from someone with experience swapping 
> js files under web2py)
>
>
The scaffolding app "adoptes" a calendar widget that is not forced upon 
anybody (web2py is a python framework to make apps, and the scaffolding app 
is not a solution for every problem). If "eval" in calendar.js is such a 
threat that the app (or the coder) can't take, he should evaluate another 
widget.

-- 
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.


[web2py] Re: Ajax/Updated Form Field

2014-12-30 Thread Mark Billion
I am wondering if I answered my own (incomprehensible) question:

I plugged in Jeditable , 
which is great.  Then I set the script up to post to a controller that 
inputs the data to the db (which validates, i.e., 'integer'), commits it, 
and then returns the value.  This seems safe & secure, but Im game if you 
guys disagree!  


MODELS##
db.define_table('dogs',
Field('dog_name','integer'))


CONTROLLERS##
def dogs():
xml_string = []
return locals()

def upd_dog_name():
#id,column = request.post_vars.id.split('.')
#value = request.post_vars.value
x = request.post_vars['id']
y = request.post_vars['value']
db.dogs[x]={'dog_name':y}
db.commit()

return y

VIEWS##




jQuery(document).ready(function(){
jQuery('.edit').editable('default/upd_dog_name',{   
tooltip: "Click to edit, enter to save",
indicator : 'updating',
 onblur: 'submit'});})

Dolor
Lorem ipsum dolor sit amet, consectetuer
adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore
magna aliquam erat volutpat.


On Tuesday, December 30, 2014 10:46:42 AM UTC-5, Mark Billion wrote:
>
> I may be an idiot but
>
> I want to set up a form so that you click to edit, and on focus out, the 
> data is committed to the DB via Ajax. 
>
> 1.  Im using the inplace_edit(f,v) module from slices:
>
> wrapper = DIV()
> inp = SQLFORM.widgets.string.widget(f,v)
> lbl = 
> SPAN(inp['_value'],_id='inplace_edit_'+inp['_id'],_style="cursor:pointer;")
> scr1 = "jQuery('#%s').hide();" % inp['_id']
> scr2 = "jQuery('#%s').bind('click',function(e){ 
> jQuery(this).hide();jQuery('#%s').show().focus();});" % \
>  (lbl['_id'],inp['_id'])
> scr3 = "jQuery('#%s').bind('blur',function(e){ 
> jQuery(this).hide();jQuery('#%s').show().text(jQuery(this).val());});" % \
>  (inp['_id'],lbl['_id'])
> jqscr = SCRIPT(scr1,scr2,scr3,_type="text/javascript")
> wrapper.components.extend([inp,lbl,jqscr])
> return wrapper
>
> 2.  My thought based on the book is that I need to add ['_onkeyup'] as an 
> attribute to the sqlform but this adds to the form itself.  
>
> ="ajax('{{=URL('default', 'echo')}}', ['name'], 'target')" 
>
> This failed horribly.
>
> Is there a slice/package/tutorial/something y'all can point me to?
>
>

-- 
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.


[web2py] Re: Content Security Policy (CSP) settings and calender.js

2014-12-30 Thread Dave S


On Tuesday, December 30, 2014 7:32:15 AM UTC-8, Niphlod wrote:
>
> I don't get what you're asking for. If you choose to create *your* own 
> policy and part of *your* application uses something that *your* own 
> policy discards, there's nothing *web2py* can do.
>
>
If it were me, I'd be asking for suggestions that either

a) modify the policy in a way that maintains security but allows the 
calendar.js to work
  (this would likely be a suggestion from someone with experience with 
security policies)

b) suggest a way to remove the dependency on 'eval'
 (this would likely be a suggestion from someone with experience swapping 
js files under web2py)

It's possible that there's a fundamental conflict, though, that makes 
either type of suggestion difficult.

/dps

-- 
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.


[web2py] Re: Is there any way to host PHP w/ Web2py on Nginx environment? PHP noob but long time Web2py user here

2014-12-30 Thread Dave S


On Monday, December 29, 2014 9:51:24 AM UTC-8, Leonel Câmara wrote:
>
> It's possible, however a better option would be for you to rewrite the php 
> functionality in a web2py controller function.
>

If the PHP stuff does a function that is well-understood and easy to 
implement locally, that should be an option, and the javascript has a 
simple interface to it.  Note that the dot-js file will need to be tweaked 
to point at the controller rather than at PHP, which is an issue mainly 
when updates of the javascript functions are issued. 

If either functionality is a complex package, though, it might be just as 
well to let be.  At this point, I will naively say that I'd use the nginx 
to handle the php as a separate server (URL would be different somewhere 
between the domain and the arguments), but I haven't any experience with 
that.  There are a few posts in the forum that discuss that sort of setup, 
though, if my recollection is correct.  They should be visible less than 18 
months back in the archives, but other than "nginx" and "apache" I'm not 
sure what search terms would be good.

/dps

-- 
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.


Re: [web2py] database select from set encoding

2014-12-30 Thread Michele Comitini
the string is a utf-8 encoded string not unicode object

>>> print 'Moj\xc4\x8dca'.decode('utf-8')
Mojčca



2014-12-30 15:32 GMT+01:00 Niphlod :

> let's tackle the problem from another side: if you avoid using DAL and
> resort to "pure" psycopg2, does it work ? If yes, can you post the code ?
> From there we can compare what DAL does and pinpoint the root cause
> accordingly.
>
> On Tuesday, December 30, 2014 8:41:56 AM UTC+1, Yebach wrote:
>>
>> Hello
>>
>> Setting db_codec changes nothing
>>
>> 2014-12-29 17:21 GMT+01:00 Marco Mansilla :
>>
>>> El Mon, 29 Dec 2014 05:53:37 -0800 (PST)
>>> Yebach  escribió:
>>>
>>> > hello
>>> >
>>> > I have a postgres dabatabase with utf8 encoding
>>> >
>>> > after executing
>>> > workersDb = db(db.worker.w_organisation == org).select(db.worker.id,
>>> > db.worker.w_nick_name).as_list()
>>> >
>>> > I get a list of dict where my strings are endoed as
>>> >
>>> > 'Moj\xc4\x8dca'
>>> >
>>> > where it should write Mojčca
>>> >
>>> > How do i set the encoding?
>>> >
>>> > Thank you
>>> >
>>> >
>>> right at the end of the section
>>>
>>> http://www.web2py.com/books/default/chapter/29/06/the-
>>> database-abstraction-layer#Connection-strings--the-uri-parameter-
>>>
>>> Marco.
>>>
>>> --
>>> 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 a topic in the
>>> Google Groups "web2py-users" group.
>>> To unsubscribe from this topic, visit https://groups.google.com/d/
>>> topic/web2py/uUf6xZaUY_Y/unsubscribe.
>>> To unsubscribe from this group and all its topics, send an email to
>>> web2py+un...@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>>
>> --
>> Lep pozdrav
>>
>> Vid Ogris
>>
>>
>>   --
> 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.
>

-- 
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.


[web2py] Ajax/Updated Form Field

2014-12-30 Thread Mark Billion
I may be an idiot but

I want to set up a form so that you click to edit, and on focus out, the 
data is committed to the DB via Ajax. 

1.  Im using the inplace_edit(f,v) module from slices:

wrapper = DIV()
inp = SQLFORM.widgets.string.widget(f,v)
lbl = 
SPAN(inp['_value'],_id='inplace_edit_'+inp['_id'],_style="cursor:pointer;")
scr1 = "jQuery('#%s').hide();" % inp['_id']
scr2 = "jQuery('#%s').bind('click',function(e){ 
jQuery(this).hide();jQuery('#%s').show().focus();});" % \
 (lbl['_id'],inp['_id'])
scr3 = "jQuery('#%s').bind('blur',function(e){ 
jQuery(this).hide();jQuery('#%s').show().text(jQuery(this).val());});" % \
 (inp['_id'],lbl['_id'])
jqscr = SCRIPT(scr1,scr2,scr3,_type="text/javascript")
wrapper.components.extend([inp,lbl,jqscr])
return wrapper

2.  My thought based on the book is that I need to add ['_onkeyup'] as an 
attribute to the sqlform but this adds to the form itself.  

="ajax('{{=URL('default', 'echo')}}', ['name'], 'target')" 

This failed horribly.

Is there a slice/package/tutorial/something y'all can point me to?

-- 
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.


[web2py] Re: Content Security Policy (CSP) settings and calender.js

2014-12-30 Thread Niphlod
I don't get what you're asking for. If you choose to create *your* own 
policy and part of *your* application uses something that *your* own policy 
discards, there's nothing *web2py* can do.

-- 
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.


Re: [web2py] Re: Daily task on production: scheduler or cron?

2014-12-30 Thread Niphlod
that's really someone overcomplicating the setup... on the queue_task 
thing, use prevent_drift as explained before. Again, setting the heartbeat 
to 10 minutes kinda sucks, as there are too many things that can happen in 
10 minutes. BTW: if you don't use cron, what are you planning to use to 
keep the scheduler process(es) running ?

-- 
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.


Re: [web2py] Re: Rocket // HTTP 400 Bad Request - Body is incomplete

2014-12-30 Thread Niphlod
you're not very fair in debugging if you have something different that 
processes the error: please simplify it and let the application alone catch 
the error, then inspect what goes on with logging calls into copystream...

-- 
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.


Re: [web2py] database select from set encoding

2014-12-30 Thread Niphlod
let's tackle the problem from another side: if you avoid using DAL and 
resort to "pure" psycopg2, does it work ? If yes, can you post the code ? 
>From there we can compare what DAL does and pinpoint the root cause 
accordingly.

On Tuesday, December 30, 2014 8:41:56 AM UTC+1, Yebach wrote:
>
> Hello
>
> Setting db_codec changes nothing
>
> 2014-12-29 17:21 GMT+01:00 Marco Mansilla  >:
>
>> El Mon, 29 Dec 2014 05:53:37 -0800 (PST)
>> Yebach > escribió:
>>
>> > hello
>> >
>> > I have a postgres dabatabase with utf8 encoding
>> >
>> > after executing
>> > workersDb = db(db.worker.w_organisation == org).select(db.worker.id,
>> > db.worker.w_nick_name).as_list()
>> >
>> > I get a list of dict where my strings are endoed as
>> >
>> > 'Moj\xc4\x8dca'
>> >
>> > where it should write Mojčca
>> >
>> > How do i set the encoding?
>> >
>> > Thank you
>> >
>> >
>> right at the end of the section
>>
>>
>> http://www.web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#Connection-strings--the-uri-parameter-
>>
>> Marco.
>>
>> --
>> 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 a topic in the 
>> Google Groups "web2py-users" group.
>> To unsubscribe from this topic, visit 
>> https://groups.google.com/d/topic/web2py/uUf6xZaUY_Y/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to 
>> web2py+un...@googlegroups.com .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> -- 
> Lep pozdrav 
>
> Vid Ogris
>
>
> 

-- 
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.


Re: [web2py] Re: navbar in sqlform.grid

2014-12-30 Thread Jim Steil
Have you tried removing all of your javascript and css to see if it works?

-Jim

On Tue, Dec 30, 2014 at 7:33 AM, Vid Ogris  wrote:

> My file
>
> {{extend 'layout.html'}}
> {{include 'web2py_ajax.html'}}
> 
> $(function(){
> $('.activateButton').click(function(){
> turnusId = $(this).val();
>  $.ajax({
> type: 'POST',
> url: '{{=URL('settings', 'activateTurnus.json')}}',
> data: {value: turnusId},
> dataType: 'json',
> success: function(result){
> //console.log("OK");
> location.reload(true);
> //$('#tablediv').load(document.URL +  ' #thisdiv');
> },
> error: function(){
> // console.log("Ni OK");
> // TODO ERROR MSG v kolkor se ni nč zgodivo
> }
> });
>
>  });
> $('.deleteButton').click(function(){
> turnusId = $(this).val();
> $.ajax({
> type: 'POST',
> url: '{{=URL('settings', 'deleteTurnus.json')}}',
> data: {value: turnusId},
> dataType: 'json',
> success: function(result){
> //console.log("OK");
> location.reload(true);
> //$('#tablediv').load(document.URL +  ' #thisdiv');
> },
> error: function(){
> //  console.log("Ni OK");
> // TODO ERROR MSG v kolkor se ni nč zgodivo
> }
> });
> });
> });
>
> var ColorPicker = function(){
> var picker = $('input[name=sh_color]');
> picker.ColorPicker({
> onSubmit: function(hsb, hex, rgb, el) {
> $(el).val(hex);
> $(el).ColorPickerHide();
> $(el).parent().css('background', '#'+hex);
> },
> onBeforeShow: function () {
> $(this).ColorPickerSetColor(this.value);
> }
> })
> .bind('keyup', function(){
> $(this).ColorPickerSetColor(this.value);
> });
> picker.each(function() {
> if (this.value) {
> $(this).parent().css('background', '#' + this.value);
>
> }
> });
> };
> function compareTime(start, end) {
>
>var s1 = start.split(":")[0] * 3600 + start.split(":")[1] * 60;
>var s2 = end.split(":")[0] * 3600 + end.split(":")[1] * 60;
>//console.log(s1,s2);
>if (s1 > s2) {
>result = (86400 - s1) + s2;
>
>}
>else {
>result = Math.abs(s1 - s2);// Gets difference in seconds
>}
>return result
> }
> //alert(dateCompare("12:40:13","20:01:01"));
>  $(document).ready(function() {
> $('.time').clockpicker({
> donetext: doneText,
> autoclose: true
> });
> ColorPicker();
> jQuery.timeEntry.setDefaults({showSeconds: false});
>  ///Pogledamo če je kje vv gruidu None da se ne kaže
> //console.log($('.web2py_htmltable'));
>  //nastavimo polje lenght da je read only ker se vrednost zračuna
> //$('#shift_sh_length1').attr("disabled", true)
> $('#shift_sh_code').prop('readonly', true);
> $('#shift_sh_code').css( 'background-color', 'DarkGray');
>  $('#shift_sh_length1').prop('readonly', true);
> $('#shift_sh_length1').css( 'background-color', 'DarkGray');
>  $('#shift_sh_length2').prop('readonly', true);
> $('#shift_sh_length2').css( 'background-color', 'DarkGray');
> $('#shift_sh_duration').prop('readonly', true);
>  //polja turnus code in duration se računjo tako za dur1 in dur2
> $( ".time" ).change(function() {
> //length1
> start  = $('#shift_sh_start1').val(),
> end = $('#shift_sh_end1').val();
> var dur = compareTime(start,end)/ 60;
> $('#shift_sh_length1').val(dur);
>   //length2
> start2  = $('#shift_sh_start2').val(),
> end2 = $('#shift_sh_end2').val();
>  if (start2){
>  var codeBeg1 = start.split(":")[0] + start.split(":")[1];
> var codeEnd1 = end.split(":")[0] + end.split(":")[1];
>  var codeBeg2 = start2.split(":")[0] + start2.split(":")[1];
> var codeEnd2 = end2.split(":")[0] + end2.split(":")[1];
>  var tCodeL = codeBeg1 +'-' + codeEnd1 + '&' + codeBeg2 + '-' + codeEnd2;
> $('#shift_sh_code').val(tCodeL);
> var dur2 = compareTime(start2,end2)/ 60;
> $('#shift_sh_length2').val(dur2);
> $('#shift_sh_duration').val(dur + dur2);
>  }
> else  {
> $('#shift_sh_length2').val(null);
> //code
> var beg = start.split(":")[0] + start.split(":")[1];
> var ed = end.split(":")[0] + end.split(":")[1];
> var tCode = beg +"-" + ed;
> $('#shift_sh_code').val(tCode);
> $('#shift_sh_duration').val(dur);
>  }
> });
> });
>
> 
> 
>
> .web2py_form {
> width: 100%;
> }
>
> .w2p_fw {
> width: 70%;
> }
>
> .generic-widget {
> height : 110%;
> }
>
> .affix {
> top: 60px;
> }
> .input-group {
> width: 100%;
> }
> .row {
> margin-bottom: 10px;
> }
> .sectionHeader {
> margin-bottom: 0;
> }
> 
> 
>
> {{ =response.title + " - " +T('Shifts')}} 
> 
>
>
> {{=T('Edit shifts')}}
> {{=T('Active shifts')}}
> 
> {{=grid_shifts}}
> 
>
> 
> 
> {{if ((str((request.url, request.env.query_string)).find("new") < 0)):}}
> {{if ((str((request.url, request.env.query_string)).find("edit") <
> 0)):}}
> 
> {{=T('Inactive shitfs')}}
> 
> 
> 
> 
> {{=T('Code')}}
> {{=T('Name')}}
> {{=T('Start')}}
> {{=T('End')}}
> {{=T('Length 1')}}
> {{=T('Start 2')}}
> {{=T('End 2')}}
> {{=T('Length 2')}}
>{{=T('Note')}}
>{{=T('Act

Re: [web2py] Re: navbar in sqlform.grid

2014-12-30 Thread Vid Ogris
My file

{{extend 'layout.html'}}
{{include 'web2py_ajax.html'}}

$(function(){
$('.activateButton').click(function(){
turnusId = $(this).val();
 $.ajax({
type: 'POST',
url: '{{=URL('settings', 'activateTurnus.json')}}',
data: {value: turnusId},
dataType: 'json',
success: function(result){
//console.log("OK");
location.reload(true);
//$('#tablediv').load(document.URL +  ' #thisdiv');
},
error: function(){
// console.log("Ni OK");
// TODO ERROR MSG v kolkor se ni nč zgodivo
}
});

 });
$('.deleteButton').click(function(){
turnusId = $(this).val();
$.ajax({
type: 'POST',
url: '{{=URL('settings', 'deleteTurnus.json')}}',
data: {value: turnusId},
dataType: 'json',
success: function(result){
//console.log("OK");
location.reload(true);
//$('#tablediv').load(document.URL +  ' #thisdiv');
},
error: function(){
//  console.log("Ni OK");
// TODO ERROR MSG v kolkor se ni nč zgodivo
}
});
});
});

var ColorPicker = function(){
var picker = $('input[name=sh_color]');
picker.ColorPicker({
onSubmit: function(hsb, hex, rgb, el) {
$(el).val(hex);
$(el).ColorPickerHide();
$(el).parent().css('background', '#'+hex);
},
onBeforeShow: function () {
$(this).ColorPickerSetColor(this.value);
}
})
.bind('keyup', function(){
$(this).ColorPickerSetColor(this.value);
});
picker.each(function() {
if (this.value) {
$(this).parent().css('background', '#' + this.value);

}
});
};
function compareTime(start, end) {

   var s1 = start.split(":")[0] * 3600 + start.split(":")[1] * 60;
   var s2 = end.split(":")[0] * 3600 + end.split(":")[1] * 60;
   //console.log(s1,s2);
   if (s1 > s2) {
   result = (86400 - s1) + s2;

   }
   else {
   result = Math.abs(s1 - s2);// Gets difference in seconds
   }
   return result
}
//alert(dateCompare("12:40:13","20:01:01"));
 $(document).ready(function() {
$('.time').clockpicker({
donetext: doneText,
autoclose: true
});
ColorPicker();
jQuery.timeEntry.setDefaults({showSeconds: false});
 ///Pogledamo če je kje vv gruidu None da se ne kaže
//console.log($('.web2py_htmltable'));
 //nastavimo polje lenght da je read only ker se vrednost zračuna
//$('#shift_sh_length1').attr("disabled", true)
$('#shift_sh_code').prop('readonly', true);
$('#shift_sh_code').css( 'background-color', 'DarkGray');
 $('#shift_sh_length1').prop('readonly', true);
$('#shift_sh_length1').css( 'background-color', 'DarkGray');
 $('#shift_sh_length2').prop('readonly', true);
$('#shift_sh_length2').css( 'background-color', 'DarkGray');
$('#shift_sh_duration').prop('readonly', true);
 //polja turnus code in duration se računjo tako za dur1 in dur2
$( ".time" ).change(function() {
//length1
start  = $('#shift_sh_start1').val(),
end = $('#shift_sh_end1').val();
var dur = compareTime(start,end)/ 60;
$('#shift_sh_length1').val(dur);
  //length2
start2  = $('#shift_sh_start2').val(),
end2 = $('#shift_sh_end2').val();
 if (start2){
 var codeBeg1 = start.split(":")[0] + start.split(":")[1];
var codeEnd1 = end.split(":")[0] + end.split(":")[1];
 var codeBeg2 = start2.split(":")[0] + start2.split(":")[1];
var codeEnd2 = end2.split(":")[0] + end2.split(":")[1];
 var tCodeL = codeBeg1 +'-' + codeEnd1 + '&' + codeBeg2 + '-' + codeEnd2;
$('#shift_sh_code').val(tCodeL);
var dur2 = compareTime(start2,end2)/ 60;
$('#shift_sh_length2').val(dur2);
$('#shift_sh_duration').val(dur + dur2);
 }
else  {
$('#shift_sh_length2').val(null);
//code
var beg = start.split(":")[0] + start.split(":")[1];
var ed = end.split(":")[0] + end.split(":")[1];
var tCode = beg +"-" + ed;
$('#shift_sh_code').val(tCode);
$('#shift_sh_duration').val(dur);
 }
});
});




.web2py_form {
width: 100%;
}

.w2p_fw {
width: 70%;
}

.generic-widget {
height : 110%;
}

.affix {
top: 60px;
}
.input-group {
width: 100%;
}
.row {
margin-bottom: 10px;
}
.sectionHeader {
margin-bottom: 0;
}



{{ =response.title + " - " +T('Shifts')}} 



{{=T('Edit shifts')}}
{{=T('Active shifts')}}

{{=grid_shifts}}




{{if ((str((request.url, request.env.query_string)).find("new") < 0)):}}
{{if ((str((request.url, request.env.query_string)).find("edit") <
0)):}}

{{=T('Inactive shitfs')}}




{{=T('Code')}}
{{=T('Name')}}
{{=T('Start')}}
{{=T('End')}}
{{=T('Length 1')}}
{{=T('Start 2')}}
{{=T('End 2')}}
{{=T('Length 2')}}
   {{=T('Note')}}
   {{=T('Activate')}}
   {{=T('Delete')}}
   
   
   
   {{for rec in query_inactive:}}
   
{{=rec['sh_code']}}
{{=rec['sh_name']}}
{{=rec['sh_start1']}}
{{=rec['sh_end1']}}
{{=rec['sh_length1']}}
{{=rec['sh_start2']}}
{{=rec['sh_end2']}}
{{=rec['sh_length2']}}
{{=rec['sh_note']}}


   
  {{pass}}
  {{pass}}
  




{{pass}}


2014-12-30 14:23 GMT+01:00 Jim S :

> Can you show your view file where the grid is included?
>
> -Jim
>
>
> On Monday, December 29, 2014 8:30:31 A

[web2py] Re: navbar in sqlform.grid

2014-12-30 Thread Jim S
Can you show your view file where the grid is included?

-Jim


On Monday, December 29, 2014 8:30:31 AM UTC-6, Yebach wrote:
>
> Hello
>
> My navbar user button does not show dropdown options when I am in a view 
> where SQLFORM.grid is? 
>
> Any suggestions why?
>
>

-- 
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.


Re: [web2py] How to set Reset password key programmatically?

2014-12-30 Thread Michele Comitini
A simple trick is to send the user (with user_id) a link (by mail or any
other way)

You can do something like this (max_time is when you want the key to expire)

 user = db.auth_user(user_id)
reset_password_key = str(int(max_time)) + '-' + web2py_uuid()
user.update_record(reset_password_key=reset_password_key)

link =auth.url(auth.settings.function,
args=('reset_password', reset_password_key),
scheme='https')

You can put this in a file .py and call it from web2py.py using the -R
option on commandline.



2014-12-28 19:52 GMT+01:00 :

> Hey everybody,
>
> I added a couple of users programmatically as suggested on the mailing
> list using
>
> my_crypt = CRYPT(key=auth.settings.hmac_key)
> crypt_pass = my_crypt(passw)[0]
> id_user= db.auth_user.insert(username = username, email = email, password
> = crypt_pass)
>
> That's perfectly fine, but... the newly created users lack a *Reset
> password key*
> How would I assign a Reset password key when creating users
> programmatically, so that users later can retrieve their password?
>
> Anybody could share a code snippet?
>
> Cheers
> Toby
>
> --
> 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.
>

-- 
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.


[web2py] Re: Auto detect of video file through url link while posting link

2014-12-30 Thread Massimo Di Pierro
;-)

from gluon.contrib.autolinks import expand_one
d = session.cache_links or {}

{{=XML(expand_one(url, d))}}



On Monday, 29 December 2014 08:59:00 UTC-6, Vikash Singh wrote:
>
> Hi Massimo,
>
> First of all have a Great year forward, 
>
> I have no match with your knowledge of awesome web2py, most of things in 
> which i have familiar, *When manually attaching a video link (from 
> YouTube, Vimeo, etc) to a post , is there a way so that it automatically 
> recognise the video link*.for example --Facebook automatically recognizes 
> the link as a video, and allows the resulting status message to play the 
> video inline. The video is displayed as an embedded player in the Wall or 
> News feed. Exactly the same thing which i want to do.
>
> Please help me, as i have tried everything but the result is not as per 
> expectation. now you are the boss.
>
> Thanks in Advance "Professor"
>  
>

-- 
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.


[web2py] Re: How would one design a promotion for products using web2py?

2014-12-30 Thread Dave S


On Monday, December 29, 2014 6:06:04 PM UTC-8, Dave S wrote:
>
>
> Just a thought:
>
> On Saturday, December 27, 2014 7:25:01 AM UTC-8, 黄祥 wrote:
>>
>> [...]
>>
>  
>
>> i'd love to learn from another products and implement it on web2py, but 
>> still have no idea how to do it in web2py ways. the reason is if it set on 
>> the table, the user (non technical) perhaps in marketing division can 
>> change their own conditional pricing rules without any help from technical 
>> or developer to set their own marketing idea.
>> [...]
>>
>
> One way to do this is to make a form that said Marketing Dept User (MDU!) 
> would fill in, being permitted to access that form's page by the auth 
> settings (auth groups, for instance), and then you just update the database 
> with the form.  But I think it would be easy to automate expiring special 
> prices by extending Massimo's table:[...]
> As a future thing, you might want have a scheduler task that every once in 
> a while checks for expired prices  and  deletes (if you allow deletes) or 
> invalidates rows that expired long enough ago that you don't need them 
> around for reference.  And a thought occurs that when the base price 
> changes, you can mark the old record expried (by setting the 'end' field to 
> yesterday) and adding the new price with a far-off expiration.
>

Sodden thought:  Don't add start and end to the table, instead queue jobs 
to the scheduler to update the [only] record with the sale price, and then 
to come back and "update" to the original price.  This doesn't handle the 
quantity discount, but cross-breeding the two solutions might be a way to 
handle that. 

 

> Caveat:  most of my experience is with device programming, so I might have 
> said somethin above that made the people with business sw experience 
> shudder.
>

This change may bring me closer to that goal   :-)
 

> Anyway, my two cents.
>

Compounded annually.


/dps


-- 
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.