def informe_mes_empleado(): empleados = db(db.empleado.is_active is True).select(db.empleado.ALL) fempl = ([" "] + [f"{p.user_code} {p.nombre} {p.apellido}" for p in empleados]) form = FORM( CENTER( H4('Marcadas del personal'), TABLE( TR( TAG('<label class "control-label">Persona</label>'), SELECT(fempl, _name='fempleado', _type='text', _id="persona", _class="form-control string")), TR( TAG('<label class "control-label">Periodo desde</label>'), INPUT(_name='fdesde', _type='date', _id="mesanio", _class="form-control string", requires=IS_NOT_EMPTY())), TR( TAG('<label class "control-label">Periodo hasta</label>'), INPUT( _name='fhasta', _type='date', _id="mesanio", _class="form-control string", ))), BR(), INPUT(_type="submit", _class="btn btn-primary btn-medium", _value='Continuar'))) if form.accepts(request, session): session.empleado = request.vars['fempleado'] session.user_code = request.vars['fempleado'].split()[0] session.fdesde = request.vars['fdesde'] session.fhasta = request.vars['fhasta'] log(f"seleccionado {session.empleado}") log(f"desde: {session.fdesde} hasta {session.fhasta}") # selector = (db.empleado.user_code == user_code) # usuario = db(selector).select().first().as_dict() session.tdesde = datetime.datetime.strptime(session.fdesde, '%Y-%m-%d') session.thasta = datetime.datetime.strptime(session.fhasta, '%Y-%m-%d') lista = aplico_politica(session.user_code, session.fdesde, session.fhasta) nombre_archivo = f'''{session.empleado} -{session.fdesde}-{session.fhasta}''' session.table = list_dict_to_table_sortable(lista, nombre_archivo) redirect(URL('informe')) else: log(f'acceso {request.function}') return dict(form=form)
def grand_button(nombre, link, icono, **kwargs): """ nombre: 1 a 3 palabras""" lista = nombre.split() spanlist = [] for i in lista: spanlist.append(SPAN(i.title())) spanlist.append(BR()) result = DIV(spanlist) if 'vars' in kwargs: url = URL(link, vars=kwargs['vars']) else: url = URL(link) boton = A(TABLE(I(_class='fa ' + str(icono) + ' fa-3x'), result), _class="btn-square-blue", _href=url) return boton
def get_html(self): streak_value = self.get_data() if self.kind == "day": card_content = P("You're at a ", B("%d day streak" % streak_value), ". Keep solving a new problem everyday!") elif self.kind == "accepted": card_content = P("You're at a ", B("%d accepted problem streak" % streak_value), ".", BR(), "Let the greens rain!") else: return "FAILURE" card_html = BaseCard.get_html( self, **dict(card_title=self.card_title, card_content=card_content, cta_links=self.get_cta_html(), card_color_class="white", card_text_color_class="black-text")) return card_html
def __call__(self): T = current.T db = current.db s3db = current.s3db s3 = current.response.s3 session_s3 = current.session.s3 output = {} # Recent Updates etable = s3db.event_event stable = s3db.event_sitrep query = (stable.deleted == False) fields = [ etable.name, stable.id, stable.date, stable.name, stable.summary, ] left = [etable.on(etable.id == stable.event_id)] language = session_s3.language if language != current.deployment_settings.get_L10n_default_language(): ntable = s3db.event_event_name left.append(ntable.on((ntable.event_id == etable.id) & \ (ntable.language == language))) fields.append(ntable.name_l10n) use_local_event_name = True else: use_local_event_name = False sitreps = db(query).select(left=left, limitby=(0, 3), orderby=~stable.date, *fields) len_sitreps = len(sitreps) if len_sitreps == 0: from s3 import S3CRUD recent_updates = DIV(S3CRUD.crud_string("event_sitrep", "msg_list_empty"), _class="empty") else: recent_updates = DIV() rappend = recent_updates.append count = 0 for s in sitreps: count += 1 if use_local_event_name: event_name = s["event_event_name.name_l10n"] or s[ "event_event.name"] else: event_name = s["event_event.name"] if not event_name: event_name = s["event_sitrep.name"] rappend( H3( A( event_name, _href=URL( c="event", f="sitrep", args=[s["event_sitrep.id"]], ), ))) rappend(P(XML(s["event_sitrep.summary"]))) if count != len_sitreps: rappend(HR()) output["recent_updates"] = recent_updates map_btn = A( T("MAP OF CURRENT NEEDS"), #_href = URL(c="default", # f="index", # args="dashboard", # ), _href=URL( c="req", f="need_line", args="map", ), _class="small primary button", ) create_btn = A( T("CREATE A NEED"), _href=URL( c="req", f="need", args="create", ), _class="small primary button", ) output["needs_btn"] = DIV( SPAN(map_btn), SPAN(create_btn), _class="button-group radius", ) output["about_btn"] = A( "%s >" % T("Read More"), _href=URL( c="default", f="about", ), ) # Resources section if current.deployment_settings.has_module("cms"): system_roles = current.auth.get_system_roles() ADMIN = system_roles.ADMIN in session_s3.roles table = s3db.cms_post ltable = s3db.cms_post_module module = "default" resource = "index" query = (ltable.module == module) & \ ((ltable.resource == None) | \ (ltable.resource == resource)) & \ (ltable.post_id == table.id) & \ (table.deleted != True) item = current.db(query).select(table.body, table.id, limitby=(0, 1)).first() if item: if ADMIN: item = DIV( XML(item.body), BR(), A(T("Edit"), _href=URL(c="cms", f="post", args=[item.id, "update"]), _class="action-btn")) else: item = DIV(XML(item.body)) elif ADMIN: if s3.crud.formstyle == "bootstrap": _class = "btn" else: _class = "action-btn" item = A(T("Edit"), _href=URL(c="cms", f="post", args="create", vars={ "module": module, "resource": resource }), _class="%s cms-edit" % _class) else: item = "" else: item = "" output["item"] = item # Inject D3 scripts from s3 import S3Report S3Report.inject_d3() # Inject charts-script appname = current.request.application scripts = s3.scripts if s3.debug: script = "/%s/static/scripts/S3/s3.ui.charts.js" % appname if script not in scripts: scripts.append(script) else: script = "/%s/static/scripts/S3/s3.ui.charts.min.js" % appname if script not in scripts: scripts.append(script) # Instantiate charts scriptopts = { # Standard SHARE theme color set: "colors": [ '#0C9CD0', # blue '#E03158', # red '#FBA629', # amber '#8ABC3F', # green '#AFB8BF', # grey ], } script = '''$('.homepage-chart').uiChart(%s)''' % json.dumps( scriptopts) s3.jquery_ready.append(script) # Add last update time of chart data last_update = HomepageStatistics.last_update() if last_update: output["last_stats_update"] = T("Updated on %(date)s") % { "date": last_update } else: output["last_stats_update"] = None self._view(THEME, "index.html") return output
def __call__(self): output = {} # Allow editing of page content from browser using CMS module ADMIN = current.auth.s3_has_role("ADMIN") s3db = current.s3db table = s3db.cms_post ltable = s3db.cms_post_module module = "default" resource = "Legal" query = (ltable.module == module) & \ (ltable.resource == resource) & \ (ltable.post_id == table.id) & \ (table.deleted != True) item = current.db(query).select(table.body, table.id, limitby=(0, 1)).first() if item: if ADMIN: content = DIV( XML(item.body), BR(), A( current.T("Edit"), _href=URL( c="cms", f="post", args=[item.id, "update"], vars={ "module": module, "resource": resource, }, ), _class="action-btn", ), ) else: content = DIV(XML(item.body)) elif ADMIN: content = A( current.T("Edit"), _href=URL( c="cms", f="post", args="create", vars={ "module": module, "resource": resource, }, ), _class="action-btn cms-edit", ) else: content = "" output["item"] = content self._view(THEME, "cmspage.html") return output
def generate_update(action, type, name, url): if item.get("name"): return TAG[""](action % type, BR(), A(name, _href=url)) else: return TAG[""](action % A(type, _href=url))
_class='refmarker refmarker_{}'.format(idx))) refcounter[idx] = r punctuation = [u'.', u';', u'·', u'"', u"'", u',', u'?', u'«', u'»', u'·'] if u.text == '': mytext.append(A(u' *', _class='placeholder', _href=u.unit_id)) elif u.readings_in_unit > 1: if u.text not in punctuation and u.language not in ['Ethiopic']: mytext.append(u' ') mytext.append(A(u.text, _class=u.language, _href=u.unit_id)) else: if u.text not in punctuation and u.language not in ['Ethiopic']: mytext.append(u' ') mytext.append(SPAN(u.text, _class=u.language)) try: if u.linebreak == 'following': mytext.append(BR()) if u.linebreak == 'doubleFollowing': mytext.append(BR()) mytext.append(BR()) except e: print 'LINEBREAK PROBLEM' print e if vbs: print 'sending', '-'.join(start_sel) return {'versions': myversions, 'current_version': current_version, 'version_language': vlang, 'mslist': mslist, 'start_sel_str': '|'.join(start_sel), 'end_sel_str': '|'.join(end_sel),