def __init__(self, data=None, excluded_emails=None, *args, **kwargs): domain_obj = None location = None if 'domain' in kwargs: domain_obj = Domain.get_by_name(kwargs['domain']) del kwargs['domain'] if 'location' in kwargs: location = kwargs['location'] del kwargs['location'] super(AdminInvitesUserForm, self).__init__(data=data, *args, **kwargs) if domain_obj and domain_obj.commtrack_enabled: self.fields['supply_point'] = forms.CharField( label='Primary Location', required=False, widget=LocationSelectWidget(domain_obj.name), initial=location.location_id if location else '') self.fields['program'] = forms.ChoiceField(label="Program", choices=(), required=False) programs = Program.by_domain(domain_obj.name, wrap=False) choices = list((prog['_id'], prog['name']) for prog in programs) choices.insert(0, ('', '')) self.fields['program'].choices = choices self.excluded_emails = excluded_emails or [] self.helper = FormHelper() self.helper.form_tag = False self.helper.form_method = 'POST' self.helper.form_class = 'form-horizontal' self.helper.label_class = 'col-sm-3 col-md-2' self.helper.field_class = 'col-sm-9 col-md-8 col-lg-6'
def __init__(self, *args, **kwargs): from corehq.apps.locations.forms import LocationSelectWidget self.domain = kwargs.pop('domain', None) super(CommtrackUserForm, self).__init__(*args, **kwargs) self.fields['assigned_locations'].widget = LocationSelectWidget( self.domain, multiselect=True, id='id_assigned_locations') self.fields[ 'assigned_locations'].help_text = ExpandedMobileWorkerFilter.location_search_help self.fields['primary_location'].widget = PrimaryLocationWidget( css_id='id_primary_location', source_css_id='id_assigned_locations', ) if self.commtrack_enabled: programs = Program.by_domain(self.domain) choices = list((prog.get_id, prog.name) for prog in programs) choices.insert(0, ('', '')) self.fields['program_id'].choices = choices else: self.fields['program_id'].widget = forms.HiddenInput() self.helper = FormHelper() self.helper.form_method = 'POST' self.helper.form_class = 'form-horizontal' self.helper.form_tag = False self.helper.label_class = 'col-sm-3 col-md-2' self.helper.field_class = 'col-sm-9 col-md-8 col-lg-6'
def __init__(self, *args, **kwargs): self.user_id = kwargs.pop('user_id') domain = None if 'domain' in kwargs: domain = kwargs['domain'] del kwargs['domain'] super(EWSUserSettings, self).__init__(*args, **kwargs) query_url = reverse('non_administrative_locations_for_select2', args=[domain]) self.fields['facility'].widget = LocationSelectWidget(domain=domain, id='facility', query_url=query_url)
def __init__(self, *args, **kwargs): from corehq.apps.locations.forms import LocationSelectWidget from corehq.apps.users.views import get_editable_role_choices self.domain = kwargs.pop('domain') self.couch_user = kwargs.pop('couch_user') super(CommCareUserFilterForm, self).__init__(*args, **kwargs) self.fields['location_id'].widget = LocationSelectWidget(self.domain) self.fields['location_id'].help_text = ExpandedMobileWorkerFilter.location_search_help if is_icds_cas_project(self.domain) and not self.couch_user.is_domain_admin(self.domain): roles = get_editable_role_choices(self.domain, self.couch_user, allow_admin_role=True, use_qualified_id=False) self.fields['role_id'].choices = roles else: roles = UserRole.by_domain(self.domain) self.fields['role_id'].choices = [('', _('All Roles'))] + [ (role._id, role.name or _('(No Name)')) for role in roles] self.fields['domains'].choices = [(self.domain, self.domain)] if len(DomainPermissionsMirror.mirror_domains(self.domain)) > 0: self.fields['domains'].choices = [('all_project_spaces', _('All Project Spaces'))] + \ [(self.domain, self.domain)] + \ [(domain, domain) for domain in DomainPermissionsMirror.mirror_domains(self.domain)] self.helper = FormHelper() self.helper.form_method = 'GET' self.helper.form_id = 'user-filters' self.helper.form_class = 'form-horizontal' self.helper.form_action = reverse('download_commcare_users', args=[self.domain]) self.helper.label_class = 'col-sm-3 col-md-2' self.helper.field_class = 'col-sm-9 col-md-8 col-lg-6' self.helper.form_text_inline = True self.helper.layout = crispy.Layout( crispy.Fieldset( _("Filter and Download Users"), crispy.Field('role_id', css_class="hqwebapp-select2"), crispy.Field('search_string'), crispy.Field('location_id'), crispy.Field('columns'), crispy.Field('domains'), ), hqcrispy.FormActions( twbscrispy.StrictButton( _("Download All Users"), type="submit", css_class="btn btn-primary submit_button", ) ), )
def __init__(self, *args, **kwargs): from corehq.apps.locations.forms import LocationSelectWidget self.domain = kwargs.pop('domain') super(CommCareUserFilterForm, self).__init__(*args, **kwargs) self.fields['location_id'].widget = LocationSelectWidget(self.domain) self.fields[ 'location_id'].help_text = ExpandedMobileWorkerFilter.location_search_help roles = UserRole.by_domain(self.domain) self.fields['role_id'].choices = [('', _('All Roles'))] + [ (role._id, role.name or _('(No Name)')) for role in roles ] self.helper = FormHelper() self.helper.form_method = 'GET' self.helper.form_id = 'user-filters' self.helper.form_class = 'form-horizontal' self.helper.form_action = reverse('download_commcare_users', args=[self.domain]) self.helper.label_class = 'col-sm-3 col-md-2' self.helper.field_class = 'col-sm-9 col-md-8 col-lg-6' self.helper.form_text_inline = True self.helper.layout = crispy.Layout( crispy.Fieldset( _("Filter and Download Users"), crispy.Field('role_id', css_class="hqwebapp-select2"), crispy.Field('search_string'), crispy.Field('location_id'), crispy.Field('columns'), ), hqcrispy.FormActions( twbscrispy.StrictButton( _("Download All Users"), type="submit", css_class="btn btn-primary submit_button", )), )
def __init__(self, *args, **kwargs): super(OpenmrsRepeaterForm, self).__init__(*args, **kwargs) self.fields['location_id'].widget = LocationSelectWidget( self.domain, id='id_location_id') self.fields[ 'location_id'].help_text = ExpandedMobileWorkerFilter.location_search_help
def __init__(self, data=None, excluded_emails=None, is_add_user=None, *args, **kwargs): domain_obj = None location = None if 'domain' in kwargs: domain_obj = Domain.get_by_name(kwargs['domain']) del kwargs['domain'] if 'location' in kwargs: location = kwargs['location'] del kwargs['location'] super(AdminInvitesUserForm, self).__init__(data=data, *args, **kwargs) if domain_obj and domain_obj.commtrack_enabled: self.fields['supply_point'] = forms.CharField( label='Primary Location', required=False, widget=LocationSelectWidget(domain_obj.name), help_text=EMWF.location_search_help, initial=location.location_id if location else '') self.fields['program'] = forms.ChoiceField(label="Program", choices=(), required=False) programs = Program.by_domain(domain_obj.name) choices = list((prog.get_id, prog.name) for prog in programs) choices.insert(0, ('', '')) self.fields['program'].choices = choices self.excluded_emails = excluded_emails or [] self.helper = FormHelper() self.helper.form_method = 'POST' self.helper.form_class = 'form-horizontal form-ko-validation' self.helper.label_class = 'col-sm-3 col-md-2' self.helper.field_class = 'col-sm-9 col-md-8 col-lg-6' self.helper.layout = crispy.Layout( crispy.Fieldset( ugettext("Information for new Web User"), crispy.Field( "email", autocomplete="off", data_bind="textInput: email", ), 'role', ), crispy.HTML( render_to_string( 'users/partials/confirm_trust_identity_provider_message.html', { 'is_add_user': is_add_user, }), ), hqcrispy.FormActions( twbscrispy.StrictButton( (ugettext("Add User") if is_add_user else ugettext("Send Invite")), type="submit", css_class="btn-primary", data_bind="enable: isSubmitEnabled", ), crispy.HTML( render_to_string( 'users/partials/waiting_to_verify_email_message.html', {}), ), ), )
def __init__(self, *args, **kwargs): super(OpenmrsRepeaterForm, self).__init__(*args, **kwargs) self.fields['location_id'].widget = LocationSelectWidget(self.domain, id='id_location_id')