fixed metacategory str for admin
authordurandn
Fri, 16 Dec 2016 12:00:48 +0100
changeset 285 aa0f3e186d29
parent 284 f52b0f6e2cd9
child 286 118756839a8a
fixed metacategory str for admin
src/iconolab/forms/comments.py
src/iconolab/models.py
--- a/src/iconolab/forms/comments.py	Fri Dec 16 11:35:10 2016 +0100
+++ b/src/iconolab/forms/comments.py	Fri Dec 16 12:00:48 2016 +0100
@@ -12,9 +12,13 @@
 
 logger = logging.getLogger(__name__)
 
+class MetaCategoryMultipleChoiceFields(forms.ModelMultipleChoiceField):
+    def label_from_instance(self, obj):
+        return obj.label
+
 class IconolabCommentForm(XtdCommentForm):
     email = forms.EmailField(required=False)
-    metacategories = forms.ModelMultipleChoiceField(widget=forms.CheckboxSelectMultiple, queryset=None, required=False)
+    metacategories = MetaCategoryMultipleChoiceFields(widget=forms.CheckboxSelectMultiple, queryset=None, required=False)
         
     def __init__(self, *args, **kwargs):
         super(IconolabCommentForm, self).__init__(*args, **kwargs)
@@ -28,4 +32,4 @@
         self.cleaned_data['email'] = ''
         data = super(IconolabCommentForm, self).get_comment_create_data()
         data.update({'user_email': ''})
-        return data
\ No newline at end of file
+        return data 
\ No newline at end of file
--- a/src/iconolab/models.py	Fri Dec 16 11:35:10 2016 +0100
+++ b/src/iconolab/models.py	Fri Dec 16 12:00:48 2016 +0100
@@ -815,7 +815,7 @@
     validation_value = models.IntegerField(choices=VALIDATION_VALUES, default=NEUTRAL)
     
     def __str__(self):
-        return self.label
+        return self.label+":"+self.collection.name
     
 
 class MetaCategoryInfo(models.Model):