def save(self, request, entry_point=ProfileEntryPoint.Direct): email = self.cleaned_data.get('email') password = self.cleaned_data.get('password') username = self.cleaned_data.get('username') phone_number = self.cleaned_data.get('phone_number') u = User(username=username, email=email, is_active=False) u.set_password(password) u.save() p = Profile.create(request, u, entry_point=entry_point, phone=phone_number) p.save() p.send_email_confirmation_mail() return u
def done(self, request, form_list): profile_form = form_list[0].cleaned_data billing_form = form_list[1].cleaned_data u = User(username=profile_form['username'], email=profile_form['email'], is_active=False) u.set_password(profile_form['password']) u.save() if u: p = Profile.create(request, u, entry_point=ProfileEntryPoint.Trade) p.set_name_data(form_list[0].cached_name) p.set_shipping_address_data(form_list[0].cached_address) p.set_billing_name_data(form_list[1].cached_name, False) p.set_billing_address_data(form_list[1].cached_address, False) p.set_billing_card_data(billing_form, True) p.send_email_confirmation_mail() res = {} res['close'] = True res['redirect_to'] = reverse('members:create_account_complete') return JsonResponse(res)
def done(self, request, form_list): data = form_list[0].cleaned_data _user = User(username=data['username'], email=data['email'], is_active=False) _user.set_password(data['password']) _user.save() if _user: _profile = Profile.create( request, _user, entry_point=self.entry_point or ProfileEntryPoint.Direct) _profile.how_did_you_hear = data['how_did_you_hear'] _profile.set_name_data(form_list[0].cached_name) _profile.send_email_confirmation_mail() template_name = 'members/wizards/signup.dialog.html' result = loader.render_to_string(template_name, { 'title': 'Profile Information', 'step': 2, 'step_count': 1, 'email': data['email'], }, context_instance=RequestContext(request)) content = json.dumps({'form': result}) return HttpResponse(content, mimetype='application/json')
def save(self, request, entry_point=ProfileEntryPoint.DeckTheHalls): email = self.cleaned_data.get('email') password = self.cleaned_data.get('password') username = self.cleaned_data.get('username') if settings.MELISSA: full_name = self.cleaned_data.get('first_name') + ' ' + self.cleaned_data.get('last_name') full_name = settings.MELISSA.inaccurate_name(full_name=full_name) first_name = full_name['first_name'] last_name = full_name['last_name'] else: first_name = self.cleaned_data.get('first_name') last_name = self.cleaned_data.get('last_name') u = User(username=username, email=email, is_active=False, first_name=first_name, last_name=last_name) u.set_password(password) u.save() p = Profile.create(request, u, entry_point=entry_point) p.save() p.send_email_confirmation_mail() return u
def clean(self): data = super(CheckoutForm, self).clean(skip_card_verification=True) if not self._errors: request = self.request user = request.user if not user.is_authenticated(): p = Profile.create(request, None, entry_point=ProfileEntryPoint.Buy) else: p = user.get_profile() self.profile = p order_data = { 'card_display_number': self.cached_card['display_number'], 'card_data': self.cached_card['data'], 'card_type': self.cached_card['type'], 'billing_state': self.cached_address['state'], 'billing_county': self.cached_address.get('county'),} self.order = BuyOrder.create(request, order_data, p) wizard = self.request.checkout_wizard f = wizard.get_form(0, self.request.POST) f.is_valid() # it's a long way to get info from here email = user.email if user.is_authenticated() else f.cleaned_data['email'] shipping_address = f.cached_address shipping_address.update(f.cached_name) shipping_address['country'] = 'USA' billing_address = self.cached_address billing_address.update(self.cached_name) billing_address['country'] = 'USA' self.billing_history = BillingHistory.create(user if user.is_authenticated() else None, order_data['card_display_number'], debit=self.order.get_order_total(), description = 'Shop Order #%s' % self.order.get_order_number(), reason='buy', type=TransactionType.BuyCheckout) if self.order.user: invoice_num = 'BUY_%s_%s' % (self.order.user.id, self.billing_history.id) else: invoice_num = 'BUY_%s' % self.billing_history.id card = self.cached_card['data'] aim_data = { 'number': card['number'], 'exp': '/'.join((card['exp_month'], card['exp_year'][-2:])), 'code': card['code'], 'billing': billing_address, 'shipping': shipping_address, 'invoice_num': invoice_num, 'description': self.order.get_aim_description(), 'x_customer_ip': self.request.META.get('REMOTE_ADDR'), 'x_email': email, 'x_po_num': self.order.order_no(), } if p.user: aim_data['x_cust_id'] = p.user.id self.billing_history.tax = self.order.get_tax_amount() self.billing_history.applied_credits = self.order.applied_credits aim_data['x_tax'] = self.billing_history.tax self.billing_history.aim_transaction_id = self.order.take_charge(aim_data) if self.billing_history.aim_transaction_id or not self.order.get_charge_amount(): self.billing_history.card_data = self.cached_card['data'] self.billing_history.save() self.order.payment_transaction = self.billing_history self.order.save() request.cart.empty() else: msg = self.order.message self.order.delete() if p.user: self.billing_history.status = TransactionStatus.Declined self.billing_history.save() else: self.billing_history.delete() raise forms.ValidationError(msg) return data