| author | Alexandre Segura <mex.zktk@gmail.com> |
| Mon, 20 Feb 2017 17:29:55 +0100 | |
| changeset 323 | 55c024fc7c60 |
| parent 285 | aa0f3e186d29 |
| child 535 | 4217bf54446a |
| permissions | -rw-r--r-- |
|
38
b319db67a5f3
work on comments (in annotation form, list in annotation detail, post in annotation detail isn't working yet)
durandn
parents:
diff
changeset
|
1 |
from django import forms |
|
b319db67a5f3
work on comments (in annotation form, list in annotation detail, post in annotation detail isn't working yet)
durandn
parents:
diff
changeset
|
2 |
from django.utils.translation import ugettext_lazy as _ |
|
b319db67a5f3
work on comments (in annotation form, list in annotation detail, post in annotation detail isn't working yet)
durandn
parents:
diff
changeset
|
3 |
from django_comments_xtd.forms import XtdCommentForm |
|
47
aec0f3381736
Added metacategories to comments + error handling on annotation forms
durandn
parents:
42
diff
changeset
|
4 |
from django_comments_xtd.models import TmpXtdComment |
|
aec0f3381736
Added metacategories to comments + error handling on annotation forms
durandn
parents:
42
diff
changeset
|
5 |
from django_comments_xtd import get_model as get_comment_model |
|
42
51257e2701d9
streamlined comment system, replicated post_comment view so form errors redirect on the annotation page and not on a preview page + added revision detail view and links for specific revisions from the comments
durandn
parents:
38
diff
changeset
|
6 |
from django.contrib.contenttypes.models import ContentType |
|
51257e2701d9
streamlined comment system, replicated post_comment view so form errors redirect on the annotation page and not on a preview page + added revision detail view and links for specific revisions from the comments
durandn
parents:
38
diff
changeset
|
7 |
from django.conf import settings |
|
51257e2701d9
streamlined comment system, replicated post_comment view so form errors redirect on the annotation page and not on a preview page + added revision detail view and links for specific revisions from the comments
durandn
parents:
38
diff
changeset
|
8 |
from django.utils.encoding import force_text |
|
51257e2701d9
streamlined comment system, replicated post_comment view so form errors redirect on the annotation page and not on a preview page + added revision detail view and links for specific revisions from the comments
durandn
parents:
38
diff
changeset
|
9 |
from django.utils import timezone |
|
38
b319db67a5f3
work on comments (in annotation form, list in annotation detail, post in annotation detail isn't working yet)
durandn
parents:
diff
changeset
|
10 |
from iconolab.models import MetaCategory |
|
138
2c2d394904db
corrected error with metacategories, fixed image import command to import metacategories with new collection
durandn
parents:
47
diff
changeset
|
11 |
import logging |
|
2c2d394904db
corrected error with metacategories, fixed image import command to import metacategories with new collection
durandn
parents:
47
diff
changeset
|
12 |
|
|
2c2d394904db
corrected error with metacategories, fixed image import command to import metacategories with new collection
durandn
parents:
47
diff
changeset
|
13 |
logger = logging.getLogger(__name__) |
|
38
b319db67a5f3
work on comments (in annotation form, list in annotation detail, post in annotation detail isn't working yet)
durandn
parents:
diff
changeset
|
14 |
|
| 285 | 15 |
class MetaCategoryMultipleChoiceFields(forms.ModelMultipleChoiceField): |
16 |
def label_from_instance(self, obj): |
|
17 |
return obj.label |
|
18 |
||
|
38
b319db67a5f3
work on comments (in annotation form, list in annotation detail, post in annotation detail isn't working yet)
durandn
parents:
diff
changeset
|
19 |
class IconolabCommentForm(XtdCommentForm): |
|
42
51257e2701d9
streamlined comment system, replicated post_comment view so form errors redirect on the annotation page and not on a preview page + added revision detail view and links for specific revisions from the comments
durandn
parents:
38
diff
changeset
|
20 |
email = forms.EmailField(required=False) |
| 285 | 21 |
metacategories = MetaCategoryMultipleChoiceFields(widget=forms.CheckboxSelectMultiple, queryset=None, required=False) |
|
323
55c024fc7c60
Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
285
diff
changeset
|
22 |
|
|
38
b319db67a5f3
work on comments (in annotation form, list in annotation detail, post in annotation detail isn't working yet)
durandn
parents:
diff
changeset
|
23 |
def __init__(self, *args, **kwargs): |
|
b319db67a5f3
work on comments (in annotation form, list in annotation detail, post in annotation detail isn't working yet)
durandn
parents:
diff
changeset
|
24 |
super(IconolabCommentForm, self).__init__(*args, **kwargs) |
|
138
2c2d394904db
corrected error with metacategories, fixed image import command to import metacategories with new collection
durandn
parents:
47
diff
changeset
|
25 |
self.collection = self.target_object.image.item.collection |
|
2c2d394904db
corrected error with metacategories, fixed image import command to import metacategories with new collection
durandn
parents:
47
diff
changeset
|
26 |
self.fields["metacategories"].queryset = self.collection.metacategories.all() |
|
38
b319db67a5f3
work on comments (in annotation form, list in annotation detail, post in annotation detail isn't working yet)
durandn
parents:
diff
changeset
|
27 |
self.fields.pop('email') |
|
323
55c024fc7c60
Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
285
diff
changeset
|
28 |
|
|
38
b319db67a5f3
work on comments (in annotation form, list in annotation detail, post in annotation detail isn't working yet)
durandn
parents:
diff
changeset
|
29 |
def get_comment_create_data(self): |
|
47
aec0f3381736
Added metacategories to comments + error handling on annotation forms
durandn
parents:
42
diff
changeset
|
30 |
self.cleaned_data['email'] = '' |
|
aec0f3381736
Added metacategories to comments + error handling on annotation forms
durandn
parents:
42
diff
changeset
|
31 |
data = super(IconolabCommentForm, self).get_comment_create_data() |
|
aec0f3381736
Added metacategories to comments + error handling on annotation forms
durandn
parents:
42
diff
changeset
|
32 |
data.update({'user_email': ''}) |
|
323
55c024fc7c60
Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
285
diff
changeset
|
33 |
return data |