Exemplo n.º 1
0
 def list_images(self, ong=None):
     o = Ong(session=self.session.get_session(), name=ong)
     if not o.load():
         return redirect(HOST + '/error')
     i = Image(session=self.session.get_session(), ong_name=ong)
     lst = i.search()
     return jsonify({'images': lst})
Exemplo n.º 2
0
 def upload_file(self, ong=None):
     o = Ong(session=self.session.get_session(), name=ong)
     if not o.load():
         return redirect(HOST + '/error')
     if request.method == 'POST':
         fd = request.files['file1']
         if fd and self.allowed_file(fd.filename):
             i = Image(session=self.session.get_session(), fd=fd, ong_name=ong)
             if i.save():
                 return render_template('response.html', msg="Imagem salva corretamente.", ong=o.get_name())
             else:
                 return render_template('response.html', msg="Falha ao salvar imagem.", ong=o.get_name())
     return render_template('ong.html', host=HOST)
Exemplo n.º 3
0
 def cadastre(self, ong):
     o = Ong(session=self.session.get_session(), name=ong)
     if not o.load():
         return redirect(HOST + '/error')
     if request.method == 'POST':
         cnpj = request.form["cnpj"]
         coo = request.form["coo"]
         data = request.form["data"]
         total = request.form["total"]
         id_image = request.form["id_image"]
         meta = MetaImage(session=self.session.get_session(), id_image=id_image)
         meta.load()
         meta.cnpj = cnpj
         meta.coo = coo
         meta.data = data
         meta.total = total
         meta.status = "valid"
         meta.update()
         return redirect(os.path.join(HOST, o.get_name(), 'cadastro'))
     meta = MetaImage(session=self.session.get_session(), id_ong=o.get_id())
     meta.search()
     if meta.id_image is None:
         return render_template('response.html', msg="Todas as imagens foram cadastradas!", ong=o.get_name(), host=HOST)
     i = Image(session=self.session.get_session(), id=meta.id_image)
     return render_template('cadastre.html', meta=meta, ong=o.get_name(), img=i, host=HOST)