Пример #1
0
    def __init__(self, domain, *args, **kwargs):
        super(AppTranslationsForm, self).__init__(*args, **kwargs)
        self.domain = domain
        self.helper = FormHelper()
        self.helper.form_tag = False
        self.helper.label_class = 'col-sm-3 col-md-4 col-lg-2'
        self.helper.field_class = 'col-sm-4 col-md-5 col-lg-3'

        self.fields['app_id'].choices = tuple((app.id, app.name) for app in get_brief_apps_in_domain(domain))
        if settings.TRANSIFEX_DETAILS:
            self.fields['transifex_project_slug'].choices = (
                tuple((slug, slug)
                      for slug in settings.TRANSIFEX_DETAILS.get('project').get(domain))
            )
        self.helper.layout = Layout(
            'app_id',
            'version',
            'use_version_postfix',
            'update_resource',
            'transifex_project_slug',
            hqcrispy.Field('source_lang', css_class="ko-select2"),
            hqcrispy.Field('target_lang', css_class="ko-select2"),
            'action',
            'lock_translations',
            'perform_translated_check',
            hqcrispy.FormActions(
                twbscrispy.StrictButton(
                    ugettext_lazy("Submit"),
                    type="submit",
                    css_class="btn btn-primary btn-lg disable-on-submit",
                )
            )
        )
Пример #2
0
    def __init__(self, *args, **kwargs):
        self.user = kwargs['existing_user']
        api_key = kwargs.pop('api_key') if 'api_key' in kwargs else None
        super(UpdateMyAccountInfoForm, self).__init__(*args, **kwargs)
        self.username = self.user.username

        username_controls = []
        if self.username:
            username_controls.append(
                hqcrispy.StaticField(ugettext_lazy('Username'), self.username))

        api_key_controls = [
            hqcrispy.StaticField(ugettext_lazy('API Key'), api_key),
            hqcrispy.FormActions(twbscrispy.StrictButton(
                ugettext_lazy('Generate API Key'),
                type="button",
                id='generate-api-key',
                css_class='btn-default',
            ),
                                 css_class="form-group"),
        ]

        self.fields['language'].label = ugettext_lazy("My Language")

        self.new_helper = cb3_helper.FormHelper()
        self.new_helper.form_method = 'POST'
        self.new_helper.form_class = 'form-horizontal'
        self.new_helper.attrs = {
            'name': 'user_information',
        }
        self.new_helper.label_class = 'col-sm-3 col-md-2 col-lg-2'
        self.new_helper.field_class = 'col-sm-9 col-md-8 col-lg-6'

        basic_fields = [
            cb3_layout.Div(*username_controls),
            hqcrispy.Field('first_name'),
            hqcrispy.Field('last_name'),
            hqcrispy.Field('email'),
        ]
        if self.set_analytics_enabled:
            basic_fields.append(
                twbscrispy.PrependedText('analytics_enabled', ''), )
        if self.set_email_opt_out:
            basic_fields.append(twbscrispy.PrependedText('email_opt_out', ''))

        self.new_helper.layout = cb3_layout.Layout(
            cb3_layout.Fieldset(ugettext_lazy("Basic"), *basic_fields),
            (hqcrispy.FieldsetAccordionGroup
             if self.collapse_other_options else cb3_layout.Fieldset)(
                 ugettext_lazy("Other Options"),
                 hqcrispy.Field('language'),
                 cb3_layout.Div(*api_key_controls),
             ),
            hqcrispy.FormActions(
                twbscrispy.StrictButton(
                    ugettext_lazy("Update My Information"),
                    type='submit',
                    css_class='btn-primary',
                )))
Пример #3
0
 def form_fields(self):
     form_fields = super(PullAppTranslationsForm, self).form_fields()
     form_fields.extend([
         hqcrispy.Field('target_lang', css_class="ko-select2"),
         hqcrispy.Field('lock_translations'),
         hqcrispy.Field('perform_translated_check'),
     ])
     return form_fields
Пример #4
0
 def form_fields(self):
     return [
         hqcrispy.Field('app_id'),
         hqcrispy.Field('version'),
         hqcrispy.Field('use_version_postfix'),
         hqcrispy.Field('transifex_project_slug'),
         hqcrispy.Field('action')
     ]
Пример #5
0
 def form_fields(self):
     return [
         hqcrispy.Field('app_id', css_class="ko-select2"),
         hqcrispy.Field('version'),
         hqcrispy.Field('use_version_postfix'),
         hqcrispy.Field('transifex_project_slug', css_class="ko-select2"),
         hqcrispy.Field('action')
     ]
Пример #6
0
    def __init__(self, *args, **kwargs):
        from corehq.apps.settings.views import ApiKeyView
        self.user = kwargs['existing_user']
        super(UpdateMyAccountInfoForm, self).__init__(*args, **kwargs)
        self.username = self.user.username

        username_controls = []
        if self.username:
            username_controls.append(hqcrispy.StaticField(
                ugettext_lazy('Username'), self.username)
            )

        self.fields['language'].label = ugettext_lazy("My Language")

        self.new_helper = FormHelper()
        self.new_helper.form_method = 'POST'
        self.new_helper.form_class = 'form-horizontal'
        self.new_helper.attrs = {
            'name': 'user_information',
        }
        self.new_helper.label_class = 'col-sm-3 col-md-2 col-lg-2'
        self.new_helper.field_class = 'col-sm-9 col-md-8 col-lg-6'

        basic_fields = [
            crispy.Div(*username_controls),
            hqcrispy.Field('first_name'),
            hqcrispy.Field('last_name'),
            hqcrispy.Field('email'),
        ]
        if self.set_analytics_enabled:
            basic_fields.append(twbscrispy.PrependedText('analytics_enabled', ''),)

        self.new_helper.layout = crispy.Layout(
            crispy.Fieldset(
                ugettext_lazy("Basic"),
                *basic_fields
            ),
            (hqcrispy.FieldsetAccordionGroup if self.collapse_other_options else crispy.Fieldset)(
                ugettext_lazy("Other Options"),
                hqcrispy.Field('language'),
                crispy.Div(hqcrispy.StaticField(
                    ugettext_lazy('API Key'),
                    mark_safe(
                        ugettext_lazy('API key management has moved <a href="{}">here</a>.')
                        .format(reverse(ApiKeyView.urlname))
                    ),
                )),
            ),
            hqcrispy.FormActions(
                twbscrispy.StrictButton(
                    ugettext_lazy("Update My Information"),
                    type='submit',
                    css_class='btn-primary',
                )
            )
        )
Пример #7
0
 def __init__(self, *args, **kwargs):
     super(CustomSMSReportRequestForm, self).__init__(*args, **kwargs)
     self.helper = HQFormHelper()
     self.helper.form_method = 'post'
     self.helper.layout = crispy.Layout(
         hqcrispy.Field('date_range'), hqcrispy.Field('start_date'),
         hqcrispy.Field('end_date'),
         twbscrispy.StrictButton(
             _('Generate Report'),
             type='submit',
             css_class='btn-primary',
         ))
Пример #8
0
    def __init__(self, *args, **kwargs):
        super(DomainRequestForm, self).__init__(*args, **kwargs)

        self.helper = cb3_helper.FormHelper()
        self.helper.form_class = 'form-horizontal'
        self.helper.label_class = 'col-sm-3 col-md-4 col-lg-2'
        self.helper.field_class = 'col-sm-6 col-md-5 col-lg-3'
        self.helper.show_form_errors = True
        self.helper.layout = cb3_layout.Layout(
            hqcrispy.Field('full_name'),
            hqcrispy.Field('email'),
            hqcrispy.Field('domain'),
            self.form_actions,
        )
Пример #9
0
    def __init__(self, domain, *args, **kwargs):
        super(AppTranslationsForm, self).__init__(*args, **kwargs)
        self.domain = domain
        self.helper = FormHelper()
        self.helper.form_tag = False
        self.helper.label_class = 'col-sm-4 col-md-4 col-lg-3'
        self.helper.field_class = 'col-sm-6 col-md-6 col-lg-5'

        self.fields['app_id'].choices = tuple(
            (app.id, app.name) for app in get_brief_apps_in_domain(domain))
        projects = TransifexProject.objects.filter(domain=domain).all()
        if projects:
            self.fields['transifex_project_slug'].choices = (tuple(
                (project.slug, project) for project in projects))
        form_fields = self.form_fields()
        form_fields.append(
            hqcrispy.Field(
                StrictButton(
                    ugettext_lazy("Submit"),
                    type="submit",
                    css_class="btn btn-primary btn-lg disable-on-submit",
                    onclick="return confirm('%s')" %
                    ugettext_lazy("Please confirm that you want to proceed?")))
        )
        self.helper.layout = crispy.Layout(*form_fields)
        self.fields['action'].initial = self.form_action
Пример #10
0
    def __init__(self, domain, *args, **kwargs):
        super(AddTransifexBlacklistForm, self).__init__(*args, **kwargs)
        self.helper = hqcrispy.HQFormHelper()

        self.fields['app_id'].choices = tuple(
            (app.id, app.name) for app in get_brief_apps_in_domain(domain))
        form_fields = [
            hqcrispy.Field('app_id'),
            hqcrispy.Field('module_id'),
            hqcrispy.Field('field_type'),
            hqcrispy.Field('field_name'),
            hqcrispy.Field('display_text'),
            hqcrispy.Field('domain'),
            hqcrispy.Field('action'),
            hqcrispy.FormActions(
                twbscrispy.StrictButton(
                    ugettext_lazy("Add"),
                    type="submit",
                    css_class="btn-primary disable-on-submit",
                ))
        ]
        self.helper.layout = crispy.Layout(
            crispy.Fieldset(ugettext_lazy("Add translation to blacklist"),
                            *form_fields), )
        self.fields['action'].initial = 'blacklist'
        self.fields['domain'].initial = domain
Пример #11
0
 def __init__(self, domain, *args, **kwargs):
     super(MigrateTransifexProjectForm, self).__init__(*args, **kwargs)
     self.domain = domain
     self._set_choices()
     self.helper = HQFormHelper()
     self.helper.layout = crispy.Layout(
         crispy.Fieldset(
             "Migrate Project",
             hqcrispy.Field('from_app_id', css_class="hqwebapp-select2"),
             hqcrispy.Field('to_app_id', css_class="hqwebapp-select2"),
             hqcrispy.Field('transifex_project_slug'),
             hqcrispy.Field('mapping_file')),
         hqcrispy.FormActions(
             twbscrispy.StrictButton(
                 ugettext_lazy("Submit"),
                 type="submit",
                 css_class="btn btn-primary disable-on-submit",
                 onclick="return confirm('%s')" % ugettext_lazy(
                     "We recommend taking a backup if you have not already."
                     "Please confirm that you want to proceed?"))))
Пример #12
0
 def form_fields(self):
     form_fields = super(DeleteAppTranslationsForm, self).form_fields()
     form_fields.append(hqcrispy.Field('perform_translated_check'))
     return form_fields
Пример #13
0
 def form_fields(self):
     form_fields = super(PushAppTranslationsForm, self).form_fields()
     form_fields.append(
         hqcrispy.Field('target_lang', css_class="ko-select2"))
     return form_fields
Пример #14
0
 def form_fields(self):
     form_fields = super(CreateAppTranslationsForm, self).form_fields()
     form_fields.append(
         hqcrispy.Field('source_lang', css_class="ko-select2"))
     return form_fields