[web2py] web2py login user problem

2012-08-24 Thread Yebach
Hello

So I am really struggling with web2py user registration
I have a database that contains come required tables for webapp to work.
Now I want to create a user register form etc.
In db.py I added a create table
#This is used to connect also to all other tables, SHOULD I CREATE A 
NEW CONNECTION FOR USER TABLES?
db = 
DAL('postgres://postgres:postgres@localhost/'+request.vars['school'], 
migrate=False)

from gluon.tools import Auth
auth = Auth(db, hmac_key=Auth.get_or_create_key())
auth.define_tables()
## configure auth policy
auth.settings.registration_requires_verification = False
auth.settings.registration_requires_approval = False
auth.settings.reset_password_requires_verification = True

And In my controler I have the following code in default.py 
def user():
return dict(form=auth())

In view I have the following script 
{{='auth' in globals() and auth.navbar(separators=(' ',' | ',''))}}

I copied all this from web2py welcome app.

I get an error NameError: global name 'auth' is not defined 

Any suggestions? The tables for user are not created yet. Is a user 
function in a wrong controler, should I created a new one? Because If I do, 
then the wrong funciton is called and again I get an error.







-- 





[web2py] Re: web2py login user problem

2012-08-27 Thread Yebach
I am using version Version 1.99.4 (2011-12-14 14:46:14) stable

The whole traceback msg  is

Traceback (most recent call last):
  File C:\workspaces\Python\portal_iUrnik_web2py\gluon\restricted.py, line 
204, in restricted
exec ccode in environment
  File 
C:/workspaces/Python/portal_iUrnik_web2py/applications/portalov_iurnik/controllers/default.py
 
http://192.168.100.101/admin/default/edit/portalov_iurnik/controllers/default.py,
 line 35, in module
  File C:\workspaces\Python\portal_iUrnik_web2py\gluon\globals.py, line 172, 
in lambda
self._caller = lambda f: f()
  File 
C:/workspaces/Python/portal_iUrnik_web2py/applications/portalov_iurnik/controllers/default.py
 
http://192.168.100.101/admin/default/edit/portalov_iurnik/controllers/default.py,
 line 33, in user
form = auth()
NameError: global name 'auth' is not defined



On Friday, August 24, 2012 1:08:43 PM UTC+2, Anthony wrote:

 Also, what version of web2py are you using?

 On Friday, August 24, 2012 7:07:49 AM UTC-4, Anthony wrote:

 Can you show the traceback(). Also, maybe pack and attach a minimal app 
 that reproduces the problem.

 On Friday, August 24, 2012 5:14:20 AM UTC-4, Yebach wrote:

 Hello

 So I am really struggling with web2py user registration
 I have a database that contains come required tables for webapp to work.
 Now I want to create a user register form etc.
 In db.py I added a create table
 #This is used to connect also to all other tables, SHOULD I CREATE A 
 NEW CONNECTION FOR USER TABLES?
 db = 
 DAL('postgres://postgres:postgres@localhost/'+request.vars['school'], 
 migrate=False)

 from gluon.tools import Auth
 auth = Auth(db, hmac_key=Auth.get_or_create_key())
 auth.define_tables()
 ## configure auth policy
 auth.settings.registration_requires_verification = False
 auth.settings.registration_requires_approval = False
 auth.settings.reset_password_requires_verification = True

 And In my controler I have the following code in default.py 
 def user():
 return dict(form=auth())

 In view I have the following script 
 {{='auth' in globals() and auth.navbar(separators=(' ',' | ',''))}}

 I copied all this from web2py welcome app.

 I get an error NameError: global name 'auth' is not defined 

 Any suggestions? The tables for user are not created yet. Is a user 
 function in a wrong controler, should I created a new one? Because If I do, 
 then the wrong funciton is called and again I get an error.









-- 





[web2py] user login tables

2012-08-27 Thread Yebach
Hello

My problem is that my app has to go to specific database on postgres to 
check for users. 
you can visit my app on http://portal.iurnik.si/

You can see that the user select a value from popup and then the app goes 
to a specific database to read data.

After that I want to create a login form. 

I created it but,.

I created a separate model users.py  with this code

database = now it is hardcoded so it works all the time
baza = DAL('postgres://postgres:postgres@localhost/'+ database, 
migrate=True)
auth = Auth(baza, hmac_key=Auth.get_or_create_key())
auth.settings.controller=user
auth.define_tables()

But what I would like to do is read the database name from url and the 
right url comes only after user selects the right value from popup. And 
that is why the app chashes if I don't hard code the db name. Logically.

What do you suggest? also after logout user would stay on the second page 
not to go to default page (where do I set that parameter)

Thank you

-- 





[web2py] Re: user login tables

2012-08-28 Thread Yebach
Where do I put  database = session.get('database','default_database') ??

In model?

So if I understand correctly first there has to be a default database, but 
then after user selects the value a connection is set for the selected 
database?



On Monday, August 27, 2012 8:59:03 PM UTC+2, Massimo Di Pierro wrote:

 If this is a new app you may want to replace

 auth = Auth(baza, hmac_key=Auth.get_or_create_key())

 with

auth = Auth(baza)

 as it will be faster and same security because latest Auth has built-in 
 salting.

 About your problem. You cannot complete let the user specify it. You must 
 have a default and a set of default values:

 database = session.get('database','default_database')

 The you can have a form that stores the one they want into session.database




 On Monday, 27 August 2012 10:09:34 UTC-5, Yebach wrote:

 Hello

 My problem is that my app has to go to specific database on postgres to 
 check for users. 
 you can visit my app on http://portal.iurnik.si/

 You can see that the user select a value from popup and then the app goes 
 to a specific database to read data.

 After that I want to create a login form. 

 I created it but,.

 I created a separate model users.py  with this code

 database = now it is hardcoded so it works all the time
 baza = DAL('postgres://postgres:postgres@localhost/'+ database, 
 migrate=True)
 auth = Auth(baza, hmac_key=Auth.get_or_create_key())
 auth.settings.controller=user
 auth.define_tables()

 But what I would like to do is read the database name from url and the 
 right url comes only after user selects the right value from popup. And 
 that is why the app chashes if I don't hard code the db name. Logically.

 What do you suggest? also after logout user would stay on the second page 
 not to go to default page (where do I set that parameter)

 Thank you



-- 





[web2py] Re: user login tables

2012-08-29 Thread Yebach
I used cookie and set db name there. It kind of works :)

I will try out your solution.

One more question though. I want a redirect after user logouts. 

And not to go to default/index page but my specific school/index. I am 
trying with auth.settings.logout_next=URL(r=request,c='school',f='index') 
but it is not working. Where do I write this code? To controler or model? 
If it is right at all

thank you

On Tuesday, August 28, 2012 3:36:18 PM UTC+2, Anthony wrote:

 Instead of a default database, how about something like this:

 session.database = session.database or request.vars.database
 if not session.database or session.database not in ['list', 'of', 'valid', 
 'databases']:
 redirect(URL('default', 'index'))

 baza = DAL('postgres://postgres:postgres@localhost/'+ session.database,migrate
 =True)
 auth = Auth(baza)

 That expects the database name to be in request.vars.database (via either 
 a get or post request with a database variable). Once submitted, the 
 database name will be stored in the session. On each request, before 
 attempting to connect to the database, it will check the session for the 
 database and confirm it is a valid database -- if not, it redirects back to 
 the home page before connecting.

 Anthony

 On Tuesday, August 28, 2012 3:21:36 AM UTC-4, Yebach wrote:

 Where do I put  database = session.get('database','default_database') ??

 In model?

 So if I understand correctly first there has to be a default database, 
 but then after user selects the value a connection is set for the selected 
 database?



 On Monday, August 27, 2012 8:59:03 PM UTC+2, Massimo Di Pierro wrote:

 If this is a new app you may want to replace

 auth = Auth(baza, hmac_key=Auth.get_or_create_key())

 with

auth = Auth(baza)

 as it will be faster and same security because latest Auth has built-in 
 salting.

 About your problem. You cannot complete let the user specify it. You 
 must have a default and a set of default values:

 database = session.get('database','default_database')

 The you can have a form that stores the one they want into 
 session.database




 On Monday, 27 August 2012 10:09:34 UTC-5, Yebach wrote:

 Hello

 My problem is that my app has to go to specific database on postgres to 
 check for users. 
 you can visit my app on http://portal.iurnik.si/

 You can see that the user select a value from popup and then the app 
 goes to a specific database to read data.

 After that I want to create a login form. 

 I created it but,.

 I created a separate model users.py  with this code

 database = now it is hardcoded so it works all the time
 baza = DAL('postgres://postgres:postgres@localhost/'+ database, 
 migrate=True)
 auth = Auth(baza, hmac_key=Auth.get_or_create_key())
 auth.settings.controller=user
 auth.define_tables()

 But what I would like to do is read the database name from url and the 
 right url comes only after user selects the right value from popup. And 
 that is why the app chashes if I don't hard code the db name. Logically.

 What do you suggest? also after logout user would stay on the second 
 page not to go to default page (where do I set that parameter)

 Thank you



-- 





[web2py] Re: user login tables

2012-08-30 Thread Yebach
I don't understand what you mean with how is the user loging out? I used 
the {{='auth' in globals() and auth.navbar(separators=(' ',' | ',''))}}

On Wednesday, August 29, 2012 4:37:45 PM UTC+2, Anthony wrote:

 And not to go to default/index page but my specific school/index. I am 
 trying with auth.settings.logout_next=URL(r=request,c='school',f='index') 
 but it is not working. Where do I write this code? To controler or model? 
 If it is right at all


 You would put that code in the model, after defining auth. I would think 
 it should work. How is the user logging out?

 Anthony 


-- 





[web2py] Re: user login tables

2012-08-31 Thread Yebach
Yes

I kid of worked it trough, the login/logout part

It works fine :)

Thanks for all the help Anthony. I read a lot of your posts and got some 
useful answers

I will address my next question shortly :)

On Thursday, August 30, 2012 9:14:29 AM UTC+2, Anthony wrote:

 On Thursday, August 30, 2012 2:46:40 AM UTC-4, Yebach wrote:

 I don't understand what you mean with how is the user loging out? I used 
 the {{='auth' in globals() and auth.navbar(separators=(' ',' | ',''))}}


 Does that mean the user is logging out by clicking the Logout link in 
 the navbar generated by auth.navbar()? 


-- 





[web2py] web2py login and register forms as part of main page

2012-09-04 Thread Yebach
Hello

I would like to create a login/register forms as part of a current page not 
to be redirected to a new page where you login or register and then be 
redirected back to the main page.

Now I have auth.navbar() but that one takes you to a new page

any suggestion??

Thank you

-- 





[web2py] Re: web2py login and register forms as part of main page

2012-09-05 Thread Yebach
Thank you for your fast reply

With main page function you mean I include them in my mainpage.py contorler?


OR do I just do a check if user is logged in and show the proper one if he 
is?

thanx again


On Tuesday, September 4, 2012 4:30:48 PM UTC+2, Anthony wrote:

 auth.login() and auth.register() generate and process the login and 
 register forms, respectively. You main page function could return those 
 forms and include them in the view.

 Anthony

 On Tuesday, September 4, 2012 9:56:36 AM UTC-4, Yebach wrote:

 Hello

 I would like to create a login/register forms as part of a current page 
 not to be redirected to a new page where you login or register and then be 
 redirected back to the main page.

 Now I have auth.navbar() but that one takes you to a new page

 any suggestion??

 Thank you



-- 





[web2py] web2py login redirect

2012-09-05 Thread Yebach
Hello

My login function doesn't work. After I try to login i am redirected to 
user/user/profile instead back to my main page /school/index.html
Register works, everything
Also, if I login and enter the url where I should be redirected again I am 
redirected to /user/user/profile

any suggestion??

Thank you

-- 





[web2py] Re: web2py login redirect

2012-09-05 Thread Yebach

my view user.html

div class=web2py_user_form id=web2py_user_form
h2{{=T( request.args(0).replace('_',' ').capitalize() )}}/h2
{{=form}} 
{{if request.args(0)=='login':}} 
{{if not 'register' in auth.settings.actions_disabled:}}
div class=flash_1 id=flash_1{{=response.flash or ''}}/div
br / a href={{=URL(args='register')}}{{=T('Register')}}/a
{{pass}} 
{{if not 'request_reset_password' in auth.settings.actions_disabled:}} br 
/ 
a href={{=URL(args='request_reset_password')}}{{=T('Lost 
Password')}}/a 
{{pass}} 
{{pass}}
div id=logo_algit
a href=http://www.algit.eu; target=_blankimg
src={{=URL(request.application,'static','images/algit.gif')}}
alt=Algit.eu /
/a
/div

my model user.py

from gluon.tools import Auth
import urllib

if (request.controller=='user' or request.controller=='school'  or 
request.controller=='timetable' and request.cookies.has_key('mycookie')):
response.generic_patterns = ['*'] if request.is_local else []
database = request.cookies['mycookie'].value
baza = DAL('postgres://postgres:postgres@localhost/' + database, 
migrate=True)
from gluon.tools import Mail

auth = Auth(baza, controller='user')



auth.settings.logout_next =  URL('school','index', 
vars=dict(school=database))
   

auth.settings.registration_requires_approval = True

   
auth.settings.register_onaccept=lambda form: 
mail.send(to=['vid.og...@algit.si'],
  subject='web2py registration',
  # If reply_to is omitted, then mail.settings.sender is used
  reply_to='u...@example.com',
  message='Kreiral se je nov uporabnik, ki ga je potrebno 
potrditi') 

auth.settings.expiration = 3600
auth.define_tables()

mail=Mail()
auth.settings.mailer=mail
mail.settings.server='smtp.gmail.com:587'
mail.settings.sender='x...@gmail.com'
mail.settings.login='x...@gmail.com:'



auth.messages.registration_pending = u'Registracija je v postopku 
odobritve. Ko bo vaš račun potrjen boste prejeli e-mail.'
auth.messages.invalid_login = 'Nepravilno geslo'
auth.messages.invalid_user = 'Uporabnik ne obstaja'

   
## configure auth policy

## if you need to use OpenID, Facebook, MySpace, Twitter, Linkedin, etc.
## register with janrain.com, write your domain:api_key in 
private/janrain.key
from gluon.contrib.login_methods.rpx_account import use_janrain
use_janrain(auth,filename='private/janrain.key')


and my controler user.py
def user():
form = auth()
#auth.settings.controller=user
return dict(form=form)


On Wednesday, September 5, 2012 2:40:09 PM UTC+2, Anthony wrote:

 First suggestion -- post your code. :-)

 On Wednesday, September 5, 2012 8:15:40 AM UTC-4, Yebach wrote:

 Hello

 My login function doesn't work. After I try to login i am redirected to 
 user/user/profile instead back to my main page /school/index.html
 Register works, everything
 Also, if I login and enter the url where I should be redirected again I 
 am redirected to /user/user/profile

 any suggestion??

 Thank you



-- 





[web2py] Re: web2py login redirect

2012-09-06 Thread Yebach
I searched if I call the auth.register() function, but i don't. not in 
view, not in controler not in model. I have absolutely no idea what could 
and where is the problem

On Wednesday, September 5, 2012 2:15:40 PM UTC+2, Yebach wrote:

 Hello

 My login function doesn't work. After I try to login i am redirected to 
 user/user/profile instead back to my main page /school/index.html
 Register works, everything
 Also, if I login and enter the url where I should be redirected again I am 
 redirected to /user/user/profile

 any suggestion??

 Thank you


-- 





[web2py] web2py login in main view

2012-09-10 Thread Yebach
Hello

I would like to have login (username, password) fields in my main view and 
not to be redirected to new page for login. But if you need to register 
then to be redirected to new page

any suggestions?

Thank you


-- 





[web2py] registration message

2012-09-20 Thread Yebach
Hello

After a new user is created I want to show the flash message and redirect a 
user back to home page.

The redirection is done with
auth.settings.register_next = URL('school','index', 
vars=dict(school=database))
and 
for message 
 auth.messages.registration_pending ('bklabafbaklva')

but the message is not shown? why?

thank you

-- 





Re: [web2py] Send Email After Registration

2012-09-20 Thread Yebach
Hello

I am getting an error 

 User_Email = auth.user.email
AttributeError: 'NoneType' object has no attribute 'email'




On Thursday, September 20, 2012 11:15:31 AM UTC+2, Alec Taylor wrote:

 Nicely done. 

 On Thu, Sep 20, 2012 at 7:13 PM, hasan alnator 
 haln...@gardeniatelco.com javascript: wrote: 
  Ok I DID it like this : 
  
  auth.settings.register_next = URL('Welcome') 
  
  def Welcome(): 
  User_Email = auth.user.email 
  mail.send(User_Email,'Welcome To website','Welcome To website') 
  if request.vars.lan == 'En': 
  redirect('index',vars={'lan':'En'}) 
  else: 
  redirect('index') 
  
  
  Best Regards, 
  
  On Thu, Sep 20, 2012 at 11:09 AM, hasan alnator 
 haln...@gardeniatelco.com javascript: 
  wrote: 
  
  Dear Alec , 
  
  I Dont want email verification , i just want to send an email that says 
  welcome . 
  
  Best Regards, 
  
  
  -- 
  
  
  


-- 





Re: [web2py] Send Email After Registration

2012-09-21 Thread Yebach
I have a  auth.settings.registration_requires_approval = True 

I just want that after a user registers a message would be printed smth 
like: Your registration is being processed...bla bla bal

I set the parameter  auth.messages.registration_pending = u'Registracija je 
v postopku odobritve. Ko bo vaš račun potrjen boste o tem obveščeni preko 
e-maila.'
And nothing happens

Also email to the user is not sent.

On Friday, September 21, 2012 8:10:58 AM UTC+2, Alec Taylor wrote:

 Throw in a decorator to that function 

 @auth.requires_login() 

 On Fri, Sep 21, 2012 at 12:15 AM, hasan alnator 
 haln...@gardeniatelco.com javascript: wrote: 
  Dear  Yebach  , 
  
  Are you logged in ? 
  
  Best Regards, 
  
  
  On Thu, Sep 20, 2012 at 5:13 PM, Yebach vid@gmail.com javascript: 
 wrote: 
  
  Hello 
  
  I am getting an error 
  
   User_Email = auth.user.email 
  AttributeError: 'NoneType' object has no attribute 'email' 
  
  
  
  
  On Thursday, September 20, 2012 11:15:31 AM UTC+2, Alec Taylor wrote: 
  
  Nicely done. 
  
  On Thu, Sep 20, 2012 at 7:13 PM, hasan alnator 
  haln...@gardeniatelco.com wrote: 
   Ok I DID it like this : 
   
   auth.settings.register_next = URL('Welcome') 
   
   def Welcome(): 
   User_Email = auth.user.email 
   mail.send(User_Email,'Welcome To website','Welcome To website') 
   if request.vars.lan == 'En': 
   redirect('index',vars={'lan':'En'}) 
   else: 
   redirect('index') 
   
   
   Best Regards, 
   
   On Thu, Sep 20, 2012 at 11:09 AM, hasan alnator 
   haln...@gardeniatelco.com 
   wrote: 
   
   Dear Alec , 
   
   I Dont want email verification , i just want to send an email that 
   says 
   welcome . 
   
   Best Regards, 
   
   
   -- 
   
   
   
  
  -- 
  
  
  
  
  
  -- 
  
  
  


-- 





[web2py] web2py inserting values into sessions

2012-09-21 Thread Yebach
I am having problems with session

After a user selects smth from drop down menu I have to insert that value 
to session.
I need that value to get to the database for auth tables in model (it 
crashes when I go to login/register form if I read from request.var). Where 
do I insert the value in session and how (view, controler).

For now I solved it using cookies but it is not the most secure.

Any suggestions?

thank you

-- 





Re: [web2py] web2py inserting values into sessions

2012-09-21 Thread Yebach
Yes I know but have to insert it in a view, because using javascript there 
is where I select a value from drop down. The problem is that the value is 
not inserted and cannot be read in model

On Friday, September 21, 2012 12:07:28 PM UTC+2, Johann Spies wrote:

 On 21 September 2012 10:50, Yebach vid@gmail.com javascript:wrote:

 I am having problems with session

 After a user selects smth from drop down menu I have to insert that value 
 to session.
 I need that value to get to the database for auth tables in model (it 
 crashes when I go to login/register form if I read from request.var). Where 
 do I insert the value in session and how (view, controler).

 For now I solved it using cookies but it is not the most secure.

 Any suggestions?


 I am not sure whether I understand your problem correctly but you can do:

 session.chosen_value = whatever value you want to put there

 where 'chosen_value'  might be any variable name you want to assign.

 Regards
 Johann 

 -- 
 Because experiencing your loyal love is better than life itself, 
 my lips will praise you.  (Psalm 63:3)



-- 





[web2py] post login redirection doesn't work

2012-09-21 Thread Yebach
Hello

I put my working web2py app to production on linux server

Everything works except the login_next redirection

This is my code on my cmp

auth.settings.login_url=URL('school','index?school=' + database)
auth.settings.logout_next =  URL('school','index', 
vars=dict(school=database))

and it works like a charm

but on server I even added login_next
auth.settings.login_next =  URL('school','index', 
vars=dict(school=database))
but it is redirected me to 
/iurnik/user/index http://portal.iurnik.si/iurnik/user/index where I get 
invalid function error (ofcourse it doesn't exist)

Any suggestions?

Thank you

-- 





[web2py] Re: post login redirection doesn't work

2012-09-21 Thread Yebach
Don't ask me but it works

I have no idea  what happened 

auth.settings.login_url = URL('school','index?school=' + database)
auth.settings.login_next = URL('school','index?school=' + database)
auth.settings.logout_next =  URL('school','index', 
vars=dict(school=database))

I tried this before it didn't work now it works. beats me

On Friday, September 21, 2012 1:45:08 PM UTC+2, Yebach wrote:

 Hello

 I put my working web2py app to production on linux server

 Everything works except the login_next redirection

 This is my code on my cmp

 auth.settings.login_url=URL('school','index?school=' + database)
 auth.settings.logout_next =  URL('school','index', 
 vars=dict(school=database))

 and it works like a charm

 but on server I even added login_next
 auth.settings.login_next =  URL('school','index', 
 vars=dict(school=database))
 but it is redirected me to 
 /iurnik/user/index http://portal.iurnik.si/iurnik/user/index where I 
 get invalid function error (ofcourse it doesn't exist)

 Any suggestions?

 Thank you


-- 





[web2py] log out user

2012-09-21 Thread Yebach
Hello

You can see my app on portal.iurnik.si  http://portal.urnik.si

I have the following problem 
after user selects a school app connects to a specific database where data 
is read from. On that database the auth tables are created so registered 
users can download some documents.
The problems occurs if I log in on one school (database) and then I go back 
to main page, select a new database I am already logged in. How?? I mean 
auth tables are created on db but the user is not. How can I solve this?

I am reading database name from cookie

Thank you


-- 





[web2py] Re: log out user

2012-09-24 Thread Yebach
Where do I insert the code? In model?

this is now my code in db.py

if session['school_db'] != request.cookies['mycookie'].value:
auth.logout()
session['school_db'] = request.cookies['mycookie'].value

But I get an error 
'NoneType' object has no attribute 'insert'

seems like smth is wrong with auth.logout()

On Friday, September 21, 2012 6:03:59 PM UTC+2, Massimo Di Pierro wrote:

 After login your user info is loaded into session. You need to add 
 something like

 if session.dbname != current_db_name:
 auth.logout()
 session.dbname = current_db_name


 On Friday, 21 September 2012 07:47:08 UTC-5, Yebach wrote:

 Hello

 You can see my app on portal.iurnik.si  http://portal.urnik.si

 I have the following problem 
 after user selects a school app connects to a specific database where 
 data is read from. On that database the auth tables are created so 
 registered users can download some documents.
 The problems occurs if I log in on one school (database) and then I go 
 back to main page, select a new database I am already logged in. How?? I 
 mean auth tables are created on db but the user is not. How can I solve 
 this?

 I am reading database name from cookie

 Thank you




-- 





Re: [web2py] Send Email After Registration

2012-09-24 Thread Yebach
For controler you mean the user controler?
Or do I create a new one?

this is my current user controler
def user():
form = auth()
if request.vars.msg:
response.flash =  'u'Registracija je v postopku odobritve. Ko bo 
vaš račun potrjen boste o tem obveščeni preko e-maila.
   
#auth.settings.controller=user
return dict(form=form,locals = locals())

and for auth.settings.register_next = URL('user',vars={'msg':'welcome'})

There is no message

On Friday, September 21, 2012 4:22:41 PM UTC+2, Hassan Alnatour wrote:

 Sorry i mean in db.py :

 auth.settings.register_next = URL('index',vars={'msg':'welcome'}) 


 Best Regards,



 On Fri, Sep 21, 2012 at 5:21 PM, hasan alnator 
 haln...@gardeniatelco.comjavascript:
  wrote:

 Dear Yebach , 

 in db.py : 

 auth.settings.register_next = URL('Welcome',vars={'msg':'welcome'})

 in controller :

 def index():
 if request.vars.msg:
   response.flash =  'u'Registracija je v postopku odobritve. Ko bo 
 vaš račun potrjen boste o tem obveščeni preko e-maila.
 return locals()



 On Fri, Sep 21, 2012 at 9:46 AM, Yebach vid@gmail.com 
 javascript:wrote:

 I have a  auth.settings.registration_requires_approval = True 

 I just want that after a user registers a message would be printed smth 
 like: Your registration is being processed...bla bla bal

 I set the parameter  auth.messages.registration_pending = u'Registracija 
 je v postopku odobritve. Ko bo vaš račun potrjen boste o tem obveščeni 
 preko e-maila.'
 And nothing happens

 Also email to the user is not sent.

 On Friday, September 21, 2012 8:10:58 AM UTC+2, Alec Taylor wrote:

 Throw in a decorator to that function 

 @auth.requires_login() 

 On Fri, Sep 21, 2012 at 12:15 AM, hasan alnator 
 haln...@gardeniatelco.com wrote: 
  Dear  Yebach  , 
  
  Are you logged in ? 
  
  Best Regards, 
  
  
  On Thu, Sep 20, 2012 at 5:13 PM, Yebach vid@gmail.com wrote: 
  
  Hello 
  
  I am getting an error 
  
   User_Email = auth.user.email 
  AttributeError: 'NoneType' object has no attribute 'email' 
  
  
  
  
  On Thursday, September 20, 2012 11:15:31 AM UTC+2, Alec Taylor 
 wrote: 
  
  Nicely done. 
  
  On Thu, Sep 20, 2012 at 7:13 PM, hasan alnator 
  haln...@gardeniatelco.com wrote: 
   Ok I DID it like this : 
   
   auth.settings.register_next = URL('Welcome') 
   
   def Welcome(): 
   User_Email = auth.user.email 
   mail.send(User_Email,'Welcome To website','Welcome To 
 website') 
   if request.vars.lan == 'En': 
   redirect('index',vars={'lan':'**En'}) 
   else: 
   redirect('index') 
   
   
   Best Regards, 
   
   On Thu, Sep 20, 2012 at 11:09 AM, hasan alnator 
   haln...@gardeniatelco.com 
   wrote: 
   
   Dear Alec , 
   
   I Dont want email verification , i just want to send an email 
 that 
   says 
   welcome . 
   
   Best Regards, 
   
   
   -- 
   
   
   
  
  -- 
  
  
  
  
  
  -- 
  
  
  

  -- 
  
  
  





-- 





[web2py] Re: log out user

2012-09-24 Thread Yebach
If I put session.clear() into the controler of the default page it works

Is that I good solution? It is true that a user has to log in again but it 
kind of works

On Monday, September 24, 2012 8:48:03 AM UTC+2, Yebach wrote:

 Where do I insert the code? In model?

 this is now my code in db.py

 if session['school_db'] != request.cookies['mycookie'].value:
 auth.logout()
 session['school_db'] = request.cookies['mycookie'].value

 But I get an error 
 'NoneType' object has no attribute 'insert'

 seems like smth is wrong with auth.logout()

 On Friday, September 21, 2012 6:03:59 PM UTC+2, Massimo Di Pierro wrote:

 After login your user info is loaded into session. You need to add 
 something like

 if session.dbname != current_db_name:
 auth.logout()
 session.dbname = current_db_name


 On Friday, 21 September 2012 07:47:08 UTC-5, Yebach wrote:

 Hello

 You can see my app on portal.iurnik.si  http://portal.urnik.si

 I have the following problem 
 after user selects a school app connects to a specific database where 
 data is read from. On that database the auth tables are created so 
 registered users can download some documents.
 The problems occurs if I log in on one school (database) and then I go 
 back to main page, select a new database I am already logged in. How?? I 
 mean auth tables are created on db but the user is not. How can I solve 
 this?

 I am reading database name from cookie

 Thank you




-- 





[web2py] Re: registration message

2012-09-24 Thread Yebach
All I needed was actually add{{=response.flash or ' '}} in my view and 
it worked

but thanx for the hint

On Monday, September 24, 2012 3:46:20 PM UTC+2, Hassan Alnatour wrote:


 Dear Yebach ,

 just add this in the default/school in the controller : 

  if request.vars.school == 'database': 
response.flash = 'your_Massage!'


 Notes : 

 check if you have {{=response.flash or ' '}} in you school page so it can 
 show the response you sent from the controller .

 Best Regards,

 On Thursday, September 20, 2012 12:05:22 PM UTC+3, Yebach wrote:

 Hello

 After a new user is created I want to show the flash message and redirect 
 a user back to home page.

 The redirection is done with
 auth.settings.register_next = URL('school','index', 
 vars=dict(school=database))
 and 
 for message 
  auth.messages.registration_pending ('bklabafbaklva')

 but the message is not shown? why?

 thank you



-- 





[web2py] get new user's email and data

2013-01-24 Thread Yebach
Hello

After a new user registers, I would like to send his data to my email (user 
email and database where it was created)
I have user requires confirmation set to true and I have a couple of 
databases so that is a must, also to check on user I need to get his e-mail 
to inform him his registration was confirmed

thank you

best regards

-- 





[web2py] Re: How to multi-line session.flash

2013-01-24 Thread Yebach
I send string to flash from my model on auth.messages.registration_pending. 

Since it is quite long i want to make it multiline. \n in my string do not 
work

how to handle that?

thank you

best regarst

On Tuesday, November 24, 2009 5:23:38 PM UTC+1, mdipierro wrote:

 response.flash = DIV(hello,BR(),world) 

 On Nov 24, 3:53 am, hamdy.a.farag hamdy.a.fa...@inbox.com wrote: 
  Hi 
  
  How can I make response.flash display a message containing new line 
  characters ?

-- 





Re: [web2py] get new user's email and data

2013-01-24 Thread Yebach
Do I insert this code in my model (db.py)?

my auth.setting.register_onaccept = lambda form: 
mail.send(to=['x...@xxx.net'],
  subject='web2py registration',
  # If reply_to is omitted, then mail.settings.sender is used
  reply_to='u...@example.com',
  message= u'A new user has been created on database %s and has to 
be confirmed' % (database)) # Here I want to add user Name and surname 
and his email

On Thursday, January 24, 2013 12:59:32 PM UTC+1, rochacbruno wrote:

 def myfunc(form):
 # here you get form.vars 

 auth.settings.register_onaccept = myfunc 
 Em 24/01/2013 06:24, Yebach vid@gmail.com javascript: escreveu:

 Hello

 After a new user registers, I would like to send his data to my email 
 (user email and database where it was created)
 I have user requires confirmation set to true and I have a couple of 
 databases so that is a must, also to check on user I need to get his e-mail 
 to inform him his registration was confirmed

 thank you

 best regards

 -- 
  
  
  



-- 





Re: [web2py] get new user's email and data

2013-01-24 Thread Yebach
Thank you
you saved my day :)



On Thursday, January 24, 2013 2:31:16 PM UTC+1, rochacbruno wrote:

 auth.setting.register_onaccept = lambda form: 
 mail.send(to=['x...@xxx.netjavascript:
 '],
   subject='web2py registration',
   # If reply_to is omitted, then mail.settings.sender is used
   reply_to='u...@example.com javascript:',
   message= u'A new user has been created on database %s and has to 
 be confirmed - User name: %s, email: %s' % (database, form.vars.first_name 
 +  _ + form.vars.last_name, form.vars.email))


-- 





[web2py] web2py user login form encoding problem

2013-03-29 Thread Yebach
hello

I have a login form for user registration

If user writes name surname password including signs š, č, ž, ć  there is 
an error 'ascii' codec can't decode byte 0xc5 in position 0: ordinal not in 
range(128)

Where can I set the encoding for form??

thank you

-- 

--- 
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/groups/opt_out.




[web2py] login form registration problem with encoding

2013-05-08 Thread Yebach
Hello

I was scouting the internet(s) and could not found the solution for my 
problem

So I am using web2py server on Linux. I also have a postgreSQL server on 
linux and when a user tries to login via login form and uses letters in 
name and surname such as š ž č ć  the following error appears 'ascii' codec 
can't decode byte 0xc5 in position 0: ordinal not in range(128)

Now the same web2py code is running on windows 7 (on my computer, including 
postgres database) and I do NOT receive that kind of error. 

I really need your help because I am getting some nervous calls from my 
clients :) 

thank you very much 

best regards

-- 

--- 
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/groups/opt_out.




Re: [web2py] login form registration problem with encoding

2013-05-09 Thread Yebach
The problem occurs when after filling the register form user clicks 
register button.

this is the basic problem of error

(dp1
S'output'
p2
Stype 'exceptions.UnicodeDecodeError' 'ascii' codec can't decode byte 
0xc5 in position 2: ordinal not in range(128)
p3
sS'layer'
p4
S'/usr/local/web2py/applications/iurnik/controllers/user.py'
p5
sS'code'
p6
S'def user():\nform = auth()\n#auth.settings.controller=user\n   
 return dict(form=form)\n\n\nresponse._vars=response._caller(user)\n'
p7
sS'snapshot'
p8
(dp9
S'exception'
p10
(dp11
S'__getslice__'
p12
Smethod-wrapper '__getslice__' of exceptions.UnicodeDecodeError object


Thank you



On Wednesday, May 8, 2013 1:11:26 PM UTC+2, Ricardo Pedroso wrote:

 On Wed, May 8, 2013 at 7:24 AM, Yebach vid@gmail.com javascript: 
 wrote: 
  Hello 
  
  So I am using web2py server on Linux. I also have a postgreSQL server on 
  linux and when a user tries to login via login form and uses letters in 
 name 
  and surname such as š ž č ć  the following error appears 'ascii' codec 
 can't 
  decode byte 0xc5 in position 0: ordinal not in range(128) 
  
  Now the same web2py code is running on windows 7 (on my computer, 
 including 
  postgres database) and I do NOT receive that kind of error. 
  

 Can you make a minimal application that replicate the issue? 
 Can you show us the traceback? 
 When exactly the error happen? In the login POST request, or after it, 
 in the redirect 


-- 

--- 
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/groups/opt_out.




Re: [web2py] login form registration problem with encoding

2013-05-15 Thread Yebach
I did the following.

I changed the destination of database from my PC. So from my app on my 
local machine that works on Windows 7 I connect to Postrge database on 
Linux. After running it and trying to register using characters ščćž ŠČĆŽ 
there are no problems, also the same type of representations is written in 
db table auth_user on Linux server

So where should I be looking for source of the problem?

thank you

On Wednesday, May 15, 2013 9:37:02 AM UTC+2, Niphlod wrote:

 for all intents and purposes AVOID inlining content if it's meant to be a 
 binary ^_^. Attachments are there for a reason (and also for text files  
 0.5 KB)...

-- 

--- 
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/groups/opt_out.




Re: [web2py] login form registration problem with encoding

2013-05-15 Thread Yebach
Thanx

I removed the 'u' infront of string and it works

thanx again

On Wednesday, May 15, 2013 11:29:34 AM UTC+2, Ricardo Pedroso wrote:

  Thank you for showing interest in resolving this. I apologize for not 
 answering faster 
  
  @Massimo - where do I set layout encoding? 
  
  
  This is the whole error trace 

 What you show us was not your traceback, here is your traceback, 
 not that hard and concise and just to the point, right? 

 Traceback (most recent call last): 
   File /usr/local/web2py/gluon/restricted.py, line 205, in restricted 
 exec ccode in environment 
   File /usr/local/web2py/applications/iurnik/controllers/user.py, 
 line 8, in module 
   File /usr/local/web2py/gluon/globals.py, line 173, in lambda 
 self._caller = lambda f: f() 
   File /usr/local/web2py/applications/iurnik/controllers/user.py, 
 line 3, in user 
 form = auth() 
   File /usr/local/web2py/gluon/tools.py, line 1161, in __call__ 
 return getattr(self,args[0])() 
   File /usr/local/web2py/gluon/tools.py, line 1967, in register 
 callback(onaccept,form) 
   File /usr/local/web2py/gluon/tools.py, line 57, in callback 
 [action(form) for action in actions] 
   File /usr/local/web2py/applications/iurnik/models/db.py, line 143, 
 in lambda 
 message=u\'Na bazi %s se je kreiral nov uporabnik %s %s z e-mailom 
 %s , ki ga je potrebno potrditi\' % (database, form.vars.first_name , 
 form.vars.last_name, form.vars.email)) 
 UnicodeDecodeError: \'ascii\' codec can\'t decode byte 0xc5 in 
 position 0: ordinal not in range(128) 


 I think your problem is in models/db.py in the following line: 

   message=u'Na bazi %s se je kreiral nov uporabnik %s %s z e-mailom %s 
 , ki ga je potrebno potrditi' % (database, form.vars.first_name, 
 form.vars.last_name, form.vars.email)) 

 try to remove the u in front of the string: 

   message = 'Na bazi . 

 or decode the form vars, ex: 

  % (, form.vars.first_name.decode('utf-8'), ) 


 Ricardo 


-- 

--- 
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/groups/opt_out.




[web2py] web2py ACE editor

2013-11-18 Thread Yebach
Hello

I got the following task

In my home page created with web2py I need to embed ACE editor. Then the 
code written in ace editor needs to be saved somewhere on server side.

I copied all ACE needed files to my static folder

In my view (html) I inserted the following code with source of course

$(document).ready (function () {
$('#textArea').each(function () {
var textarea = $(this);
 
var mode = textarea.data('editor');

var editDiv = $(div, {
position: 'absolute',
width: textarea.width(),
height: textarea.height(),
'class': textarea.attr('class')
}).insertBefore(textarea);
 
textarea.css('visibility', 'hidden');
 
var editor = ace.edit(editDiv[0]);
editor.renderer.setShowGutter(false);
editor.getSession().setValue(textarea.val());
editor.getSession().setMode(ace/mode/javascript);
editor.setTheme(ace/theme/dawn);
})
 
});

textarea name=my-xml-editor id =textArea data-editor=xml rows=50 
cols=50/textarea


now I need to get the text from this editor to write it into file and save 
it.

I need some direction how to do this. What is the best way? I am a total 
newbe here so please bare with me.

Thank you


-- 
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/groups/opt_out.


[web2py] calling controller from view to retrieve data

2013-11-26 Thread Yebach
Hello

I menage to call my function that is in my default.py controler  from my 
view but I cannot  retrieve data that this function is suppose to retrieve

function is called on button click to load some text from database into ACE 
editor 

this is some of my code in controler.py 

def load_last():
PgSQL = db_conn()
cur = PgSQL.cursor()
sql_read = SELECT file_text FROM datoteke WHERE id = (SELECT max(id) 
FROM datoteke)
cur.execute(sql_read)
ver = cur.fetchone()[0]
print ver

return dict(data = ver)

in my editor.html view my java script code that should get data from def 
load_last functions is

function load_last() {
   var editor = ace.edit(editor);
   editor.setValue();
   $.ajax({
   url: {{=URL('default', 'load_last')}},
   data: {}, //*WHAT DO I WRITE HERE*
   success: function(){
   console.log(neki je ratal);
   },
   dataType: 'html'
 });
}


I am really stuck here

In addidtion another question. What would you recommend,  a user writes 
some text in my ace editor that is saved in a database. Text is varified 
for errors with engine on server and if there is an error user has to be 
prompted to correct them, only after that he can save data. What would be 
the best way to do that. 

Also user can read file from database to update an existing file. any 
recomendations

please help
thank you

-- 
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/groups/opt_out.


Re: [web2py] calling controller from view to retrieve data

2013-11-26 Thread Yebach
You mean I insert  the controller code into model?


-- 
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/groups/opt_out.


[web2py] server returns error but query is commited

2013-12-01 Thread Yebach
Hello

I have a db insert statement in my controller code. After user inserts 
text, clicks save it is saved into database, but the javascript part of the 
code returns error. This only occurs if page is accessed from another 
computer.If I run it from localhost of the server no error is returned

Any ideas?

here is my code

the controller in default.py


def add_item():

acedata =  request.body.read()
data = gluon.contrib.simplejson.loads(acedata)
ace_script =  str(data[podatki])
#print ace_script
#print tukej
PgSQL = db_conn() ##
cur = PgSQL.cursor()
print cur

sql = 
INSERT INTO datoteke(
file_name, file_text)
VALUES ('%s', '%s'); % ('neki', ace_script)
#print sql
cur.execute(sql)
PgSQL.commit()
PgSQL.close()
print DONE!!!
return dict()

and my js part

 function add_item(url, item_id, some_detail) {
  var test = saveContent();
  var dat = {'podatki' : test};
  console.log(dat);
  var data = JSON.stringify(dat);
  console.log(url);
  doPost({{=URL('default', 'add_item')}}, data);
  
 }

function doPost(callback, data) {
  $.post(callback, data, function(data){})
  .done(function() { alert(Done!); })
  .fail(function() { alert(Failed!);})
 }



-- 
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/groups/opt_out.


[web2py] user profile fields for referenced table

2013-12-03 Thread Yebach
Hello

I have the following question

In user register I show only some fields for user, but in user profile I 
would like to add more fields. 

This fields come from tables referenced on auth_user table

my db.py code so far is

db.define_table('auth_user',
Field('username', type='string',
  label=T('Username')),
Field('first_name', type='string',
  label=T('First Name')),
Field('last_name', type='string',
  label=T('Last Name')),
Field('email', type='string',
  label=T('Email')),
Field('password', type='password',
  readable=False,
  label=T('Password')),
Field('created_on','datetime',default=request.now,
  label=T('Created On'),writable=False,readable=False),
Field('modified_on','datetime',default=request.now,
  label=T('Modified On'),writable=False,readable=False,
  update=request.now),
Field('registration_key',default='',
  writable=False,readable=False),
Field('reset_password_key',default='',
  writable=False,readable=False),
Field('registration_id',default='',
  writable=False,readable=False),
Field('organization', 'reference organization'),   reference to 
table organization
format='%(username)s',
migrate=settings.migrate)


##fileds from table organization
auth.settings.extra_fields['auth_user']= [
Field('o_name','reference organization'),
Field('o_telnumber','reference organization'),
Field('o_street','reference organization'),
Field('o_city','reference organization'),
Field('o_state','reference organization'),
Field('o_country','reference organization'),
Field('o_TaxNumber','reference organization'),
Field('o_note','reference organization'),
]


## table organization


db.define_table('organization',
 Field('o_id_o',type='integer' ),
 Field('o_usern',type='integer' ),
 Field('o_daten',type='date'),
 Field('o_useru',type='integer' ),
 Field('o_dateu',type='date' ),
 Field('o_status',type='integer' ),
 Field('o_code',type='string', length = 64 ),
 Field('o_name',type='string', length = 256 ),
 Field('o_telnumber',type='string', length = 64 ),
 Field('o_faxnumber',type='string', length = 64 ),
 Field('o_street',type='string', length = 64 ),
 Field('o_post',type='string', length = 64 ),
 Field('o_city',type='string', length = 64 ),
 Field('o_state',type='string', length = 64 ),
 Field('o_country',type='string', length = 64 ),
 Field('o_TaxNumber',type='string', length = 64 ),
 Field('o_rootid',type='integer' ),
 Field('o_parentid',type='integer' ),
 Field('o_levelid',type='integer'), 
 Field('o_positionx',type='string', length = 64 ),
 Field('o_positiony',type='string', length = 64 ),
 Field('o_note',type = 'text'),
 migrate=settings.migrate)


auth.define_tables(migrate = settings.migrate)

On user profile only field organization is shown, but no additional fields

any suggestions what am I doing wrong??
thank you

-- 
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/groups/opt_out.


[web2py] Re: user profile fields for referenced table

2013-12-03 Thread Yebach
I left the default auth.create_table(migrate = setting.migrate)
then added extra fields
then deffined my table organization

in user profile only first name, last name and email are shown

where am I going wrong?



On Tuesday, December 3, 2013 11:14:45 AM UTC+1, 黄祥 wrote:

 i think you shouldn't define the auth_user table, just keep it default, 
 and if you want to add the new field of auth_user table, please use 
 extra_fields. e.g.
 # append fields : auth.signature
 db._common_fields.append(auth.signature)

 # custom auth user table add fields gender, address, zip_code, city, 
 country, phone, branch, bank, account_no
 auth.settings.extra_fields['auth_user'] = [ 
 Field('gender', 
   label = T('Gender'), 
   notnull = True, 
   required = True, 
   requires = IS_IN_SET({T('Male'), T('Female') } ) ), 
 Field('address', 'text', 
   label = T('Address'), 
   notnull = True, 
   represent = lambda address, field: A(address, _title=T(View Maps), 
 _target=_blank, _href=
 http://maps.google.com/maps?f=qhl=engeocode=time=date=ttype=q=%s,+%s,+%s;
  
 % (field.address, field.city, field.country) ), 
   required = True, 
   requires = IS_NOT_EMPTY() ), 
 Field('zip_code', 
   label = T('Zip Code'), 
   notnull = True, 
   required = True, 
   requires = IS_MATCH('^\d{5,5}$', error_message = 'not a Zip Code') ), 
 Field('city', 
   label = T('City'), 
   notnull = True, 
   required = True, 
   requires = IS_NOT_EMPTY() ), 
 Field('country', 
   label = T('Country'), 
   notnull = True, 
   required = True, 
   requires = IS_NOT_EMPTY() ), 
 Field('phone', 'list:string', 
   label = T('Phone'), 
   notnull = True, 
   required = True), 
 Field('branch', 'reference branch', 
   label = T('Branch'), 
   notnull = True, 
   required = True, 
   requires = IS_IN_DB(db, db.branch.id, '%(address)s') ), 
 Field('bank', 'reference bank', 
   label = T('Bank'), 
   notnull = True, 
   represent = lambda bank, field: A(bank.bank, _title=T(eBanking), 
 _target=_blank, _href=%s % bank.ebanking), 
   required = True, 
   requires = IS_IN_DB(db, db.bank.id, '%(bank)s') ), 
 Field('account_no', 
   label = T('Account No'), 
   notnull = True, 
   required = True, 
   requires = IS_NOT_EMPTY() ), 
 ]

 # create all tables needed by auth if not custom tables, add username field
 auth.define_tables(username = True, signature = True)

  custom_auth_table 
 custom_auth_table = db[auth.settings.table_user_name]
 # label
 custom_auth_table.first_name.label = T('First Name')
 custom_auth_table.last_name.label = T('Last Name')
 custom_auth_table.email.label = T('Email')
 # represent
 custom_auth_table.email.represent = lambda email, field: \
 A(email, _title=T(Send to %s) % email, _target=_blank, 
 _href=mailto:%s; % email)
 # requires
 custom_auth_table.phone.requires = IS_NOT_IN_DB(db, 
 custom_auth_table.phone)

 auth.settings.table_user = custom_auth_table

 best regards,
 stifan


-- 
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/groups/opt_out.


[web2py] Re: user profile fields for referenced table

2013-12-03 Thread Yebach
I meanaged to add fileds, but insted of being the fileds of referenced 
table they were added to auth_user table all of them of type integer

I want them to be read from table organization

code in db.py

auth.settings.extra_fields['auth_user']= [
Field('o_name','reference organization',label = T('Org 
name'),),
Field('o_telnumber','reference organization'),
Field('o_street','reference organization'),
Field('o_city','reference organization'),
Field('o_state','reference organization'),
Field('o_country','reference organization'),
Field('o_TaxNumber','reference organization'),
Field('o_note','reference organization'),
]

-- 
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/groups/opt_out.


[web2py] Re: user profile fields for referenced table

2013-12-03 Thread Yebach
So how do i resolve that

I have aut_user table that has a field organization (id)

In table organization I have more fields (org name, adress, etc)
Now I want to show this fields (almost all) of table organization to user 
in user profile view. 

??


On Tuesday, December 3, 2013 1:34:06 PM UTC+1, 黄祥 wrote:

 1 more thing, if you have reference field to another table it will refer 
 to the table id of your target, so i think it's useless if you define a lot 
 of auth user extra field to just 1 table, because it will return 1 value 
 which is the table id, in this case will be organization id.

 best regards,
 stifan


-- 
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/groups/opt_out.


[web2py] Re: user profile fields for referenced table

2013-12-03 Thread Yebach
where do you put he query  db.auth_user.branch_adress?



On Tuesday, December 3, 2013 1:54:57 PM UTC+1, 黄祥 wrote:

 i think it will make the database table denormalization (make data 
 redundancy) if you put almost all of your organization table value to your 
 auth_user table. 
 i think just refer the organization from auth_user table is more than 
 enough, and if you want to know this user belong to which organization 
 address, city, state, etc, then you can just query it.
 please examine the example code i gave first, you will see that my 
 auth_user table is refer to table branch, which is have almost the same 
 field like your (address, city, state), but in my case i just refer only 
 one, if i want to know where is this user works in, i can query it in my 
 example : db.auth_user.branch.address.
 e.g. 
 db.define_table('company', 
 Field('name'), 
 Field('website'), 
 Field('logo', 'upload'), 
 format = '%(name)s')

 db.define_table('bank', 
 Field('bank'), 
 Field('ebanking'), 
 format = '%(bank)s')

 db.define_table('branch', 
 Field('address', 'text'), 
 Field('zip_code'), 
 Field('city'), 
 Field('country'), 
 Field('phone', 'list:string'), 
 Field('fax', 'list:string'), 
 Field('email', 'list:string'), 
 Field('bank', 'list:reference bank'), 
 Field('company', 'reference company'), 
 format = '%(address)s')

 best regards,
 stifan


-- 
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/groups/opt_out.


[web2py] Re: user profile fields for referenced table

2013-12-03 Thread Yebach
where do you put he query  db.auth_user.branch_adress?

I want the user to add company, not to choose from avaliable companies, but 
the data is inserted into organization table



On Tuesday, December 3, 2013 1:54:57 PM UTC+1, 黄祥 wrote:

 i think it will make the database table denormalization (make data 
 redundancy) if you put almost all of your organization table value to your 
 auth_user table. 
 i think just refer the organization from auth_user table is more than 
 enough, and if you want to know this user belong to which organization 
 address, city, state, etc, then you can just query it.
 please examine the example code i gave first, you will see that my 
 auth_user table is refer to table branch, which is have almost the same 
 field like your (address, city, state), but in my case i just refer only 
 one, if i want to know where is this user works in, i can query it in my 
 example : db.auth_user.branch.address.
 e.g. 
 db.define_table('company', 
 Field('name'), 
 Field('website'), 
 Field('logo', 'upload'), 
 format = '%(name)s')

 db.define_table('bank', 
 Field('bank'), 
 Field('ebanking'), 
 format = '%(bank)s')

 db.define_table('branch', 
 Field('address', 'text'), 
 Field('zip_code'), 
 Field('city'), 
 Field('country'), 
 Field('phone', 'list:string'), 
 Field('fax', 'list:string'), 
 Field('email', 'list:string'), 
 Field('bank', 'list:reference bank'), 
 Field('company', 'reference company'), 
 format = '%(address)s')

 best regards,
 stifan


-- 
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/groups/opt_out.


[web2py] response.flash to another view

2013-12-04 Thread Yebach
Hello

After a new user registers I have a redirect to index page 
(redirect(URL(request.application, 'default', 'index'))). I would like the 
response.flash windows (popup or whatever you call it) such as thank you 
for filing the reg form  to be shown in the default index.html page.

any suggestions

thank you

-- 
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/groups/opt_out.


[web2py] Re: user profile fields for referenced table

2013-12-04 Thread Yebach
So based on your answers I menaged to do my form

The next question or problem I have is following. When user registers a new 
record is created in two tables (auth_user and organization). But when the 
user goes to profile page the form is empty and after filling it a new 
record is inserted in organization (only there) table. I would like to 
populate the form at the beginning and then update the table organization. 

how do I get the current user Id or users organization id or some other 
unique id to use it for update statement?

any suggestions?

thank you 

-- 
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/groups/opt_out.


[web2py] update table from sqlform

2013-12-05 Thread Yebach
Hello

I am trying to update records in user profile from form

I have two tables that need to be updated

auth_user and organization

record = db((db.auth_user.organization==db.organization.id)  
(db.auth_user.id == uid)).select().first()

if form.process().accepted:

record.update_record(**db.organization._filter_fields(form.vars))


I also tried the https://groups.google.com/forum/#!topic/web2py/hpH7a3Qz3Wg but 
kind of the same problem

I am getting the following error
type 'exceptions.KeyError' 'update_record'


thank you in advance

-- 
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/groups/opt_out.


[web2py] Re: update table from sqlform

2013-12-05 Thread Yebach


Hello

 I am trying to update records in user profile from form

 I have two tables that need to be updated

 auth_user and organization

 record = db((db.auth_user.organization==db.organization.id)  (
 db.auth_user.id == uid)).select().first()

 if form.process().accepted:
 
 record.update_record(**db.organization._filter_fields(form.vars))


 I also tried the 
 https://groups.google.com/forum/#!topic/web2py/hpH7a3Qz3Wg but kind of 
 the same problem

 I am getting the following error
 type 'exceptions.KeyError' 'update_record'

 

 Doing some  experiments even if there is no error the update does not 
 happen. the table's fields in db are not updated


 thank you in advance


-- 
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/groups/opt_out.


[web2py] SQLForm set default values from database

2013-12-06 Thread Yebach
Hello

I have a SQLFORM and I would like to set the default values for user 
profile that are already in database (it is a reference of 2 tables)


this is my current solution
record = db((db.auth_user.organization==db.organization.id)  
(db.auth_user.id == uid)).select().as_list()[0]
db.auth_user.first_name.default = record[auth_user][first_name]


now  since there is quite a lot of those fields i don't want to write 
sentance for each field. is it possible to do it with for loop or smth.

thank you

-- 
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/groups/opt_out.


[web2py] dropdown menu repopulate from database

2013-12-19 Thread Yebach
Hello

I have the following question

On my page I have a drop down menu where user selects some texts from db 
and it is then inserted into into ace editor. the user then saves the 
script using bootstrap modal with a new name.

After he enters the new name of the text it is saved, but the drop down 
menu list is not updated.

here is my code

this populates drop down 

ul class=dropdown-menu role=menu 
aria-labelledby=dropdownMenu1
{{for item in skripte:}}
li role=presentationa role=menuitem tabindex=-1 
href=#{{=item}}/a/li
{{pass}}
  /ul


my controler/editor.py  for editor.html is 

def editor():
uid =  auth.user_id
#print uid
record = db((db.script.sc_user == db.auth_user.id)  (db.script.sc_user 
== uid)).select(db.script.sc_name)
#print record
skripte = []
for rec in record:
skripte.append(rec.sc_name)

form=SQLFORM.factory(db.script.sc_name)

return dict(skripte = skripte, form = form)

thank you

-- 
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/groups/opt_out.


[web2py] check if db field is empty

2014-01-22 Thread Yebach
Hello

How do I check is database field is empty?

eng_out = db(db.script.id == 
id_skripte).select(db.script.sc_engine_output)
 print eng_out ,eng_out 

## this returns
##eng_out  script.sc_engine_output
##NULL

if eng_out is None: ## check for nullability
print field is Null


Thank you

-- 
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/groups/opt_out.


[web2py] Re: check if db field is empty

2014-01-22 Thread Yebach
I tryied with 

eng_out = db(db.script.id == 
id_skripte).select(db.script.sc_engine_output)[0]['sc_engine_output']
print eng_out , eng_out

if eng_out is None:
print Ni podatkov


but I am sure there has to be a better way. 

thanx again

-- 
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/groups/opt_out.


[web2py] user roles

2014-06-02 Thread Yebach
Hello

I am trying to get user's role looking into membership table etc.

Following all the codes on majority of forums my code does not work. 

this is my controller 

from gluon.tools import Auth

database = request.cookies['mycookie'].value
db = DAL('postgres://postgres:postg...@195.xxx.yyy.zzz/' + database, 
migrate=False)
auth = Auth(db)

def index():
if not auth.is_logged_in():

login_adress= auth.settings.login_url = URL('user','user', 
args='login') 
redirect (login_adress)

print auth.user_id ###Works

print auth.user_group ### result is bound method Auth.user_group of 
gluon.tools.Auth object at 0x0A307F28
print auth.has_membership(auth.id_group('Member'),auth.user.id)

type 'exceptions.AttributeError' 'NoneType' object has no attribute 'role'

Also, If I try with some DAL select sentances none of them work. error is 
usually

if code is 
 rows = db(db.auth_user).select()

or 

rows = db((db.auth_user.email == 
auth.user.email)(db.auth_membership.user_id == 
auth.user_id)(db.auth_group.id==db.auth_membership.group_id)).select(db.auth_group.ALL)

error is 

type 'exceptions.KeyError' 'auth_user'

what am I doing wrong here. It is a f#$# simple ask. Get user role so I 
can get a user a specific view based on that role (btw any suggestions on 
that would be nice).

thank you

-- 
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: user roles

2014-06-03 Thread Yebach
If I use your if statement in my controller, this is the error I get

type 'exceptions.AttributeError' 'Auth' object has no attribute 
'user_groups'

why??


On Monday, June 2, 2014 3:13:26 PM UTC+2, Michael Beller wrote:

 If the user is logged in, then auth.user_groups contains a dictionary of 
 the user's roles.  You can also use auth.has_membership('role name') to 
 check membership.

 You can search auth.user_groups for a role, e.g.,
 if any (role in ['customer_service', 'admin'] for role in auth.user_groups
 .itervalues()): 

 On Monday, June 2, 2014 8:53:55 AM UTC-4, Yebach wrote:

 Hello

 I am trying to get user's role looking into membership table etc.

 Following all the codes on majority of forums my code does not work. 

 this is my controller 

 from gluon.tools import Auth

 database = request.cookies['mycookie'].value
 db = DAL('postgres://postgres:postg...@195.xxx.yyy.zzz/' + database, 
 migrate=False)
 auth = Auth(db)

 def index():
 if not auth.is_logged_in():

 login_adress= auth.settings.login_url = URL('user','user', 
 args='login') 
 redirect (login_adress)
 
 print auth.user_id ###Works

 print auth.user_group ### result is bound method Auth.user_group of 
 gluon.tools.Auth object at 0x0A307F28
 print auth.has_membership(auth.id_group('Member'),auth.user.id)

 type 'exceptions.AttributeError' 'NoneType' object has no attribute 
 'role'

 Also, If I try with some DAL select sentances none of them work. error is 
 usually

 if code is 
  rows = db(db.auth_user).select()

 or 

 rows = db((db.auth_user.email == 
 auth.user.email)(db.auth_membership.user_id == auth.user_id)(
 db.auth_group.id==db.auth_membership.group_id)).select(db.auth_group.ALL)

 error is 

 type 'exceptions.KeyError' 'auth_user'

 what am I doing wrong here. It is a f#$# simple ask. Get user role so I 
 can get a user a specific view based on that role (btw any suggestions on 
 that would be nice).

 thank you



-- 
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] Editing tables with datatables

2014-07-07 Thread Yebach
Hello

I am using datatables plugin to dynamically edit table of workers which are 
read from database

my code on client side is 

JAVASCRIPT
var getTableData = function (){
var table = $('#example').tableToJSON(), // Convert the table into a 
javascript object
datas = JSON.stringify(table);
 return datas;
};

var saveTableData = function(){
var tableData = getTableData();
$.ajax({
 type: 'POST',
 url: '{{=URL('script', 'saveWorkers.json')}}',
 data: {data : tableData},
 dataType: 'json',
 }).done(function( msg ) { });
 };

$(document).ready(function() {
var table = $('#example').dataTable();
saveTableData(); //Will be triggered on save button

 //Hide columns
$('#example tr *:nth-child(1)').css('display','none');
$('#example tr *:nth-child(2)').css('display','none');
$('#example').editableTableWidget().numericInputExample().find('td:first').focus();

} );

HTML

table id=example class=table table-striped table-bordered display 
cellspacing=0 width=100%
   thead
tr
 thId/th
thOrganizacija/th
thIme/th
thPriimek/th
thVzdevek/th
thE-mail/th
thStatus/th
thKomentar/th
/tr
/thead

tbody
 {{for worker in workers:}}
tr
td{{=worker['w_id_w']}}/td
td{{=worker['w_organisation']}}/td
td{{=worker['w_first_name']}}/td
td{{=worker['w_last_name']}}/td
td{{=worker['w_nick_name']}}/td
td{{=worker['w_email']}}/td
td{{=worker['w_status']}}/td
td{{=worker['w_note']}}/td
/tr
{{pass}} 
/tbody
/table


What is the best way to menage editing (update/delete/add) record(s). I 
have all workers in one table (also on view part) for fast and easy edit 
from client's part of view
Also I am experiencing problems with add new row to table and delete last 
row

First I would like to be saved/updated/deleted on button click but if not 
too complicated I would like them to be saved every time I change table 
cell.

Thans for any guidelines suggestions etc. 
Best regards


-- 
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] SQLFORM.grid changes request

2014-07-08 Thread Yebach
Hello

When I try to put form = SQLFORM.grid(db.mytable) in my controller the 
request changes to 
my/web/site/view?_signature=520af19b1095db04dda2f1b6cbea3a03c3551e13 which 
causes my if statement in controller to collapse. Can smbd please explain 
why this happens?

thank you


-- 
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] SQLform.Grid problems with lookout and url

2014-07-14 Thread Yebach
If anyone can hellp me with this

I have a page with embeded htmls. One of them should have a SQLForm.grid to 
manage table of workers

I am having difficulties because SQLForm.grid is in edit function. Besides 
the fact that it looks awful it also does not work properly 

I asked a question on stackoverflow so here is a link together with python 
code for controller

http://stackoverflow.com/questions/24648604/web2py-sqlform-grid-url


any suggestions

-- 
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] SQLFORM smart grid child table fields and editing excelike

2014-07-15 Thread Yebach
Hello

I am using SQLFORM smartgrid. My child table field is not shown on my form 
(status.s_code). Why?

Also. If I (user) click(s) on edit, all fields are editable. how do I set 
which fileds are or can be editable and which one not.
Is it possible to create a form that is click in editable (like excel?), so 
u don't have to open another window?


thank you


This is my code in contorller.

workers = db(db.worker.w_organisation == 10).select(db.worker.w_id_w, 
db.worker.w_organisation, db.worker.w_first_name, 
db.worker.w_last_name,db.worker.w_nick_name,db.worker.w_email,db.worker.w_status,db.worker.w_note).as_list()
 #Define the query object. Here we are pulling all contacts having date of 
birth less than 18 Nov 1990
query = ((db.worker.w_organisation == 10) )# 
(db.worker.w_status==db.status.s_id_s))
 
fields = (db.worker.w_id_w,db.worker.w_first_name, 
db.worker.w_last_name,db.worker.w_nick_name,db.worker.w_email
*,db.status.s_code*,db.worker.w_note)
 #Define headers as tuples/dictionaries
headers = {'worker.w_id_w' :   'Id', 
'worker.w_first_name' :   'Ime',
   'worker.w_last_name' : 'Priimek',
   'worker.w_nick_name' : 'Vzdevek',
   'worker.w_email' : 'E-posta',
   'status.s_code': 'Status',
   'worker.w_note' : 'Komentar' }
 #Let's specify a default sort order on date_of_birth column in grid
default_sort_order=[db.worker.w_last_name]
 form = SQLFORM.smartgrid(db.worker,fields = fields,headers= 
headers,linked_tables=['status'])



-- 
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: smartgrid: linked_tables=dict(parent=['child'], child=[''])

2014-07-15 Thread Yebach
How did you insert icons for edit in your form

I am using SQLFORM.smartgrid and I want my grid to be more bootstrap like. 

Also I am having problems with displaying my child table fields (They are 
not displayed :))

Any suggestions?


Here is my code

workers = db(db.worker.w_organisation == 10).select(db.worker.id, 
db.worker.w_organisation, db.worker.w_first_name, 
db.worker.w_last_name,db.worker.w_nick_name,db.worker.w_email,db.worker.w_status,db.worker.w_note).as_list()
 #Define the query object. Here we are pulling all contacts having date of 
birth less than 18 Nov 1990
query = ((db.worker.w_organisation == 10) )# 
(db.worker.w_status==db.status.s_id_s))
 
#Define the fields to show on grid. Note: (you need to specify id field in 
fields section in 1.99.2
fields = (db.worker.id,db.worker.w_first_name, 
db.worker.w_last_name,db.worker.w_nick_name,db.worker.w_email,db.status.s_code,db.worker.w_note)
 #Define headers as tuples/dictionaries
headers = {'worker.id' :   'Id', 
'worker.w_first_name' :   'Ime',
   'worker.w_last_name' : 'Priimek',
   'worker.w_nick_name' : 'Vzdevek',
   'worker.w_email' : 'E-posta',
   'status.s_code': 'Status',
   'worker.w_note' : 'Komentar' }
 #Let's specify a default sort order on date_of_birth column in grid
default_sort_order=[db.worker.w_last_name]
 form = SQLFORM.smartgrid(db.worker,fields = fields,headers= 
headers,linked_tables=['status'])


And db.py

db.define_table('worker',
Field('id', type ='id'),
Field('w_organisation', type ='integer'),
Field('w_user', type ='integer'),
Field('w_status', 'reference status'),
Field('w_first_name',type='text'),
Field('w_last_name',type='text'),
Field('w_nick_name',type='text'),
Field('w_email',type='text'),
Field('w_note',type='text'),
migrate=settings.migrate
)

db.define_table('status',
Field('s_id_s', type ='id'),
Field('s_code', type ='text'),
Field('s_description', type ='text'),
migrate=settings.migrate
)

thank you 

best regards


On Friday, September 21, 2012 5:58:05 PM UTC+2, Adi wrote:

 I'm wondering what to do in this situation? I have self-referencing fields 
 in the child table, and due to that smartgrid display links, which 
 basically can't do anything. 

 I'm trying to eliminate them, but not sure what would be a proper way? 

 Thanks.

 Simplified code sample: 
 db.define_table('campaign',
 Field('tbl_uuid', length=64, default=lambda:str(uuid.
 uuid4())),
 Field('name','string', label=T('Campaing Name')),
 format='%(name)s',
 )

 db.define_table('message',
 Field('tbl_uuid', length=64, default=lambda:str(uuid.
 uuid4())),
 Field('name','string', label=T('Name')),
 Field('campaign_id', 'reference campaign', label=T(
 'Campaign')),
 Field('action_yes_id', 'reference message)', 
 label=T('Action 
 Yes'),),
 Field('action_no_id', 'reference message)', 
 label=T('Action 
 No')),
 migrate=True)



 grid=SQLFORM.smartgrid(Campaign, details=False, links_in_grid=True,
 linked_tables=['message'],
 #linked_tables=dict(campaign=['message'], 
 message=['']),
 links=dict(campaign=[lambda row:(_get_messages(row))
 ]),
 )
 Enter code here...




-- 
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: SQLFORM smart grid child table fields and editing excelike

2014-07-16 Thread Yebach
models for two tables that need to be shown

db.define_table('worker',
Field('id', type ='id'),
Field('w_organisation', type ='integer'),
Field('w_user', type ='integer'),
Field('w_status', 'reference status'),
Field('w_first_name',type='text'),
Field('w_last_name',type='text'),
Field('w_nick_name',type='text'),
Field('w_email',type='text'),
Field('w_note',type='text'),
migrate=settings.migrate
)

db.define_table('status',
Field('id', type ='id'),
Field('s_code', type ='text'),
Field('s_description', type ='text'),
migrate=settings.migrate
)

-- 
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: SQLFORM smart grid child table fields and editing excelike

2014-07-16 Thread Yebach
Also, how do I costumize the edit view (etc. drop down menus, filed size). 
The input text fields are enormous. Using set max length does not work. It 
prevents the text larger then set to be inserted (but only on submit button 
click it rases an error - is it possibel to create an on the fly validator 
for field ) but size of fileds is still too big. 

On Tuesday, July 15, 2014 3:58:17 PM UTC+2, Anthony wrote:

 On Tuesday, July 15, 2014 6:58:28 AM UTC-4, Yebach wrote:

 Hello

 I am using SQLFORM smartgrid. My child table field is not shown on my 
 form (status.s_code). Why?


 Can you show your models? Does the child table have a field of type 
 reference that refers to the parent table?
  


 Also. If I (user) click(s) on edit, all fields are editable. how do I set 
 which fileds are or can be editable and which one not.


 You can set the readable/writable attributes of the fields at any point 
 before generating the grid.
  

 Is it possible to create a form that is click in editable (like excel?), 
 so u don't have to open another window?


 Not out of the box -- you would have to code that yourself.

 Anthony


-- 
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] SQLFORM grid process not working

2014-07-21 Thread Yebach
Hello

I have a SQLForm.grid. 

I want to create a response.flash message but on my if evaluation I get an 
error when my edit view is done

type 'exceptions.AttributeError' 'DIV' object has no attribute 'process'
even on my sqlform.grid view

this is my controller function

 form = SQLFORM.grid(query=query, 
left=db.status.on(db.worker.w_status == db.status.id),
fields=fields,  searchable=True, orderby=default_sort_order,create=True,
deletable=True, editable=True, paginate=25, buttons_placement = 'right')
  if form.process().accepted:
response.flash = 'form accepted'
 elif form.errors:
response.flash = 'form has errors'
else:
response.flash = 'please fill the form'
# Note: no form instance is passed to the view
 return dict(form=form)

-- 
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] json parsing and db insert problem

2014-07-25 Thread Yebach
Hello

OK can smbd. explains this S4!#T to me.
I am sending json string from my view to controller. in 
request.vars['value'] there is a string /dict and for easier handling I 
want to convert it to a dict. 
Now this code works.

def saveAsFormData():
import json 
#data =  simplejson.loads(request.vars.value)
#print data
#datumDo = data[dateTo]
#datumOd = data[dateFrom]
data = request.vars['value']
name = request.vars['name']
data_dict =  json.loads(data)
datumOd = data_dict[dateFrom]
datumDo = data_dict[dateTo]
 schedule = {}
schedule['from'] = '1970-01-01'
schedule['to'] = '1970-01-01'
return
id = db.script.insert(sc_name = name, sc_user = auth.user_id, 
sc_organization = auth.user.organization, sc_cal_start = datumOd,\
 sc_cal_end = datumDo, sc_status = 1, sc_modified = 'now')
 return_data = {
'type': 1,
'msg': 'aaa',
'id': id
}
 print New script inserted into db
return dict(return_data)

this code 

def saveAsFormData():
 import json 
#data =  simplejson.loads(request.vars.value)
#print data
#datumDo = data[dateTo]
#datumOd = data[dateFrom]
data = request.vars['value']
name = request.vars['name']
data_dict =  json.loads(data)
datumOd = data_dict[dateFrom]
datumDo = data_dict[dateTo]
 schedule = {}
schedule['from'] = '1970-01-01'
schedule['to'] = '1970-01-01'

id = db.script.insert(sc_name = name, sc_user = auth.user_id, 
sc_organization = auth.user.organization, sc_cal_start = datumOd,\
 sc_cal_end = datumDo, sc_status = 1, sc_modified = 'now')
 return_data = {
'type': 1,
'msg': 'aaa',
'id': id
}
 print New script inserted into db
return dict(return_data)

return an error 
type 'exceptions.TypeError' expected string or buffer
in line data_dict =  json.loads(data)

WHY?? why does insert or smth crashes it on line before it is 
executed???

-- 
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] multiple SQLFORM.grid on tabs

2014-08-11 Thread Yebach
Hello

I am trying to create a view where I have tabs and each tab has its own 
view.
All tabs are included into main view. lets call it settings.

In settings there are tabs for user to insert workers into tables, posts, 
etc etc. all the (un)necessary stuff.

For each I would like to use SQLFORM.grid. It already works for inserting 
workers, but how to add new ones??

I guess in controller I have to create function for each table (form.grid) 
and for each I have to create new view (html)??

And what function to create for main view? - Basically it should show data 
for workers but this way all I get is workers SQLform.grid

Is this it even possible.

Any guideliness would be nice

Thank you

some code

main view 

ul class=nav nav-tabs
li class=activea href=#zaposleni 
data-toggle=tab{{=T('Delavci')}}/a/li
lia href=#turnusi data-toggle=tab{{=T('Turnusi')}}/a/li
/ul

div class=tab-content
div class=tab-pane active id=visual
{{include '../views/settings/workers.html'}}
/div
div class=tab-pane id=turnusi
{{include '../views/settings/turnusi.html'}}
/div
/div
div
div class=col-md-2
div id=navVisual data-spy=affix data-offset-top=60
ul class=nav nav-pills nav-stacked style=margin-top: 10px;
lia href=#SifrantDelavcev{{=T('Delavci')}}/a/li
lia href=#unkn{{=T('Turnusi')}}/a/li
/ul
/div
/div
/div

My view for workers

div class=row 
div id=mainContainer class=col-md-10
h4b{{=T('Šifrant delavcev')}}/b/h4
div class=flash{{=response.flash}}/div
div id=SifrantDelavcev class=well well-sm
{{=grid}}
/div
/div
/div

my view for turnusi

div class=row 
div id=mainContainer class=col-md-10
h4b{{=T('Šifrant turnusov')}}/b/h4
div class=flash{{=response.flash}}/div
{{=grid}}
/div
/div


and for both i have fucntions in controller


-- 
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] sqlform.grid edit view back button

2014-08-19 Thread Yebach
Hello

I have to create multiple sqlform.grids in my page

i used bootstrap tabs to load different htmls with different controller 
functions (each for every grid)

It works ok and does the trick except when I edit record I and click the 
back button the link is not back to the page it was so I cannot see tabs 
anymore

My main html has address http://127.0.0.1:8080/iRazpored/settings/sifranti
but after clicking my back button I am send 
to http://127.0.0.1:8080/iRazpored/settings/turnusi 

I hope I am clear enough.
Also when I am on edit view tabs are not shown since the url 
is http://127.0.0.1:8080/iRazpored/settings/turnusi/edit/shifts
Is is possible to set the back button address or is there any other way 
around it?

Thank you

this is my html

my main view

{{ extend 'layout.html' }}
{{include 'web2py_ajax.html'}}
script
$(document).ready(function() {
$('#worker_w_note').width(200).height(75);
//glyphicon glyphicon-edit
$('#workers').load('workers.html');
$('#turnusi').load('turnusi.html');
});
/script

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

div class=tabbable style=margin-bottom: 18px;
  ul class=nav nav-tabs
li class=activea href=#workers 
data-toggle=tabZaposleni/a/li
li class=a href=#turnusi 
data-toggle=tabTurnusi/a/li
  /ul
div class=col-md-12
  div class=tab-content style=padding-bottom: 9px; 
border-bottom: 1px solid #ddd;
div class=tab-pane active id=workers
/div
div class=tab-pane id=turnusi
/div
  /div
/div
/div​



And the two htmls for my sqlform.grid

{{extend 'layout.html'}}
{{include 'web2py_ajax.html'}}
style
.affix {
top: 60px;
}
.input-group {
width: 100%;
}
.row {
margin-bottom: 10px;
}
.sectionHeader {
margin-bottom: 0;
}
/style
body
div class=col-md-12
{{=grid_shifts}}

/div
/body


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

script
/script

style
.affix {
top: 60px;
}
.input-group {
width: 100%;
}
.row {
margin-bottom: 10px;
}
.sectionHeader {
margin-bottom: 0;
}
/style
body
div class=col-md-12
{{=grid_workers}}

/div
/body

-- 
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] web2py postgres sort by

2014-11-03 Thread Yebach
Hello

I have a postgres db with encoding and collation settings

CREATE DATABASE algit_osnovna_sola
  WITH OWNER = postgres
   ENCODING = 'UTF8'
   TABLESPACE = pg_default
   LC_COLLATE = 'en_US.UTF-8'
   LC_CTYPE = 'en_US.UTF-8'
   CONNECTION LIMIT = -1;

When I use select with order by I do not get the right sort order for 
Slovenian language. It is not completely off, but for some letters they are 
treated as the same
My select 

teacher_list=db(db.teachers.t_name!='None').select(db.teachers.t_name, 
orderby=db.teachers.t_name, distinct=True).as_list()

my result 

[{'t_name': 'BABI\xc4\x8c Biljana'}, {'t_name': 'BARBO Sre\xc4\x8dko'}, 
{'t_name': 'BARUCA Ingrid'}, {'t_name': 'CERKVENIK Karmen'}, {'t_name': 
'DANI\xc4\x8cI\xc4\x8c Vu\xc4\x8dko'}, {'t_name': '\xc4\x90OROVI\xc4\x86 
Aleksandar'}, {'t_name': 'FALKNER Anja'}, {'t_name': 
'FLORJAN\xc4\x8cI\xc4\x8c Andrej'}, {'t_name': 'GAZI\xc4\x8c Mojca'}, 
{'t_name': 'GORJAN Melina'}, {'t_name': 'GRLJ Vilko'}, {'t_name': 'HARCET 
Franjo'}, {'t_name': 'HRE\xc5\xa0\xc4\x8cAK Erika'}, {'t_name': 'JAHN 
Marjan'}, {'t_name': 'JELEN Branko'}, {'t_name': 'JEREBICA Nevenka'}, 
{'t_name': 'JERMAN Nata\xc5\xa1a'}, {'t_name': 'KING Mojca'}, {'t_name': 
'KOCJAN\xc4\x8cI\xc4\x8c Dolores'}, {'t_name': 'KOCJAN\xc4\x8cI\xc4\x8c 
Nevio'}, {'t_name': 'KORO\xc5\xa0EC Erika'}, {'t_name': 'KOZJAK Igor'}, 
{'t_name': 'KRAJNC Elvira'}, {'t_name': 'KRT Sini\xc5\xa1a'}, {'t_name': 
'KUZMAN Franjo'}, {'t_name': 'LEDINEK Bianka'}, {'t_name': 'LENASSI 
Andreja'}, {'t_name': 'MARA\xc5\xbd Jelica'}, {'t_name': 'MAVRI\xc4\x8c 
Barbara'}, {'t_name': 'MEJAK Giliola'}, {'t_name': 'MESARI\xc4\x8c Alen'}, 
{'t_name': 'MIKOLAV\xc4\x8cI\xc4\x8c Mitja'}, {'t_name': 'MUNIH Marko'}, 
{'t_name': 'NOVOSELEC Katarina'}, {'t_name': 'PAULI\xc4\x8c Simona'}, 
{'t_name': 'PE\xc4\x8cAR BOLE Bojana'}, {'t_name': 'PLAZNIK Jadran'}, 
{'t_name': 'PODGORNIK Marko'}, {'t_name': 'POHLEN Doris'}, {'t_name': 
'POKLAR Branko'}, {'t_name': 'PREGELJC Damjana'}, {'t_name': 'RUDL Ensi'}, 
{'t_name': '\xc5\xa0AV Angel'}, {'t_name': '\xc5\xa0IRCELJ Du\xc5\xa1an'}, 
{'t_name': '\xc5\xa0KERJANC Marko'}, {'t_name': 'SLAVEC Marija'}, 
{'t_name': '\xc5\xa0TEMBERGER Samo'}, {'t_name': 'TRAJBAR Mitja'}, 
{'t_name': 'UMER Jo\xc5\xbea'}, {'t_name': 'URANJEK Damjan'}, {'t_name': 
'VALENTI\xc4\x8c Maja'}, {'t_name': 'VERGAN Helena'}, {'t_name': 'VOUK 
Renato'}, {'t_name': 'ZAVRTANIK Boris'}, {'t_name': '\xc5\xbdNIDARI\xc4\x8c 
Maja'}, {'t_name': 'ZRINSKI Elen'}]

The problem is  for example with {'t_name': '\xc5\xa0AV Angel'}, {'t_name': 
'\xc5\xa0IRCELJ Du\xc5\xa1an'}, {'t_name': '\xc5\xa0KERJANC Marko'}, 
{'t_name': 'SLAVEC Marija'}, {'t_name': '\xc5\xa0TEMBERGER Samo'}

Where 'SLAVEC Marija should be the first one followd by '\xc5\xa0 names

any suggestions?

In my db.py I set encoding to utf-8 but that does not help.

thank you







-- 
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: web2py postgres sort by

2014-11-05 Thread Yebach
Since I cannot change the db settings is there a way to order my list 
inside web2py? 



On Tuesday, November 4, 2014 10:19:51 AM UTC+1, Michele Comitini wrote:

 Just to be sure try the _select:

 print db(db.teachers.t_name!='None')._select(db.teachers.t_name, 
 orderby=db.teachers.t_name, distinct=True)

 You will should see same result using the resulting statement under psql.

 Now the problem seems your database.  The collation is wrong, since it's 
 for US:
  LC_COLLATE = 'en_US.UTF-8'
  LC_CTYPE = 'en_US.UTF-8'

 Install proper locales for slovenian restart postgres and create a new 
 database with proper collations.
 See on postgresql.org how to do it.

 mic


 2014-11-04 9:56 GMT+01:00 Niphlod nip...@gmail.com javascript::

 this is more suited to a postgresql forum than a web2py's one


 On Tuesday, November 4, 2014 8:52:54 AM UTC+1, Yebach wrote:

 Hello

 I have a postgres db with encoding and collation settings

 CREATE DATABASE algit_osnovna_sola
   WITH OWNER = postgres
ENCODING = 'UTF8'
TABLESPACE = pg_default
LC_COLLATE = 'en_US.UTF-8'
LC_CTYPE = 'en_US.UTF-8'
CONNECTION LIMIT = -1;

 When I use select with order by I do not get the right sort order for 
 Slovenian language. It is not completely off, but for some letters they are 
 treated as the same
 My select 

 teacher_list=db(db.teachers.t_name!='None').select(db.teachers.t_name, 
 orderby=db.teachers.t_name, distinct=True).as_list()

 my result 

 [{'t_name': 'BABI\xc4\x8c Biljana'}, {'t_name': 'BARBO Sre\xc4\x8dko'}, 
 {'t_name': 'BARUCA Ingrid'}, {'t_name': 'CERKVENIK Karmen'}, {'t_name': 
 'DANI\xc4\x8cI\xc4\x8c Vu\xc4\x8dko'}, {'t_name': '\xc4\x90OROVI\xc4\x86 
 Aleksandar'}, {'t_name': 'FALKNER Anja'}, {'t_name': 
 'FLORJAN\xc4\x8cI\xc4\x8c Andrej'}, {'t_name': 'GAZI\xc4\x8c Mojca'}, 
 {'t_name': 'GORJAN Melina'}, {'t_name': 'GRLJ Vilko'}, {'t_name': 'HARCET 
 Franjo'}, {'t_name': 'HRE\xc5\xa0\xc4\x8cAK Erika'}, {'t_name': 'JAHN 
 Marjan'}, {'t_name': 'JELEN Branko'}, {'t_name': 'JEREBICA Nevenka'}, 
 {'t_name': 'JERMAN Nata\xc5\xa1a'}, {'t_name': 'KING Mojca'}, {'t_name': 
 'KOCJAN\xc4\x8cI\xc4\x8c Dolores'}, {'t_name': 'KOCJAN\xc4\x8cI\xc4\x8c 
 Nevio'}, {'t_name': 'KORO\xc5\xa0EC Erika'}, {'t_name': 'KOZJAK Igor'}, 
 {'t_name': 'KRAJNC Elvira'}, {'t_name': 'KRT Sini\xc5\xa1a'}, {'t_name': 
 'KUZMAN Franjo'}, {'t_name': 'LEDINEK Bianka'}, {'t_name': 'LENASSI 
 Andreja'}, {'t_name': 'MARA\xc5\xbd Jelica'}, {'t_name': 'MAVRI\xc4\x8c 
 Barbara'}, {'t_name': 'MEJAK Giliola'}, {'t_name': 'MESARI\xc4\x8c Alen'}, 
 {'t_name': 'MIKOLAV\xc4\x8cI\xc4\x8c Mitja'}, {'t_name': 'MUNIH Marko'}, 
 {'t_name': 'NOVOSELEC Katarina'}, {'t_name': 'PAULI\xc4\x8c Simona'}, 
 {'t_name': 'PE\xc4\x8cAR BOLE Bojana'}, {'t_name': 'PLAZNIK Jadran'}, 
 {'t_name': 'PODGORNIK Marko'}, {'t_name': 'POHLEN Doris'}, {'t_name': 
 'POKLAR Branko'}, {'t_name': 'PREGELJC Damjana'}, {'t_name': 'RUDL Ensi'}, 
 {'t_name': '\xc5\xa0AV Angel'}, {'t_name': '\xc5\xa0IRCELJ Du\xc5\xa1an'}, 
 {'t_name': '\xc5\xa0KERJANC Marko'}, {'t_name': 'SLAVEC Marija'}, 
 {'t_name': '\xc5\xa0TEMBERGER Samo'}, {'t_name': 'TRAJBAR Mitja'}, 
 {'t_name': 'UMER Jo\xc5\xbea'}, {'t_name': 'URANJEK Damjan'}, {'t_name': 
 'VALENTI\xc4\x8c Maja'}, {'t_name': 'VERGAN Helena'}, {'t_name': 'VOUK 
 Renato'}, {'t_name': 'ZAVRTANIK Boris'}, {'t_name': '\xc5\xbdNIDARI\xc4\x8c 
 Maja'}, {'t_name': 'ZRINSKI Elen'}]

 The problem is  for example with {'t_name': '\xc5\xa0AV Angel'}, 
 {'t_name': '\xc5\xa0IRCELJ Du\xc5\xa1an'}, {'t_name': '\xc5\xa0KERJANC 
 Marko'}, {'t_name': 'SLAVEC Marija'}, {'t_name': '\xc5\xa0TEMBERGER Samo'}

 Where 'SLAVEC Marija should be the first one followd by '\xc5\xa0 names

 any suggestions?

 In my db.py I set encoding to utf-8 but that does not help.

 thank you







  -- 
 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+un...@googlegroups.com javascript:.
 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] registration settings not working

2014-11-10 Thread Yebach
Hello

In my db.py i have the following settings

auth.settings.registration_requires_verification = True
auth.settings.registration_requires_approval = True/False  - it is always 
Fasle - user can login even if I set to True??
auth.settings.reset_password_requires_verification = True


mail=Mail() 
auth.settings.mailer=mail
mail.settings.server=':25'
mail.settings.sender='sen...@algit.si'
mail.settings.login=':pass'
mail.settings.tls = False
  
auth.messages.verify_email = 'Click on the link 
http://'+request.env.http_host+URL(r=request,c='default',f='user',args=['verify_email'])+'/%(key)s
 
to verify your email'
auth.settings.reset_password_requires_verification = True
auth.messages.reset_password = 'Click on the link http://'+\
  request.env.http_host+\
  URL(r=request,c='default',f='user',args=['reset_password'])+\
  '/%(key)s to reset your password'


none of this seems to be working.
Mail server is ok because 
mail.send('vi...@net.si',  'Message subject',  'Plain text 
body of the message') is working


Any suggestions?

-- 
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] send mail error

2014-11-12 Thread Yebach

Hello

I am getting this error on my local Windows machine where I run my web2py 
server

web2py:Mail.send failure:[Errno 10061] No connection could be made because 
the target machine actively refused it


Any suggestions?

Thank you

-- 
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 automatically send emails to users if they perform an action like sign up...

2014-11-12 Thread Yebach
My login settings such as 

auth.settings.registration_requires_verification = True
auth.settings.registration_requires_approval = False
auth.settings.reset_password_requires_verification = True


are not working

Any idea why?

On Monday, January 21, 2013 2:26:31 PM UTC+1, rochacbruno wrote:



 in your models.

 mail = auth.settings.mailer
 mail.settings.server = your_smtp_server_and:port
 mail.settings.sender = y...@you.com javascript:
 mail.settings.login = y...@you.com:password

 # sends an verification e-mail upon registration
 auth.settings.registration_requires_verification = True


 def send_email(user, subject):
 message =  Multi line string for %(first_name)s..
 message = open(somefile.html, r).read()
 # you also have the option to include everyone in bcc=[...]
 mail.send(to=user.email,
subject=subject,
message=message % user)


 Now in any place like controllers or scripts

 users = db(db.auth_user).select()
 for user in users:
 send_email(user, some subject)


 Dont forget to keep track of sent emails, use try: except... try to not 
 use gmail for more than 500 recipients.




 If you want an email to be send everytime a user login in your page

 auth.settings.login_onaccept = lambda form: mail.send(to=form.vars.email, 
 subject=%(first_name)s logged in % form.vars, message=User logged in %s 
 % str(form.vars))




-- 
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] get record id to delete row in table

2014-11-26 Thread Yebach

Hello

I have a table and a SQLFORM.grid in my view. In SQLFORM.grid I show list 
of active workers and in my table I show all inactive workers. I am not 
using a SQLFROM for both since showing two results in double forms after 
edit/view click

In my table of inactive workers I have a button activate which would 
activate a worker and consequently  move him/her into SQLFORM.grid. 
Any suggestions what would be the most web2py way to do it?

Thank you

-- 
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] autofill noneditable field in SQLFORM.grid

2014-11-28 Thread Yebach
Hello

I have a SQLFROM.grid and some fields are not editable but the value is 
calculated based on two other fields a user inserts and should be seen for 
user after he inserts the values for them

e.g.: 
start time : 9:00 --user inserts
end time : 11:00 --user inserts
duration: 2:00 - calculated and non editable field

any suggestion?

thank you


-- 
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] SQLFORM.grid field is not empty if another field is full

2014-12-01 Thread Yebach
Hello

I have a SQLFORM.grid and I have to raise error for user if he inserts 
value into one field and not another. 

Example

start 1 10:00
end 1  12:00 - has to show error if field is empty - 

start 2 16:00 - not necessary to be inserted
end 2 20:00 - has to show error if start 2 is not empty

What would be the best solution?

Thank you


-- 
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: SQLFORM.grid field is not empty if another field is full

2014-12-01 Thread Yebach
Thanx. Nice solution

On Monday, December 1, 2014 2:46:24 PM UTC+1, Anthony wrote:

 You can either use an onvalidation function or do something like:

 Field('end1', requires=IS_NOT_EMPTY() if request.post_vars.start1 else 
 None)

 Anthony

 On Monday, December 1, 2014 8:27:30 AM UTC-5, Yebach wrote:

 Hello

 I have a SQLFORM.grid and I have to raise error for user if he inserts 
 value into one field and not another. 

 Example

 start 1 10:00
 end 1  12:00 - has to show error if field is empty - 

 start 2 16:00 - not necessary to be inserted
 end 2 20:00 - has to show error if start 2 is not empty

 What would be the best solution?

 Thank you




-- 
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] SQLFORM.grid extra button

2014-12-02 Thread Yebach
Hello

I have a SQLFORM.grid and beside the default buttons  (edit,view, 
delete,...) I would like to add a new one to change a status in my database 
table.

Any suggestions?

thank you

-- 
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: Rendering null values in SQLFORM.grid

2014-12-02 Thread Yebach
Since I have time and integer fields I cannot set default to ''. What do 
you suggest for a solution?


On Monday, June 10, 2013 5:32:33 PM UTC+2, Niphlod wrote:

 The second one you said (i.e. altering the default repr for None values). 
 From a theoretical standpoint, a null value is not an empty string. If 
 your app doesn't care for the difference, set a default='' on the 
 interested fields.

 Il giorno lunedì 10 giugno 2013 15:42:21 UTC+2, Lamps902 ha scritto:

 If there's a NULL value in my postgresql DB, SQLFORM.grid renders it as 
 None. Is it there something that can be done globally for an SQLFORM.grid 
 that would simply make it display all NULL values as an empty string (i.e. 
 not display anything in the grid for NULLs), or does that have to be 
 determined individually for every field by setting the respective field's 
 *represent 
 *parameter? Thanks.



-- 
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: python in javascript extension file (*.js)

2014-12-02 Thread Yebach
Is it possible to include {{=T()}} in my static js file??

Smth like 
$('.multiselectDays').multiselect({
numberDisplayed: 5,
nonSelectedText: 'Izberite dneve', // {{=T('Select days')}}
includeSelectAllOption: true,
selectAllText: 'Izberi vse' //{{=T('Select all')}}
});

I need it for translation of my bootstrap elements



On Wednesday, March 12, 2014 2:55:31 PM UTC+1, 黄祥 wrote:

 thank you so much for your detail explaination, massimo. i've figure it 
 out why and how it works now.
 e.g.
 shortcut.add(Ctrl+F12, function() {
 window.open(/test/default/index, _self);
 });

 thanks and best regards,
 stifan


-- 
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] SQLFORM.grid stylize

2014-12-04 Thread Yebach
Hello

What is the best way to stylize my SQLFORM.grid form

E.g.: my dropdown field is smaller the others also the edit form is as wide 
as the page I would like to reduce the size, etc.

thank you

-- 
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] presenting None values in SQLFORM.grid

2014-12-11 Thread Yebach
Hello

In my SQLFORM.grid I have fields of type integer (as in database) and if 
they are null the presentation in my view is None. I would like to change 
them to be presented as empty

Any suggestions?

thank you

-- 
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: Verification email is not sent

2014-12-11 Thread Yebach
These are my settings.

Are you using standard form for registration or custom form?

## configure email
mail = auth.settings.mailer
mail.settings.server = 'mx.fdff.si:25'
mail.settings.sender = ''
mail.settings.login = 'ix'
mail.settings.tls = False
auth.messages.verify_email = T('Click on the link ') + ' my_url' + 
URL(r=request,c='default',f='user',args=['verify_email']) +  '/%(key)s '+ 
T('to verify your email')
auth.messages.reset_password = T('Click on the link ') + 'my_ur' + 
 URL(r=request,c='default',f='user',args=['reset_password']) + '/%(key)s 
'+T('to reset your password')

## configure auth policy
auth.settings.registration_requires_verification = True
auth.settings.registration_requires_approval = False
auth.settings.reset_password_requires_verification = True

On Wednesday, December 10, 2014 9:34:56 PM UTC+1, Richard D wrote:

 Hi,

 In my app standard email can be send using mail.send(to=['ric 
 The registration email is not sent however.

 db.py:
 ## configure email
 mail = auth.settings.mailer
 mail.settings.server = 'logging' if request.is_local else '
 mail.mampl.com:26'
 mail.settings.sender = 'u...@mampl.com javascript:'
 mail.settings.login = 'u...@mampl.com javascript::pw'

 ## configure auth policy
 auth.settings.registration_requires_verification = True
 auth.settings.registration_requires_approval = False
 auth.settings.reset_password_requires_verification = True

 auth.messages.verify_email = 'Click here'

 I have no further controller functions.

 What can be wrong? Thank you for your feedback.

 Richard D


-- 
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] adding html to SQLform.grid

2014-12-24 Thread Yebach
Hello

Is it possible to add html (span) to SQLFORM.grid. I have a color picker 
widget and it works ok but it colors the whole field. I would like to add a 
new html tag inside a table where color picker would be presentet. It is 
possible to do this inside web2py or do I have to write JS code.

Also in my view grid I would like to have a field where color would be 
presented. Again. Is it possible to add html inside web2py or is JS or 
JQuery code needed?

thank you

-- 
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] database select from set encoding

2014-12-29 Thread Yebach
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


-- 
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] navbar in sqlform.grid

2014-12-29 Thread Yebach
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.


[web2py] Re: export table to csv

2015-01-22 Thread Yebach
I managed to solve the issue with the following code

def csvExport():
scriptId = request.args[0]
#rows = db(query,ignore_common_filters=True).select()
rows = db(db.result.r_id_script == scriptId).select(db.result.r_item1_name, 
db.result.r_date, db.result.r_time_start,db.result.r_time_end)
 from gluon.contenttype import contenttype
response.headers['Content-Type'] = contenttype('.csv')
response.headers['Content-disposition'] = 'attachment; 
filename=export_%s.csv' % (scriptId)
import csv, cStringIO
s = cStringIO.StringIO()
rows.export_to_csv_file(s, delimiter=',', quotechar='', 
quoting=csv.QUOTE_NONNUMERIC)
return s.getvalue()

andbutton in my view.html

  {{=A(T('CSV export'), _class='btn btn-primary', 
_href=URL('script','csvExport',  args = request.args[0]))}}

instead of callback i used _href

it works :)

-- 
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] export table to csv

2015-01-21 Thread Yebach
Hello

I am trying to create a one button click export to csv, so if a user click 
he gets a download popup without redirect to new page

my controller (script.py)

@auth.requires_login()
def excelExport():
import csv
import cStringIO
scriptId = request.args[0]
rows = db(db.result.r_id_script == scriptId).select(db.result.r_item1_name, 
db.result.r_date, db.result.r_time_start,db.result.r_time_end)
s = cStringIO.StringIO()
rows.export_to_csv_file(s, quoting=csv.QUOTE_ALL)
return s.getvalue()

and my view in views/script/view.html

  {{ if auth.is_logged_in():}}
{{=A(T('Export EXCEL'), _class='btn btn-primary', 
callback=URL('script','excelExport',  args = request.args[0]))}}
{{pass}}

Function is called but what am I missing to get a download window for file 
so user can save it as and where he wishes?

and one more question. Is there a way to name column headers in csv?

thank you




-- 
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] auth_user table referenced table

2015-02-12 Thread Yebach
Hello

I have a question regarding adding extra fields to auth_user table 

now I saw a couple of posts but none answers my question

I have a table organization. On user registration user adds organization 
name in form. this value should be inserted into table organization and id 
of the record into auth_user.organization field. 

Also some other default values should be inserted into another config table.
I had this working now I am getting an error 
class 'psycopg2.IntegrityError' insert or update on table auth_user 
violates foreign key constraint auth_user_organization_fkey DETAIL: Key 
(organization)=(0) is not present in table organizations.

my db.py code

db.define_table('organizations',
Field('id',type='id'),
Field('o_daten', type='datetime',default=request.now),
Field('o_dateu', type='datetime',default=request.now),
Field('o_status',type='integer' ),
Field('o_code',type='string', length = 64 ),
Field('o_name',type='string', label= T('Organization name'), length = 
256),
Field('o_telnumber',type='string',label= T('Telephone number'), length 
= 64 ),
Field('o_faxnumber',type='string',label= T('Fax Nb.'), length = 64 ),
Field('o_street',type='string',label= T('Street'), length = 64 ),
Field('o_post',type='string',label= T('Post'), length = 64 ),
Field('o_city',type='string',label= T('City'), length = 64 ),
Field('o_state',type='string',label= T('State'), length = 64 ),
Field('o_country',type='string',label= T('Country'), length = 64 ),
Field('o_TaxNumber',type='string',label= T('Tax number'), length = 64 ),
Field('o_rootid',type='integer' ),
Field('o_parentid',type='integer' ),
Field('o_levelid',type='integer'), 
Field('o_positionx',type='string', length = 64 ),
Field('o_positiony',type='string', length = 64 ),
Field('o_note',label= 'Note',type = 'text'),
migrate=settings.migrate
)



then extra field, autocomplete is not really necessary

auth.settings.extra_fields['auth_user'] = [ Field('organization', 
'reference organizations', 
  
widget=SQLFORM.widgets.autocomplete(request, db.organizations.o_name, 
id_field=db.organizations.id),
   label = 
T('Organization'))]   


my function to add organization and rows in config table

def add_organization(form):

Always adds new organization
   


#if not form.vars.organization:
   # print form.vars ,form.vars
ret = 
db.organizations.validate_and_insert(o_name=form.vars._autocomplete_organization_o_name_aux)

 
if ret.errors:
form.errors.organizations = ret.errors['name']
else:
   
org = ret.id

Dodamo podatke v config tabelo ko se kreira nova organizacija
holiday_duration1480portalDefault trajanje praznika
vacation_duration1480portalDefault trajanje dopusta
holiday_color1008000portaltemno zelena
vacation_color100ff00portalsvetlo zelena

db.config.insert(co_code = holiday_duration, co_value = '420', 
co_organisation = org, co_note = 'Default trajanje praznika')
db.config.insert(co_code = vacation_duration, co_value = '480', 
co_organisation = org , co_note = 'Default trajanje dopusta')   
 
db.config.insert(co_code = holiday_color, co_value = '008000 ', 
co_organisation = org, co_note = 'Default barva holiday temno zelena') 
db.config.insert(co_code = vacation_color, co_value = '00ff00 ', 
co_organisation = org, co_note = 'Default barva vacation svetlo zelena')
db.config.insert(co_code = minimum_time_period, co_value = '15 ', 
co_organisation = org, co_note = 'Default vrednost časovne periode')


#if not form.vars.organizations:
#print form.vars._autocomplete_organizations_o_name_aux
org_name = form.vars._autocomplete_organizations_o_name_aux
ret = db.organizations.insert(o_name = org_name)


and at the end 

auth.settings.register_onvalidation = add_organization

## create all tables needed by auth if not custom tables
auth.define_tables(username=False, signature=False)


-- 
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] return javascript alert from contorler without redirection

2015-02-19 Thread Yebach
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-primaryspan 
class=glyphicon glyphicon-export/spannbsp;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: i...@algit.si'))

-- 
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] SQLFORM.grid check if record in db

2015-01-27 Thread Yebach
Hello

I have a SQLFORM.grid page

Values for one filed (code) in add or edit view is filed with js code from 
values of two other fields.

User can deactivate this record - it can not be deleted only status is 
set to e.g. 100

If user creates a new record that creates the same values for code field 
(two users can have the same values in code field, since it is not based on 
id) I would like to remind the user that record with this value already 
exist in the db and if he wants to activate the record and not create a new 
one.

I hope the question is clear enough

Also if creating value for field sh_code is possible with python I would 
rather use it but user has to see the values of sc_code field before db 
insert

Thank you

my controler code

def turnusi():
user = auth.user_id
org = db(db.auth_user.id == 
user).select(db.auth_user.organization)[0][organization]
 db.worker.w_user.default = user
db.worker.w_organisation.default = org
#Naredimo še grid za šifrant turnusov
db.shift.sh_organisation.default = org
 query_shifts = ((db.shift.sh_organisation == org)  (db.shift.sh_status == 
1))
query_inactive = db((db.shift.sh_organisation == org)  (db.shift.sh_status 
== 100)).select().as_list()
#print query_inactive
 fields_shifts =(
db.shift.sh_code,
db.shift.sh_name,
db.shift.sh_color,
db.shift.sh_start1,
db.shift.sh_end1,
db.shift.sh_length1,
db.shift.sh_start2,
db.shift.sh_end2,
db.shift.sh_length2,
db.shift.sh_duration1,
# db.shift.sh_start3,
# db.shift.sh_end3,
# db.shift.sh_start4,
# db.shift.sh_end4,
# db.shift.sh_start5,
# db.shift.sh_end5,
db.shift.sh_note)
 db.shift.sh_organisation.readable = False
db.shift.sh_organisation.writable = False
db.shift.sh_organisation.editable = False
 #db.shift.sh_code.editable = db.shift.sh_code.writable = False
 
#db.shift.sh_duration.writable = False
 db.shift.sh_duration1.readable = db.shift.sh_duration1.writable = False
#db.shift.sh_length1.writable = False
 #db.shift.sh_start2.readable = db.shift.sh_start2.writable = False
#db.shift.sh_start2.writable = False
 #db.shift.sh_end2.readable = db.shift.sh_end2.writable = False
#db.shift.sh_end2.writable = False
#db.shift.sh_length2.readable = db.shift.sh_length2.writable = False
 db.shift.sh_start3.readable = db.shift.sh_start3.writable = False
#db.shift.sh_start3.writable = False
 db.shift.sh_end3.readable = db.shift.sh_end3.writable = False
#db.shift.sh_end3.writable = False
db.shift.sh_length3.readable = db.shift.sh_length3.writable = False
 db.shift.sh_start4.readable = db.shift.sh_start4.writable = False
#db.shift.sh_start4.writable = False
db.shift.sh_length4.readable = db.shift.sh_length4.writable = False
 db.shift.sh_end4.readable = db.shift.sh_end4.writable = False
#db.shift.sh_end4.writable = False
 db.shift.sh_start5.readable = db.shift.sh_start5.writable = False
#db.shift.sh_start5.writable = False
 db.shift.sh_length5.readable = db.shift.sh_length5.writable = False
db.shift.sh_end5.readable = db.shift.sh_end5.writable = False
#db.shift.sh_end5.writable = False#

 db.shift.sh_code.widget = SQLFORM.widgets.string.widget
db.shift.sh_name.widget = SQLFORM.widgets.string.widget
db.shift.sh_note.widget = SQLFORM.widgets.string.widget
 grid_shifts = SQLFORM.grid(query=query_shifts, 
fields=fields_shifts,  searchable=False,create=True,
deletable=False, editable=True, paginate=25, buttons_placement = 'right',
showbuttontext = False,formname = 'shiftTable',
formargs=dict(message_onsuccess=T('New record inserted'),
message_onfailure=T('Form has errors')),
#oncreate=myfunction,
ui = dict(widget='',
  header='',
  content='',
  default='',
  cornerall='',
  cornertop='',
  cornerbottom='',
  button='button btn btn-default',
  buttontext='buttontext button',
  buttonadd='icon plus icon-plus glyphicon glyphicon-plus',
  buttonback='icon leftarrow icon-arrow-left glyphicon 
glyphicon-arrow-left',
  buttonexport='icon downarrow icon-download glyphicon 
glyphicon-download',
  buttondelete='icon trash icon-trash glyphicon glyphicon-trash',
  buttonedit='icon pen icon-pencil glyphicon glyphicon-pencil',
  buttontable='icon rightarrow icon-arrow-right glyphicon 
glyphicon-arrow-right',
  buttonview='icon magnifier icon-zoom-in glyphicon 
glyphicon-eye-open',
  buttonvidov = 'icon glyphicon glyphicon-euro' 
  ),
exportclasses  = dict(csv_with_hidden_cols=False, html = False, tsv = 
False, tsv_with_hidden_cols=False, json = False))
# for input in grid_shifts.elements('input', _class='string'):
# input['_class'] = 'testniKlass'
 if request.args and request.args[0] in ['edit', 'new']:
 #dolocamo sirino polj
grid_shifts.element('input[name=sh_color]')['_style']='width:30%'
grid_shifts.element('[title=Back]').parent['_href'] = 
URL('settings','turnusi')
 return dict(grid_shifts=grid_shifts,query_inactive=query_inactive)



my js code in view to get 

[web2py] logging exceptions

2015-01-28 Thread Yebach
Hello

In my app I have a lot of functions with try: exception: 

What would be the best way to catch and log exceptions in a file ?

thank you 

-- 
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] on user registration insert user id into referenced table

2015-01-12 Thread Yebach
Hello

I would like to insert a new registered user Id into another table. What 
would be the easiest way without controller code?

thank you

-- 
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] submenus in layout

2015-02-10 Thread Yebach

I would like to create a drop down menu in my layout. The data for menu is 
read from menu.py

this is my list for menu

response.menu_logged = [
(T('Schedules'),URL('default','index')==URL(),URL('default','index')),
(T('New schedule'),URL('script','edit')==URL(),URL('script','edit', 
args='new')),
(T('Settings'), False, None, [ 
  
(T('Workers'),URL('settings','workers')==URL(),URL('settings','workers')),

(T('Shifts'),URL('settings','turnusi')==URL(),URL('settings','turnusi')),
(T('Config'),URL('settings','config')== URL(),URL('settings','config')) 
,]
)]


Now I would like to put workers, shifts and config in one submenu 
(dropdown) called settings (Schedules,new schedule, and config to be 
horizontal and then config menus vertical )

and in my layout.html

 {{if auth.is_logged_in():}}
 {{ for i, page in enumerate(response.menu_logged): }}
li{{ if response.menu_logged[i][1]: 
response.write(XML(' class=active')) }}a href={{ 
=response.menu_logged[i][2] }}{{ =response.menu_logged[i][0] }}/a/li

{{ pass }}
  lia 
href=https://sites.google.com/site/navodilawoshi/; 
target=_blank{{=T('Help')}}/a/li
any suggestions?

Is there is a possibility to do it with web2py and not html/css/js?

thank you

-- 
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] web2py shutil move or delete

2015-02-10 Thread Yebach
Hello
I encounter an interesting problem or bug

I have a app that runs some *.exe program that returns a file (*.out) to be 
processed every couple of second. 
If I want to stop this exe from working I delete *.lls file. 
So if a user hits play button I create lls file put it in a directory, sets 
status in db to 11 and then after some calculation is done user clicks on 
stop button and lls file is deleted, status in db is set back to 10, and 
some more actions are done with out file (doesn't really matter)

NOW HERE IS THE CATCH

If I run web2py from eclipse it works fine

if I run web2py as standalone so doble click on web2py.py file in my 
windows explorer the lls file is not deleted, BUT there is a catch. If I 
refresh the page, click the stop button in my webapp lls file is deleted

ANY suggestions?

BTW there are no errors

here is my code


id =  (request.vars.id)
try:
path = os.path.join(request.folder, 'engine')
llsPath = os.path.join(request.folder, 'engine', 'e1', 
request.vars.id + '.lls') 

data = 
db(getDbScript(db(getDbScript(request.vars.id)).select(db.scripts.id, 
db.scripts.sc_lls, db.scripts.sc_engine_output, db.scripts.sc_status, 
db.scripts.sc_menu_data).first())).select(db.scripts.id, db.scripts.sc_lls, 
db.scripts.sc_engine_output, db.scripts.sc_status, 
db.scripts.sc_menu_data).first()
script = db(getDbScript(request.vars.id)).select(db.scripts.id, 
db.scripts.sc_lls, db.scripts.sc_engine_output, db.scripts.sc_status, 
db.scripts.sc_menu_data,db.scripts.sc_organization, 
db.scripts.sc_cal_start).first()
org = script[sc_organization]
shifts = db(db.shifts.sh_organisation == 
org).select(db.shifts.sh_code, 
db.shifts.sh_start1,db.shifts.sh_start2,db.shifts.sh_end1,db.shifts.sh_end2,db.shifts.sh_color,db.shifts.sh_length1,db.shifts.sh_length2).as_list()
outPath = os.path.join(request.folder, 'engine', 'e1', 
request.vars.id + '.out')

if not script:
return dict(status = -1)

###Status = 11 - Script is being  calculated 
if script.sc_status == 11:


# Change status - status = 10 -- user lahko da skripo računat 
- nima napak oz pomanjklivih podatkov
 #, sc_engine_output = readOutFile(request.vars.id))s
# Add when user stopped calculation (ce bojo problemi se bo 
zraven posiljalo tudi id od script activitya)
#Odstranim lls datoteko -- engine preneha delovat
if os.path.isfile(llsPath):
os.remove(llsPath)

activity = db(db.script_activity.sa_id_script == 
request.vars.id).select(db.script_activity.id, db.script_activity.sa_stop, 
orderby = ~db.script_activity.id, limitby = (0, 1)).first()
activity.update_record(sa_stop = 'now')
script.update_record(sc_status = 10)


##če obstaja out datotkea
if os.path.isfile(outPath):
#preberemo fajl
out = readOutFile(request.vars.id).split('\n')
#Vnesemo podatke v tabelo script
script.update_record(sc_engine_output = 
readOutFile(request.vars.id))
#odstranim out. datoteko
os.remove(outPath)
workersDb = db(db.workers.w_organisation == 
org).select(db.workers.id, db.workers.w_nick_name).as_list()
#sparsamo out datoteko da jo lahko damo v tabelo result
dateStart =  script[sc_cal_start]
resultData = parseOut(out, dateStart, shifts, workersDb, 
org)
#Pišemo rezultate v tabelo results
resultsDbInsert(resultData[resultsDbData], org, id)


return dict(status = 1)

   
else:
   
##prevedemo skripto v id.lls, prav tako zapišemo še v sc_lls
#
db.script_activity.insert(sa_id_script = request.vars.id, 
sa_start = 'now');

##validiramo json če ima kakršne koli napake idt.
valJson = validateJson(script.sc_menu_data)
if 1!=1 :#not valJson:
#validacija ni uspela vrnemo error 300 
return dict(status = 300)
#$#nov json - z vsemi errorji zapiđšemo v sc_menu_data
script.update_record(sc_menu_data = valJson[formJson])
#če obstajjo errorji pol konc
if  1!=1:#valJson[errors]:
#skripta gre v status 91, kar pomen da je user ne more dat 
računat
script.update_record(sc_status = 91)
#print valJson[errors]
return dict(status = 200)

else:
script.update_record(sc_status = 11)
if os.path.isfile(outPath):
os.remove(outPath)
TranslateData(script.sc_menu_data, path, id, org)
# Run 

[web2py] Re: auth_user table referenced table

2015-02-12 Thread Yebach
I removed wizard from extra filed.

At least there is only one record inserted into organization table (before 
that it inserted two), but wizzard still returns 0

On Thursday, February 12, 2015 at 11:28:20 AM UTC+1, mcamel wrote:

 Hi,

 It seems wizard is returning id=0 instead of the actual organization id. 
 Try removing the wizard from extra fields to guess more.

 Just in case, you can try this other syntax:

  auth.settings.register_onvalidation.append(lambda form: add_organization(
 form))


 Regards.


 El jueves, 12 de febrero de 2015, 10:18:46 (UTC+1), Yebach escribió:

 Hello

 I have a question regarding adding extra fields to auth_user table 

 now I saw a couple of posts but none answers my question

 I have a table organization. On user registration user adds organization 
 name in form. this value should be inserted into table organization and id 
 of the record into auth_user.organization field. 

 Also some other default values should be inserted into another config 
 table.
 I had this working now I am getting an error 
 class 'psycopg2.IntegrityError' insert or update on table auth_user 
 violates foreign key constraint auth_user_organization_fkey DETAIL: Key 
 (organization)=(0) is not present in table organizations.

 my db.py code

 db.define_table('organizations',
 Field('id',type='id'),
 Field('o_daten', type='datetime',default=request.now),
 Field('o_dateu', type='datetime',default=request.now),
 Field('o_status',type='integer' ),
 Field('o_code',type='string', length = 64 ),
 Field('o_name',type='string', label= T('Organization name'), length = 
 256),
 Field('o_telnumber',type='string',label= T('Telephone number'), 
 length = 64 ),
 Field('o_faxnumber',type='string',label= T('Fax Nb.'), length = 64 ),
 Field('o_street',type='string',label= T('Street'), length = 64 ),
 Field('o_post',type='string',label= T('Post'), length = 64 ),
 Field('o_city',type='string',label= T('City'), length = 64 ),
 Field('o_state',type='string',label= T('State'), length = 64 ),
 Field('o_country',type='string',label= T('Country'), length = 64 ),
 Field('o_TaxNumber',type='string',label= T('Tax number'), length = 64 
 ),
 Field('o_rootid',type='integer' ),
 Field('o_parentid',type='integer' ),
 Field('o_levelid',type='integer'), 
 Field('o_positionx',type='string', length = 64 ),
 Field('o_positiony',type='string', length = 64 ),
 Field('o_note',label= 'Note',type = 'text'),
 migrate=settings.migrate
 )



 then extra field, autocomplete is not really necessary

 auth.settings.extra_fields['auth_user'] = [ Field('organization', 
 'reference organizations', 
   
 widget=SQLFORM.widgets.autocomplete(request, db.organizations.o_name, 
 id_field=db.organizations.id),
label = 
 T('Organization'))]   


 my function to add organization and rows in config table

 def add_organization(form):
 
 Always adds new organization

 

 #if not form.vars.organization:
# print form.vars ,form.vars
 ret = 
 db.organizations.validate_and_insert(o_name=form.vars._autocomplete_organization_o_name_aux)
 
  
 if ret.errors:
 form.errors.organizations = ret.errors['name']
 else:

 org = ret.id
 
 Dodamo podatke v config tabelo ko se kreira nova organizacija
 holiday_duration1480portalDefault trajanje 
 praznika
 vacation_duration1480portalDefault trajanje 
 dopusta
 holiday_color1008000portaltemno zelena
 vacation_color100ff00portalsvetlo zelena
 
 db.config.insert(co_code = holiday_duration, co_value = '420', 
 co_organisation = org, co_note = 'Default trajanje praznika')
 db.config.insert(co_code = vacation_duration, co_value = '480', 
 co_organisation = org , co_note = 'Default trajanje dopusta')   
  
 db.config.insert(co_code = holiday_color, co_value = '008000 ', 
 co_organisation = org, co_note = 'Default barva holiday temno zelena') 
 db.config.insert(co_code = vacation_color, co_value = '00ff00 
 ', co_organisation = org, co_note = 'Default barva vacation svetlo zelena')
 db.config.insert(co_code = minimum_time_period, co_value = '15 
 ', co_organisation = org, co_note = 'Default vrednost časovne periode')
 
 
 #if not form.vars.organizations:
 #print form.vars._autocomplete_organizations_o_name_aux
 org_name = form.vars._autocomplete_organizations_o_name_aux
 ret = db.organizations.insert(o_name = org_name)


 and at the end 

 auth.settings.register_onvalidation = add_organization

 ## create all tables needed by auth if not custom tables
 auth.define_tables(username=False, signature=False)




-- 
Resources:
- http://web2py.com
- http://web2py.com

[web2py] Re: web2py shutil move or delete

2015-02-10 Thread Yebach
What do you suggest  then? This part work? the problem is inside if 
script.sc_status == 11: 

On Tuesday, February 10, 2015 at 2:21:13 PM UTC+1, Niphlod wrote:

 oh please DON'T chdir ! it's not thread safe

 On Tuesday, February 10, 2015 at 11:19:18 AM UTC+1, Yebach wrote:

 Hello
 I encounter an interesting problem or bug

 I have a app that runs some *.exe program that returns a file (*.out) to 
 be processed every couple of second. 
 If I want to stop this exe from working I delete *.lls file. 
 So if a user hits play button I create lls file put it in a directory, 
 sets status in db to 11 and then after some calculation is done user clicks 
 on stop button and lls file is deleted, status in db is set back to 10, and 
 some more actions are done with out file (doesn't really matter)

 NOW HERE IS THE CATCH

 If I run web2py from eclipse it works fine

 if I run web2py as standalone so doble click on web2py.py file in my 
 windows explorer the lls file is not deleted, BUT there is a catch. If I 
 refresh the page, click the stop button in my webapp lls file is deleted

 ANY suggestions?

 BTW there are no errors

 here is my code


 id =  (request.vars.id)
 try:
 path = os.path.join(request.folder, 'engine')
 llsPath = os.path.join(request.folder, 'engine', 'e1', 
 request.vars.id + '.lls') 
 
 data = db(getDbScript(db(getDbScript(request.vars.id)).select(
 db.scripts.id, db.scripts.sc_lls, db.scripts.sc_engine_output, 
 db.scripts.sc_status, db.scripts.sc_menu_data).first())).select(
 db.scripts.id, db.scripts.sc_lls, db.scripts.sc_engine_output, 
 db.scripts.sc_status, db.scripts.sc_menu_data).first()
 script = db(getDbScript(request.vars.id)).select(db.scripts.id, 
 db.scripts.sc_lls, db.scripts.sc_engine_output, db.scripts.sc_status, 
 db.scripts.sc_menu_data,db.scripts.sc_organization, 
 db.scripts.sc_cal_start).first()
 org = script[sc_organization]
 shifts = db(db.shifts.sh_organisation == 
 org).select(db.shifts.sh_code, 
 db.shifts.sh_start1,db.shifts.sh_start2,db.shifts.sh_end1,db.shifts.sh_end2,db.shifts.sh_color,db.shifts.sh_length1,db.shifts.sh_length2).as_list()
 outPath = os.path.join(request.folder, 'engine', 'e1', 
 request.vars.id + '.out')
 
 if not script:
 return dict(status = -1)
 
 ###Status = 11 - Script is being  calculated 
 if script.sc_status == 11:
 
 
 # Change status - status = 10 -- user lahko da skripo 
 računat - nima napak oz pomanjklivih podatkov
  #, sc_engine_output = readOutFile(request.vars.id))s
 # Add when user stopped calculation (ce bojo problemi se bo 
 zraven posiljalo tudi id od script activitya)
 #Odstranim lls datoteko -- engine preneha delovat
 if os.path.isfile(llsPath):
 os.remove(llsPath)
 
 activity = db(db.script_activity.sa_id_script == 
 request.vars.id).select(db.script_activity.id, 
 db.script_activity.sa_stop, orderby = ~db.script_activity.id, limitby = 
 (0, 1)).first()
 activity.update_record(sa_stop = 'now')
 script.update_record(sc_status = 10)
 
 
 ##če obstaja out datotkea
 if os.path.isfile(outPath):
 #preberemo fajl
 out = readOutFile(request.vars.id).split('\n')
 #Vnesemo podatke v tabelo script
 script.update_record(sc_engine_output = readOutFile(
 request.vars.id))
 #odstranim out. datoteko
 os.remove(outPath)
 workersDb = db(db.workers.w_organisation == org).select(
 db.workers.id, db.workers.w_nick_name).as_list()
 #sparsamo out datoteko da jo lahko damo v tabelo result
 dateStart =  script[sc_cal_start]
 resultData = parseOut(out, dateStart, shifts, workersDb, 
 org)
 #Pišemo rezultate v tabelo results
 resultsDbInsert(resultData[resultsDbData], org, id)
 
 
 return dict(status = 1)
 

 else:

 ##prevedemo skripto v id.lls, prav tako zapišemo še v sc_lls
 #
 db.script_activity.insert(sa_id_script = request.vars.id, 
 sa_start = 'now');
 
 ##validiramo json če ima kakršne koli napake idt.
 valJson = validateJson(script.sc_menu_data)
 if 1!=1 :#not valJson:
 #validacija ni uspela vrnemo error 300 
 return dict(status = 300)
 #$#nov json - z vsemi errorji zapiđšemo v sc_menu_data
 script.update_record(sc_menu_data = valJson[formJson])
 #če obstajjo errorji pol konc
 if  1!=1:#valJson[errors]:
 #skripta gre v status 91, kar pomen da je user ne more 
 dat računat

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

2015-01-08 Thread Yebach
Do you mean in auth tables or other tables
In auth tables I  do not have, only thing is I added one field

I have in other tables

On Friday, January 2, 2015 8:16:42 PM UTC+1, Alex Glaros wrote:

 just guessing

 do you have the requires clause in your db.py file?  E.g.:

 db.yourTable.yourField.requires = IS_NULL_OR(IS_IN_DB(db, 
 db.otherTable.otherField, '%(fieldName)s',zero=T('choose one')))


-- 
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] return server error to uese

2015-03-26 Thread Yebach
Hello

What would be the best way to return server error in try, except to user 

I have multiple functions and i have try, except in each and I would like 
to show user in alert what the error was (only for selected functions)

my except is 

except Exception as e:
script.update_record(sc_status = 10)
exc_type, exc_obj, exc_tb = sys.exc_info()
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
errmsg = [exc_type, fname, exc_tb.tb_lineno,e.__doc__ , 
e.message]
print errmsg , errmsg
print(exc_type, fname, exc_tb.tb_lineno)
print e.__doc__
print e.message

return dict(status = 666, errmsg = errmsg)

any suggestions

-- 
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] try exception update does not work

2015-03-26 Thread Yebach
Hello

In my controller function I have a couple of try excepts. In case of except 
I want to update db record status to different value based on where the 
error occurred. somehow update record is not executed

any suggestions why?

here is my controller  function

def runWoshi(scriptId, script, outPath, org, path,llsPath):


print scriptId , scriptId
db.script_activity.insert(sa_id_script = scriptId, sa_start = 'now', 
sa_organization = org, sa_location =  llsPath);

##validiramo json če ima kakršne koli napake idt.
try:
print tukej validiram neki
valJson = validateJson(script.sc_menu_data)

except Exception as e:
Če je napaka v validaciji Jsona je status v  92
script.update_record(sc_status = 92)
print db._lastsql
print je biu error scripta id  ,scriptId

exc_type, exc_obj, exc_tb = sys.exc_info()
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
errmsg = [error v validaciji Jsona, exc_type, fname, 
exc_tb.tb_lineno,e.__doc__ , e.message]
print errmsg
print(exc_type, fname, exc_tb.tb_lineno)
print e.__doc__
print e.message
return dict(status = 672, errmsg = errmsg)
 

#if not valJson:
#script.update_record(sc_status = 92)
##validacija ni uspela vrnemo error 300 
#return dict(status = 300)
##nov json - z vsemi errorji zapiđšemo v sc_menu_data
#else:
script.update_record(sc_menu_data = valJson[formJson])

#če obstajjo errorji pol konc
if valJson[errors]:
#skripta gre v status 91, kar pomen da je user ne more dat računat
update = db(db.scripts.id == scriptId).update(sc_status = 91)
print Json errors  , valJson[errors]
return dict(status = 200)



updateScripts = db(db.scripts.id == scriptId).update(sc_engine_output = 
None)

##kreiram LLS
try:
transData = TranslateData(script.sc_menu_data, path, scriptId, org)

except Exception as e:

Status 91 pomen da je bila napaka pri kreiranju lls skripte
update = db(db.scripts.id == scriptId).update(sc_status = 90)
exc_type, exc_obj, exc_tb = sys.exc_info()
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
errmsg = [Creating LLS from Json failed , exc_type, fname, 
exc_tb.tb_lineno,e.__doc__ , e.message]
print errmsg , errmsg
print(exc_type, fname, exc_tb.tb_lineno)
print e.__doc__
print e.message
return dict(status = 668, errmsg = errmsg)


#Se prav se je zgodu error pri kreiranju datoteke
#if transData[data][type] == 666:
##status damo v 90 in vrnemo kar je v error
#update = db(db.scripts.id == scriptId).update(sc_status = 90)
##print 'transData[data] ' , transData[data]
##transDataError = transData[data]
#return  dict(status = 664)   
#
#try:
#Pobiršem out file če obstaja v mapi engine/e1 in sc_engine_out
count = 0
while ( count  10 and ( os.path.isfile(outPath))):
count += 1 
#print count
#print brisem out...
os.remove(outPath)
time.sleep(0.05)

# Run woshi engine
path_1 =  os.path.join(path, 'e1')
os.chdir(path_1)
#pot =  path_1 + \\woshi_engine.exe
#print pot
#p = subprocess.Popen(['w_parameter.bat', id], shell=True, stdout = 
subprocess.PIPE)
p = subprocess.Popen(['woshi_engine.exe', scriptId], shell=True, stdout 
= subprocess.PIPE)

return dict(status = 1)

-- 
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: serving a zip file

2015-01-30 Thread Yebach
Using parts of your code I have a problem with zip file. It appends text to 
new file in my zip
So first worker has in his ics file his data but second one has his and 
from previous

This is my code
 cal = Calendar()
import zipfile, cStringIO
exported_chunks_zip = cStringIO.StringIO()
zipf = zipfile.ZipFile(exported_chunks_zip, w, 
compression=zipfile.ZIP_DEFLATED )

for i, rec in enumerate(grouped):
worker =  rec['rw_worker_nick'].encode('cp1250')
for rr in rec[allData]:
startDate = rr['rw_date']
startTime = rr['rw_time_start']
endTime = rr['rw_time_end']
evtstart = datetime.datetime.combine(startDate,startTime)
evtend = datetime.datetime.combine(startDate,endTime)
event = Event()

event.add('summary', rec['rw_worker_nick'])
event.add('dtstart', evtstart)
event.add('dtend', evtend)
cal.add_component(event)
text = cal.to_ical()
zipf.writestr(worker +'.ics', text)
text = ''

On Sunday, October 16, 2011 at 12:45:25 PM UTC+2, peter wrote:

 I have now tried the downloady example remotely, on a linux server 
 with niginx and uswgi. This streams the zip file correctly with both 
 chrome and IE8. 

 So the problem is there only when I use the rocket server on windows. 

 I just tried the rocket server remotely, and streaming is correct. 

 So I only get the problem with the rocket server on windows and 
 streaming on windows using IE8. 

 I hope that this helps. As I only need it to work remotely on my linux 
 server I am not left with a problem, but it does appear there is a 
 minor bug there. 

 Peter 



 On Oct 15, 4:34 pm, peter peterchutchin...@gmail.com wrote: 
  This is the code I used, as above 
  def downloady(): 
  
  import os 
  import contenttype as c 
  path=somepath/album.zip 
  response.headers['Content-Type'] = c.contenttype(path) 
  response.headers['Content-Disposition'] = 'attachment; 
  filename=album.zip'# to force download as attachment 
  
  return response.stream(open(path,'rb'),chunk_size=4096) 
  
  Peter 
  
  On Oct 15, 3:53 pm, Massimo Di Pierro massimo.dipie...@gmail.com 
  wrote: 
  
  
  
   Why 
   response.headers['Content-Type'] = application/octet-stream 
   shouldn't it be 
   response.headers['Content-Type'] = application/zip 
  
   I am not sure this causes the problem but it may be, if IE thinks the 
   data is ascii and not binary. 
  
   On Oct 15, 4:46 am, peter peterchutchin...@gmail.com wrote: 
  
Yes, the downloaded file is corrupted with IE8 but not with chrome. 
When I compare the files with a hex editor, they both begin and end 
the same, however, the last byte of the original file is at 6EA11, 
whereas the last byte of the downloaded file is at 6D7311. 
  
So it appears that it is losing a few bytes but not at either end. 
  
Windows reports the size of the two files as 6.91MB on server and 
6.83MB after downloading 
  
Peter 
  
On Oct 14, 11:40 pm, Massimo Di Pierro massimo.dipie...@gmail.com 
wrote: 
  
 You mean the downloaded file is corrupted? Can you check the size? 
  
 On Oct 14, 5:33 pm, peter peterchutchin...@gmail.com wrote: 
  
  Okay this is where I am now. 
  
  My example 'downloady' above works correctly in chrome but 
 incorrectly 
  in IE8. In IE8, the file appears to download correctly but will 
 not 
  unzip. 
  
  Peter 
  
  On Oct 14, 7:13 pm, Matt Broadstone mbroa...@gmail.com wrote: 
  
   On Fri, Oct 14, 2011 at 12:48 PM, Massimo Di Pierro
 massimo.dipie...@gmail.com wrote: 
What browser? 
  
   That was chrome. The previously fix suggested by Brian works 
 for me (thanks!). 
  
   Matt 
  
On Oct 14, 10:30 am, Matt Broadstone mbroa...@gmail.com 
 wrote: 
On Fri, Oct 14, 2011 at 9:35 AM, peter 
 peterchutchin...@gmail.com wrote: 
 If I now do exactly what I did one month ago, there is 
 now no error 
 with zip streaming. So maybe you have changed things in 
 response.stream since then. 
  
 Peter 
  
 On Oct 14, 1:24 pm, peter peterchutchin...@gmail.com 
 wrote: 
 I sent from my wifes emailhttp://
 groups.google.com/group/web2py/browse_thread/thread/fe85dca9e4... 
  
 However with hindsight I think I did not give sufficient 
 information 
 in my forum entry. I guess I was seeing if other people 
 had had 
 problems with downloading zip files. 
  
 Today, I just tried the following 
  
 def downloady(): 
  
 import os 
 import contenttype as c 
 path=somepath/album.zip 
 response.headers['Content-Type'] = 
 c.contenttype(path) 
 response.headers['Content-Disposition'] = 
 'attachment; 
 filename=album.zip'# to force download as attachment 
  
 

[web2py] concatenating strings in group by select

2015-06-04 Thread Yebach
Hello

I have the following SQL for PostgreSQL

select 
rw_worker
, rw_date
, array_to_string(array_agg(distinct results_woshi.rw_shift),'') AS shifts

from 
results_woshi 
where 
rw_date  '2015-01-01' and rw_script = 42 
group by rw_worker, rw_date
order by rw_date

The result is

49;2015-05-01;2200-0600
50;2015-05-01;0600-14001400-2200
51;2015-05-01;0600-1400
52;2015-05-01;1400-22002200-0600


any ideas how to translate it to web2py DAL

So I have to concatenate strings in group by statement where strings are 
concatenated in order.

Thank you

-- 
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: one to many relationship

2015-08-11 Thread Yebach
To create one to many form i tried to follow the post from this 
guy 
http://blog.jotbe-fx.de/articles/2522/web2py-Normalized-many-to-many-model-with-multiselect-drop-down

Also to create the dropdown etc.

The thing worked kind of but the problem was that my grid was not getting 
populated once you wanted to edit the new record etc.

I got stuck here with these code.
If anybody has some extra time to go trough and help me optimize it I would 
appreciate it otherwise I will go with normal list: reference field

Thank you

@auth.requires_login() 
def workers():
#za nekatere polja (w_user in W_organizacija) rabmo default vrednosti, ki 
jih ne more nastavljat uporabnik
user = auth.user_id
org = db(db.auth_user.id == 
user).select(db.auth_user.organization)[0][organization]
db.workers.w_user.default = user
db.workers.w_organisation.default = org
#Load workers
#workers = db((db.workers.w_organisation == 10)  (db.workers.w_status== 
db.status.id)).select(db.workers.id,db.workers.w_status, 
db.workers.w_organisation, db.workers.w_first_name, db.workers.w_last_name,\
# 
db.workers.w_nick_name,db.workers.w_email,db.status.s_code,db.workers.w_note)
#print workers
#NAredimo grrid za šifrant delavcev
#Define the query object. Here we are pulling all contacts having date of 
birth less than 18 Nov 1990
query = ((db.workers.w_organisation == org)  ((db.workers.w_status == 1) 
or (db.workers.w_status == 90)))
query_inactive = db((db.workers.w_organisation == org)  
(db.workers.w_status == 100)).select().as_list()
#print query_inactive
 
#Define the fields to show on grid. Note: (you need to specify id field in 
fields section in 1.99.2
fields = (#db.workers.id,
db.workers.w_first_name,
db.workers.w_last_name,
#db.status.s_code,
db.workers.w_nick_name,
db.workers.w_email,
db.workers_skills.skill,
db.workers.w_note)
#Let's specify a default sort order on date_of_birth column in grid
default_sort_order=[db.workers.w_last_name]
db.workers.w_organisation.readable = db.workers.w_user.readable = False
db.workers.w_organisation.writable = db.workers.w_user.writable = False
db.workers.w_organisation.editable = db.workers.w_user.editable = False
#Nardiš polje bl text like :) WIU WIU
db.workers.w_first_name.widget = SQLFORM.widgets.string.widget
db.workers.w_last_name.widget = SQLFORM.widgets.string.widget
db.workers.w_nick_name.widget = SQLFORM.widgets.string.widget
db.workers.w_email.widget = SQLFORM.widgets.string.widget
#VAlidatorji
#db.workers.w_status.requires = IS_IN_DB(db,db.status.s_code) #tega sm rešu 
v db.py
db.workers.w_nick_name.requires = [IS_NOT_EMPTY(error_message=T('Missing 
nick name'))]
db.workers.w_first_name.requires = [IS_NOT_EMPTY(error_message=T('Missing 
first name'))]
db.workers.w_email.requires = IS_EMAIL(error_message=T('Incorrect e-mail 
address'))
#form = SQLFORM.smartgrid(db.workers,linked_tables=['status'])
#Creating the grid object
if (request.args) and (request.args[0] in ['viev', 'edit', 'new']):
skills = [(r.id, r.sk_name) for r in db(db.skills).select()]
grid_workers = SQLFORM.factory(
db.workers,
   
Field('w_status', type='integer', label= T('Status'), widget = 
SQLFORM.widgets.options.widget, default = 1),
Field('w_first_name',type='text', label= T('First 
name'),represent=repr),
  Field('w_last_name',type='text', label= T('Last 
name'),represent=repr),
  Field('w_nick_name',type='text', label= T('Nick 
name'),represent=repr),
Field('w_email',type='text', label= T('e-mail'),represent=repr),
#Field('w_skills','list:reference skills',requires = 
IS_IN_DB(db,db.skills.id,'%(sk_name)s',multiple=True),label= T('Skills')),
#Field('w_groups','list:reference groups',requires = 
IS_IN_DB(db,db.groups.id,'%(gr_name)s',multiple=True),label= T('Groups')),
Field('skills',requires=IS_IN_SET(skills, multiple=True)),
Field('w_note',type='text', label= T('Comment'),represent=repr))
# (3) Validate form data
   if grid_workers.process().accepted:
# (4) Insert package
   
worker_insert = db.workers.insert(
   **db.workers._filter_fields(grid_workers.vars))
if worker_insert and grid_workers.vars.skills:
# (5) Insert component package associations

worker = db(db.workers)
for skills in grid_workers.vars.skills:
existing_skill = db.skills(id)
db.workers_skills.insert(
skill=skills,
worker=worker_insert
)
response.flash = New record created

else:
grid_workers= SQLFORM.grid(query=query, 
left=db.status.on(db.workers.w_status == db.status.id),
fields=fields,  searchable=False, 
orderby=[db.workers.w_nick_name],create=True,
deletable=False, editable=True, paginate=50, buttons_placement = 'right',
showbuttontext = False,
#oncreate=myfunction,
ui = dict(widget='',
 header='',
 content='',
 default='',
 cornerall='',
 cornertop='',
 cornerbottom='',
 button='button btn btn-default',
 

  1   2   >