Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/webapp/polls
diff options
context:
space:
mode:
Diffstat (limited to 'webapp/polls')
-rw-r--r--webapp/polls/models.py1
-rw-r--r--webapp/polls/templates/mustache/field.html12
-rw-r--r--webapp/polls/tests/structure_tests.py31
3 files changed, 44 insertions, 0 deletions
diff --git a/webapp/polls/models.py b/webapp/polls/models.py
index e6f3813..ee96cf9 100644
--- a/webapp/polls/models.py
+++ b/webapp/polls/models.py
@@ -668,6 +668,7 @@ class Field(AbstractObject, ComponentStructure):
order = data.get('order', None)
self.order = int(order) if order else order
self.name = data.get('name', None)
+ self.img = data.get('img', None)
value = data.get('dependence', None)
self.dependence = value
diff --git a/webapp/polls/templates/mustache/field.html b/webapp/polls/templates/mustache/field.html
index 2a4b130..a967893 100644
--- a/webapp/polls/templates/mustache/field.html
+++ b/webapp/polls/templates/mustache/field.html
@@ -49,6 +49,18 @@
value="[[ name ]]"
placeholder="Pregunta..." />
+ <div class="fileupload fileupload-new" data-provides="fileupload">
+ <div class="fileupload-new thumbnail" style="width: 50px; height: 50px;">
+ <img src="[[ img_src ]]" /></div>
+ <div class="fileupload-preview fileupload-exists thumbnail" style="width: 50px; height: 50px;"></div>
+ <span class="btn btn-file">
+ <span class="fileupload-new">Elegir imagen</span>
+ <span class="fileupload-exists">Change</span>
+ <input type="file" name="groups.[[ group_order ]].fields.[[ order ]].img"/>
+ </span>
+ <a href="#" class="btn fileupload-exists" data-dismiss="fileupload">Remove</a>
+ </div>
+
</div>
<div class="row-fluid">
diff --git a/webapp/polls/tests/structure_tests.py b/webapp/polls/tests/structure_tests.py
index a91f854..8c2e931 100644
--- a/webapp/polls/tests/structure_tests.py
+++ b/webapp/polls/tests/structure_tests.py
@@ -219,3 +219,34 @@ class StructureTests(MongoTestCase):
structure.add_group(group, group.order)
self.assertEqual(expected, structure.to_python())
+
+ def test_structure_with_a_question_with_img(self):
+
+ poll = Poll({"name": "poll name"})
+ poll_id = poll.save()
+ poll = poll.get(poll_id)
+ img = "img"
+ data = {
+ 'groups': {
+ '0': {
+ 'name': "group name",
+ 'fields': {
+ '0': {
+ 'name': "field_0_0",
+ 'widget_type': Field.TextInput,
+ 'options': {
+ '131212': {
+ 'text': "text",
+ 'order': 0
+ }
+ },
+ 'img': img
+ }
+ }
+ }
+ }
+ }
+
+ structure = Structure(data=data, poll=poll)
+
+ self.assertEqual(img, structure.groups[0].fields[0].img)