Beispiel #1
0
    def get(self, registry_id, filename):
        user = self.get_current_user()
        filename = unquote(filename)
        file_data = dict()
        file_id = '/'.join([registry_id,filename])
        self._file = model.Studio().retrieve(file_id)
        
        if self._file != None:
            file_data = self._file.getFileInfo(user, filename)

            file_data["apagar"] = isAllowedToDeleteObject(user, file_data["owner"], file_id)
            file_data["alterar"] = isAllowedToEditObject(user, file_data["owner"], file_id)
            file_data["data_upload"] = short_datetime(file_data["data_upload"])
            file_data["data_alt"] = short_datetime(file_data["data_alt"])
            file_data["comentar"] = isAllowedToComment(user, file_id, file_data["owner"])
            for comentario in file_data["comentarios"]:
                comentario["comment"] = comentario["comment"].replace("\r\n", "<br/>")
                comentario["apagar"] = isAllowedToDeleteComment(user, registry_id, comentario["owner"])
                comentario["data_fmt"] = short_datetime(comentario["data_cri"])
            
            links = []
            links.append(("Ver", "/static/imagens/icones/view32.png", "/studio/"+file_id+"?disp=inline&size=G"))
            links.append(("Baixar", "/static/imagens/icones/down32.png", "/studio/"+file_id+"?disp=attachment&size=G"))
            if isAllowedToEditObject(user, file_data["owner"], file_id):
                links.append(("Alterar este arquivo", "/static/imagens/icones/edit32.png", "/studio/edit/"+file_id))
            if isAllowedToDeleteObject(user, file_data["owner"], file_id):
                links.append(("Remover este arquivo", "/static/imagens/icones/delete32.png", "/studio/delete/"+file_id,
                              "return confirm('Deseja realmente remover este Arquivo?');"))
            self.render("modules/studio/file-info.html", NOMEPAG=u'Estúdio', \
                        REGISTRY_ID=registry_id, \
                        LINKS=links, \
                        FILE=file_data, MSG="")
        else:
            self.render("home.html", MSG=u"Arquivo não encontrado.", \
                        NOMEPAG=u'Estúdio', REGISTRY_ID=registry_id)
Beispiel #2
0
    def post(self, registry_id, filename):
        
        user = self.get_current_user()
        
        file_id = '/'.join([registry_id,unquote(filename)])

        self._file = model.Studio().retrieve(file_id)
        if self._file:
            if isAllowedToEditObject(user, self._file.owner, file_id):
                
                self._file.editFile(user, self.get_argument("description",""), 
                                    splitTags(self.get_argument("tags","")),
                                    self.get_argument("acesso_publico","S"),
                                    self.get_argument("url",""))

                log.model.log(user, u'alterou imagem do studio de games', objeto=file_id, tipo="studio")
                self.redirect("/studio/info/%s" % file_id)
                
            else:
               self.render("home.html", MSG=u"Você não tem permissão para alterar este arquivo.", \
                           NOMEPAG=u'Estúdio', REGISTRY_ID=user)

        else:
                self.render("home.html", MSG=u"Erro: Arquivo inexistente!", \
                            NOMEPAG=u'Estúdio', REGISTRY_ID=registry_id)
Beispiel #3
0
 def get(self, registry_id, filename):
     user = self.get_current_user()
     file_id = '/'.join([registry_id,unquote(filename)])
     self._file = model.Studio().retrieve(file_id)
     if self._file:
         if isAllowedToEditObject(user, self._file.owner, file_id):
             self.render("modules/studio/file-edit.html", \
                         NOMEPAG=u'Estúdio', REGISTRY_ID=registry_id, \
                         FILE=self._file, MSG="")
     else:
         self.render("home.html", MSG=u"Erro: Arquivo inexistente!", \
                     NOMEPAG=u'Estúdio', REGISTRY_ID=registry_id)
Beispiel #4
0
 def listStudioFiles(self, user, registry_id, type):
     def _strListSize(values_list, str):
         plural = lambda x: 's' if x!=1 else ''
         if values_list:
             return u"%d %s%s" % (len(values_list), str, plural(len(values_list)))
         else:
             return u"nenhum %s" % str
             
     files = []
     i = 0
     for row in database.STUDIO.view('studio/all_data',startkey=[registry_id],endkey=[registry_id, {}]):
         if row.value["type"] == type:
             (registry_id, file_id) = row.key
             file_data = dict()
             file_data["registry_id"] = registry_id
             file_data["owner"] = row.value["owner"]
             file_data["acesso_publico"] = row.value["acesso_publico"]
             file_data["description"] = row.value["description"]
             file_data["url"] = row.value["url"]
             #file_data["tags"] = row.value["tags"]
             file_data["file_id"] = file_id
             
             # _file = Studio().retrieve(file_id)
             file_data["apagar"] = isAllowedToDeleteObject(user, row.value["owner"], file_id)
             file_data["alterar"] = isAllowedToEditObject(user, row.value["owner"], file_id)
             file_data["data_nofmt"] = row.value["data_alt"]
             file_data["data_alt"] = short_datetime(row.value["data_alt"])
             file_data["alterado_por"] = row.value["alterado_por"]
             file_data["num_comments"] = _strListSize (row.value["comentarios"], u"comentário")
             file_data["i"] = i
             i = i + 1
             
             files.append(file_data)
         
     files = sorted(files, key=itemgetter("data_nofmt"), reverse = True)
     return files