For example I have this type of functions:
# sono autorizzati i vari manager a seconda della sede
@auth.requires(auth.has_membership('Total-manager') | auth.has_membership('Conegliano-studente') | auth.has_membership('Pordenone-manager') | auth.has_membership('Pordenone-studente') | auth.has_membership('Udine-studente'))
def appuntamenti_studente():
# recupero lo studente selezionato
studente = request.args(0)
# recupero il gruppo
# query per recuperare il nome dello studente
# recupero nome e cognome dello studente
row = db(query_nome_studente).select(db.auth_user.first_name,db.auth_user.last_name).first()
#seleziono gli eventi dello studente
query = (db.evento.studenti.contains(studente))
eventi_stud = db(query).select()
# imposto la grid per far vedere gli eventi dello studente
exportcls = dict(csv_with_hidden_cols=False, html=False, json=False, tsv_with_hidden_cols=False, tsv=False)
# solo se lo studente corrisponde a chi si è loggato
#print 'sono al form normale'
form = SQLFORM.grid(query, args=[studente], fields=[db.evento.titolo, db.evento.inizio,db.evento.fine,db.evento.risorsa, db.evento.materia,db.evento.docente],create=False, details=False, editable=False, deletable=False, maxtextlength=60, exportclasses = exportcls)
else:
redirect(URL('default','index'))
return locals()
I'm testing different "fixed" values in the @auth.requires, but they can be more or less depending on how many roles are in the db. I'd like to do this dynamically from the db, extracting and compising this @auth.requires line in dynamic way. Is it possible? Do you have any examples? Thank you