def __init__(self): super(Command, self).__init__() self.ocl = None self.username = None self.password = None self.web_host = os.environ['OCL_WEB_HOST'] self.ORG_ID = None self.locale_list = [d['code'] for d in _get_locale_list()] self.source_type_list = _get_source_type_list() self.concept_class_list = _get_concept_class_list() self.datatype_list = _get_datatype_list()
def __init__(self, *args, **kwargs): super(SourceNewForm, self).__init__(*args, **kwargs) # create widgets here to delay calls to api until initialization of the form self.fields['source_type'].widget = ComboBoxWidget( data_list=[(v) for v in _get_source_type_list()], name="source_type_list") self.fields['default_locale'].widget = ComboBoxWidget( data_list=[[l['code'], l['name']] for l in _get_locale_list()], name="default_locale_list") self.fields['supported_locales'].widget = MultipleInputWidget( data_list=[l['name'] for l in _get_locale_list()], name="supported_locale_list")
def __init__(self): super(Command, self).__init__() self.ocl = None self.username = None self.password = None self.api_host = os.environ['OCL_API_HOST'] self.web_host = os.environ['OCL_WEB_HOST'] self.ORG_ID = None self.SOURCE_ID = None self.locale_list = [d['code'] for d in _get_locale_list()] self.source_type_list = _get_source_type_list() self.concept_class_list = _get_concept_class_list() self.datatype_list = _get_datatype_list()
class SourceNewForm(forms.Form): """ source create form """ required_css_class = 'required' short_name = forms.CharField( label=_('Source Short Code'), max_length=128, required=True, help_text= _('Allowed characters are : Alphabets(a-z,A-Z), Numbers(0-9) and Hyphen(-) <br/> Your new source will live at: http://www.openconceptlab.org' '<span id="new_repository_base_url">/[OwnerType]/[Owner]/sources/</span>' '<span id="new_repository_id" style="font-weight:bold;">[SourceCode]</span>/' ), widget=forms.TextInput(attrs={'placeholder': "e.g. ICD-10"})) full_name = forms.CharField( label=_('Source Full Name'), max_length=256, required=True, widget=forms.TextInput(attrs={ 'placeholder': "e.g. International Classification for Diseases v10" })) website = forms.URLField( label=_('Website'), required=False, widget=forms.TextInput(attrs={ 'placeholder': "e.g. http://apps.who.int/classifications/icd10/" })) source_type = forms.ChoiceField(choices=[(v, v) for v in _get_source_type_list()], label=_('Source Type'), required=False) public_access = forms.ChoiceField(label=_('Public Access'), required=False, initial='View', choices=(('View', 'View (default)'), ('Edit', 'Edit'), ('None', 'None'))) default_locale = forms.ChoiceField(label=_('Default Locale'), choices=[ (d['code'], d['name'] + ' (' + d['code'] + ')') for d in _get_locale_list() ], required=True) supported_locales = forms.CharField( max_length=30, label=_('Supported Locales'), required=True, widget=forms.TextInput(attrs={'placeholder': "e.g. en,fr,es"})) custom_validation_schema = forms.ChoiceField( label=_('Custom Validation Schema'), choices=[(v, v) for v in _get_custom_validation_schema_list()], required=False) description = forms.CharField(max_length=512, label=_('Description'), required=False) external_id = forms.CharField( label=_('External ID'), required=False, widget=forms.TextInput( attrs={'placeholder': "e.g. UUID from external system"})) # TODO([email protected]): Is this mis-named or not used? def clean_concept_id(self): """ concept ID must be unique """ concept_id = self.cleaned_data['concept_id'] source = self.initial['source'] request = self.initial['request'] api = OclApi(request, debug=True) result = api.get('orgs', source['owner'], 'sources', source['id'], 'concepts', concept_id) if result.status_code == 200: raise forms.ValidationError(_('This Concept ID is already used.')) return concept_id
def __init__(self, *args, **kwargs): super(SourceNewForm, self).__init__(*args, **kwargs) # create widgets here to delay calls to api until initialization of the form self.fields['source_type'].widget = ComboBoxWidget(data_list=[(v) for v in _get_source_type_list()], name="source_type_list") self.fields['default_locale'].widget = ComboBoxWidget(data_list=[[l['code'], l['name']] for l in _get_locale_list()], name="default_locale_list") self.fields['supported_locales'].widget = MultipleInputWidget(data_list=[l['name'] for l in _get_locale_list()], name="supported_locale_list")