# HG changeset patch # User durandn # Date 1467289497 -7200 # Node ID aec0f3381736cabc861aed266423bc32d50f17a4 # Parent 86608f92ebeddc13efbea71e28c2cceee15d7184 Added metacategories to comments + error handling on annotation forms diff -r 86608f92ebed -r aec0f3381736 src/iconolab/fixtures/dev_initial_data.json --- a/src/iconolab/fixtures/dev_initial_data.json Fri Jul 01 11:19:59 2016 +0200 +++ b/src/iconolab/fixtures/dev_initial_data.json Thu Jun 30 14:24:57 2016 +0200 @@ -68,8 +68,7 @@ "author": 1, "created": "2016-03-24 14:13:44.913765+01" } - }, - { + },{ "model": "iconolab.Annotation", "pk": 2, "fields": { @@ -79,8 +78,7 @@ "author": 1, "created": "2016-03-24 14:13:44.913765+01" } - }, - { + },{ "model": "iconolab.Annotation", "pk": 3, "fields": { @@ -90,8 +88,7 @@ "author": 1, "created": "2016-03-24 14:13:44.913765+01" } - }, - { + },{ "model": "iconolab.AnnotationStats", "pk": 1, "fields": { @@ -116,8 +113,7 @@ "state": 1, "created": "2016-03-25 14:13:44.913765+01" } - }, - { + },{ "model": "iconolab.AnnotationRevision", "pk": 2, "fields": { @@ -130,8 +126,7 @@ "state": 1, "created": "2016-03-25 14:13:44.913765+01" } - }, - { + },{ "model": "iconolab.AnnotationRevision", "pk": 3, "fields": { @@ -144,7 +139,19 @@ "state": 1, "created": "2016-03-25 14:13:44.913765+01" } + },{ + "model": "iconolab.MetaCategory", + "pk": 1, + "fields": { + "collection": 1, + "label": "Appel à contribution" + } + },{ + "model": "iconolab.MetaCategory", + "pk": 2, + "fields": { + "collection": 1, + "label": "Trouble" + } } - - ] \ No newline at end of file diff -r 86608f92ebed -r aec0f3381736 src/iconolab/forms/comments.py --- a/src/iconolab/forms/comments.py Fri Jul 01 11:19:59 2016 +0200 +++ b/src/iconolab/forms/comments.py Thu Jun 30 14:24:57 2016 +0200 @@ -1,6 +1,8 @@ from django import forms from django.utils.translation import ugettext_lazy as _ from django_comments_xtd.forms import XtdCommentForm +from django_comments_xtd.models import TmpXtdComment +from django_comments_xtd import get_model as get_comment_model from django.contrib.contenttypes.models import ContentType from django.conf import settings from django.utils.encoding import force_text @@ -8,7 +10,7 @@ from iconolab.models import MetaCategory class IconolabCommentForm(XtdCommentForm): - metacategories = forms.ModelMultipleChoiceField(queryset=MetaCategory.objects.all(), required=False) + metacategories = forms.ModelMultipleChoiceField(widget=forms.CheckboxSelectMultiple, queryset=MetaCategory.objects.all(), required=False) email = forms.EmailField(required=False) def __init__(self, *args, **kwargs): @@ -16,15 +18,7 @@ self.fields.pop('email') def get_comment_create_data(self): - return dict( - content_type=ContentType.objects.get_for_model(self.target_object), - object_pk=force_text(self.target_object._get_pk_val()), - user_name=self.cleaned_data["name"], - user_email='', - user_url=self.cleaned_data["url"], - comment=self.cleaned_data["comment"], - submit_date=timezone.now(), - site_id=settings.SITE_ID, - is_public=True, - is_removed=False, - ) \ No newline at end of file + self.cleaned_data['email'] = '' + data = super(IconolabCommentForm, self).get_comment_create_data() + data.update({'user_email': ''}) + return data \ No newline at end of file diff -r 86608f92ebed -r aec0f3381736 src/iconolab/models.py --- a/src/iconolab/models.py Fri Jul 01 11:19:59 2016 +0200 +++ b/src/iconolab/models.py Thu Jun 30 14:24:57 2016 +0200 @@ -213,12 +213,12 @@ tag_accuracy = tag_data.get("accuracy", 0) tag_relevancy = tag_data.get("relevancy", 0) - if tag_string.startswith("http://"): #check if url + if tag_string.startswith("http://") or tag_string.startswith("https://"): #check if url if Tag.objects.filter(link=tag_string).exists(): #check if tag already exists tag_obj = Tag.objects.get(link=tag_string) else: tag_obj = Tag.objects.create( - link = settings.BASE_URL+tag_string, + link = tag_string, ) else: tag_obj = Tag.objects.create( diff -r 86608f92ebed -r aec0f3381736 src/iconolab/templates/iconolab/change_annotation.html --- a/src/iconolab/templates/iconolab/change_annotation.html Fri Jul 01 11:19:59 2016 +0200 +++ b/src/iconolab/templates/iconolab/change_annotation.html Thu Jun 30 14:24:57 2016 +0200 @@ -75,26 +75,56 @@