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)
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)