示例#1
0
    def _get_user_form(self, bound_data):
        domain_obj = Domain.get_by_name(self.domain)
        form = self._user_form_class(
            project=domain_obj,
            data=bound_data,
            request_user=self.request_user,
            prefix='location_user',
        )

        if domain_obj.strong_mobile_passwords:
            initial_password = generate_strong_password()
            pw_field = crispy.Field(
                'password',
                value=initial_password,
            )
        else:
            pw_field = 'password'

        form.fields['username'].help_text = None
        form.fields[
            'location_id'].required = False  # This field isn't displayed
        form.helper.label_class = 'col-sm-3 col-md-4 col-lg-2'
        form.helper.field_class = 'col-sm-4 col-md-5 col-lg-3'
        form.helper.layout = crispy.Layout(
            crispy.Fieldset(
                _("Location User"),
                'username',
                'first_name',
                'last_name',
                pw_field,
            ))
        return form
示例#2
0
    def _get_user_form(self, bound_data):
        domain_obj = Domain.get_by_name(self.domain)
        form = self._user_form_class(
            project=domain_obj,
            data=bound_data,
            request_user=self.request_user,
            prefix='location_user',
        )

        if domain_obj.strong_mobile_passwords:
            initial_password = generate_strong_password()
            pw_field = crispy.Field(
                'password',
                value=initial_password,
            )
        else:
            pw_field = 'password'

        form.fields['username'].help_text = None
        form.fields['location_id'].required = False  # This field isn't displayed
        form.helper.label_class = 'col-sm-3 col-md-4 col-lg-2'
        form.helper.field_class = 'col-sm-4 col-md-5 col-lg-3'
        form.helper.layout = crispy.Layout(
            crispy.Fieldset(
                _("Location User"),
                'username',
                'first_name',
                'last_name',
                pw_field,
            )
        )
        return form
示例#3
0
    def _get_user_form(self, bound_data):
        domain_obj = Domain.get_by_name(self.domain)
        form = NewMobileWorkerForm(
            project=domain_obj,
            data=bound_data,
            user=self.request_user,
            prefix='location_user',
        )

        if domain_obj.strong_mobile_passwords:
            initial_password = generate_strong_password()
            pw_field = crispy.Field(
                'password',
                data_bind=
                "initializeValue: password, value: password, valueUpdate: 'input'",
                value=initial_password,
            )
        else:
            pw_field = 'password'

        form.fields['username'].help_text = None
        form.helper.label_class = 'col-sm-3 col-md-4 col-lg-2'
        form.helper.field_class = 'col-sm-4 col-md-5 col-lg-3'
        form.helper.layout = crispy.Layout(
            crispy.Fieldset(
                _("Location User"),
                'username',
                'first_name',
                'last_name',
                pw_field,
            ))
        return form
示例#4
0
def make_location_user(location):
    """For locations where location_type.has_user is True"""
    return CommCareUser.create(
        location.domain,
        _get_unique_username(location.domain, location.site_code),
        generate_strong_password(),  # They'll need to reset this anyways
        uuid=uuid.uuid4().hex,
        commit=False,
    )
示例#5
0
def make_location_user(location):
    """For locations where location_type.has_user is True"""
    return CommCareUser.create(
        location.domain,
        _get_unique_username(location.domain, location.site_code),
        generate_strong_password(),  # They'll need to reset this anyways
        uuid=uuid.uuid4().hex,
        commit=False,
    )