def signup(request): if request.user.is_authenticated(): return HttpResponseRedirect(reverse('forms_set')) if request.method == 'POST': post_form = RegistrationForm(request.POST) if post_form.is_valid(): try: with transaction.commit_on_success(): data = post_form.cleaned_data user = User.objects.create_user( data['mail'].lower(), data['mail'], data['password1'] ) user.save() # TODO need text email, need params for smpt # email sending # send_mail(u"Title", # u"Text message" # % (data['username'], data['password1']), "Email of service", [data['mail']], # fail_silently=True) if user.is_active: new_user = authenticate( username = data['mail'].lower(), password = data['password1'] ) django_login(request, new_user) return HttpResponseRedirect(reverse('forms_set')) except Exception, e: pass #todo log #logger.error("Controller:signup error:" + e.message) return render_to_response('client_data_core/signup.html', {'form' : post_form, }, context_instance = RequestContext(request),)
def register(request): context = {"nem_base_url" : "http://" + settings.SITE_URL + "/static/nem/", "site_url" : "http://" + settings.SITE_URL + "/",} if request.method == 'POST': # If the form has been submitted... form = RegistrationForm(request.POST) # A form bound to the POST data if form.is_valid(): # All validation rules passes # Process the data in form.cleaned_data amount_bool = form.cleaned_data['amount'] email = form.cleaned_data['email'] name = form.cleaned_data['name'] branch = form.cleaned_data['branch'] batch = form.cleaned_data['batch'] pt = Registration.objects.create(amount=amount_bool, email=email, name=name, branch=branch, batch=batch, status=LIMBO) transaction_id = pt.id notes="" if settings.ENV == "dev": transaction_id = "dev-nem" + str(pt.id) else: transaction_id = "nem" + str(pt.id) callback_url = "http://" + settings.SITE_URL + "/nem/payment-return" amount = 1500 if int(amount_bool) == ALUMNI else 500 context = {"payment_dict" : get_post_object(callback_url, amount, email, transaction_id, notes)} return render_to_response("nem/registration_payment_redirect.html", RequestContext(request, context)) else: form = RegistrationForm() # An unbound form context['form'] = form return render(request, "nem/register.html", context)
def registration(request): cache.clear() if request.user.is_authenticated(): return redirect('/') if request.method == 'POST': form = RegistrationForm(request.POST) if form.is_valid(): try: user_pk = form.save(request.FILES.get('avatar')) admins = User.objects.filter(is_superuser=True) msg = EmailMessage( u'Новый пользователь %s' % request.POST['username'], (u'<html>' u'<meta http-equiv="Content-Type" content="text/html; ' u'charset=UTF-8"><body>' u'Зарегистрировался новый пользователь ' u'<a href="http://%s/admin/auth/user/%i">%s</a>' u'<br />' u'Данные:<br /><ul>%s</ul>' u'</body></html>') % (settings.HOSTNAME, user_pk, request.POST['username'], form.as_ul()), u'admin@%s' % settings.HOSTNAME, [a.email for a in admins] ) msg.content_subtype = "html" msg.send() return redirect(reverse('registration-thanks')) except ValidationError: pass else: form = RegistrationForm() return render(request, 'registration/registration.html', {'form': form})
def register(): form = RegistrationForm() if g.user is not None: return redirect(url_for("users.home")) if request.method == "POST" and form.validate(): if User.query.filter_by(username=form.username.data).first(): flash("The username already exists idiot") return render_template("users/register.html", title="register", form=form) if User.query.filter_by(email=form.email.data).first(): flash("The email has already been registored") return render_template("users/register.html", title="register", form=form) file = form.image.data profile_pic = utilities.file_save(file, "profilepics") user = User( username=form.username.data, email=form.email.data, password=generate_password_hash(form.password.data), description=form.description.data, profile_pic=profile_pic, homepage=form.homepage.data, role=form.role.data, zodiac=form.zodiac.data, ) psc_db.session.add(user) psc_db.session.commit() session["user_id"] = user.id flash("well done f****t") return redirect(url_for("users.profile", userId=user.id)) return render_template("users/register.html", title="register", form=form)
def registration_view(request): """ регистрация форма регистрации короткая, только обязательные поля пароль сохраняется в два этапа: сохранение пользователя, зтем установка пароля при удаче переход на редактирование профиля """ if request.method == 'POST': form = RegistrationForm(request.POST, request.FILES) if form.is_valid(): f = form.save(commit=False) f.save() u = CustomUser.objects.get(pk = f.id) u.set_password(request.POST.get('password')) u.save() else: form = RegistrationForm(request.POST, request.FILES) else: form = RegistrationForm() t = loader.get_template('accounts_registration.html') c = RequestContext(request,{ # 'current_user' : user, 'form' : form, }, processors=[custom_proc]) return HttpResponse(t.render(c))
def create(): form = RegistrationForm() if form.validate() is False: return render_template('blog/new.html', form=form) else: post = Post() post.title = form.title.data post.author = form.author.data post.text_content = form.text_content.data post.text_call = form.text_call.data post.postage_date = datetime.now().strftime('%Y-%m-%d %H:%M:%S') post.active = 0 subjects_names = form.subject.data.replace(', ', ',').split(',') for name in subjects_names: subject = Subject.query.filter_by(name=name).first() if (not subject): subject = Subject() subject.name = name post.subjects.append(subject) db.session.add(post) db.session.flush() if len(form.thumb.data.split(',')) > 1: upload_folder = os.path.join(app.config['UPLOAD_FOLDER'], mod.name, str(post.id), 'images') post.thumb = save_b64_image(form.thumb.data.split(',')[1], upload_folder, 'thumb') db.session.commit() message = u'Muito obrigado! Seu post foi submetido com sucesso!' flash(message, 'success') return redirect(url_for('blog.admin'))
def update(id): form = RegistrationForm() id = int(id.encode()) if form.validate() is False: return render_template('blog/edit.html', form=form) else: post = Post.query.filter_by(id=id).first_or_404() post.title = form.title.data post.author = form.author.data post.text_content = form.text_content.data post.postage_date = datetime.now().strftime('%Y-%m-%d %H:%M:%S') subjects_names = form.subject.data.replace(', ', ',').split(',') num_subjects = len(post.subjects) for i in range(0, num_subjects): post.subjects.remove(post.subjects[0]) for name in subjects_names: subject = Subject.query.filter_by(name=name).first() if (not subject): subject = Subject() subject.name = name post.subjects.append(subject) db.session.flush() if len(form.thumb.data.split(',')) > 1: upload_folder = os.path.join(app.config['UPLOAD_FOLDER'], mod.name, str(post.id), 'images') post.thumb = save_b64_image(form.thumb.data.split(',')[1], upload_folder, 'thumb') db.session.commit() message = u'Post editado com sucesso!' flash(message, 'success') return redirect(url_for('blog.admin'))
def login(): if current_user.is_authenticated(): return redirect(url_for('index')) form_login = LoginForm() form_registration = RegistrationForm() if form_login.validate_on_submit(): user = User.query.filter_by(name=form_login.login.data).first() if user is None: flash('Invalid login') elif user.verify_password(form_login.password.data): login_user(user, form_login.remember_me.data) return redirect(request.args.get('next') or url_for('index')) else: flash('Invalid password') if form_registration.validate_on_submit(): user = User( email=form_registration.email.data, name=form_registration.login.data, password=form_registration.password.data) db.session.add(user) db.session.commit() flash('You can now login.') return render_template('login.html', title='Hello!', form_login=form_login, form_registration=form_registration) return render_template('login.html', title='Hello!', form_login=form_login, form_registration=form_registration)
def register(request): state = " Se dispone a realizar un nuevo registro.Recuerde que todos los campos son obligatorios" if request.method == 'POST': form = RegistrationForm(request.POST) if form.is_valid(): name_user = form.cleaned_data['username'] email_user = form.cleaned_data['email'] pass_user = form.cleaned_data['password1'] create_user = User.objects.create_user(username= name_user, email= email_user,password=pass_user) create_user.save() pseudo="@"+name_user extend=ExtendUser(user=create_user,pseudo=pseudo) extend.save() return redirect('/login') else: state=" Error en el registro" return render_to_response('nuevo.html', {'title':'Registro', 'formulario': form,'state':state}, context_instance=RequestContext(request)) else: form = RegistrationForm() return render_to_response('nuevo.html', {'title':'Registro', 'formulario': form,'state':state}, context_instance=RequestContext(request))
def index(): if g.user is None: login_form = LoginForm(prefix="login") registration_form = RegistrationForm(prefix="register") button = request.form.get('button') if button == 'login' and login_form.validate_on_submit(): user = login_form.user user.touch() session['username'] = user.username return redirect(request.args.get('next', url_for('index'))) elif button == 'register' and registration_form.validate_on_submit(): count = User.query.count() user = User( registration_form.username.data, generate_password_hash(registration_form.password.data), registration_form.email.data, False, True, bool(count == 0), ) db.session.add(user) db.session.flush() email.send_account_created_email(user) db.session.commit() session['username'] = user.username flash('Registration successful! Please check your e-mail so we can verify your address.') return redirect(url_for('index')) else: return render_template('index.html', login_form=login_form, registration_form=registration_form) else: identity_tokens = list(g.user.identity_tokens.filter_by(enabled=True)) return render_template('index.html', identity_tokens=identity_tokens)
def register(request): if request.method == 'POST': form = RegistrationForm(request.POST) if form.is_valid(): registration = form.save(commit=False) registration.save() for workshop in form.cleaned_data['workshops']: registration.workshops.add(Workshop.objects.get(id=workshop)) current_site = Site.objects.get_current() subject = render_to_string('workshops/confirmation_email_subject.txt', {'site': current_site}) subject = ''.join(subject.splitlines()) message = render_to_string('workshops/confirmation_email.txt', {'registration': registration}) send_mail(subject, message, settings.DEFAULT_FROM_EMAIL, [registration.email]) return HttpResponseRedirect(reverse('workshop-registration-complete')) else: form = RegistrationForm() return render_to_response('workshops/registration_form.html', {'form': form})
def register(): form = RegistrationForm(request.form) if request.method == 'POST' and form.validate(): assay_id = form.assay_id.data assay_number = form.assay_number.data date = form.assay_date.data jc_id = form.jc_sample.data serial_number = str(assay_id)+"_"+str(assay_number)+"_"+str(date.day).zfill(2)+"-"+str(date.month).zfill(2)+"-"+str(date.year).zfill(4)+"_"+str(jc_id) #Add to DB try: data = models.AssayJCData(id=serial_number,assay_id=assay_id,\ assay_number=int(assay_number),\ assay_date=date,jc_id=jc_id) db.session.add(data) db.session.commit() except: print "Exception in user code:" print '-'*60 traceback.print_exc(file=sys.stdout) print '-'*60 return "Error inserting in Database. What are you doing man??\n",409 flash('Assay data logged as: '+str(serial_number)) return redirect(url_for('register')) return render_template('register.html',form = form)
def registration(): form = RegistrationForm(request.form) if request.method == 'POST' and form.validate(): db = get_db() count = db.execute("select count(*) from profile where login = ? ;", [form.nickname.data]).fetchone()[0] if (count == 0): db.cursor().execute('insert into profile(login, password, email, question, answer) values(?, ?, ?, ?, ?);', \ [form.nickname.data, form.password.data, form.email.data, form.question.data, form.answer.data]) db.commit() title = "FSecurity registration" text = """ Hello, {user} You are registered to FSecurity Your password is {password} """.format(user=form.nickname.data, password=form.password.data) try: send_mail(form.email.data, title, text) except Exception, e: pass flash('Thank you for registering') db = get_db() db.cursor().execute('insert into log(description, warning_level, data) values(?, ?, ?);', \ ["{user} created".format(user=form.nickname.data), 0, time()]) db.commit() return redirect(url_for('index')) else: flash('Nickname have been captured before')
def view_raid(request, raid_id): raid = get_object_or_404(Raid, id=raid_id) if request.method == 'POST': form = RegistrationForm(request.POST) if form.is_valid(): registration = Registration(player=request.user, raid=raid, role=form.cleaned_data['role']) if 'standby' in form.cleaned_data: registration.standby = form.cleaned_data['standby'] registration.save() else: form = RegistrationForm() dps = Registration.objects.filter(raid=raid,role="dps").order_by("-won", "-number") tanks = Registration.objects.filter(raid=raid,role="tank").order_by("-won", "-number") healers = Registration.objects.filter(raid=raid,role="healer").order_by("-won", "-number") registered = { 'DPS': dps, 'Tanks': tanks, 'Healers': healers } return render_to_response('raid/view.djhtml', {'raid': raid, 'registered': registered, 'registration_form': form, 'is_registered': raid.is_registered(request.user) }, context_instance=RequestContext(request))
def post(self): data = dict((k, v) for (k, [v]) in self.request.arguments.iteritems()) # FIXME - Is this the only way to pass data? form = RegistrationForm(**data) if form.validate(): self.write("<h2>Form validates</h2>") self.render("register.html", form=form)
def register(request, template_name = 'registration/register.html'): if request.method == 'POST': print("POST") postdata = request.POST.copy() #form = UserCreationForm(postdata) form = RegistrationForm(postdata) if form.is_valid(): print("valid user input") user = form.save(commit = False) user.email = postdata.get('email', '') user.save() #form.save() un = postdata.get('username', '') pw = postdata.get('password1', '') from django.contrib.auth import login, authenticate new_user = authenticate(username = un, password = pw) if new_user and new_user.is_active: login(request, new_user) url = urlresolvers.reverse('my_account') return HttpResponseRedirect(url) else: print("GET") #form = UserCreationForm() form = RegistrationForm() page_title = 'User Registration' return render_to_response(template_name, locals(), context_instance = RequestContext(request))
def registerBanda(request): registered = False if request.method == 'POST': form = RegistrationForm(data=request.POST) banda_form = BandaForm(data = request.POST) if form.is_valid() and banda_form.is_valid: user = User.objects.create_user(form.cleaned_data['username'], form.cleaned_data['email'], form.cleaned_data['password1']) user.save() banda = banda_form.save() banda.save() usuario = auth.authenticate(username=request.POST['username'], password=request.POST['password1']) login(request,usuario) return HttpResponseRedirect('/') else: print form.errors, banda_form.errors else: form = RegistrationForm() banda_form = BandaForm() return render(request, 'registroBanda1.html', {'user':form, 'banda_form':banda_form, 'registered':registered})
def register_view(request): if request.method == 'POST': login_form = LoginForm(request.POST) register_form = RegistrationForm(request.POST) if register_form.is_valid(): user = register_form.save() salt = hashlib.sha1(str(random.random())).hexdigest()[:5] user.activation_key = hashlib.sha1(salt+user.email).hexdigest() #user.key_expires = timezone.now() + timezone.timedelta(100) user.save() plaintext = get_template('email/register_email.txt') htmly = get_template('email/register_email.html') d = Context({'username': user.username}) subject, from_email, to = 'Account has been created', '*****@*****.**', user.email text_content = plaintext.render(d) html_content = htmly.render(d) msg = EmailMultiAlternatives(subject, text_content, from_email, [to]) msg.attach_alternative(html_content, "text/html") msg.send() return HttpResponseRedirect(reverse('success_register')) else: register_form = RegistrationForm() login_form = LoginForm() context = {'register_form': register_form, 'login_form': login_form} return render(request, "register.html", context)
def registration(request): return redirect("accounts:frontend:login") if request.method == "POST": form = RegistrationForm(request.POST) if form.is_valid(): user = User( username=form.cleaned_data["username"], email=form.cleaned_data["email"], first_name=form.cleaned_data["first_name"], last_name=form.cleaned_data["last_name"], is_active=True, ) user.set_password(form.cleaned_data["password"]) user.save() group = Group.objects.get(name="users") user.groups.add(group) # hash = md5_constructor(str(user.id) + form.cleaned_data['username']).hexdigest() # confirm = RegConfirm(hash=hash, user_id=user.id) # confirm.save() # current_site = Site.objects.get(id=1) # message = u'Поздравляем! Вы зарегистрировались на %s . Пожалуйста, пройдите по адресу %s для активации учетной записи.' % \ # (current_site.domain, "http://" + current_site.domain + "/accounts/confirm/" + hash, ) # # # send_mail(u'Активация учетной записи ' + current_site.domain, message, 'system@'+current_site.domain, # [form.cleaned_data['email']]) return render(request, "accounts/frontend/registration_done.html") else: form = RegistrationForm() return render(request, "accounts/frontend/registration.html", {"form": form})
def signup(): if request.method == 'GET': return render_template('signup.html', form=RegistrationForm()) form = RegistrationForm(request.form) if form.validate_on_submit(): user = User(form.username.data, form.email.data) form.populate_obj(user) user.set_password(form.password.data) db.session.add(user) db.session.commit() msg = Message( 'Successful registration!', sender=('Blog Tceh Cource', '*****@*****.**'), recipients=[form.email.data] ) msg.body = 'Welcome to our blog!' mail.send(msg) flash('Successful registration! Please login.') return redirect(url_for('auth.login')) else: return render_template('signup.html', form=form)
def register(): form = RegistrationForm(request.form) if request.method == 'POST': form_is_valid = form.validate_on_submit() if form_is_valid: username = request.form['username'] username_exist = User.query.\ filter_by(username=username).first() if username_exist is not None: flash("Username already in use. Please try again.") return render_template('registration.html', form=form) else: user = User(form.username.data, form.password.data, form.email.data) db.session.add(user) db.session.commit() login_user(user) flash('Thanks for signing up! Now create your first blomoLink~') return redirect(url_for('index')) else: flash('Signup form is not complete') return render_template('registration.html', form=form) elif request.method == 'GET': return render_template('registration.html', form=form)
def register(request, success_url='/accounts/register/complete/'): """ Allows a new user to register an account. On successful registration, an email will be sent to the new user with an activation link to click to make the account active. This view will then redirect to ``success_url``, which defaults to '/accounts/register/complete/'. This application has a URL pattern for that URL and routes it to the ``direct_to_template`` generic view to display a short message telling the user to check their email for the account activation link. Context:: form The registration form Template:: registration/registration_form.html """ if request.method == 'POST': form = RegistrationForm(request.POST) if form.is_valid(): new_user = RegistrationProfile.objects.create_inactive_user(username=form.clean_data['username'], password=form.clean_data['password1'], email=form.clean_data['email']) return HttpResponseRedirect(success_url) else: form = RegistrationForm() return render_to_response('registration/registration_form.html', { 'form': form }, context_instance=RequestContext(request))
def view_raid(request, raid_id): raid = get_object_or_404(Raid, id=raid_id) if request.method == "POST": form = RegistrationForm(request.POST) if form.is_valid(): registration = Registration(player=request.user, raid=raid, role=form.cleaned_data["role"]) if "standby" in form.cleaned_data: registration.standby = form.cleaned_data["standby"] registration.save() else: form = RegistrationForm() dps = Registration.objects.filter(raid=raid, role="dps").order_by("-won", "-number") tanks = Registration.objects.filter(raid=raid, role="tank").order_by("-won", "-number") healers = Registration.objects.filter(raid=raid, role="healer").order_by("-won", "-number") registered = {"DPS": dps, "Tanks": tanks, "Healers": healers} return render_to_response( "raid/view.djhtml", { "raid": raid, "registered": registered, "registration_form": form, "is_registered": raid.is_registered(request.user), }, context_instance=RequestContext(request), )
def add_new_user(): salt = PASSWORD_SALT #Get data from Registration Form form = RegistrationForm(request.form) if not form.validate(): flash("All fields are required.") return render_template("new_user_form.html", form=form) given_name = form.given_name.data surname = form.surname.data email = form.email.data password = hashlib.sha1(form.password.data+salt).hexdigest() user_exist = model.session.query(model.User).filter_by(email=email).all() #check to see if user exists if user_exist: flash("User account has already been created with this email.") return render_template("login_user.html", form=form) #create user object user = model.User(given_name=given_name, surname=surname, email=email, password=password, admin=0) model.session.add(user) model.session.commit() session["email"] = email if form.validate_on_submit(): flash ("Your account has been created, " + form.given_name.data + ".") return redirect("/index") return redirect("/user/new")
def register(): form = RegistrationForm(request.form) if request.method == 'POST' and form.validate(): S=BotCheck(request.form.get('g-recaptcha-response')) user = User.query.get(form.email.data.lower()) if user: flash('Entered Email ID is already registered with us.') return render_template('register.html', form=form) if S==False: flash('Entered Email ID is already registered with us or Invalid Bot Captcha') return render_template('register.html', form=form) user=User(form.username.data,form.email.data.lower(),form.password.data,form.age.data) db.session.add(user) db.session.commit() try: mail.send(GetWelcomeMessage(user.name,user.email)) except: print("Error while Sending Mail") flash('Thanks for registering,you can login Now and start chating') return redirect(url_for('login')) return render_template('register.html', form=form)
def registration(request): if request.method == 'POST': form = RegistrationForm(request.POST) if form.is_valid(): user = User.objects.create_user(form.cleaned_data['username'], form.cleaned_data['email'], form.cleaned_data['password1']) user.first_name = form.cleaned_data['first_name'] user.last_name = form.cleaned_data['last_name'] user.save() profile = Profile(user_id=user.id, phone=form.cleaned_data['phone']) profile.save() messages.info(request, 'Registrácia prebehla úspešne') return HttpResponseRedirect('/') else: form = RegistrationForm() page_info = {} page_info['title'] = 'Registrácia nového uživateľa' page_info['page'] = 1 page_info['form_name'] = 'registration' page_info['form_action'] = '/registracia/' return render_to_response('registracia.html', {'form': form, 'countInfo': countInfo, 'recentNews': recentNews, 'page_info': page_info}, context_instance=RequestContext(request))
def signup(request): if request.method == 'POST': form = RegistrationForm(request.POST) if form.is_valid(): user = User.objects.create_user( username=form.cleaned_data['username'], password=form.cleaned_data['password1'], email=form.cleaned_data['email'] ) user = authenticate(username=form.cleaned_data['username'], password=form.cleaned_data['password1']) profile = Profile( first_name=form.cleaned_data['first_name'], last_name=form.cleaned_data['last_name'], user=user) profile.save() login(request, user) msg = ("Thanks for registering! You are now logged in and ready to " "go questing.") messages.info(request, msg) return HttpResponseRedirect(reverse('quest_maker_app:homepage')) else: form = RegistrationForm() variables = RequestContext(request, {'form': form}) return render_to_response('registration/signup.html', variables)
def register(request): ''' This handles the request sent to registration. If the user has sent a confirmation to their email before, simply send another one. This is to, hopefully, counteract the fact that people might have expired invitations in their inbox, or they deleted the confirmation email on accident. ''' if request.user.is_authenticated(): return render(request, 'register.html', {'action': '/register/'}) if request.method == 'POST': form = RegistrationForm(request.POST) if form.is_valid(): ''' We need to go to the email-sent page (even though an email isn't sent at the moment. ''' user = form.save() EmailConfirmation.objects.send_confirmation(user=user) return render(request, 'email_sent.html', {'email': form.cleaned_data['email'] }) else: form = RegistrationForm() return render(request, 'register.html', {'form': form, 'action': '/register/'})
def registertest(): form = RegistrationForm() if g.user is not None: return redirect(url_for("users.home")) if request.method == "POST" and form.validate(): return "yeah" return render_template("users/register.html", title="register", form=form)
def register(): form = RegistrationForm(request.form) if request.method == 'POST' and form.validate(): user = User(form.login.data, form.password.data, form.name.data, form.email.data) db_session.add(user) return redirect(url_for('index')) return render_template('register.html', form=form)
def register(): form = RegistrationForm() if form.validate_on_submit(): return redirect(url_for('home')) return render_template(register.html, )
def register(): form = RegistrationForm() if form.validate_on_submit(): flash(f'Account created for {form.username.data}!', 'success') return redirect(url_for('home')) return render_template('register.html', title='Register', form=form)
def landing_submit(): registration_form = RegistrationForm() #TODO: save registration customer = Customer("Aaron Evans", "*****@*****.**", "425-242-4304", "One Shore Inc") if registration_form.tell_me_more.data == True: return redirect(url_for('details')) #TODO: we can't remove the anchor if registration_form.sign_up.data == True: if registration_form.validate_on_submit(): return redirect('register') return redirect(url_for('register'), code=307) contact_form = ContactForm() if registration_form.validate_on_submit(): #TODO: save registration customer = Customer(name=registration_form.name.data, email=registration_form.email.data, phone=registration_form.phone.data, company=registration_form.company.data) if registration_form.tell_me_more.data == True: customer.registered = 0 db.session.add(customer) db.session.commit() return redirect(url_for( 'details', _anchor='registered')) #TODO: we can't remove the anchor if registration_form.sign_up.data == True: db.session.add(customer) db.session.commit() return redirect(url_for('order', _anchor='registered')) else: session['name'] = registration_form.name.data session['email'] = registration_form.email.data session['phone'] = registration_form.phone.data session['company'] = registration_form.company.data contact_form = ContactForm() if contact_form.validate_on_submit(): # TODO: save message contact = Contact(name=contact_form.name.data, email=contact_form.email.data, phone=contact_form.phone.data, message=contact_form.message.data) db.session.add(contact) db.session.commit() return "message sent" if contact_form.send.data == True: if contact_form.validate_on_submit(): return redirect(url_for('contact')) content = render_template('landing.html', registration_form=registration_form, contact_form=contact_form) return content
def register(): form = RegistrationForm() return render_template('register.html', title='Register', form=form)
def sigup(): form = RegistrationForm() if form.validate_on_submit(): return redirect(url_for('home')) return render_template('signup.html', title='signup', form=form)
def register(): form = RegistrationForm() if form.validate_on_submit(): flash(f'Account created for {form.username.data}!', 'success') #bootstrap method return redirect(url_for('home')) #this is the NAME of THE FUNCTION return render_template('register.html', title='Register', form=form) #form keyword renders RegistrationForm class instance from forms.py
def register(request): """ This view handles user registration """ if request.method == 'POST': # If the form has been submitted... form = RegistrationForm(request.POST) # A form bound to the POST data if form.is_valid(): # All validation rules pass # Process the data in form.cleaned_data # Create user and send activation mail # Create user user = User.objects.create_user(form.cleaned_data.get('username'), form.cleaned_data.get('email'), form.cleaned_data.get('password')) user.is_staff = False user.is_active = False user.save() # Fill profile profile = Profile.objects.get(user=user) # Generate activation key email_key = user.username + uuid.uuid4().hex profile.activation_key = email_key profile.key_expires = datetime.datetime.now() + datetime.timedelta( days=2) # Save Profile profile.save() # Send activation mail text = get_template('mail/activation.txt') html = get_template('mail/activation.haml') mail_context = Context({ 'username': form.cleaned_data.get('username'), 'activation_key': email_key }) text_content = text.render(mail_context) html_content = html.render(mail_context) message = EmailMultiAlternatives('Welcome to Element43!', text_content, settings.DEFAULT_FROM_EMAIL, [form.cleaned_data.get('email')]) message.attach_alternative(html_content, "text/html") message.send() # Add success message messages.success( request, """Your account has been created and an e-mail message containing your activation key has been sent to the address you specified. You have to activate your account within the next 48 hours.""") # Redirect home return HttpResponseRedirect(reverse('home')) else: form = RegistrationForm() # An unbound form rcontext = RequestContext(request, {}) return render_to_response('register.haml', {'form': form}, rcontext)
def cadastro(): form = RegistrationForm() return render_template('register.html', form=form)
def register(): form = RegistrationForm() if form.validate_on_submit(): flash(f"Account created for {form.username.data} !", "Success") return redirect(url_for("home")) return render_template("register.html", title="Register", form=form)
def home(): return render_template("home.html", loginform=LoginForm(), registrationform=RegistrationForm())
def register(): form = RegistrationForm() if form.validate_on_submit(): flash(message='Account created', category='success') return redirect(url_for('home')) return render_template('register.html', form=form, title='Register')
def register(): form = RegistrationForm() return render_template("register.html", title="Register", form=form)
def register(): form = RegistrationForm() if form.validate_on_submit(): flash('Account created for !') return redirect(url_for('home')) return render_template('register.html', title='Register', form=form)
def register(): form = RegistrationForm() if form.validate_on_submit(): flash(f'Hello {form.username.data}, Welcome to FlaskApp!', 'success') return redirect(url_for('home')) return render_template('register.html', title='Register', form=form)
def signup(): form = RegistrationForm() if form.validate_on_submit(): print(form.first_name.data) return redirect(url_for("dashboard")) return render_template("signup.html", form=form)
def register(): form= RegistrationForm() if form.validate_on_submit(): flash(f'Account created for {form.username.data}!', 'success') #success is a bootstrap method for alert return redirect(url_for('home')) #if valid form is submitted, redirect to home page return render_template('register.html', title='register', form=form)
def index(): form = RegistrationForm() return render_template('sign_up.html', form=form)
def new(): form = RegistrationForm() return render_template('scholar/new.html', form=form, action=url_for('scholar.create'))
def register(): form = RegistrationForm() if request.method == 'POST' and form.validate_on_submit(): flash(f"Account created for {form.username.data}", 'success') return redirect(url_for('home')) return render_template('register.html', form=form)
def index(request): context = {'form': RegistrationForm()} return render(request, 'users/index.html', context)
def login(): form = RegistrationForm() return render_template('login.html', title='Login', form=form)
def register(): form = RegistrationForm() if form.validate_on_submit(): flash('account succes created', 'success') return redirect(url_for('home')) return render_template("register.html", title="register", form=form)
def product(prod_id,bol_): prod = Hobies.query.get_or_404(prod_id) bol=bol_ return render_template('product.html', prod = prod, form=LoginForm(), forml=RegistrationForm(), bol = bol)
def register(): """ Handle requests to the /register route Add an employee to the database through the registration form """ form = RegistrationForm() if form.validate_on_submit(): user = User(email=form.email.data, name=form.name.data, password=form.password.data) # add employee to the database db.session.add(employee) db.session.commit() flash('You have successfully registered! You may now login.') # redirect to the login page return redirect(url_for('auth.login')) # load registration template return render_template('register.html', form=form, title='Register') # @auth.route('/login', methods=['GET', 'POST']) # def login(): # """ # Handle requests to the /login route # Log an employee in through the login form # """ # form = LoginForm() # if form.validate_on_submit(): # # check whether employee exists in the database and whether # # the password entered matches the password in the database # employee = Employee.query.filter_by(email=form.email.data).first() # if employee is not None and employee.verify_password( # form.password.data): # # log employee in # login_user(employee) # # redirect to the dashboard page after login # return redirect(url_for('home.dashboard')) # # when login details are incorrect # else: # flash('Invalid email or password.') # # load login template # return render_template('auth/login.html', form=form, title='Login') # @auth.route('/logout') # @login_required # def logout(): # """ # Handle requests to the /logout route # Log an employee out through the logout link # """ # logout_user() # flash('You have successfully been logged out.') # # redirect to the login page # return redirect(url_for('auth.login'))
def registration(): form = RegistrationForm() if form.validate_on_submit(): flash(f'Le compte de {form.username.data} est crée ! ', 'success') return redirect(url_for('home')) return render_template('register.html', title='Register', form=form)
def home(): formq=SearchBar() return render_template('home.html', form=LoginForm(), forml=RegistrationForm(), formq=formq)
def get(self): form = RegistrationForm() self.render("register.html", form=form)
class Register(Component): form = RegistrationForm() def updated(self, field): self.validate(field)
def create(): csrf_token = request.form.get('csrf_token') upload_folder = os.path.join(app.config['UPLOAD_FOLDER'], mod.name, csrf_token, 'files') form = RegistrationForm() if not os.path.exists(upload_folder): flash(u'Selecione o arquivo do artigo para enviá-lo.', 'danger') return render_template('scholar/new.html', form=form) if form.validate() is False: form.set_choices(approved_articles_keywords()) return render_template('scholar/new.html', form=form) else: article = Article() article.title = form.title.data article.theme = form.theme.data article.abstract = form.abstract.data article.postage_date = datetime.now().strftime('%Y-%m-%d %H:%M:%S') article.approval_status = 0 author_input_list = form.authors.data.replace(', ', ',').split(',') for author_input in author_input_list: article.authors.append(AuthorScholar(author_input)) for keyword_input in form.keywords.data: keyword = KeyWord.query.filter_by(name=keyword_input).first() if not keyword: article.keywords.append(KeyWord(keyword_input)) else: article.keywords.append(keyword) db.session.add(article) db.session.flush() if os.path.exists(upload_folder): file_name = [file for file in os.listdir(upload_folder)][0] article.file_url = upload_helper.upload_s3_file( os.path.join(upload_folder, file_name), os.path.join('scholar/', str(article.id), 'files/', 'article'), { 'ContentType': "application/pdf", 'ContentDisposition': 'attachment; filename=dataviva-article-' + str(article.id) + '.pdf' }) shutil.rmtree(os.path.split(upload_folder)[0]) db.session.commit() upload_helper.log_operation(module=mod.name, operation='create', user=(g.user.id, g.user.email), objs=[(article.id, article.title)]) new_article_advise(article, request.url_root) message = dictionary()["article_submission"] flash(message, 'success') return redirect(url_for('scholar.index'))
def index(): form1 = RegistrationForm() """Render website's initial page and let VueJS take over.""" return render_template('index.html', form1=form1)