Esempio n. 1
0
    def __init__(self, data=None, excluded_emails=None, *args, **kwargs):
        domain = None
        location = None
        if 'domain' in kwargs:
            domain = 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 and domain.commtrack_enabled:
            self.fields['supply_point'] = forms.CharField(label='Supply Point:', required=False,
                                                          widget=SupplyPointSelectWidget(domain.name),
                                                          initial=location.location_id if location else '')
            self.fields['program'] = forms.ChoiceField(label="Program", choices=(), required=False)
            programs = Program.by_domain(domain.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'
Esempio n. 2
0
 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 = SupplyPointSelectWidget(domain=domain, id='facility', query_url=query_url)
Esempio n. 3
0
 def __init__(self, data=None, excluded_emails=None, *args, **kwargs):
     domain = None
     if 'domain' in kwargs:
         domain = Domain.get_by_name(kwargs['domain'])
         del kwargs['domain']
     super(AdminInvitesUserForm, self).__init__(data=data, *args, **kwargs)
     if domain and domain.commtrack_enabled:
         self.fields['supply_point'] = forms.CharField(
             label='Supply Point:',
             required=False,
             widget=SupplyPointSelectWidget(domain=domain.name))
         self.fields['program'] = forms.ChoiceField(label="Program",
                                                    choices=(),
                                                    required=False)
         programs = Program.by_domain(domain.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 []
Esempio n. 4
0
 def __init__(self, *args, **kwargs):
     super(OpenmrsRepeaterForm, self).__init__(*args, **kwargs)
     self.fields['location_id'].widget = SupplyPointSelectWidget(self.domain, id='id_location_id')