<commit_before># -*- coding: utf-8 -*-
"""
Forms for concepts.

# Preserving this method here as it may be useful later!
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 in this source.'))
    return concept_id

"""
from django.utils.translation import ugettext as _
from django import forms
from django.forms.formsets import formset_factory

#from libs.ocl import OCLapi
from apps.core.views import (_get_locale_list, _get_concept_class_list, _get_datatype_list)


class ConceptRetireForm(forms.Form):
    """
    Concept retirement form
    """
    required_css_class = 'required'

    comment = forms.CharField(
        label=_('Retire Reason'),
        required=True,
        widget=forms.Textarea(attrs={'rows':5,
                                     'placeholder':'Note the reason for retiring the concept'}))



class ConceptNewMappingForm(forms.Form):
    """
    New concept mapping form -- from_mapping is already set
    """
    required_css_class = 'required'

    map_type = forms.CharField(
        label=_('Map Type'),
        required=True,
        help_text=_('<small>Enter the type of relationship between the concepts</small>'),
        widget=forms.TextInput(attrs={'placeholder': "e.g. SAME-AS, NARROWER-THAN, BROADER-THAN"}))

    is_internal_or_external = forms.ChoiceField(
        choices=[('Internal', 'Internal'), ('External', 'External'],
        label=_('Mapping Destination'),
        required=True,
        widget=forms.RadioSelect())

    internal_to_concept_url = forms.CharField(
        label=_('To Concept Url'),
        required=False,
        help_text=_('<small>Copy/paste the URL of a concept stored in OCL</small>'),
        widget=forms.TextInput(attrs={'placeholder': "e.g. /orgs/CIEL/sources/CIEL/concepts/32/"}))

    external_source_url = forms.CharField(
        label=_('To Source Url'),
        required=False,
        help_text=_('<small>Copy/paste the URL of a source in '
                    'OCL with source type "External"</small>'),
        widget=forms.TextInput(attrs={'placeholder': "e.g. /orgs/IHTSDO/sources/SNOMED-CT/"}))

    external_concept_code = forms.CharField(
        label=_('To Concept Code'),
        required=False,
        help_text=_('<small>Enter the name of the external concept code</small>'),
        widget=forms.TextInput(attrs={'placeholder': "e.g. A15.1"}))

    external_concept_name = forms.CharField(<commit_msg>Fixed typo in concept forms.py<commit_after># -*- coding: utf-8 -*-
"""
Forms for concepts.

# Preserving this method here as it may be useful later!
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 in this source.'))
    return concept_id

"""
from django.utils.translation import ugettext as _
from django import forms
from django.forms.formsets import formset_factory

#from libs.ocl import OCLapi
from apps.core.views import (_get_locale_list, _get_concept_class_list, _get_datatype_list)


class ConceptRetireForm(forms.Form):
    """
    Concept retirement form
    """
    required_css_class = 'required'

    comment = forms.CharField(
        label=_('Retire Reason'),
        required=True,
        widget=forms.Textarea(attrs={'rows':5,
                                     'placeholder':'Note the reason for retiring the concept'}))



class ConceptNewMappingForm(forms.Form):
    """
    New concept mapping form -- from_mapping is already set
    """
    required_css_class = 'required'

    map_type = forms.CharField(
        label=_('Map Type'),
        required=True,
        help_text=_('<small>Enter the type of relationship between the concepts</small>'),
        widget=forms.TextInput(attrs={'placeholder': "e.g. SAME-AS, NARROWER-THAN, BROADER-THAN"}))

    is_internal_or_external = forms.ChoiceField(
        choices=[('Internal', 'Internal'), ('External', 'External')],
        label=_('Mapping Destination'),
        required=True,
        widget=forms.RadioSelect(attrs={'class':'radio-inline'}))

    internal_to_concept_url = forms.CharField(
        label=_('To Concept Url'),
        required=False,
        help_text=_('<small>Copy/paste the URL of a concept stored in OCL</small>'),
        widget=forms.TextInput(attrs={'placeholder': "e.g. /orgs/CIEL/sources/CIEL/concepts/32/"}))

    external_source_url = forms.CharField(
        label=_('To Source Url'),
        required=False,
        help_text=_('<small>Copy/paste the URL of a source in '
                    'OCL with source type "External"</small>'),
        widget=forms.TextInput(attrs={'placeholder': "e.g. /orgs/IHTSDO/sources/SNOMED-CT/"}))

    external_concept_code = forms.CharField(
        label=_('To Concept Code'),
        required=False,
        help_text=_('<small>Enter the name of the external concept code</small>'),
        widget=forms.TextInput(attrs={'placeholder': "e.g. A15.1"}))

    external_concept_name = forms.CharField(
{'fraction_non_alphanumeric': 0.13122090941639813, 'fraction_numerical': 0.0035803795202291443, 'mean_word_length': 3.30763299922899, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7034005', 'n_tokens_mistral': 1699, 'n_tokens_neox': 1649, 'n_words': 393}