def update(self, request, event, registration): form = RegistrationForm(event, data=request.POST, instance=registration) if request.GET['role'] == 'cm-admin': # POSTing the form as an chairman administrating the event request.user.check_admin_of(event.committee) if form.is_valid(): form.save(registration.participant) messages.success(request, _("Inschrijving bijgewerkt!")) return redirect('event-edit', event.pk) else: # Render previous page with validation errors registration_view = RegistrationView(self.route, self.request) return registration_view.edit(self.request, event.pk, form=form) elif request.GET['role'] == 'user': # POSTing the form as an user updating their own registration self.check_user(registration.participant) # Make sure deadline hasn't passed and event is open if event.is_expired() or not event.is_published(): raise PermissionDenied if form.is_valid(): form.save(request.user) messages.success(request, _("Inschrijving bijgewerkt!")) return redirect('event-detail', event.pk) else: # Render previous page with validation errors event_view = EventView(self.route, self.request) return event_view.show(self.request, event.pk, form=form)
def post(self): if g.user is not None and g.user.is_authenticated: return redirect(url_for('IndexView:get_0')) form = RegistrationForm(request.form) if form.validate_on_submit(): form.save() login_user(form.user, True) return redirect(url_for('IndexView:get_0')) return render_template('registration.html', title='Sign In', form=form)
def SignUp(request): if request.method == 'POST': form = RegistrationForm(request.POST) if form.is_valid(): form.save() return redirect('/app') else: form = RegistrationForm() args = {'form': form} return render(request, 'app/signup.html', args)
def home(request): if request.method == 'POST': form = RegistrationForm(request.POST) if form.is_valid(): form.save() username = request.POST['username'] messages.success(request, f'User created successfully for user {username}') return HttpResponseRedirect('/home/') else: form = RegistrationForm() return render(request, 'app/home.html', {'form': form})
def register(request): if request.method == 'POST': form = RegistrationForm(request.POST) if form.is_valid(): form.save() args = { 'title': 'Sign Up Selection', 'year': datetime.now().year, } return render(request, app / about.html, args) else: form = RegistrationForm() args = {'form': form} return render(request, 'app/register.html', args)
def registration_view(request): form = RegistrationForm(request.POST or None) context = {} context['form'] = form if form.is_valid(): new_user = form.save(commit=False) email = form.cleaned_data['email'] password = form.cleaned_data['password'] new_user.set_password(password) new_user.first_name = form.cleaned_data['first_name'] new_user.last_name = form.cleaned_data['last_name'] new_user.email = email new_user.company = form.cleaned_data['company'] new_user.position = form.cleaned_data['position'] new_user.second_name = form.cleaned_data['second_name'] new_user.save() login_user = authenticate(email=email, password=password) if login_user: login(request, login_user) return HttpResponseRedirect(reverse('main_page')) return HttpResponseRedirect(reverse('main_page')) return render(request, 'app/registration.html', context)
def register(request): status = 200 if request.method == 'POST': form = RegistrationForm(request.POST) if form.is_valid(): logger.debug('Registering user email=%s' % form.cleaned_data['email']) user = form.save() registration.send('app.views.auth.register', user=user) return render(request, 'registration/check_inbox.html', status=201) else: errors = {field: error[0] for field, error in form.errors.items()} logger.debug('Registration failed ' + str(errors)) status = 400 else: form = RegistrationForm() return render(request, 'registration/register.html', {'form': form}, status=status)
def register(request): if request.method == "POST": form = RegistrationForm(request.POST, request.FILES) if form.is_valid(): form.save() messages.success(request, "Registration Successful") return render_to_response('register.html', {'form': RegistrationForm}, context_instance=RequestContext(request)) else: messages.error(request, "Some Error Occured") return render_to_response('register.html', {'form': form}, context_instance=RequestContext(request)) else: return render_to_response('register.html', {'form': RegistrationForm}, context_instance=RequestContext(request))
def post(self, request): f = RegistrationForm(request.POST) if f.is_valid(): user = f.save() login(request, user) return redirect('home') else: return render(request, 'registration.html', context={'form': f})
def registration_view(request): context = {} if request.POST: form = RegistrationForm(request.POST) if form.is_valid(): form.save() username = form.cleaned_data.get('username') raw_password = form.cleaned_data.get('password1') account = authenticate(username=username, password=raw_password) login(request, account) return redirect('home') else: context['registration_form'] = form else: form = RegistrationForm() context['registration_form'] = form return render(request, 'app/register.html', context)
def sing_up(request): form = RegistrationForm(request.POST or None) if form.is_valid(): new_user = form.save() email = form.cleaned_data['email'] password = form.cleaned_data['password'] username = form.cleaned_data['username'] new_user.username = username new_user.email = email new_user.set_password(password) new_user.save() user = authenticate(username=username, password=password) if user: auth_login(request, user) return HttpResponseRedirect(reverse('index')) context = {'form': form} return render(request, 'sing_up.html', context)
def register(request): if request.method == 'POST': form = RegistrationForm(request.POST) if form.is_valid(): # Save account user = form.save() # Login under new account login(request, user) # Go to account home return redirect('account_home') else: form = RegistrationForm() ctx = {'form': form} return render(request, 'auth/register.html', ctx)
def registration(request): if request.method == 'POST': form = RegistrationForm(request.POST) if form.is_valid(): user = form.save() user.refresh_from_db() user.profile.verified = False user.save() my_password = form.cleaned_data.get('password1') user = auth.authenticate(username=user.username, password=my_password) auth.login(request, user) logger.info( log_username(request) + " зарегистрировался, пароль: {0}".format(my_password)) return redirect('home') else: form = RegistrationForm() return render(request, 'app/registration.html', {'form': form})
def register(request): if request.method == 'POST': form = RegistrationForm(request.POST) if form.is_valid(): user = form.save() user.refresh_from_db( ) # load the profile instance created by the signal user.profile.age = form.cleaned_data.get('age') user.save() raw_password = form.cleaned_data.get('password1') user = authenticate(username=user.username, firstname=user.first_name, lastname=user.last_name, password=raw_password) login(request, user) #return redirect('dashboard') return redirect('register') else: form = RegistrationForm() return render(request, 'register.html', {'form': form})
def store(self, request, event): if request.GET['role'] == 'cm-committee': # Bulk registration of whole committee by chairman # Get committee that was POSTed and check if user is chairman committee = Committee.objects.get(name=request.POST['committee']) self.check_user(committee.chairman) # Register all members for event committee.enroll(Mailer(settings.DEFAULT_FROM_EMAIL), event, request) messages.success( request, _("Commissie {} geregistreerd!").format(committee.name)) return redirect('event-detail', event.pk) elif request.GET['role'] == 'cm-admin': # Bulk registration of users as staff administrating the event request.user.check_staff() # Create list of tuples from three lists of inputs rows = list( zip_longest(request.POST.getlist('username'), request.POST.getlist('note'), request.POST.getlist('date'))) # Build list of forms forms = [ RegistrationsForm(event, data={ 'username': username, 'note': note, 'date': date }) for username, note, date in rows ] count = 0 with Mailer(settings.DEFAULT_FROM_EMAIL) as mailer: for form in forms: if form.is_valid(): form.save(mailer, request) count += 1 else: messages.error(request, form.errors) if count > 0: messages.success( request, _("{} inschrijvingen toegevoegd!").format(count)) return redirect('event-edit', event.pk) elif request.GET['role'] == 'user': form = RegistrationForm(event, data=request.POST) # Make sure deadline hasn't passed and event is open if event.is_expired() or not event.is_published(): raise PermissionDenied if form.is_valid(): form.save(request.user) messages.success(request, _("Inschrijving geregistreerd!")) return redirect('event-detail', event.pk) else: # Render previous page with validation errors event_view = EventView(self.route, self.request) return event_view.show(self.request, event.pk, form=form)