Example #1
0
    menu_lateral = MenuLateral(list())
    menu_migas = MenuMigas()

from gluon.storage import Storage
from agiscore.gui.mic import Accion, grid_simple

# TODO: remove
response.menu = []

menu_lateral.append(Accion(T('Tipos de pagos'),
                           URL('index'),
                           True),
                    ['index'])
menu_lateral.append(Accion(T('Control de pagos'),
                           URL('pagos'),
                           auth.has_membership(role=myconf.take('roles.admin'))),
                    ['pagos'])

@auth.requires(auth.has_membership(role=myconf.take('roles.admin')))
def index():
    C = Storage()
    C.escuela = db.escuela(1)
    menu_migas.append(T("Tipos de pagos"))
    
    C.titulo = T("Registro de tipos de pago")
    
    # permisos
    puede_editar = auth.has_membership(role=myconf.take('roles.admin'))
#     puede_borrar = auth.has_membership(role=myconf.take('roles.admin'))
    puede_crear = auth.has_membership(role=myconf.take('roles.admin'))
Example #2
0
def run(bot, event, db):
    mod_name = __name__.rsplit('.', 1)[1]
    this_mod = db(db.bot_modules.name == mod_name).select()
    prefix = this_mod.first().vars_pre
    s = event.message.split()
    try:
        trusted = bot.trusted
    except AttributeError:
        trusted = set()

    auth = Auth(db)
    auth.define_tables(username=False, signature=False)

    if event.message.lower().startswith('!ident') and len(s) == 2:
        bot.bot_reply(event, "!ident is deprecated.  Please use !auth.")
        return
        if event.source in trusted_users:
            if s[1] == trusted_users[event.source]:
                trusted.add(event.source)
                bot.trusted = trusted
                bot.bot_reply(event, "Thank you.")
            else:
                bot.bot_reply(event, "Authorization denied.")
        else:
            bot.bot_reply(event, "Authorization denied.")

    if event.message.lower().startswith('!auth') and len(s) > 2:
        user = auth.login_bare(s[1], ' '.join(s[2:]))
        if user and auth.has_membership(user_id=user.id, role='wheel'):
            trusted.add(event.source)
            bot.trusted = trusted
            bot.bot_reply(event, "Thank you.")
        else:
            bot.bot_reply(event, "Authorization denied.")

    if event.message.lower().startswith('!pyc') and len(s) > 1:
        if event.source in trusted:
            import os, sys
            sys.stdout = open('stdout.tmp', 'w')
            exec ' '.join(s[1:])
            sys.stdout.flush()
            sys.stdout = sys.__stdout__
            o = open('stdout.tmp', 'r')
            for line in o.readlines():
                bot.bot_reply(event, line, False)
            o.close()
        else:
            bot.bot_reply(event, "Please authorize yourself with !auth")
    elif event.message.lower().startswith('!py') and len(s) > 1:
        if event.source in trusted:
            import os, sys, sh
            res = str(eval(' '.join(s[1:])))
            #import re
            #res = re.sub(r'[^\w\d\s]', '', res)
            bot.bot_reply(event, res.strip('\n'))
        else:
            bot.bot_reply(event, "Please authorize yourself with !auth")
            
    if s[0] == '!enmod' and len(s) > 1:
        if event.source in trusted:
            mods = s[1:]
            mods_tbl = db.bot_modules
            for m in mods:
                db(mods_tbl.name == m).update(mod_enabled=True)
            bot.bot_reply(event, 'Module(s) {} enabled'.format(', '.join(mods)))
        else:
            bot.bot_reply(event, "Please authenticate yourself with !auth")
    if s[0] == '!dismod' and len(s) > 1:
        if event.source in trusted:
            mods = s[1:]
            mods_tbl = db.bot_modules
            for m in mods:
                db(mods_tbl.name == m).update(mod_enabled=False)
            bot.bot_reply(event, 'Module(s) {} disabled'.format(', '.join(mods)))
        else:
            bot.bot_reply(event, "Please authenticate yourself with !auth")
    if s[0] == '!say' and len(s) > 1:
        if event.source in trusted:
            bot.bot_reply(event, ' '.join(s[1:]), False)
    if (s[0] == '!msg' or s[0] == '!sayc') and len(s) > 2:
        if event.source in trusted:
            target = s[1]
            msg = ' '.join(s[2:])
            bot.bot_log('PRIVMSG', bot.nickname, target, msg)
            bot.send_message(target, msg)
    if s[0] == '!me' and len(s) > 2:
        if event.source in trusted:
            target = s[1]
            msg = ' '.join(s[2:])
            bot.bot_log('CTCP_ACTION', bot.nickname, target, msg)
            bot.send_action(target, msg)
    if s[0] == '!join' and len(s) > 1:
        if event.source in trusted:
            for chan in s[1:]:
                bot.join(chan)
        else:
            bot.bot_reply(event, "Please authenticate yourself with !auth")
    if s[0] == '!part' and len(s) > 1:
        if event.source in trusted:
            for chan in s[1:]:
                bot.part(chan)
        else:
            bot.bot_reply(event, "Please authenticate yourself with !auth")
    if s[0] == '!traceback':
        if event.source in trusted:
            tb = db(db.event_log.event_type == 'ERROR').select().last()
            msg = tb.event_message.split('\n')
            bot.bot_reply(event, 'Time: {}, Source: {}, Target: {}'.format(tb.event_time, tb.event_source, tb.event_target))
            for line in msg:
                bot.bot_reply(event, line, False)
    if s[0] == '!log':
        return
        if event.source in trusted:
            event.target = bot.nickname  # so replies will automatically go to private message
            temp = "{} {}: {} <{}> {}"  # time, target, type, source, message
            if len(s) > 1:
                numlogs = int(s[1])
            else:
                numlogs = 20
            logs = db().select(db.event_log.ALL, orderby=~db.event_log.id, limitby=(0,numlogs)).as_list(storage_to_dict=False)[-1::-1]
            for l in logs:
                msg = temp.format(l.event_time, l.event_target, l.event_type, l.event_source, l.event_message)
                bot.bot_reply(event, msg)
        elif event.target.startswith('#'):
            chan = event.target
            event.target = bot.nickname  # so replies will go to private message
            temp = "{} {}: {} <{}> {}"  # time, target, type, source, message
            if len(s) > 1:
                numlogs = min(int(s[1]), 50)
            else:
                numlogs = 20
            logs = db(db.event_log.event_target == chan).select(db.event_log.ALL, orderby=~db.event_log.id, limitby=(0,numlogs)).as_list(storage_to_dict=False)[-1::-1]
            for l in logs:
                msg = temp.format(l.event_time, l.event_target, l.event_type, l.event_source, l.event_message)
                bot.bot_reply(event, msg)
        else:
            bot.bot_reply(event, "Please authenticate yourself with !auth")
    if s[0] == '!nick' and len(s) == 2:
        if event.source in trusted:
            bot.set_nickname(s[1])
        else:
            bot.bot_reply(event, "Please authenticate yourself with !auth")
Example #3
0
from gluon.storage import Storage
from agiscore.gui.mic import Accion, grid_simple
from agiscore.gui.evento import form_configurar_evento
from agiscore.db.evento import esta_activo
from agiscore.db import pais as pais_model
from agiscore.db.matricula import SIN_MATRICULAR, SIN_MATRICULAR_CON_DEUDA
from agiscore.db.matricula import MATRICULADO, MATRICULADO_CON_DEUDAS
from agiscore.db.candidatura import NO_ADMITIDO, ADMITIDO
from agiscore.validators import IS_DATE_LT

# TODO: remove
response.menu = []

menu_lateral.append(Accion(T('Configurar evento'),
                           URL('configurar', args=[request.args(0)]),
                           auth.has_membership(role=myconf.take('roles.admin'))),
                    ['configurar'])
menu_lateral.append(Accion(T('Registro de admitidos'),
                           URL('index', args=[request.args(0)]),
                           auth.user is not None),
                    ['index', 'pago', 'matricular'])

@auth.requires(auth.has_membership(role=myconf.take('roles.admin')))
def configurar():
    """Configuración del evento"""
    C = Storage()
    C.evento = db.evento(request.args(0))
    C.ano = db.ano_academico(C.evento.ano_academico_id)
    C.unidad = db.unidad_organica(C.ano.unidad_organica_id)
    C.escuela = db.escuela(C.unidad.escuela_id)
Example #4
0
auth.settings.registration_requires_approval = False
auth.settings.reset_password_requires_verification = True

auth.messages.verify_email = auxiliartools.render_verifymail(
    request.vars.email, request.vars.first_name)
auth.messages.reset_password = auxiliartools.render_resetmail(
    request.vars.email)
auth.settings.register_onaccept = auxiliartools.set_membership(
    auth, 'clientes')

auth.messages.verify_email_subject = '[gextiendas.es] Verificación de email'
auth.messages.reset_password_subject = '[gextiendas.es] Password reset'
auth.messages.reset_password_log = '[gextiendas.es] User %(id)s Password reset'
auth.messages.label_reset_password_key = '[gextiendas.es] Reset Password key'

if auth.has_membership('administradores') or auth.has_membership(
        'superadministradores'):
    auth.settings.login_next = URL(c='administrator', f='bloglist')
else:
    auth.settings.login_next = URL(c='account', f='index')
# auth.settings.login_next = URL('index')
auth.settings.logout_next = URL(c='default', f='index')
# auth.settings.profile_next = URL('index')
auth.settings.register_next = URL(c='verifyprocess', f='index')
# auth.settings.retrieve_username_next = URL('user', args='login')
auth.settings.retrieve_password_next = URL('index')
auth.settings.change_password_next = URL('index')
auth.settings.request_reset_password_next = URL(c='verifyprocess',
                                                f='requestreset')
auth.settings.reset_password_next = URL(c='app_dashboard', f='index')
auth.settings.verify_email_next = URL('verifyprocess', 'verified')
Example #5
0
    menu_migas = MenuMigas()

from gluon.storage import Storage
from agiscore.gui.mic import Accion, grid_simple
from agiscore import tools

# TODO: remove
response.menu = []

menu_lateral.append(Accion(T('Asignación de aulas'),
                           URL('index', args=[request.args(0)]),
                           True),
                    ['index'])
menu_lateral.append(Accion(T('Codificación de los estudiantes'),
                           URL('codificacion', args=[request.args(0)]),
                           auth.has_membership(role=myconf.take('roles.admin')) or
                           auth.has_membership(role=myconf.take('roles.oexamen'))),
                    ['codificacion'])
menu_lateral.append(Accion(T('Asignación de notas'),
                           URL('notas', args=[request.args(0)]),
                           True),
                    ['notas'])
menu_lateral.append(Accion(T('Reporte de notas'),
                           URL('notas_reporte', args=[request.args(0)]),
                           auth.has_membership(role=myconf.take('roles.admin')) or
                           auth.has_membership(role=myconf.take('roles.admdocente'))),
                    ['notas_reporte'])
menu_lateral.append(Accion(T('Distribución por aulas'),
                           URL('distribucion', args=[request.args(0)]),
                           True),
                    ['distribucion'])
Example #6
0
File: db.py Project: paapu68/web2py
db.define_table('kurssi',
   Field('title', unique=True),
   Field('opettaja_id', 'reference opettaja'),
   format = '%(title)s')

db.define_table('kurssityon_nimi',
   Field('title'),
   Field('kurssi_id','reference kurssi'),
   Field('opettaja_id', 'reference opettaja'),
   format = '%(title)s')

db.define_table('kurssityo',
   Field('nimi_id','reference kurssityon_nimi'),
   Field('palautettu', 'upload'),
   Field('korjattu', 'upload',writable = auth.has_membership(auth.id_group('opettaja'))),
   Field('arvosana',writable = auth.has_membership(auth.id_group('opettaja'))),
   Field('kurssi_id', 'reference kurssi'),
   Field('opiskelija_id', 'reference opiskelija'),
   format=lambda r: '%s' \
       % (db.kurssityon_nimi[r.nimi_id].title)
   )

#db.tyo.title.requires = IS_NOT_IN_DB(db, db.tyo.title)
#db.post.image_id.requires = IS_IN_DB(db, db.image.id, '%(title)s')
#db.post.author.requires = IS_NOT_EMPTY()
#db.post.email.requires = IS_EMAIL()
#db.post.body.requires = IS_NOT_EMPTY()

#db.post.image_id.writable = db.post.image_id.readable = False
Example #7
0
#get_pdts = lambda rec: '\n'.join(rec(pairfields[i][3]) or '' for i in xrange(10))

get_pttl = lambda rec: '\n'.join(p['ttl'] or '' for p in rec['pairs'])
get_pdet = lambda rec: '\n'.join(p['det'] or '' for p in rec['pairs'])

get_pttl_array = lambda rec: [p['ttl'] or '' for p in rec['pairs']]

#get_whenwho = lambda: dict(modon=request.now.date(), modby=user_id)
#get_whenwho = lambda: dict(modon=request.now, modby=user_id)

## after defining tables, uncomment below to enable auditing
# auth.enable_record_versioning(db)

user_id = '%X'%auth.user.id if auth.user else False
#user_id = ObjectId(auth.user.id) if auth.user else ''
is_admin = auth.has_membership('administrators')

#if auth.user:
    #print auth.user.id, auth.user.first_name
    #print 'managers', auth.has_membership('managers')
    #print 'administrators', auth.has_membership('administrators')

if is_admin:
    response.headers['Admin'] = True
response.headers['User-Id'] = user_id
btnBack = XML('<button type="button" class="close" aria-hidden="true" onclick="history.back();return false;" title="%s (Esc)">&times;</button>' % T("Back"))
PFORM = lambda title, form, script='': DIV(DIV(DIV(title, btnBack, _class="panel-heading"), DIV(form, _class="panel-body"), _class="panel panel-info"), SCRIPT('$("div.panel input:visible:first").focus();', script, _type='text/javascript'), _class="container cont-mid")
itext = lambda c, t: I(_class='glyphicon glyphicon-'+c) + ' ' + t

if not request.ajax:
    response.title = request.application.replace('_',' ').title()
Example #8
0
mail.settings.sender = '*****@*****.**'
mail.settings.login = '******'


## configure auth policy
#To activate email based verification
auth.settings.registration_requires_verification = True
#To allow user to automatically login after regirsteration
auth.settings.login_after_registration = True
#Not to create user group for every user
auth.settings.create_user_groups = False

auth.messages.verify_email = 'You are now registered customer of Glassy.Please 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.messages.reset_password = '******' + request.env.http_host + URL(r=request,c='default',f='user',args=['reset_password']) + '/%(key)s to reset your password'

if auth.has_membership(role='admin'):
    auth.settings.login_next = URL('admin','manage_users')
    auth.settings.register_next = URL('admin','manage_users')
else:
    auth.settings.login_next = URL('default','browseandshop')
    auth.settings.register_next = URL('default','browseandshop')

#########################################################################
## 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'
## There is an implicit 'id integer autoincrement' field
## Consult manual for more options, validators, etc.