Re: [web2py] Re: want to insert the data in database when the user will log-in first time

2012-02-25 Thread Sanjeet Kumar
Thanks Massimo

On Fri, Feb 24, 2012 at 9:23 PM, Massimo Di Pierro 
massimo.dipie...@gmail.com wrote:

 How about adding this at the bottom of your model:

 def do_something(form): 
 auth.settings.login_onaccept = do_something

 On Feb 24, 3:47 am, Sanjeet Kumar sanjeet@gmail.com wrote:
   I want to insert the data in database when the user will log-in first
 time
  . if the user refresh the index page after login it will again insert the
  date and time I have the following sample code  i know this code is wrong
  but i want to insert the data only first time when the user will log-in.
 
  @auth.requires_login()
  def index():
  #response.flash = c
  if auth.is_logged_in():
  response.flash='You are logged in'
  else:
  import datetime
  c=datetime.datetime.now()
  for row in db(db.auth_user.email ==
  auth.user.email).select(db.auth_user.first_name):
  firstname=row.first_name
  db.employee_detail.insert(employee_id = auth.user.email,
  employee_name=firstname, employee_login_time=c)
  return dict(message=T('Hello World'))



[web2py] Re: want to insert the data in database when the user will log-in first time

2012-02-24 Thread Massimo Di Pierro
How about adding this at the bottom of your model:

def do_something(form): 
auth.settings.login_onaccept = do_something

On Feb 24, 3:47 am, Sanjeet Kumar sanjeet@gmail.com wrote:
  I want to insert the data in database when the user will log-in first time
 . if the user refresh the index page after login it will again insert the
 date and time I have the following sample code  i know this code is wrong
 but i want to insert the data only first time when the user will log-in.

 @auth.requires_login()
 def index():
     #response.flash = c
     if auth.is_logged_in():
         response.flash='You are logged in'
     else:
         import datetime
         c=datetime.datetime.now()
         for row in db(db.auth_user.email ==
 auth.user.email).select(db.auth_user.first_name):
             firstname=row.first_name
         db.employee_detail.insert(employee_id = auth.user.email,
 employee_name=firstname, employee_login_time=c)
     return dict(message=T('Hello World'))


[web2py] Re: want to insert the data in database when the user will log-in first time

2012-02-24 Thread weheh
Not to take away from Massimo's answer, which is obviously the right
way to do it, but the thing you're example is trying to do is
basically done for you automatically in the auth_event table.

On Feb 24, 11:53 pm, Massimo Di Pierro massimo.dipie...@gmail.com
wrote:
 How about adding this at the bottom of your model:

 def do_something(form): 
 auth.settings.login_onaccept = do_something

 On Feb 24, 3:47 am, Sanjeet Kumar sanjeet@gmail.com wrote:







   I want to insert the data in database when the user will log-in first time
  . if the user refresh the index page after login it will again insert the
  date and time I have the following sample code  i know this code is wrong
  but i want to insert the data only first time when the user will log-in.

  @auth.requires_login()
  def index():
      #response.flash = c
      if auth.is_logged_in():
          response.flash='You are logged in'
      else:
          import datetime
          c=datetime.datetime.now()
          for row in db(db.auth_user.email ==
  auth.user.email).select(db.auth_user.first_name):
              firstname=row.first_name
          db.employee_detail.insert(employee_id = auth.user.email,
  employee_name=firstname, employee_login_time=c)
      return dict(message=T('Hello World'))


[web2py] Re: want to insert the data in database when the user will log-in first time

2012-02-24 Thread pbreit
Is there any way to add captured data or otherwise customize the auth_event 
auto-logging?

[web2py] Re: want to insert the data in database when the user will log-in first time

2012-02-24 Thread Anthony
On Friday, February 24, 2012 12:57:50 PM UTC-5, pbreit wrote:

 Is there any way to add captured data or otherwise customize the 
 auth_event auto-logging?


One option might be to add some custom fields to the auth_event table and 
then dynamically set default values for those fields so when the Auth 
system does an insert into the table, the extra fields will be populated 
appropriately.

Anthony