コード例 #1
0
 def __init__(self, *args, **kwargs):
     super(PasswordResetBeginForm, self).__init__(*args, **kwargs)
     self.helper = FormHelper(self)
     self.helper.form_tag = False
     self.helper.layout = Div(
         Field('account', css_class="form-control"),
         FormActions(Submit('next', u'下一步', css_class='btn btn-lg btn-success btn-block')),
         css_class='login-wrap',
         style="background: #FFFFFF;",
     )
     self.helper.help_text_inline = True
     self.helper.error_text_inline = True
コード例 #2
0
    def __init__(self, *args, **kwargs):
        super(PasswordResetForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper(self)
        self.helper.form_tag = False
        self.helper.layout = Div(
            Field('account', css_class="form-control"),
            'password',
            'password_repeat',
            FormActions(Submit('commit', u'提交', css_class='btn btn-lg btn-primary btn-block')),
            css_class='login-wrap',
            style="background: #FFFFFF;",
        )

        self.helper.help_text_inline = True
        self.helper.error_text_inline = True
コード例 #3
0
 def __init__(self, *args, **kwargs):
     prefix_url = ""
     if len(kwargs) > 0:
         if kwargs.get("next_url") is not None:
             next_url = kwargs["next_url"]
             if next_url != "":
                 prefix_url += "&next={0}".format(next_url)
             kwargs.pop("next_url")
         if kwargs.get("origin") is not None:
             origin = kwargs["origin"]
             if origin != "":
                 prefix_url += "&origin={0}".format(origin)
             kwargs.pop("origin")
     if len(prefix_url) > 1:
         prefix_url = "?" + prefix_url[1:]
     super(UserLoginForm, self).__init__(*args, **kwargs)
     self.helper = FormHelper(self)
     self.helper.form_tag = False
     self.helper.form_show_labels = False
     if settings.MODULES["User_Register"]:
         if settings.MODULES["WeChat_Module"]:
             self.helper.layout = Div(
                 Field('email', css_class="form-control", placeholder='邮箱/手机号/用户名'),
                 Field('password', css_class="form-control", placeholder='密码'),
                 HTML("""<div class="checkbox clearfix"><label><input type="checkbox">下次自动登录</label><a href="/account/begin_password_reset" class="pull-right">忘记密码了?</a></div>"""),
                 FormActions(Submit('login', u'登录', css_class='btn btn-lg btn-success btn-block')),
                 HTML("""<p class="text-center">或使用以下账号登录</p><a href="/wechat/login{0}" class="weixin"><img src='/static/www/images/weixin.png'>&nbsp;微信</a>""".format(prefix_url)),
                 HTML("""<div class="linkregister text-center">现在<a href="/register{0}">注册</a></div>""".format(prefix_url)),
                 css_class='login-wrap',
                 style="background: #FFFFFF;",
             )
         else:
             self.helper.layout = Div(
                 Field('email', css_class="form-control", placeholder='邮箱/手机号/用户名'),
                 Field('password', css_class="form-control", placeholder='密码'),
                 HTML("""<div class="checkbox clearfix"><label><input type="checkbox">下次自动登录</label><a href="/account/begin_password_reset" class="pull-right">忘记密码了?</a></div>"""),
                 FormActions(Submit('login', u'登录', css_class='btn btn-lg btn-success btn-block')),
                 HTML("""<div class="linkregister text-center">现在<a href="/register{0}">注册</a></div>""".format(prefix_url)),
                 css_class='login-wrap',
                 style="background: #FFFFFF;",
             )
     else:
         self.helper.layout = Div(
             Field('email', css_class="form-control", placeholder='邮箱/手机号/用户名'),
             Field('password', css_class="form-control", placeholder='密码'),
             FormActions(Submit('login', u'登录', css_class='btn btn-lg btn-success btn-block')),
             css_class='login-wrap',
             style="background: #FFFFFF;",
         )
     self.helper.help_text_inline = True
     self.helper.error_text_inline = True
     self.helper.form_id = 'form-user-login'
     self.helper.form_class = 'form-horizontal'
コード例 #4
0
ファイル: services.py プロジェクト: yhtsnda/rainbond-console
    def __init__(self, *args, **kwargs):
        initial = kwargs.pop('initial', None)
        is_update = kwargs.pop('is_update', False)

        super(ServicePublishForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper(self)
        self.helper.form_tag = False

        if initial is not None:
            for field in initial:
                value = initial[field]['value']
                attrs = initial[field].get('attrs', {})
                self.fields[field].initial = value
                self.fields[field].widget.attrs.update(attrs)

        if is_update:
            del self.fields['service_key'].widget.attrs['data-remote']
            submit = Submit('update',
                            u'更新',
                            css_class='btn btn-lg btn-primary btn-block')
        else:
            submit = Submit('publish',
                            u'发布',
                            css_class='btn btn-lg btn-success btn-block')

        self.helper.layout = Layout(
            Field('service_key'),
            Field('app_name'),
            Field('app_version'),
            Field('app_info'),
            Field('pay_type'),
            Field('price'),
            Field('change_log'),
            FormActions(submit),
        )

        self.helper.help_text_inline = True
        self.helper.error_text_inline = True
        self.helper.label_class = 'col-lg-2'
        self.helper.field_class = 'col-lg-8'
コード例 #5
0
    def __init__(self, *args, **kwargs):
        init_phone = ""
        init_email = ""
        init_tenant = ""
        init_region = ""
        selected_region = ""
        next_url = None
        origin = None
        prefix_url = ""
        if len(kwargs) > 0:
            if kwargs.get("initial") is not None:
                initalObj = kwargs.get("initial")
                init_phone = initalObj["phone"]
                init_email = initalObj["email"]
                init_tenant = initalObj["tenant"]
                init_region = initalObj["region"]
            if kwargs.get("region_level") is not None:
                selected_region = kwargs["region_level"]["region"]
                kwargs.pop("region_level")
            if kwargs.get("next_url") is not None:
                next_url = kwargs["next_url"]
                prefix_url += "&next={0}".format(next_url)
                kwargs.pop("next_url")
            if kwargs.get("origin") is not None:
                origin = kwargs["origin"]
                prefix_url += "&origin={0}".format(origin)
                kwargs.pop("origin")
        if len(prefix_url) > 1:
            prefix_url = "?" + prefix_url[1:]
        if len(args) > 0:
            if type(args) is tuple:
                if args[0].get("initial") is not None:
                    initalObj = args[0]["initial"]
                    if type(initalObj) is list:
                        initalObj = initalObj(0)
                    init_phone = initalObj["phone"]
                    init_email = initalObj["email"]
                    init_tenant = initalObj["tenant"]
                    init_region = initalObj["region"]
        super(RegisterForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper(self)
        self.helper.form_tag = False

        text_phone = "手机号"
        text_email = "请输入邮箱地址"
        text_tenant = "团队域名"
        if init_phone is not None and init_phone != "":
            self.fields['phone'].widget.attrs['readonly'] = True
            text_phone = init_phone
        if init_email is not None and init_email != "":
            self.fields['email'].widget.attrs['readonly'] = True
            text_email = init_email
        if init_tenant is not None and init_tenant != "":
            self.fields['tenant'].widget.attrs['readonly'] = True
            text_tenant = init_tenant
        if init_region is not None and init_region != "":
            self.fields['machine_region'].initial = init_region
            self.fields['machine_region'].widget.attrs['readonly'] = True
        if selected_region is not None and selected_region != "":
            self.fields['machine_region'].initial = selected_region

        init_region = RegionInfo.register_choices()[0][0]
        # 对于社区版注册表单进行处理
        is_private = sn.instance.is_private()
        tenant_name = None
        if is_private:
            tenant_num = Tenants.objects.count()
            if tenant_num == 1:
                tenant_list = Tenants.objects.all()
                tenant = tenant_list[0]
                tenant_name = tenant.tenant_name

        # if settings.MODULES["Sms_Check"]:
        if settings.MODULES["WeChat_Module"]:
            self.helper.layout = Layout(
                Div(
                    Field('tenant',
                          "",
                          placeholder='请输入团队名(可使用小写英文字母、数字、下划线及中划线)',
                          css_class="form-control") if tenant_name is None else
                    Field('tenant',
                          "",
                          placeholder='请输入团队名(可使用小写英文字母、数字、下划线及中划线)',
                          css_class="form-control",
                          readonly="readonly",
                          value=tenant_name),
                    Field('nick_name',
                          css_class="form-control",
                          placeholder='请输入用户名(可使用小写英文字母、数字、下划线及中划线)'),
                    Field('email',
                          css_class="form-control",
                          placeholder='请输入邮箱(选填)'),
                    HTML("<hr/>"),
                    # 默认为ali-sh
                    Hidden('machine_region', value=init_region),
                    Hidden('next', value=next_url),
                    Hidden('origin', value=origin),
                    Field('password',
                          css_class="form-control",
                          placeholder='请设置密码,至少包含8位字符'),
                    Field('password_repeat',
                          css_class="form-control",
                          placeholder='请再输入一次密码'),
                    Field('phone',
                          css_class="form-control",
                          placeholder='请输入手机号'),
                    AppendedText(
                        'captcha_code',
                        '<img id="captcha_code" src="/captcha" /> <a href="javascript:void(0)" onclick="refresh();">看不清,换一张</a>  ',
                        css_class='input-xlarge',
                        placeholder='图片验证码'),
                    AppendedText(
                        'phone_code',
                        '<a href="javascript:void(0)" id="PhoneCodeBtn" onclick="getPhoneCode();">点击发送验证码</a>  ',
                        css_class='input-xlarge',
                        placeholder='手机验证码'),
                    HTML(
                        """<div class="linkfw text-center">点击注册表示你已阅读并同意《<a href="http://www.goodrain.com/goodrainlaws.html" target="_blank">云帮服务条款</a>》</div>"""
                    ),
                    FormActions(
                        Submit('register',
                               u'注册',
                               css_class='btn btn-lg btn-success btn-block')),
                    HTML("""<p class="text-center">或使用以下账号注册</p>"""),
                    HTML(
                        """<a href="/wechat/login{0}" class="weixin"><img src="static/www/images/weixin.png">微信</a>"""
                        .format(prefix_url)),
                    HTML(
                        """<div class="linkregister text-center">直接<a href="/login{0}">登录</a></div>"""
                        .format(prefix_url)),
                    # HTML("""<a href="http://www.goodrain.com/" class="linkgood text-center">goodrain.com</a>"""),
                    css_class="login-wrap"))
        else:
            self.helper.layout = Layout(
                Div(
                    Field('tenant',
                          "",
                          placeholder='请输入团队名(可使用小写英文字母、数字、下划线及中划线)',
                          css_class="form-control") if tenant_name is None else
                    Field('tenant',
                          "",
                          placeholder='请输入团队名(可使用小写英文字母、数字、下划线及中划线)',
                          css_class="form-control",
                          readonly="readonly",
                          value=tenant_name),
                    Field('nick_name',
                          css_class="form-control",
                          placeholder='请输入用户名(可使用小写英文字母、数字、下划线及中划线)'),
                    Field('email',
                          css_class="form-control",
                          placeholder='请输入邮箱(选填)'),
                    HTML("<hr/>"),
                    Hidden('machine_region', value=init_region),
                    Hidden('next', value=next_url),
                    Hidden('origin', value=origin),
                    Field('password',
                          css_class="form-control",
                          placeholder='请设置密码,至少包含8位字符'),
                    Field('password_repeat',
                          css_class="form-control",
                          placeholder='请再输入一次密码'),
                    Field('phone',
                          css_class="form-control",
                          placeholder='请输入手机号'),
                    AppendedText(
                        'captcha_code',
                        '<img id="captcha_code" src="/captcha" /> <a href="javascript:void(0)" onclick="refresh();">看不清,换一张</a>  ',
                        css_class='input-xlarge',
                        placeholder='验证码'),
                    AppendedText(
                        'phone_code',
                        '<a href="javascript:void(0)" id="PhoneCodeBtn" onclick="getPhoneCode();">点击发送验证码</a>  ',
                        css_class='input-xlarge',
                        placeholder='手机验证码'),
                    HTML(
                        """<div class="linkfw text-center">点击注册表示你已阅读并同意《<a href="http://www.goodrain.com/goodrainlaws.html" target="_blank">云帮服务条款</a>》</div>"""
                    ),
                    FormActions(
                        Submit('register',
                               u'注册',
                               css_class='btn btn-lg btn-success btn-block')),
                    HTML(
                        """<div class="linkregister text-center">直接<a href="/login{0}">登录</a></div>"""
                        .format(prefix_url)),
                    # HTML("""<a href="http://www.goodrain.com/" class="linkgood text-center">goodrain.com</a>"""),
                    css_class="login-wrap"))
        self.helper.form_id = 'form-normal-reg'
        self.helper.form_class = 'form-horizontal'