diff options
| author | Étienne Loks <etienne.loks@proxience.com> | 2015-05-05 13:03:09 +0200 | 
|---|---|---|
| committer | Étienne Loks <etienne.loks@proxience.com> | 2015-05-05 13:05:06 +0200 | 
| commit | 3166cbb3aa53406ad693aa7f137effb51b71cb42 (patch) | |
| tree | 333db30d0b6bbb112d77c32ca1b878c8f70ee69a /ishtar_common/forms_common.py | |
| parent | ada0ab4962eb437bfbd2b300c5aca69bf5719bfb (diff) | |
| download | Ishtar-3166cbb3aa53406ad693aa7f137effb51b71cb42.tar.bz2 Ishtar-3166cbb3aa53406ad693aa7f137effb51b71cb42.zip | |
Imports: manage importation interface, error file
Diffstat (limited to 'ishtar_common/forms_common.py')
| -rw-r--r-- | ishtar_common/forms_common.py | 16 | 
1 files changed, 8 insertions, 8 deletions
| diff --git a/ishtar_common/forms_common.py b/ishtar_common/forms_common.py index 677656af6..d8740b68c 100644 --- a/ishtar_common/forms_common.py +++ b/ishtar_common/forms_common.py @@ -101,10 +101,10 @@ class NewImportForm(forms.ModelForm):  class TargetKeyForm(forms.ModelForm):      class Meta:          model = models.TargetKey -        fields = ('target', 'value', 'key') +        fields = ('target', 'key', 'value')          widgets = { -            'value': forms.TextInput(attrs={'readonly':'readonly'}), -            'key': forms.Select(), +            'key': forms.TextInput(attrs={'readonly':'readonly'}), +            'value': forms.Select(),          }      def __init__(self, *args, **kwargs): @@ -112,8 +112,8 @@ class TargetKeyForm(forms.ModelForm):          instance = getattr(self, 'instance', None)          if instance and instance.pk:              self.fields['target'].widget.attrs['readonly'] = True -            self.fields['value'].widget.attrs['readonly'] = True -        self.fields['key'].widget.choices = list(instance.target.get_choices()) +            self.fields['key'].widget.attrs['readonly'] = True +        self.fields['value'].widget.choices = list(instance.target.get_choices())      def clean_target(self):          instance = getattr(self, 'instance', None) @@ -122,12 +122,12 @@ class TargetKeyForm(forms.ModelForm):          else:              return self.cleaned_data['target'] -    def clean_value(self): +    def clean_key(self):          instance = getattr(self, 'instance', None)          if instance and instance.pk: -            return instance.value +            return instance.key          else: -            return self.cleaned_data['value'] +            return self.cleaned_data['key']      def save(self, commit=True):          super(TargetKeyForm, self).save(commit) | 
