mail.settings.login = '******' # your credentials or None auth.settings.hmac_key = 'sha512:4b841008-250d-45e3-82ca-e2edf506c2ab' # before define_tables() auth.define_tables() # creates all needed tables auth.settings.mailer = mail # for user email verification auth.settings.registration_requires_verification = False auth.settings.registration_requires_approval = True auth.messages.verify_email = 'Click on the link http://'+request.env.http_host+URL('default','user',args=['verify_email'])+'/%(key)s to verify your email' auth.settings.reset_password_requires_verification = True auth.messages.reset_password = '******'+request.env.http_host+URL('default','user',args=['reset_password'])+'/%(key)s to reset your password' auth.define_tables(username=True) crud.settings.auth = None # =auth to enforce authorization on crud if auth.is_logged_in(): user_id = auth.user.id user_name = auth.user.first_name else: user_id = None user_name = None Campos = db.define_table('campos', Field('estado', 'string', length=300), Field('cidade', 'string', length=100), Field('nivel', 'string', length=100), Field('salario', 'double', length=100), Field('framework', 'string', length=100), Field('tipo', 'string', length=100)
Field('description', 'text', required=True, label='Description'), Field('hours','double', label='hours'), Field('usr_id','reference auth_user', label='ID', readable=False) ) db.timeclock.project.requires = IS_IN_DB(db,'siri_projects.name') db.timeclock.work_date.requires = IS_DATE(format='%m/%d/%Y') db.timeclock.time_in.requires = IS_NOT_EMPTY() db.timeclock.time_in_ampm.requires = IS_IN_SET(['AM', 'PM']) db.timeclock.time_in_ampm.default = 'AM' db.timeclock.time_out.requires = IS_NOT_EMPTY() db.timeclock.time_out_ampm.requires = IS_IN_SET(['AM', 'PM']) db.timeclock.time_out_ampm.default = 'PM' db.timeclock.description.requires = IS_NOT_EMPTY() # db.timeclock.hours.readable = False db.timeclock.usr_id.writable = db.timeclock.usr_id.readable = False if auth.is_logged_in(): db.timeclock.usr_id.default = auth.user.id db.define_table('siri_projects', Field('name', 'string', label='Name'), Field('description', 'text', label='Description'), Field('coordinator', 'string', label='Coordinator'), Field('contact_org', 'string', label='Organization'), Field('contact_name', 'string', required=True, label='Contact Person'), Field('contact_phone', 'string', label='Contact Phone'), Field('contact_email', 'string', required=True, label='Contact Email'), Field('contact_loc', 'string', label='Contact Location'), Field('num_students', 'integer', label='# of Students'), Field('reviewed', 'boolean', label='Reviewed'), Field('contracted', 'boolean', label='Contracted'), Field('is_active', 'boolean', label='Active')
## configure email mail=auth.settings.mailer mail.settings.server = 'smtp.googlemail.com' # your SMTP server mail.settings.sender = 'B2B-Ray [server]' # your email # the following line should not be commited to github mail.settings.login = '******' # your credentials or None ## configure auth policy auth.settings.registration_requires_verification = False auth.settings.registration_requires_approval = False auth.settings.reset_password_requires_verification = True auth.settings.create_user_groups = False # requireing login for all application if not auth.is_logged_in() and (request.controller != 'default'): session.flash = 'You need to be logged in to access this page!' redirect(URL(r=request, c='default', f='user', args=['login'], vars=dict(_next=URL(c=request.controller, f=request.function, vars=request.vars, args=request.args)))) ## 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') from gluon.custom_import import track_changes; track_changes(True) ######################################################################### ## Define your tables below (or better in another model file) for example ##
db.define_table('advisor', db.Field('pubid',db.publication,requires = IS_IN_DB(db,'publication.id','%(title)s')), db.Field('personid',db.auth_user,requires = IS_IN_DB(db,'auth_user.id','%(first_name)s %(last_name)s')), ) db.define_table('book', db.Field('pubid',db.publication), db.Field('title','string',length=256,required=True,label='Title*',unique=True), db.Field('xdate','date',requires=IS_DATE(),label='Date*'), # for conf paper, this date is the first day of conference db.Field('publisher','string',length=256,required = True,label='Publisher*'), db.Field('abstract','text'), db.Field('subjectarea',db.subject,requires = IS_IN_DB(db,'subject.id','%(name)s')), db.Field('num','integer',label='Number',default=-1), # techreport serial number db.Field('pdf','upload',label='PDF'), db.Field('ppt','upload',label='Presentation',comment='ppt, etc.',authorize=lambda row: auth.is_logged_in()), db.Field('pdfsource','upload',label='PDF Source',comment='latex, doc, etc.',authorize=lambda row: auth.is_logged_in()), db.Field('programs','upload',comment='tgz, zip, etc.',authorize=lambda row: auth.is_logged_in()), db.Field('icon','upload'), db.Field('xkey','string',label='Key',length=64,comment = 'Bibtex key for citations'), db.Field('edited','boolean',comment='Is this book edited or authored? Edited means different authors for each chapter and an editor acts as a coordinator.'), db.Field('volume','string',length=64), db.Field('series','string',length=64), db.Field('edition','integer',requires = IS_NULL_OR(IS_INT_IN_RANGE(1,100000))), db.Field('bookurl','string',length=256,requires = IS_NULL_OR(IS_URL())), db.Field('uploaded_by','string'), db.Field('upload_date','date',requires=IS_DATE()), ) #book.pdfsource.requires = IS_NOT_EMPTY()
mail.settings.login = '******' ## configure auth policy auth.settings.registration_requires_verification = False auth.settings.registration_requires_approval = False auth.settings.reset_password_requires_verification = True ## 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') ######################################################################### #login as first user if user comes from localhost ######################################################################### import os.path if not auth.is_logged_in() and db(db.auth_user.id>0).count() and not os.path.exists(os.path.join(request.folder, 'LOCK')) and (request.env.remote_addr in '127.0.0.1 localhost'.split()): from gluon.storage import Storage user = db(db.auth_user.id==1).select().first() auth.user = Storage(auth.settings.table_user._filter_fields(user, id=True)) auth.environment.session.auth = Storage(user=user, last_visit=request.now, expiration=auth.settings.expiration) response.flash = 'You were automatically logged in as %s %s. To prevent this create the file %s'%(user.first_name, user.last_name, os.path.join(request.folder, 'LOCK')) ######################################################################### ######################################################################### ## Define your tables below (or better in another model file) for example ## ## >>> db.define_table('mytable',Field('myfield','string')) ## ## Fields can be 'string','text','password','integer','double','boolean' ## 'date','time','datetime','blob','upload', 'reference TABLENAME'
crud, service, plugins = Crud(db), Service(), PluginManager() auth.settings.login_url = URL("users", "login") auth.settings.controller = "users" ## create all tables needed by auth if not custom tables auth.define_tables(username=False, signature=False) ## configure email mail = auth.settings.mailer mail.settings.server = "logging" or "smtp.gmail.com:587" mail.settings.sender = "*****@*****.**" mail.settings.login = "******" ## configure auth policy auth.settings.registration_requires_verification = False auth.settings.registration_requires_approval = False auth.settings.reset_password_requires_verification = True ## 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") userId = (auth.user.id) if (auth.is_logged_in()) else 0 databaseQueries.defineDBTables(db, userId) ## after defining tables, uncomment below to enable auditing # auth.enable_record_versioning(db)
## configure email mail = auth.settings.mailer mail.settings.server = 'smtp.googlemail.com' # your SMTP server mail.settings.sender = 'B2B-Ray [server]' # your email # the following line should not be commited to github mail.settings.login = '******' # your credentials or None ## configure auth policy auth.settings.registration_requires_verification = False auth.settings.registration_requires_approval = False auth.settings.reset_password_requires_verification = True auth.settings.create_user_groups = False # requireing login for all application if not auth.is_logged_in() and (request.controller != 'default'): session.flash = 'You need to be logged in to access this page!' redirect( URL(r=request, c='default', f='user', args=['login'], vars=dict(_next=URL(c=request.controller, f=request.function, vars=request.vars, args=request.args)))) ## 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')