Beispiel #1
0
 def __init__(self, *args, **kwargs):
     super(CorteForm, self).__init__(*args, **kwargs)
     self.helper.layout = Fieldset(u'Corte de Caja', *self.field_names)
Beispiel #2
0
 def __init__(self, *args, **kwargs):
     super(ItemTemplateSearchForm, self).__init__(*args, **kwargs)
     self.helper.layout = Fieldset(u'Formulario de Proveedor',
                                   *self.field_names)
Beispiel #3
0
 def __init__(self, *args, **kwargs):
     super(CompraForm, self).__init__(*args, **kwargs)
     self.helper.layout = Fieldset(u'Formulario de Compra',
                                   *self.field_names)
Beispiel #4
0
 def __init__(self, *args, **kwargs):
     super(TransferidoForm, self).__init__(*args, **kwargs)
     self.helper.layout = Fieldset(u'Agregar Producto a Transferir',
                                   *self.field_names)
Beispiel #5
0
 def __init__(self, *args, **kwargs):
     super(ItemCompradoForm, self).__init__(*args, **kwargs)
     self.helper.layout = Fieldset(u'Agregar Producto Comprado',
                                   *self.field_names)
Beispiel #6
0
    def __init__(self, project, request_user, *args, **kwargs):
        super(NewMobileWorkerForm, self).__init__(*args, **kwargs)
        email_string = "@{}.commcarehq.org".format(project.name)
        max_chars_username = 80 - len(email_string)
        self.project = project
        self.domain = self.project.name
        self.request_user = request_user
        self.can_access_all_locations = request_user.has_permission(
            self.domain, 'access_all_locations')
        if not self.can_access_all_locations:
            self.fields['location_id'].required = True

        if self.project.strong_mobile_passwords:
            if settings.ENABLE_DRACONIAN_SECURITY_FEATURES:
                validator = "validate_password_draconian"
            else:
                validator = "validate_password_standard"
            self.fields['password'].widget = forms.TextInput(
                attrs={
                    validator: "",
                    "ng_keydown": "markNonDefault()",
                    "class": "default",
                })
            self.fields['password'].help_text = mark_safe_lazy(
                string_concat(
                    '<i class="fa fa-warning"></i>',
                    ugettext_lazy(
                        'This password is automatically generated. Please copy it or create your own. It will not be shown again.'
                    ), '<br />'))

        if project.uses_locations:
            self.fields['location_id'].widget = AngularLocationSelectWidget(
                require=not self.can_access_all_locations)
            location_field = crispy.Field(
                'location_id',
                ng_model='mobileWorker.location_id',
            )
        else:
            location_field = crispy.Hidden(
                'location_id',
                '',
                ng_model='mobileWorker.location_id',
            )

        self.helper = HQModalFormHelper()
        self.helper.form_tag = False
        self.helper.layout = Layout(
            Fieldset(
                _('Basic Information'),
                crispy.Field(
                    'username',
                    ng_required="true",
                    validate_username="",
                    # What this says is, update as normal or when the element
                    # loses focus. If the update is normal, wait 300 ms to
                    # send the request again. If the update is on blur,
                    # send the request.
                    ng_model_options="{ "
                    " updateOn: 'default blur', "
                    " debounce: {'default': 300, 'blur': 0} "
                    "}",
                    ng_model='mobileWorker.username',
                    ng_maxlength=max_chars_username,
                    maxlength=max_chars_username,
                ),
                crispy.Field(
                    'first_name',
                    ng_required="false",
                    ng_model='mobileWorker.first_name',
                    ng_maxlength="30",
                ),
                crispy.Field(
                    'last_name',
                    ng_required="false",
                    ng_model='mobileWorker.last_name',
                    ng_maxlength="30",
                ),
                location_field,
                crispy.Field(
                    'password',
                    ng_required="true",
                    ng_model='mobileWorker.password',
                    data_bind="value: password, valueUpdate: 'input'",
                ),
            ))
Beispiel #7
0
 def __init__(self, *args, **kwargs):
     super(TransferenciaForm, self).__init__(*args, **kwargs)
     self.helper.layout = Fieldset(
         u'Formulario de Transferencia de Inventario', *self.field_names)
Beispiel #8
0
 def __init__(self, *args, **kwargs):
     super(VentaPeriodoForm, self).__init__(*args, **kwargs)
     self.helper.layout = Fieldset(u'Detalle de Ventas de un Periodo',
                                   *self.field_names)
Beispiel #9
0
 def __init__(self, *args, **kwargs):
     super(TipoPagoPeriodoForm, self).__init__(*args, **kwargs)
     self.helper.layout = Fieldset(u'Pagos por Tipo y Periodo',
                                   *self.field_names)
Beispiel #10
0
 def __init__(self, *args, **kwargs):
     super(CierreTurnoForm, self).__init__(*args, **kwargs)
     self.helper.layout = Fieldset(u'Agregar cierre de Turno',
                                   *self.field_names)
Beispiel #11
0
 def __init__(self, *args, **kwargs):
     super(TurnoCajaCierreForm, self).__init__(*args, **kwargs)
     self.helper.layout = Fieldset(u'Cerrar Turno', *self.field_names)
Beispiel #12
0
 def __init__(self, *args, **kwargs):
     super(TurnoCajaForm, self).__init__(*args, **kwargs)
     self.helper.layout = Fieldset(u'Iniciar un Turno', *self.field_names)
Beispiel #13
0
 def __init__(self, *args, **kwargs):
     super(PagoForm, self).__init__(*args, **kwargs)
     self.helper.layout = Fieldset(u'Agregar un método de Pago',
                                   *self.field_names)
Beispiel #14
0
 def __init__(self, *args, **kwargs):
     super(InventarioForm, self).__init__(*args, **kwargs)
     self.helper.layout = Fieldset(u'Relación entre Ventas e Inventario',
                                   *self.field_names)
Beispiel #15
0
class CreateUserForm(forms.ModelForm):
    helper = FormHelper()
    helper.layout = Layout(
        Div(
            Div(Fieldset(
                '',
                'name',
                'email',
                Field('country',
                      css_class='selectpicker',
                      data_style='btn selectpicker-btn'),
                Field('secondary_language',
                      css_class='selectpicker',
                      data_style='btn selectpicker-btn'),
            ),
                css_class="col-sm-6"),
            Div(Fieldset(
                '',
                'therapeutic_areas',
                'groups',
            ),
                css_class="col-sm-6"),
            css_class="row",
        ), )
    email = forms.EmailField(label=_('Email address'), required=True)

    class Meta:
        model = User
        fields = [
            'email', 'name', 'therapeutic_areas', 'country',
            'secondary_language', 'groups'
        ]

    def save(self, commit=True):
        user = super().save()
        user.username = self.cleaned_data['email']
        # User becomes active once he sets up his password
        user.is_active = False
        if commit:
            user.save()
        return user

    def send_set_password_email(self, user, request):
        plaintext_mail = get_template('users/emails/set_password_initial.txt')
        html_mail = get_template('users/emails/set_password_initial.html')
        subject = "[MSL Insights] Finish your account setup!"
        from_email = settings.DEFAULT_FROM_EMAIL
        to = user.email
        current_site = get_current_site(request)

        email_context = Context({
            'user':
            user,
            'set_password_url':
            user.get_set_password_url(request),
            'site_name':
            current_site.name,
            'site_domain':
            current_site.domain
        })
        text_content = plaintext_mail.render(email_context)
        html_content = html_mail.render(email_context)
        msg = EmailMultiAlternatives(subject, text_content, from_email, [to])
        msg.attach_alternative(html_content, "text/html")
        msg.send()
Beispiel #16
0
 def __init__(self, *args, **kwargs):
     super(PagoStatusForm, self).__init__(*args, **kwargs)
     self.helper.layout = Fieldset(u'Cambiar Estado de Pago',
                                   *self.field_names)
Beispiel #17
0
    def __init__(self, *args, query_params=None, data=None, **kwargs):
        self.submission = kwargs.pop("submission", None)

        if self.person_form_instance.config.get("hidden_fields"):
            self.hidden_fields = {
                desc["id"]: desc
                for desc in self.person_form_instance.config["hidden_fields"]
            }

        # s'assurer que les informations des champs hidden fields viennent forcément de GET
        if data is not None and query_params is not None:
            data = copy(data)  # to make it mutable
            for f in self.hidden_fields:
                data[f] = query_params.get(f)

        super().__init__(*args, data=data, **kwargs)

        if self.person_form_instance.editable and self.submission is not None:
            for id, value in get_data_from_submission(self.submission).items():
                self.initial[id] = value
            self.is_submission_edition = True

        parts = []

        # lors de la création et du test du formulaire, celui-ci n'a pas encore d'ID, et on ne peut pas manipuler
        # ses tags
        if not self.person_form_instance._state.adding:
            self.tag_queryset = self.person_form_instance.tags.all()

            if len(self.tag_queryset) > 1:
                self.fields["tag"] = PersonTagChoiceField(
                    queryset=self.tag_queryset,
                    to_field_name="label",
                    required=True,
                    label=self.person_form_instance.main_question,
                )
                parts.append(Fieldset(_("Ma situation"), Row(FullCol("tag"))))
            elif len(self.tag_queryset) == 1:
                self.tag = self.tag_queryset[0]

        opts = self._meta
        if opts.fields:
            for f in opts.fields:
                self.fields[f].required = True

        self.helper = FormHelper()
        self.helper.form_method = "POST"
        if self.person_form_instance.campaign_template is not None:
            self.helper.add_input(
                Submit("preview", "Prévisualiser l'email",
                       formtarget="_blank"))

        self.helper.add_input(
            Submit(
                "submit",
                self.person_form_instance.submit_label,
                disabled=self.person_form_instance.campaign_template
                is not None,
            ))
        self.helper.layout = Layout()

        if self.person_form_instance.custom_fields:
            self.parts = [
                get_form_part(part)
                for part in self.person_form_instance.custom_fields
            ]
        else:
            self.parts = []

        for part in self.parts:
            part.set_up_fields(self, self.is_submission_edition)

        self.update_meta_initial()

        # Vérifier les potentiels risques de sécurité ici (forger un lien qui préremplit un formulaire
        # différement de ce qu'on aurait souhaité).
        if query_params is not None:
            for field in self.fields:
                if field in query_params:
                    self.initial[field] = query_params[field]

        for id, field_desc in self.hidden_fields.items():
            self.fields[id] = get_form_field(
                {
                    **field_desc, "widget": SuperHiddenDisplay()
                },
                is_submission_edition=self.is_submission_edition,
            )
Beispiel #18
0
 def __init__(self, *args, **kwargs):
     super(PersonaForm, self).__init__(*args, **kwargs)
     self.helper.layout = Fieldset(u'Datos del Cliente', *self.field_names)
     self.helper.form_id = "persona_form"
Beispiel #19
0
 def __init__(self, *args, **kwargs):
     super(ItemRequisicionForm, self).__init__(*args, **kwargs)
     self.helper.layout = Fieldset(u'Formulario de Requisición de Producto',
                                   *self.field_names)
Beispiel #20
0
 def __init__(self, *args, **kwargs):
     super(ReciboForm, self).__init__(*args, **kwargs)
     self.helper.layout = Fieldset(u'Datos del Recibo', *self.field_names)
Beispiel #21
0
 def __init__(self, *args, **kwargs):
     super(TransferirForm, self).__init__(*args, **kwargs)
     self.helper.add_input(Submit('submit', 'Aplicar'))
     self.helper.layout = Fieldset(u'¿Aplicar la Transferencia Ahora?',
                                   *self.field_names)
Beispiel #22
0
 def __init__(self, *args, **kwargs):
     super(VentaForm, self).__init__(*args, **kwargs)
     self.helper.layout = Fieldset(u'Agregar un Cargo', *self.field_names)
Beispiel #23
0
 def __init__(self, *args, **kwargs):
     super(HistorialForm, self).__init__(*args, **kwargs)
     self.helper.layout = Fieldset(u'Crear Historial de Inventario',
                                   *self.field_names)
Beispiel #24
0
    def __init__(self, *args, **kwargs):
        self.user = kwargs.pop('user')
        super(PaperForm, self).__init__(*args, **kwargs)
        # self.email = self.cleaned_data['email']

        # self.fields['authorship'].label = "I am the corresponding author"
        # self.fields['contact'].label = "I can be contacted by participants"

        # self.fields['feedback'].label = "I wish to received feedback on reproductions"
        self.fields[
            'public'].label = "I wish to receive feedback on reproductions"
        self.helper = FormHelper(self)
        self.helper.form_method = 'post'
        self.helper.add_input(Submit('submit', 'Submit paper'))
        self.helper.layout = Layout(
            HTML('<h2>Paper details<h2>'),
            'title',
            'citation_txt',
            'citation_bib',
            'doi',
            'description',
            'why',
            'focus',
            Fieldset(
                "Links to Resources",
                Row(
                    Column('paper_url', css_class='form-group col-md-6 mb-0'),
                    Column('data_url', css_class='form-group col-md-6 mb-0'),
                    css_class='form-row',
                ),
                Row(
                    Column('code_url', css_class='form-group col-md-6 mb-0'),
                    Column('extra_url', css_class='form-group col-md-6 mb-0'),
                    css_class='form-row',
                ),
            ),
            Field('tools', label="Useful Software Skills"),
            HTML('<h3>Submitter contact details<h3>'),
            Row(
                Column(css_class='form-group col-md-4 mb-0'),
                css_class='form-row',
            ),
            Fieldset(
                "Authorship details",
                # Row(
                #     Column('authorship', label="I am corresponding author",
                #            css_class='form-group col-md-6 mb-0'),
                #     Column('author_first_name',
                #            css_class='form-group col-md-3 mb-0'),
                #     Column('author_last_name',
                #            css_class='form-group col-md-3 mb-0'),
                #     Column('author_email',
                #            css_class='form-group col-md-6 mb-0'),
                #     css_class='form-row',
                # ),
                Row(
                    Column('public',
                           label="Feedback can be published",
                           css_class='form-group col-md-6 mb-0'),
                    css_class='form-row',
                ),
            ),
        )
Beispiel #25
0
 def __init__(self, *args, **kwargs):
     super(ItemTemplateSearchForm, self).__init__(*args, **kwargs)
     self.helper.add_input(Submit('submit', 'Buscar'))
     self.helper.layout = Fieldset(u'Buscar Producto', *self.field_names)
Beispiel #26
0
class TicketForm(forms.ModelForm):
    helper = FormHelper()
    helper.layout = Layout(
        Fieldset(
            '',
            Div(
                Div(
                    Div('customer'),
                    Div('address'),
                    css_class='col',
                ),
                Div(Div('salesperson'),
                    Div(
                        PrependedText(
                            'phone',
                            '<i class="fa fa-phone" aria-hidden="true"></i>')),
                    Div(
                        PrependedText(
                            'email',
                            '<i class="fa fa-envelope-o" aria-hidden="true"></i>'
                        )),
                    css_class='col'),
                css_class="row",
            ),
            Div(
                Div('work_requested', css_class='col'),
                css_class='row',
            ),
            Div(
                Div('work_completed', css_class='col'),
                css_class='row',
            ),
            Div(
                Div('installers', css_class='col self.helper.form_id'),
                Div(PrependedText(
                    'date_completed',
                    '<i class="fa fa-calendar" aria-hidden="true"></i>'),
                    css_class='col'),
                css_class='row',
            ),
        ),
        FormActions(
            Submit('submit', 'Save', css_class="btn btn-outline-success"),
            HTML(
                """<a href="{% url "ticket-list" %}" class="btn btn-secondary">Cancel</a>"""
            ),
            HTML("""{% if object %}
                    <a href="{% url "ticket-delete" object.id %}"
                    class="btn btn-outline-danger pull-right">
                    Delete <i class="fa fa-trash-o" aria-hidden="true"></i></button></a>
                    {% endif %}"""),
        ))

    class Meta:
        model = Ticket
        fields = (
            'customer',
            'salesperson',
            'address',
            'phone',
            'email',
            'installers',
            'work_requested',
            'work_completed',
            'date_completed',
        )
        widgets = {
            'address': forms.Textarea(attrs={'rows': 4}),
            'email': forms.TextInput(attrs={'placeholder': 'Email'}),
            'phone': forms.TextInput(attrs={'placeholder': 'Phone'}),
            'work_requested': forms.Textarea(attrs={'rows': 10}),
            'work_completed': forms.Textarea(attrs={'rows': 10}),
            'date_completed': forms.DateInput(format='%b %d, %Y'),
        }

    def __init__(self, *args, **kwargs):
        super(TicketForm, self).__init__(*args, **kwargs)
        self.fields['address'].label = "Job Address"
        self.fields['email'].label = ""
        self.fields['phone'].label = ""
Beispiel #27
0
 def __init__(self, *args, **kwargs):
     super(ItemForm, self).__init__(*args, **kwargs)
     self.helper.layout = Fieldset(u'Formulario de Item Inventariado',
                                   *self.field_names)
Beispiel #28
0
    def __init__(self, *args, **kwargs):
        """
        Add placeholders and classes, remove auto-generated
        labels and set autofocus on first field
        """
        super().__init__(*args, **kwargs)
        self.fields["full_name"].widget.attrs["autofocus"] = True
        for field in self.fields:
            if field != "saveinfo":
                self.fields[field].widget.attrs["class"] = "all-form-input"
                self.fields[field].label = False
            else:
                self.fields[field].label = "Save this number to my profile"

        # Defines the layout for the form using crispy FormHelper
        self.helper = FormHelper()
        self.helper.form_method = "POST"
        self.helper.form_class = "crispyform"
        self.helper.form_id = "payment-form"
        self.helper.layout = Layout(
            HTML("""
                <div class="row">
                    <div class="col-12 col-lg-6">
                        <p class="booking-subheader">Please fill out the \
                            form below to complete your booking
                        </p>
                        <div class="crispyform">
                """),
            Fieldset(
                "Contact Details",
                Field("full_name", placeholder="Full Name", autofocus=True),
                Field("contact_email", placeholder="Email Address"),
                Field("contact_number", placeholder="Phone Number"),
                CustomCheckbox('saveinfo'),
                css_class="rounded px-3 mb-3",
            ),
            Fieldset(
                "Billing Details",
                Field("street_address1", placeholder="Street Address 1 *"),
                Field("street_address2", placeholder="Street Address 2"),
                Field("town_or_city", placeholder="Town or City *"),
                Field("county", placeholder="County, State or Locality"),
                Field("postcode", placeholder="Postal Code *"),
                Field("country", placeholder="Country *"),
                css_class="rounded px-3 mb-3",
            ),
            Fieldset(
                "Payment",
                Div(css_class="mb-3 all-form-input", id="card-element"),
                Div(css_class="text-danger mb-3",
                    id="card-errors",
                    role="alert"),
                Hidden(css_class="text-danger mb-3",
                       value="{{ client_secret }}",
                       name="client_secret"),
                css_class="px-3",
            ),
            HTML("""
                    </div>
                </div>

                {% include 'checkout/includes/summary/checkout-summary.html' %}
                """))
Beispiel #29
0
 def __init__(self, *args, **kwargs):
     super(ItemTypeForm, self).__init__(*args, **kwargs)
     self.helper.layout = Fieldset(u'Formulario de Tipos de Producto',
                                   *self.field_names)
Beispiel #30
0
 def __init__(self, *args, **kwargs):
     super(ExamenFacturarForm, self).__init__(*args, **kwargs)
     self.helper.layout = Fieldset(u'Facturar Examen', *self.field_names)