def profile(): form = CreationForm() if form.validate() and request.method == "POST": user = UserProfile(first_name=request.form['first_name'], last_name=request.form['last_name'], email=request.form['email'], location=request.form['location'], photo=request.files['photo'].filename, bio=request.form['bio'], gender=request.form['gender'], datte=datetime.datetime.now().strftime("%B %d,%Y")) db.session.add(user) db.session.commit() file = request.files['photo'] filename = secure_filename(file.filename) file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename)) flash('You have successfully filled out the form', 'success') return render_template( "profile.html", first_name=request.form['first_name'], last_name=request.form['last_name'], email=request.form['email'], location=request.form['location'], photo=filename, bio=request.form['bio'], datte=datetime.datetime.now().strftime("%B %d,%Y")) return profiles("Please select a profile")
def home(): form = CreationForm() if request.method == "POST": if form.validate(): return profile() return render_template('home.html', form=form)
def creation_org(): form = CreationForm(request.form) if request.method == 'POST': Nombre = form.Nombre.data Acrónimo = form.Acrónimo.data Photo = form.Photo.data Descripción = form.Descripción.data Tags = form.Tags.data Tags = Tags.split(",") Frase = form.Frase.data Foto_aux = form.Foto_aux.data Titulo_noticia = form.Titulo_noticia.data Cuerpo_noticia = form.Cuerpo_noticia.data Convocatoria = form.Convocatoria.data Redes_Sociales = form.Redes_Sociales.data if Nombre != None and Photo != None and Descripción != None and Tags != None and Acrónimo != None and Frase != None and Foto_aux != None and Titulo_noticia != None and Cuerpo_noticia != None and Convocatoria != None and Redes_Sociales != None: Org = { 'Nombre': Nombre, 'Acrónimo': Acrónimo, 'photo': Photo, 'Descripción': Descripción, 'Tags': Tags, 'Frase': Frase, 'Foto_aux': Foto_aux, 'Titulo_noticia': Titulo_noticia, 'Cuerpo_noticia': Cuerpo_noticia, 'Convocatoria': Convocatoria, 'Redes_Sociales': Redes_Sociales } db_insert_user(perfiles_organizacion, Org) return redirect('/') return render_template('Register.html')
def test_choicefield_2(request): if request.method == "POST": text = "Ali" CUSTOM_CHOICES = [ ("L1", "L1"), ("L2", "L2"), ("L5", "L5"), ("U1", "U1"), ("U3", "U3"), ("U6", "U6"), ("U7", "U7"), ] creation_form = CreationForm(text, CUSTOM_CHOICES, request.POST) import pdb pdb.set_trace() if creation_form.is_valid(): # print(creation_form.cleaned_data['copies']) print(creation_form.cleaned_data["license_type"]) else: CUSTOM_CHOICES = [ ("L1", "L1"), ("L2", "L2"), ("L5", "L5"), ("U1", "U1"), ("U3", "U3"), ("U6", "U6"), ("U7", "U7"), ] text = "Ali" creation_form = CreationForm(text, CUSTOM_CHOICES) context = {} context["creation_form"] = creation_form context.update(csrf(request)) return render(request, "code_test/test_choicefield.html", context)
def create_user(request): form=CreationForm() if request.method == 'POST': form=CreationForm(request.POST) if form.is_valid(): form.save() return HttpResponseRedirect('goo') context={'form':form} return render(request,'adminuser/createuser.html', context)
def creation_user(): form = CreationForm(request.form) if request.method == 'POST': Nombre = form.Nombre.data Photo = form.Photo.data Descripción = form.Descripción.data Tags = form.Tags.data if Nombre != None and Photo != None and Descripción != None and Tags != None: Org = { 'user': Nombre, 'photo': Photo, 'Descripción': Descripción, 'Tags': Tags } db_insert_user(perfiles_usuario, Org) return redirect('/') return render_template('Register.html')