def post(self): num_usuarios = self.get_argument("num_usuarios","") data_inicial = converteDataDMYToYMDStr(self.get_argument("data_inicio","")) data_final = converteDataDMYToYMDStr(self.get_argument("data_encerramento","")) format = '%Y-%m-%d' msg = "" if (not data_inicial) or (not data_final): msg = u"Data final ou inicia _prv.apps = priv_appsl inválida. <br/>" elif ((datetime.strptime(data_final, format)) < (datetime.strptime(data_inicial, format))): msg = u"Data final anterior à data inicial. <br/>" (listaDeDados, listaDeMembros) = model.Log.get_system_user_stats(num_usuarios, data_inicial, data_final) tamanho_eixo = model.get_maximum_axis_size(listaDeDados) if msg: self.render("modules/log/form-system-user-stats.html", NOMEPAG=u"estatísticas", REGISTRY_ID=PRIV_GLOBAL_ADMIN, \ MSG=msg) else: self.render("modules/log/render-system-user-stats.html", NOMEPAG=u"estatísticas", LISTADEDADOS = listaDeDados, LISTADEUSUARIOS = listaDeMembros, \ REGISTRY_ID=PRIV_GLOBAL_ADMIN, \ TAMANHO_EIXO=tamanho_eixo, TITLE=u"Ações de usuário(s) ao longo do tempo",ALTURA = (len(listaDeDados)*45))
def post(self,registry_id): nome_comunidade = self.get_argument("nome_comunidade","") tipo = self.get_argument("tipo_servico","") membro = self.get_argument("select_membros","") tipo_log = self.get_argument("group1","") periodo_estatistica = self.get_argument("periodo_estatistica","") data_inicial = converteDataDMYToYMDStr(self.get_argument("data_inicio","")) data_final = converteDataDMYToYMDStr(self.get_argument("data_encerramento","")) format = '%Y-%m-%d' msg = "" if (not data_inicial) or (not data_final): msg = u"Data final ou inicial inválida." elif ((datetime.strptime(data_final, format)) < (datetime.strptime(data_inicial, format))): msg = u"Data final anterior à data inicial." else: if periodo_estatistica == "diario": (listaDeDados, listaDeMembros) = model.get_community_user_action_list(nome_comunidade, data_inicial, data_final, tipo, membro, tipo_log, format) if len(listaDeMembros) > 20: msg = u"Não é possível gerar este gráfico com mais de 20 usuários. Por favor, restrinja mais a sua busca ou utilize a estatística de todo o período." elif periodo_estatistica == "total": (listaDeDados, listaDeMembros) = model.get_community_users_action_list_bar_chart(nome_comunidade, data_inicial, data_final, tipo, tipo_log, format) if not listaDeDados: msg = u"Não há ações de um usuário no período solicitado." else: tamanho_eixo = model.get_maximum_axis_size(listaDeDados, periodo_estatistica) if msg: comunidade = core.model.Community().retrieve(registry_id) listaMembrosDaComunidade = [ part[0] for part in comunidade.getMembersList(return_is_owner=False)[1] ] tabs = [] tabs.append(("Nº de Acessos por Usuário", "")) tabs.append(("Nº de Acessos por Objeto", "/stats/object/"+registry_id)) self.render("modules/log/plot-stats-data.html", NOMEPAG=u"estatísticas", \ NOMECOMUNIDADE=registry_id, MEMBROSDACOMUNIDADE=listaMembrosDaComunidade, REGISTRY_ID=registry_id, \ TABS=tabs, MSG=msg) else: if periodo_estatistica == "diario": self.render("modules/log/stats-render.html", NOMEPAG=u"estatísticas", LISTADEDADOS = listaDeDados, LISTADEUSUARIOS = listaDeMembros, \ REGISTRY_ID=registry_id, TAMANHO_EIXO=tamanho_eixo, TITLE=u"Ações de usuário(s) ao longo do tempo") elif periodo_estatistica == "total": self.render("modules/log/stats-render-bar-chart.html", NOMEPAG=u"estatísticas", LISTADEDADOS = listaDeDados, LISTADEUSUARIOS = listaDeMembros, \ REGISTRY_ID=registry_id, TAMANHO_EIXO=tamanho_eixo, TITLE=u"Ações de usuário(s) ao longo do tempo",ALTURA = (len(listaDeDados)*45))