def __init__(self, *args, **kwargs):
super(SubVacuumForm, self).__init__(*args, **kwargs)
self.helper = FormHelper()
self.helper.form_id = 'inactive-subscribers-form'
self.helper.form_method = 'post'
self.helper.form_action = '/dashboard/network/inactive-subscribers'
# Render the inactive_days field differently depending on whether or
# not this feature is active.
if args[0]['sub_vacuum_enabled']:
days_field = Field('inactive_days')
else:
days_field = Field('inactive_days', disabled=True)
self.helper.layout = Layout(
'sub_vacuum_enabled',
days_field,
Submit('submit', 'Save', css_class='pull-right'),
)
python类Field()的实例源码
dashboard_forms.py 文件源码
项目:CommunityCellularManager
作者: facebookincubator
项目源码
文件源码
阅读 22
收藏 0
点赞 0
评论 0
forms.py 文件源码
项目:Django-Web-Development-with-Python
作者: PacktPublishing
项目源码
文件源码
阅读 20
收藏 0
点赞 0
评论 0
def __init__(self, *args, **kwargs):
super(BulletinFilterForm, self).__init__(*args, **kwargs)
self.helper = FormHelper()
self.helper.form_action = ""
self.helper.form_method = "GET"
self.helper.layout = layout.Layout(
layout.Fieldset(
_("Filter bulletins"),
layout.Field("bulletin_type"),
layout.Field("category"),
),
bootstrap.FormActions(
layout.Submit("submit", _("Filter")),
),
)
def __init__(self, *args, **kwargs):
super(SponsorContactForm, self).__init__(*args, **kwargs)
self.helper = FormHelper()
self.helper.layout = Layout(
Field("responded"),
Field("companyName"),
Field("contactEMail"),
HTML("<p class=\"text-info\">Please ensure the correctness of the address. It will later be used in the billing process.</p>"),
Field("street"),
Field("zipcode"),
Field("city"),
Field("country"),
Field("contactPersonFirstname"),
Field("contactPersonSurname"),
Field("contactPersonGender"),
Field("contactPersonEmail"),
Field("contactPersonLanguage"),
Field("template"),
Field("comment")
)
self.helper.add_input(Submit("Save", "Save"))
def __init__(self, *args, **kwargs):
super(SignupForm, self).__init__(*args, **kwargs)
self.helper = FormHelper()
self.fields["email"].widget.input_type = "email" # ugly hack
self.helper.form_class = 'form-horizontal'
self.helper.label_class = 'col-md-4 col-xs-4 hidden-sm hidden-xs'
self.helper.field_class = 'col-md-8 col-xs-12'
# self.helper.form_show_labels = False
if 'bootstrap' in settings.CRISPY_TEMPLATE_PACK:
email_field = PrependedText('email', '@', placeholder="Enter Email", autofocus="")
else:
email_field = Field('email', placeholder="Enter Email", autofocus="")
self.helper.layout = Layout(
email_field,
Field('name', placeholder="Enter your full name"),
Field('password1', placeholder="Enter Password"),
Field('password2', placeholder="Confirm Password"),
Field('register_for_api', placeholder="Register for our API access"),
Field('country', placeholder="Select your country"),
Field('institution', placeholder="Your institution"),
Field('phone', placeholder="Phone"),
Field('comment', placeholder="Any comment ?"),
Field('tos', ),
Submit('sign_up', 'Sign up', css_class="btn btn-lg btn-primary btn-block"),
)
def convert_field(self, f, counts):
col_class = "col-sm-%d" % int(math.ceil(12 / counts))
if not (isinstance(f, Field) or issubclass(f.__class__, Field)):
f = layout.Field(f)
if f.wrapper_class:
f.wrapper_class += " %s" % col_class
else:
f.wrapper_class = col_class
return f
def convert_field(self, f, counts):
col_class = "col-sm-%d" % int(math.ceil(12 / counts))
if not (isinstance(f, Field) or issubclass(f.__class__, Field)):
f = layout.Field(f)
if f.wrapper_class:
f.wrapper_class += " %s" % col_class
else:
f.wrapper_class = col_class
return f
def convert_field(self, f, counts):
col_class = "col-sm-%d" % int(math.ceil(12 / counts))
if not (isinstance(f, Field) or issubclass(f.__class__, Field)):
f = layout.Field(f)
if f.wrapper_class:
f.wrapper_class += " %s" % col_class
else:
f.wrapper_class = col_class
return f
def convert_field(self, f, counts):
col_class = "col-sm-%d" % int(math.ceil(12 / counts))
if not (isinstance(f, Field) or issubclass(f.__class__, Field)):
f = layout.Field(f)
if f.wrapper_class:
f.wrapper_class += " %s" % col_class
else:
f.wrapper_class = col_class
return f
def convert_field(self, f, counts):
col_class = "col-sm-%d" % int(math.ceil(12 / counts))
if not (isinstance(f, Field) or issubclass(f.__class__, Field)):
f = layout.Field(f)
if f.wrapper_class:
f.wrapper_class += " %s" % col_class
else:
f.wrapper_class = col_class
return f
dashboard_forms.py 文件源码
项目:CommunityCellularManager
作者: facebookincubator
项目源码
文件源码
阅读 20
收藏 0
点赞 0
评论 0
def __init__(self, *args, **kwargs):
super(NetworkSettingsForm, self).__init__(*args, **kwargs)
self.helper = FormHelper()
self.helper.form_id = 'network-settings-form'
self.helper.form_method = 'post'
self.helper.form_action = '/dashboard/network/edit'
# Render the autoupgrade field channel and window fields differently
# depending on the state of autoupgrade_enabled.
if args[0]['autoupgrade_enabled']:
channel_field = Field('autoupgrade_channel')
in_window_field = Field('autoupgrade_in_window')
# Render the window-time selection field differently depending on
# the value of autoupgrade_in_window.
if args[0]['autoupgrade_in_window']:
window_field = Field('autoupgrade_window_start')
else:
window_field = Field('autoupgrade_window_start', disabled=True)
else:
channel_field = Field('autoupgrade_channel', disabled=True)
in_window_field = Field('autoupgrade_in_window', disabled=True)
window_field = Field('autoupgrade_window_start', disabled=True)
self.helper.layout = Layout(
'network_name',
'subscriber_currency',
'number_country',
'autoupgrade_enabled',
channel_field,
in_window_field,
window_field,
Submit('submit', 'Save', css_class='pull-right'),
)
forms.py 文件源码
项目:Django-Web-Development-with-Python
作者: PacktPublishing
项目源码
文件源码
阅读 21
收藏 0
点赞 0
评论 0
def __init__(self, *args, **kwargs):
super(InspirationQuoteForm, self).__init__(*args, **kwargs)
self.helper = FormHelper()
self.helper.form_action = ""
self.helper.form_method = "POST"
self.helper.layout = layout.Layout(
layout.Fieldset(
_("Quote"),
layout.Field("author"),
layout.Field("quote", rows=3),
layout.HTML("""
{% include "quotes/includes/image_upload_widget.html" %}
"""),
layout.Field("picture_path"), # hidden
layout.Field("delete_picture"), # hidden
),
bootstrap.FormActions(
layout.Submit("submit", _("Save"), css_class="btn btn-primary"),
)
)
forms.py 文件源码
项目:Django-Web-Development-with-Python
作者: PacktPublishing
项目源码
文件源码
阅读 23
收藏 0
点赞 0
评论 0
def __init__(self, *args, **kwargs):
super(MovieForm, self).__init__(*args, **kwargs)
self.helper = FormHelper()
self.helper.form_action = ""
self.helper.form_method = "POST"
self.helper.layout = layout.Layout(
layout.Field("title"),
layout.Field("categories", template="utils/checkbox_select_multiple_tree.html"),
bootstrap.FormActions(
layout.Submit("submit", _("Save")),
)
)
forms.py 文件源码
项目:Django-Web-Development-with-Python
作者: PacktPublishing
项目源码
文件源码
阅读 24
收藏 0
点赞 0
评论 0
def __init__(self, *args, **kwargs):
super(MovieForm, self).__init__(*args, **kwargs)
self.helper = FormHelper()
self.helper.form_action = ""
self.helper.form_method = "POST"
self.helper.layout = layout.Layout(
layout.Field("title"),
layout.Field("categories", template="utils/checkbox_select_multiple_tree.html"),
bootstrap.FormActions(
layout.Submit("submit", _("Save")),
)
)
def convert_field(self, f, counts):
col_class = "col-sm-%d" % int(math.ceil(12 / counts))
if not (isinstance(f, Field) or issubclass(f.__class__, Field)):
f = layout.Field(f)
if f.wrapper_class:
f.wrapper_class += " %s" % col_class
else:
f.wrapper_class = col_class
return f
def __init__(self, *args, **kwargs):
super(DevroomGeneralForm, self).__init__(*args, **kwargs)
self.helper = FormHelper()
if self.instance and self.instance.logo:
self.helper.layout = Layout(
Field("projectName"),
Field("logo"),
Div(
HTML("<p>Current logo:</p><img src=\"{{object.logo.url}}\" style=\"max-height:200px\"/>"),
css_class = "control-group"),
Field("homepage"),
# FormActions(Submit("Save", "Save changes"))
)
else:
self.helper.layout = Layout(
Field("projectName"),
Div(
Div(Field("logo"),css_class = "col-md-2"),
css_class = "row"
),
Field("homepage"),
# FormActions(Submit("Save", "{% if object %}Save changes{% else %}Register{% endif %}"))
)
if self.instance is not None and self.instance.id is not None:
self.helper.add_input(Submit("Save", "Save changes"))
else:
self.helper.add_input(Submit("Save", "Register"))
def __init__(self, *args, **kwargs):
super(DevroomDescriptionForm, self).__init__(*args, **kwargs)
self.helper = FormHelper()
self.helper.layout = Layout(
Field("descriptionDE"),
Field("descriptionEN"),
# FormActions(Submit("Save", "Save changes"))
)
self.helper.add_input(Submit("Save","Save changes"))
def __init__(self, *args, **kwargs):
super(DevroomProgramForm, self).__init__(*args, **kwargs)
self.helper = FormHelper()
self.helper.layout = Layout(
Field("schedule"),
Field("plannedProgram"),
Field("anticipatedGuests"),
# FormActions(Submit("Save", "Save changes"))
)
self.helper.add_input(Submit("Save","Save changes"))
def __init__(self, *args, **kwargs):
super(ExhibitorGeneralForm, self).__init__(*args, **kwargs)
self.helper = FormHelper()
if self.instance and self.instance.logo:
self.helper.layout = Layout(
Field("projectName"),
Field("logo"),
Div(
HTML("<p>Current logo:</p><img src=\"{{object.logo.url}}\" style=\"max-height:200px\"/>"),
css_class = "control-group"),
Field("homepage"),
# FormActions(Submit("Save", "Save changes"))
)
else:
self.helper.layout = Layout(
Field("projectName"),
Div(
Div(Field("logo"),css_class = "col-md-2"),
css_class = "row"
),
Field("homepage"),
# FormActions(Submit("Save", "{% if object %}Save changes{% else %}Register{% endif %}"))
)
if self.instance is not None and self.instance.id is not None:
self.helper.add_input(Submit("Save", "Save changes"))
else:
self.helper.add_input(Submit("Save", "Register"))
def __init__(self, *args, **kwargs):
super(ExhibitorDescriptionForm, self).__init__(*args, **kwargs)
self.helper = FormHelper()
self.helper.layout = Layout(
Field("descriptionDE"),
Field("descriptionEN"),
# FormActions(Submit("Save", "Save changes"))
)
self.helper.add_input(Submit("Save","Save changes"))
def __init__(self, *args, **kwargs):
super(PackagesImporterForm, self).__init__(*args, **kwargs)
self.helper = FormHelper()
self.helper.form_class = 'form-horizontal'
self.helper.label_class = 'col-lg-5'
self.helper.field_class = 'col-lg-5'
self.helper.layout = Layout(
Field("fromYear"),
)
self.helper.form_action = "sponsorpackage_import"
self.helper.add_input(Submit("Import", "Import"))
def __init__(self, *args, **kwargs):
super(SponsorCreationForm, self).__init__(*args, **kwargs)
self.helper = FormHelper()
self.helper.form_tag = False
self.helper.layout = Layout(
Field("sponsorUsername"),
Field("sponsorPackage"),
Field("internalComment")
)
self.helper.add_input(Submit("Save","Create sponsor"))
def __init__(self, *args, **kwargs):
super(SponsorPackageForm, self).__init__(*args, **kwargs)
self.helper = FormHelper()
self.helper.layout = Layout(
Field("name"),
Field("hpCatagoryName"),
Field("comments"),
Field("color"),
AppendedText("price",u"€"),
Field("countPackages"),
Field("logoWebsitePositionEN"),
Field("logoWebsitePositionDE"),
Field("hasLogoOnPrintmedia"),
Field("hasSocialMedia"),
Field("hasHpText"),
Field("hasProgramAdText"),
Field("programAdTextNumWords"),
Field("hasProgramAd"),
Div(
Field("programAdInfo"),
Field("programAdInfoDescEN"),
Field("programAdInfoDescDE"),
HTML("<div class=\"form-grouper-label\">Program ad</div>"),
css_class="form-grouper", css_id="program-ad-grouper"),
Field("hasPackets"),
Field("hasBooth"),
Div(
Field("boothPositionEN"),
Field("boothPositionDE"),
HTML("<div class=\"form-grouper-label\">Booth position</div>"),
css_class="form-grouper", css_id="booth-grouper"),
Field("hasRecruitingEvent"),
Field("hasParticipants"),
Field("numFreeTickets"),
Field("additionalContentTextEN"),
Field("additionalContentTextDE"),
)
self.helper.add_input(Submit("Save", "Save"))
def convert_field(self, f, counts):
col_class = "col-sm-%d" % int(math.ceil(12 / counts))
if not (isinstance(f, Field) or issubclass(f.__class__, Field)):
f = layout.Field(f)
if f.wrapper_class:
f.wrapper_class += " %s" % col_class
else:
f.wrapper_class = col_class
return f
def convert_field(self, f, counts):
col_class = "col-sm-%d" % int(math.ceil(12 / counts))
if not (isinstance(f, Field) or issubclass(f.__class__, Field)):
f = layout.Field(f)
if f.wrapper_class:
f.wrapper_class += " %s" % col_class
else:
f.wrapper_class = col_class
return f
def convert_field(self, f, counts):
col_class = "col-sm-%d" % int(math.ceil(12 / counts))
if not (isinstance(f, Field) or issubclass(f.__class__, Field)):
f = layout.Field(f)
if f.wrapper_class:
f.wrapper_class += " %s" % col_class
else:
f.wrapper_class = col_class
return f
def convert_field(self, f, counts):
col_class = "col-sm-%d" % int(math.ceil(12 / counts))
if not (isinstance(f, Field) or issubclass(f.__class__, Field)):
f = layout.Field(f)
if f.wrapper_class:
f.wrapper_class += " %s" % col_class
else:
f.wrapper_class = col_class
return f
def convert_field(self, f, counts):
col_class = "col-sm-%d" % int(math.ceil(12 / counts))
if not (isinstance(f, Field) or issubclass(f.__class__, Field)):
f = layout.Field(f)
if f.wrapper_class:
f.wrapper_class += " %s" % col_class
else:
f.wrapper_class = col_class
return f
def __init__(self, *args, **kwargs):
super(LoginForm, self).__init__(*args, **kwargs)
self.helper = FormHelper()
self.fields["username"].widget.input_type = "email" # ugly hack
self.helper.layout = Layout(
Field('username', placeholder="Enter Email", autofocus=""),
Field('password', placeholder="Enter Password"),
HTML('<a href="{}">Forgot Password?</a>'.format(
reverse("accounts:password-reset"))),
Field('remember_me'),
Submit('sign_in', 'Log in',
css_class="btn btn-lg btn-primary btn-block"),
)
def __init__(self, *args, **kwargs):
super(PasswordChangeForm, self).__init__(*args, **kwargs)
self.helper = FormHelper()
self.helper.layout = Layout(
Field('old_password', placeholder="Enter old password",
autofocus=""),
Field('new_password1', placeholder="Enter new password"),
Field('new_password2', placeholder="Enter new password (again)"),
Submit('pass_change', 'Change Password', css_class="btn-warning"),
)
def __init__(self, *args, **kwargs):
super(PasswordResetForm, self).__init__(*args, **kwargs)
self.helper = FormHelper()
self.helper.layout = Layout(
Field('email', placeholder="Enter email",
autofocus=""),
Submit('pass_reset', 'Reset Password', css_class="btn-warning"),
)