def get(self, **kwargs): if self.is_logged: return self.redirect_to('property/list') kwargs['form'] = self.form no_promo = True if 'promo' in kwargs: plan = Plan.all().filter('slug', kwargs['promo']).get() if plan and plan.enabled == 1: kwargs['promo'] = plan kwargs['default_plan'] = str(plan.key()) kwargs['planes'] = None no_promo = False if no_promo: planes = Plan.all().filter('online = ', 1).filter('enabled = ', 1).order('amount').fetch(3) kwargs['planes'] = planes kwargs['promo'] = None kwargs['default_plan'] = str(planes[1].key()) kwargs['selected_plan'] = None return self.render_response('backend/signup.html', **kwargs)
def get(self, **kwargs): if self.is_logged: return self.redirect_to('property/list') #kwargs['planes'] = Plan.all().filter('online = ',1).order('amount').fetch(3) kwargs['plan'] = Plan.all().filter('online = ', 1).filter('amount =', 0).get() kwargs['form'] = self.form return self.render_response('backend/signup.html', **kwargs)
def post(self, **kwargs): self.request.charset = 'utf-8' kwargs['planes'] = Plan.all().filter('online = ', 1).filter( 'enabled = ', 1).order('amount').fetch(3) kwargs['selected_plan'] = None plan = get_or_404(self.request.POST.get('plan')) # if not plan: # kwargs['form'] = self.form # kwargs['flash'] = self.build_error('Seleccione un plan vigente.') # return self.render_response('backend/signup.html', **kwargs) form_validated = self.form.validate() if not form_validated: kwargs['form'] = self.form if self.form.errors: kwargs['flash'] = self.build_error( 'Verifique los datos ingresados.') kwargs['default_plan'] = str(plan.key()) return self.render_response('backend/signup.html', **kwargs) # Generamos la inmo en estado TRIAL y le ponemos el Plan realEstate = RealEstate.new() realEstate.telephone_number = self.form.telephone_number.data realEstate.name = self.form.name.data realEstate.email = self.form.email.data realEstate.plan = plan # realEstate.status = RealEstate._REGISTERED realEstate.status = RealEstate._ENABLED if plan.is_free else RealEstate._REGISTERED realEstate.email_image = None realEstate.email_image_url = '' # Ya tenemos registrado ese domain_id realEstate.domain_id = do_slugify(realEstate.name) tmp = validate_domain_id(realEstate.domain_id) if tmp['result'] != 'free': realEstate.domain_id = realEstate.domain_id + datetime.now( ).strftime('%Y%m%d%H%M') realEstate.put() # Generamos la primer factura con fecha hoy+dias_gratis # Utilizamos el indicador I para indicar 'id' en vez de 'name' first_date = (datetime.utcnow() + timedelta(days=plan.free_days)).date() if first_date.day > 28: first_date = date(first_date.year, first_date.month, 28) invoice = Invoice() invoice.realestate = realEstate invoice.trx_id = '%sI%d' % (first_date.strftime('%Y%m'), realEstate.key().id()) invoice.amount = plan.amount #invoice.state = Invoice._NOT_PAID if plan.amount > 0 else Invoice._INBANK invoice.state = Invoice._NOT_PAID if not plan.is_free else Invoice._INBANK invoice.date = first_date invoice.put() # Volvemos a guardar el realEstate con los datos nuevos realEstate.last_invoice = invoice.date realEstate.save() # Generamos el usuario y le asignamos la realestate user = User.new() user.email = self.form.email.data user.password = self.form.password.data user.rol = 'owner' user.realestate = realEstate user.put() # Mando Correo de bienvenida y validación de eMail. # Armo el contexto dado que lo utilizo para mail plano y mail HTML. context = { 'server_url': 'http://' + self.request.headers.get('host', 'no host'), 'realestate_name': realEstate.name, 'validate_user_link': self.url_for('backend/validate/user', key=str(user.key()), _full=True), 'support_url': 'http://' + self.request.headers.get('host', 'no host') } # Armo el body en plain text. body = self.render_template( 'email/' + self.config['ultraprop']['mail']['signup']['template'] + '.txt', **context) # Armo el body en HTML. html = self.render_template( 'email/' + self.config['ultraprop']['mail']['signup']['template'] + '.html', **context) # Envío el correo. mail.send_mail(sender="www.ultraprop.com.ar <%s>" % self.config['ultraprop']['mail']['signup']['sender'], to=user.email, subject="ULTRAPROP - Bienvenido", body=body, html=html) self.set_ok( u'Un correo ha sido enviado a su casilla de email. Ingrese a ULTRAPROP a través del enlace recibido.' ) return self.redirect_to('backend/auth/login')