| author | Harris Baptiste <harris.baptiste@iri.centrepompidou.fr> |
| Fri, 12 Aug 2016 10:59:57 +0200 | |
| changeset 113 | 541dd2ecde0c |
| parent 38 | b319db67a5f3 |
| child 187 | 456d13962c0d |
| 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:
35
diff
changeset
|
1 |
from django import forms |
|
24
6b6b183447a2
work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents:
diff
changeset
|
2 |
from iconolab.models import AnnotationRevision |
|
33
f9d4c9a63e4e
Backend work on tags (needs testing) + model changes (image_guid, Tag)
durandn
parents:
24
diff
changeset
|
3 |
import json |
|
24
6b6b183447a2
work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents:
diff
changeset
|
4 |
|
|
38
b319db67a5f3
work on comments (in annotation form, list in annotation detail, post in annotation detail isn't working yet)
durandn
parents:
35
diff
changeset
|
5 |
class MultipleTagsField(forms.TypedMultipleChoiceField): |
|
33
f9d4c9a63e4e
Backend work on tags (needs testing) + model changes (image_guid, Tag)
durandn
parents:
24
diff
changeset
|
6 |
pass |
|
24
6b6b183447a2
work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents:
diff
changeset
|
7 |
|
|
38
b319db67a5f3
work on comments (in annotation form, list in annotation detail, post in annotation detail isn't working yet)
durandn
parents:
35
diff
changeset
|
8 |
class AnnotationRevisionForm(forms.ModelForm): |
|
b319db67a5f3
work on comments (in annotation form, list in annotation detail, post in annotation detail isn't working yet)
durandn
parents:
35
diff
changeset
|
9 |
tags = forms.CharField() |
|
b319db67a5f3
work on comments (in annotation form, list in annotation detail, post in annotation detail isn't working yet)
durandn
parents:
35
diff
changeset
|
10 |
comment = forms.CharField(widget=forms.Textarea) |
|
35
31d4f0e86723
added backend json handling for tags (properly tested/corrected) + corrected templates to replace image_ref with image_guid
durandn
parents:
33
diff
changeset
|
11 |
|
|
24
6b6b183447a2
work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents:
diff
changeset
|
12 |
class Meta: |
|
6b6b183447a2
work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents:
diff
changeset
|
13 |
model = AnnotationRevision |
|
35
31d4f0e86723
added backend json handling for tags (properly tested/corrected) + corrected templates to replace image_ref with image_guid
durandn
parents:
33
diff
changeset
|
14 |
fields = ('title', 'description', 'fragment') |
|
24
6b6b183447a2
work on models + auth register/login system + adapted existing app and templates so editing annotations is working as before + created empty templates to fill
durandn
parents:
diff
changeset
|
15 |
widgets = { |
|
38
b319db67a5f3
work on comments (in annotation form, list in annotation detail, post in annotation detail isn't working yet)
durandn
parents:
35
diff
changeset
|
16 |
'fragment': forms.HiddenInput(), |
|
b319db67a5f3
work on comments (in annotation form, list in annotation detail, post in annotation detail isn't working yet)
durandn
parents:
35
diff
changeset
|
17 |
'tags': forms.HiddenInput() |
|
33
f9d4c9a63e4e
Backend work on tags (needs testing) + model changes (image_guid, Tag)
durandn
parents:
24
diff
changeset
|
18 |
} |
|
f9d4c9a63e4e
Backend work on tags (needs testing) + model changes (image_guid, Tag)
durandn
parents:
24
diff
changeset
|
19 |
|
|
f9d4c9a63e4e
Backend work on tags (needs testing) + model changes (image_guid, Tag)
durandn
parents:
24
diff
changeset
|
20 |
def tags_json(self): |
|
f9d4c9a63e4e
Backend work on tags (needs testing) + model changes (image_guid, Tag)
durandn
parents:
24
diff
changeset
|
21 |
if self.instance: |
|
f9d4c9a63e4e
Backend work on tags (needs testing) + model changes (image_guid, Tag)
durandn
parents:
24
diff
changeset
|
22 |
tags_list = [] |
|
f9d4c9a63e4e
Backend work on tags (needs testing) + model changes (image_guid, Tag)
durandn
parents:
24
diff
changeset
|
23 |
for tag_info in self.instance.tagginginfo_set.all(): |
|
35
31d4f0e86723
added backend json handling for tags (properly tested/corrected) + corrected templates to replace image_ref with image_guid
durandn
parents:
33
diff
changeset
|
24 |
tags_list.append({ |
|
33
f9d4c9a63e4e
Backend work on tags (needs testing) + model changes (image_guid, Tag)
durandn
parents:
24
diff
changeset
|
25 |
'tag_input': tag_info.tag.link, |
|
f9d4c9a63e4e
Backend work on tags (needs testing) + model changes (image_guid, Tag)
durandn
parents:
24
diff
changeset
|
26 |
'relevancy': tag_info.relevancy, |
|
f9d4c9a63e4e
Backend work on tags (needs testing) + model changes (image_guid, Tag)
durandn
parents:
24
diff
changeset
|
27 |
'accuracy': tag_info.accuracy |
|
f9d4c9a63e4e
Backend work on tags (needs testing) + model changes (image_guid, Tag)
durandn
parents:
24
diff
changeset
|
28 |
}) |
|
f9d4c9a63e4e
Backend work on tags (needs testing) + model changes (image_guid, Tag)
durandn
parents:
24
diff
changeset
|
29 |
return json.dumps(tags_list) |
|
f9d4c9a63e4e
Backend work on tags (needs testing) + model changes (image_guid, Tag)
durandn
parents:
24
diff
changeset
|
30 |
else: |
|
f9d4c9a63e4e
Backend work on tags (needs testing) + model changes (image_guid, Tag)
durandn
parents:
24
diff
changeset
|
31 |
return '[]' |