示例#1
0
    def get(self, registry_id, tipo):
        user = self.get_current_user()
        
        if isOwner(user, registry_id):
            self._aval = model.Evaluation()
            if tipo=="member":
                self._aval.tipo = "participantes"
                self._comu = core.model.Community().retrieve(registry_id)
                avaliados = self._comu.getMembersList(return_is_owner=False)[1]
                grupos = {}
                for item in self._comu.groups:
                    grupos[item.encode('iso-8859-1')] = [x.encode('iso-8859-1') for x in self._comu.groups[item]]
                groupnames = {}
                for grupo in grupos:  
                    groupnames[grupo.encode('iso-8859-1')] = grupo.encode('iso-8859-1') 
                
            else:       # tipo =="wiki"
                self._aval.tipo = u"páginas"
                avaliados = [row.key[1].split("/")[1] for row in wiki.database.WIKI.view('wiki/partial_data',startkey=[registry_id],endkey=[registry_id, {}]) if row.value["is_folder"]!="S" and not row.value["removido"]]
                (grupos, groupnames) = wiki.model.Wiki.listWikiFolderItens(registry_id, encoding='iso-8859-1')
                
            self.render("modules/evaluation/newevaluation-form.html", MSG="", EVALUATIONDATA=self._aval, \
                                AVALIADOS=avaliados, REGISTRY_ID=registry_id, \
                                GROUPS=grupos, \
                                GROUPNAMES=groupnames, \
                                NOMEPAG=u"Avaliações")

        else:
            self.render("home.html", MSG=u"Você não pode criar avaliação nesta comunidade.", REGISTRY_ID=ifExists(registry_id, user), \
                            NOMEPAG="comunidades")
        """
示例#2
0
    def post(self, registry_id, aval):
        user = self.get_current_user()
        
        if isOwner(user, registry_id):
            aval_id = '/'.join([registry_id,unquote(aval).decode("UTF-8")])
            self._aval = model.Evaluation().retrieve(aval_id)
            if self._aval:            
                msg = ''
                self._aval.data_inicio = self.get_argument("data_inicio","")
                if self._aval.data_inicio == "":
                    msg += u"O campo 'Data/hora de início' não foi preenchido.<br/>"
                self._aval.data_encerramento = self.get_argument("data_encerramento","")
                if self._aval.data_encerramento == "":
                    msg += u"O campo 'Data/hora de encerramento' não foi preenchido.<br/>"
                
                self._aval.descricao = self.get_argument("descricao", "")
                self._aval.data_alt = str(datetime.now())
                if msg:
                    self.render("modules/evaluation/evaluation-edit.html", MSG=msg, EVALUATIONDATA=self._aval, \
                                        REGISTRY_ID=registry_id, NOMEPAG=u"Avaliações")
                    return

                self._aval.save()
                
                log.model.log(user, u'alterou a avaliação', objeto=aval_id, tipo="evaluation")
                self.redirect("/evaluation/%s" % registry_id)

            else:
                self.render("home.html", MSG=u"Avaliação inexistente.", REGISTRY_ID=registry_id, \
                                NOMEPAG=u"Avaliações")
        else:
            self.render("home.html", MSG=u"Você não pode alterar avaliações nesta comunidade.", REGISTRY_ID=ifExists(registry_id, user), \
                            NOMEPAG="comunidades")
示例#3
0
文件: rest.py 项目: labase/activnce
    def get(self, registry_id):
        user = self.get_current_user()        
        if isOwner(user, registry_id):
            avaliacoes = model.Evaluation.listEvaluationsByUser(registry_id)
            
            log.model.log(user, u'acessou os resultados das avaliações de', objeto=registry_id, tipo="evaluation", news=False)
            self.write (dict(status=0, result=avaliacoes))                

        else:
            self.write (dict(status=1, msg=u"Você não tem permissão para acessar esta página."))
示例#4
0
    def get (self, registry_id):
        user = self.get_current_user()
        # Validar acesso
        #if eh_acesso_invalido(self, registry_id): return

        # Classe noticias
        noticias = Noticias(registry_id)
        lista = noticias.get_obj_lista_noticias(user=user)
        
        links = []
        if isOwner(user, registry_id):
            links.append((u"Nova notícia", "/static/imagens/icones/add_news32.png", "/noticia/"+registry_id+"/new"))

        log.model.log(user, u'acessou as notícias de', objeto=registry_id, tipo="noticia", news=False)
                
        #chamando a página
        self.render("modules/noticia/noticia-list.html", NOMEPAG=u'Notícias', \
                    REGISTRY_ID=registry_id, \
                    LINKS=links, NOW=str(datetime.now())[0:11], \
                    LISTA=lista, EH_EDITOR=isOwner(user,registry_id))
        return
示例#5
0
    def post(self):
        user = self.get_current_user()
        msg = ""
            
        #Email agora é um array
        emails = self.get_argument("email", "")
        email_array = list(set(emails.split()))
        
        msg += self._validate_emails(email_array)
        
        user_keys = core.database.REGISTRY[user]['mykeys']
        lista_invited = [ model.MAGKEYS[key]["email"] for key in user_keys]
            
        invited_before = self._already_invited(email_array,lista_invited)
        
        if invited_before:
            for mail in invited_before:
                msg += u"Você já convidou o e-mail: %s<br/>" %mail
        
        for email in email_array:
            if emailExists(email):
                msg += u"Já existe um usuário cadastrado com o email: %s<br/>" % email
        
        # Comunidades é uma lista das comunidades default do usuário
        # que vai se cadastrar com esta chave
        comunidades = []
        for comu in list(set(self.get_argument("comunidades", "").split())):
            if isACommunity(comu):
                if isOwner(user, comu) or isMember(user, PRIV_GLOBAL_ADMIN):
                    comunidades.append(comu)
                else:
                    msg += u"Você deve ser dono ou administrador da comunidade %s.<br/>" % comu
                    
            else:
                msg += u"Comunidade %s não existente.<br/>" % comu
        
        if not msg:
            [self._send_invites(mail, user, comunidades) for mail in email_array]

            request_id = self.get_argument("request_id", "")
            if request_id != "":
                request_data = _EMPTYREQUESTINVITE()
                request_data.update(model.REQUESTINVITE[request_id])
                request_data["estado"] = "aprovado"
                model.REQUESTINVITE[request_id] = request_data
        else:
            msg += u"Os convites não foram enviados.<br/>"

        if msg:
            showInvitesPage(self, user, msg, email_list=emails, community_list=self.get_argument("comunidades", ""))
        else:
            showInvitesPage(self, user, u"Convites enviados com sucesso.<br/>")
示例#6
0
    def get(self, registry_id):
        user = self.get_current_user()        
        if isOwner(user, registry_id):
            avaliacoes = model.Evaluation.listEvaluationsByUser(registry_id)
            
            log.model.log(user, u'acessou os resultados das avaliações de', objeto=registry_id, tipo="evaluation", news=False)
            
            self.render("modules/evaluation/evaluation-votes.html", EVALUATIONRESULTS=avaliacoes, REGISTRY_ID=registry_id, \
                                NOMEPAG=u"Avaliações")

        else:
            self.render("home.html", MSG=u"Você tem autorização para entrar nesta página.", REGISTRY_ID=ifExists(registry_id, user), \
                            NOMEPAG="comunidades")
示例#7
0
    def get(self, registry_id):
        user = self.get_current_user()
        if isMember(user, registry_id):
            
            aval_data = prepareEvaluations(user, model.Evaluation.listEvaluations(user, registry_id))
            
            links = []
            if isOwner(user, registry_id):
                links.append((u"Nova avaliação de páginas", "/static/imagens/icones/wiki32.png", "/evaluation/new/"+registry_id+"/wiki"))
                links.append((u"Nova avaliação de participantes", "/static/imagens/icones/members32.png", "/evaluation/new/"+registry_id+"/member"))
                links.append(("Votos dos participantes", "/static/imagens/icones/vote32.png", "/evaluation/result/"+registry_id))

            log.model.log(user, u'acessou a lista de avaliações de', objeto=registry_id, tipo="evaluation", news=False)
            self.render("modules/evaluation/evaluation-list.html", EVALUATIONDATA=aval_data, \
                        MSG="", \
                        REGISTRY_ID=registry_id, PERMISSION=isOwner(user,registry_id), \
                        LINKS=links, \
                        NOMEPAG=u"Avaliações")

        else:
            self.render("home.html", MSG=u"Você não é membro desta comunidade.", REGISTRY_ID=ifExists(registry_id, user), \
                            NOMEPAG="comunidades")
示例#8
0
文件: rest.py 项目: labase/activnce
    def get(self, registry_id, aval):
        user = self.get_current_user()
        if isOwner(user, registry_id):
            aval_id = '/'.join([registry_id,unquote(aval).decode("UTF-8")])
            self._aval = model.Evaluation().retrieve(aval_id)
            if self._aval:            
                aval_data = prepareResults(self._aval.calcResultAvaliacao())
                log.model.log(user, u'acessou o resultado da avaliação', objeto=aval_id, tipo="evaluation", news=False)

                self.write (dict(status=0, result=aval_data))                
            else:
                self.write (dict(status=1, msg=u"Avaliação inexistente."))                  
        else:
            self.write (dict(status=1, msg=u"Você não tem permissão para acessar esta página."))
示例#9
0
    def get(self, registry_id, aval):
        user = self.get_current_user()
        
        if isOwner(user, registry_id):
            
            aval_id = '/'.join([registry_id,unquote(aval).decode("UTF-8")])
            
            self._aval = model.Evaluation().retrieve(aval_id)
            if self._aval:                    
                self._aval.delete()
                log.model.log(user, u'removeu a avaliação', objeto=aval_id, tipo="none")

            self.redirect("/evaluation/%s" % registry_id)
            
        else:
            self.render("home.html", MSG=u"Você não tem permissão para remover esta avaliação.", REGISTRY_ID=ifExists(registry_id, user), \
                            NOMEPAG="comunidades")
示例#10
0
    def get(self, registry_id, aval):
        user = self.get_current_user()
        if isOwner(user, registry_id):
            aval_id = '/'.join([registry_id,unquote(aval).decode("UTF-8")])
            self._aval = model.Evaluation().retrieve(aval_id)
            if self._aval:            
                aval_data = prepareResults(self._aval.calcResultAvaliacao())
                log.model.log(user, u'acessou o resultado da avaliação', objeto=aval_id, tipo="evaluation", news=False)

                self.render("modules/evaluation/evaluation-result.html", AVALDATA=aval_data, \
                                REGISTRY_ID=registry_id, NOMEPAG=u"Avaliações") 
            else:
                self.render("home.html", MSG=u"Avaliação inexistente.", REGISTRY_ID=registry_id, \
                                NOMEPAG=u"Avaliações")         
        else:
            self.render("home.html", MSG=u"Você não tem permissão para acessar eta página.", REGISTRY_ID=ifExists(registry_id, user), \
                                NOMEPAG=u"Avaliações")         
示例#11
0
    def get(self, registry_id, aval):
        user = self.get_current_user()

        if isOwner(user, registry_id):
            aval_id = '/'.join([registry_id,unquote(aval).decode("UTF-8")])
            self._aval = model.Evaluation().retrieve(aval_id)
            if self._aval:            
                links = []
                links.append((u"Alterar permissões desta avaliação", "/static/imagens/icones/permissions32.png", "/permission/evaluation/"+aval_id, "", "", True))     
                
                self.render("modules/evaluation/evaluation-edit.html", MSG="", EVALUATIONDATA=self._aval, \
                                    REGISTRY_ID=registry_id, NOMEPAG=u"Avaliações", LINKS=links)
            else:
                self.render("home.html", MSG=u"Avaliação inexistente.", REGISTRY_ID=registry_id, \
                                NOMEPAG=u"Avaliações")
        else:
            self.render("home.html", MSG=u"Você não pode alterar avaliações nesta comunidade.", REGISTRY_ID=ifExists(registry_id, user), \
                            NOMEPAG="comunidades")
示例#12
0
文件: rest.py 项目: labase/activnce
 def get (self, registry_id, pagina):
     user = self.get_current_user()
     doc_id = '/'.join([registry_id, pagina])
     self._wiki = model.Wiki().retrieve(doc_id)
     if self._wiki: 
             _revision = self._wiki.rev
             
             form = dict(
                           action="",
                           nomepag=dict(type="@hidden",value=self._wiki.nomepag),
                           revision=dict(type="@hidden",value=self._wiki.rev),
                           tags=dict(type="@text",value=self._wiki.tags),
                           e_usuario=dict(type="@text",value=isAUser(registry_id)),
                           e_owner=dict(type="@text",value=isOwner(user, registry_id)),
                           conteudo=dict(type="@textarea", value=self._wiki.historico[-1]["conteudo"])
             )
             self.write (dict(status=0, result=form))
     else:
         self.write (dict(status=1, msg=u"Documento não encontrado."))
示例#13
0
文件: rest.py 项目: labase/activnce
 def get (self, registry_id):
     user = self.get_current_user()
     folder = self.get_argument("folder","")
     items = self.request.arguments["items"]
     desc_list = []
     for item in items:
         doc_id = '/'.join([registry_id, item])
         self._wiki = model.Wiki().retrieve(doc_id)
         desc = self._wiki.getDescendentsList()
         if desc: 
             desc_list.extend(desc)
     select_folders = [ f for f in model.Wiki.listWikiFolders(registry_id) if f not in desc_list]
     
     if folder:
         doc_id = '/'.join([registry_id, folder])
         self._folder = model.Wiki().retrieve(doc_id)
         if self._folder: 
             
             self.write (dict(status=0, result=dict(path=self._folder.getPagePath(links=False),  
                                                    e_usuario=isAUser(registry_id), e_owner=isOwner(user, registry_id), 
                                                    items=items, folder=folder, folders=select_folders)))
             
     else:
         self.write (dict(status=0, result=dict(path="/%s/"%registry_id,  
                                                    e_usuario=isAUser(registry_id), e_owner=isOwner(user, registry_id), 
                                                    items=items, folder=folder, folders=select_folders)))
示例#14
0
文件: rest.py 项目: labase/activnce
 def get (self, registry_id, pagina):
     user = self.get_current_user()
     doc_id = '/'.join([registry_id, pagina])
     self._wiki = model.Wiki().retrieve(doc_id)
     if self._wiki:
         
         self.write (dict(status=0, result=dict(path=self._wiki.getPagePath(links=False), pagina=pagina,   
                                                    e_usuario=isAUser(registry_id), e_owner=isOwner(user, registry_id))))
     else:
         self.write (dict(status=1, msg=u"Documento não encontrado."))
示例#15
0
文件: rest.py 项目: labase/activnce
    def post(self, registry_id, pagina):
        user = self.get_current_user()
        doc_id = '/'.join([registry_id, pagina])
        self._wiki = model.Wiki().retrieve(doc_id)
        if self._wiki: 
            old_name = self._wiki.nomepag
            new_name = self.get_argument("nomepag_novo","")
            if new_name:
                if model.Wiki.nomepagExists(registry_id, new_name):
                    msg = u"Já existe uma página ou pasta com este nome<br/>"
                    self.write (dict(status=1, result=dict(path=self._wiki.getPagePath(links=False), pagina=pagina, newname=new_name, msg=msg,    
                                                       e_usuario=isAUser(registry_id), e_owner=isOwner(user, registry_id))))
        
                else:
                    # atualiza nome da pasta
                    self._wiki.nomepag = new_name
                    self._wiki.data_alt = str(datetime.now())
                    self._wiki.alterado_por = user
                    self._wiki.save()
                    
                    # notifica o dono da página movida
                    email_msg = u"Pasta renomeada: "+doc_id+"\n"+\
                                u"De: " + old_name + " Para: " + new_name + "\n" +\
                                Notify.assinatura(user, registry_id, self._wiki.data_alt)+"\n\n"
                    Notify.email_notify(self._wiki.owner, user, u"renomeou uma pasta criada por você", \
                                   message=email_msg, \
                                   link="/wiki/%s?folder=%s"%(registry_id, pagina))
                    
                    log.model.log(user, u'renomeou a pasta', objeto=registry_id+"/"+self._wiki.nomepag, link="/wiki/%s?folder=%s"%(registry_id, pagina), tipo="wiki")
                    self.write (dict(status=0, msg=u"Pasta renomeada com sucesso."))
                    
            else:
                msg = u"Nome da pasta não preenchido."
                self.write (dict(status=1, result=dict(path=self._wiki.getPagePath(links=False), pagina=pagina, newname=new_name, msg=msg,    
                                                       e_usuario=isAUser(registry_id), e_owner=isOwner(user, registry_id))))

                
        else:
            self.write (dict(status=0, msg=u"Documento não encontrado: provavelmente o mesmo foi removido enquanto você editava-o."))
示例#16
0
    def post(self, registry_id, aval):
        user = self.get_current_user()
        
        aval_id = '/'.join([registry_id,unquote(aval).decode("UTF-8")])
        self._aval = model.Evaluation().retrieve(aval_id)
        if self._aval:            
            #if verificaPeriodo(aval_data["data_inicio"], aval_data["data_encerramento"]):
            if verificaIntervaloDMY(self._aval.data_inicio, self._aval.data_encerramento) == 0:

                if self._aval.alreadyHasEvaluated(user):
                    self.render("home.html", MSG=u"Você já realizou esta avaliação.", REGISTRY_ID=registry_id, \
                                NOMEPAG=u"Avaliações")                    
                else:   
                    # processa a avaliação realizada
                    participantes = core.database.REGISTRY[registry_id]["participantes"]
    
                    opcoes = []
                    for i in range(len(self._aval.pontuacao)):
                        opcao = self.get_argument("opcao%d"%(i+1),"")
                        if not opcao:
                            self.render("modules/evaluation/evaluation-form.html", MSG=u"Alguma opção não foi selecionada.", \
                                AVALDATA=self._aval, PARTICIPANTES=participantes, AVAL_ID=aval_id, REGISTRY_ID=registry_id, \
                                NOMEPAG=u"Avaliações")
                            return
                        else:  
                            opcoes.append(opcao)
                    if len(opcoes) != len(list(set(opcoes))):
                        self.render("modules/evaluation/evaluation-form.html", MSG=u"Alguma opção foi selecionada mais de uma vez.",
                                AVALDATA=self._aval, PARTICIPANTES=participantes, AVAL_ID=aval_id, REGISTRY_ID=registry_id, \
                                NOMEPAG=u"Avaliações")
                        return

                    # atualiza a lista de votos dados pelo usuário
                    if user in self._aval.avaliacoes:
                        self._aval.avaliacoes[user]["votos_dados"] = opcoes
                    else:
                        self._aval.avaliacoes[user] = {
                            "votos_dados": opcoes,
                            "votos_recebidos": 0
                        }
                        
                    # incrementa a pontuação de cada usuário votado
                    pos=0
                    for op in opcoes:
                        if op not in self._aval.avaliacoes:
                            self._aval.avaliacoes[op] = {
                                "votos_dados": [],
                                "votos_recebidos": 0
                            }
                        self._aval.avaliacoes[op]["votos_recebidos"] += int(self._aval.pontuacao[pos])
                        pos += 1
                        
                    self._aval.save()   
                    log.model.log(user, u'realizou a avaliação', objeto=aval_id, tipo="evaluation")
                    
                    aval_data = prepareEvaluations(user, model.Evaluation.listEvaluations(user, registry_id))
                    
                    links = []
                    if isOwner(user, registry_id):
                        links.append((u"Nova avaliação de páginas", "/static/imagens/icones/wiki32.png", "/evaluation/new/"+registry_id+"/wiki"))
                        links.append((u"Nova avaliação de participantes", "/static/imagens/icones/members32.png", "/evaluation/new/"+registry_id+"/member"))
                        links.append(("Votos dos participantes", "/static/imagens/icones/vote32.png", "/evaluation/result/"+registry_id))
        
                    self.render("modules/evaluation/evaluation-list.html", EVALUATIONDATA=aval_data, \
                                MSG=u"Avaliação realizada com sucesso.", \
                                REGISTRY_ID=registry_id, PERMISSION=isOwner(user,registry_id), \
                                LINKS=links, \
                                NOMEPAG=u"Avaliações")
            
            else:
                self.render("home.html", MSG=u"Fora do período de avaliação.", REGISTRY_ID=registry_id, \
                        NOMEPAG=u"Avaliações")

        else:
            self.render("home.html", MSG=u"Avaliação inexistente.", REGISTRY_ID=registry_id, \
                            NOMEPAG=u"Avaliações")         
示例#17
0
    def post(self, registry_id, tipo):
        user = self.get_current_user()
        
        msg = ""
        if isOwner(user, registry_id):
            self._aval = model.Evaluation()
            self._aval.nome = self.get_argument("nome","")
            if not self._aval.nome:
                msg += u"Nome da avaliação não informado.<br/>"
            else:
                self._aval.nome = remove_special_chars(remove_diacritics(self._aval.nome.replace(" ","_")))
                if self._aval.nome == "":
                    msg += u"Nome da avaliação inválido.<br/>"
            
            self._aval.descricao = self.get_argument("descricao", "")
            
            if tipo=="member":
                self._aval.tipo = "participantes"
                self._comu = core.model.Community().retrieve(registry_id)
                avaliados = self._comu.participantes
                grupos = self._comu.groups
                groupnames = {}
                for grupo in grupos:  
                    groupnames[grupo] = grupo  
                
            else:       # tipo =="wiki"
                self._aval.tipo = u"páginas"
                avaliados = [row.key[1].split("/")[1] for row in wiki.database.WIKI.view('wiki/partial_data',startkey=[registry_id],endkey=[registry_id, {}]) if row.value["is_folder"]!="S" and not row.value["removido"]]
                (grupos, groupnames) = wiki.model.Wiki.listWikiFolderItens(registry_id)



                
            # qdo colocamos as views passou a dar erro de encoding
            # avaliados = [x.encode("UTF-8") for x in avaliados]
            for item in avaliados:
                if self.get_argument(item,"") == "S":
                    self._aval.avaliados.append(item)
                    
            if not self._aval.avaliados:
                msg += u"Selecione pelo menos um item para ser avaliado.<br/>"
                
            pontuacao = self.get_argument("pontuacao","").strip()
            if pontuacao:
                self._aval.pontuacao = pontuacao.split(",")
            else:
                msg += u"O campo 'Pontuação' não foi preenchido.<br/>"
            self._aval.owner = user
            self._aval.data_cri = str(datetime.now())
            
            self._aval.data_inicio = self.get_argument("data_start","")
            if not self._aval.data_inicio:
                msg += u"O campo 'Data/hora de início' não foi preenchido.<br/>"
            
            self._aval.data_encerramento = self.get_argument("data_end","")
            if not self._aval.data_encerramento:
                msg += u"O campo 'Data/hora de encerramento' não foi preenchido.<br/>"

            if msg:
                self.render("modules/evaluation/newevaluation-form.html", MSG=msg, EVALUATIONDATA=self._aval, \
                                    AVALIADOS=avaliados, REGISTRY_ID=registry_id, \
                                    GROUPS=grupos, \
                                    GROUPNAMES=groupnames, \
                                    NOMEPAG=u"Avaliações")                
            else:
                aval_id = "%s/%s" % (registry_id, self._aval.nome)
                try:
                    self._aval.save(id=aval_id)
                except Exception as detail:
                    self.render("modules/evaluation/newevaluation-form.html", MSG=u"Já existe uma avaliação com este nome", EVALUATIONDATA=self._aval, \
                                    AVALIADOS=avaliados, REGISTRY_ID=registry_id, \
                                    GROUPS=grupos, \
                                    GROUPNAMES=groupnames, \
                                    NOMEPAG=u"Avaliações")
                    return
                    
                log.model.log(user, u'criou a avaliação', objeto=aval_id, tipo="evaluation")
                self.redirect("/evaluation/%s" % registry_id)
                
        else:
            self.render("home.html", MSG=u"Você não pode criar avaliação nesta comunidade.", REGISTRY_ID=ifExists(registry_id, user), \
                            NOMEPAG="comunidades")
示例#18
0
文件: rest.py 项目: labase/activnce
 def get (self, registry_id, pagina):
     user = self.get_current_user()
     doc_id = '/'.join([registry_id, pagina])
     self._wiki = model.Wiki().retrieve(doc_id)
     if self._wiki: 
         if isAllowedToWriteObject(user, "wiki", registry_id, pagina):
             folders = [f for f in model.Wiki.listWikiFolders(registry_id) if f not in self._wiki.getDescendentsList()]
             
             self.write (dict(status=0, result=dict(pagina=pagina, path=self._wiki.getPagePath(links=False),  
                                                    e_usuario=isAUser(registry_id), e_owner=isOwner(user, registry_id),folders=folders)))
             
         else:
              self.write (dict(status=1, msg=u"Você não tem permissão para alterar esta página."))
     else:
         self.write (dict(status=1, msg=u"Documento não encontrado."))