Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/webapp
diff options
context:
space:
mode:
authorCode Raguet <ignacio.code@gmail.com>2013-09-25 20:16:42 (GMT)
committer Code Raguet <ignacio.code@gmail.com>2013-09-25 20:16:42 (GMT)
commit71e4df8e2d613c7500e45dcf3bca00368062c865 (patch)
tree6ebefa4c204e7b4ad4b987f7c1fb628ab59d634f /webapp
parent85eba59ab50a5430ac1877af4d79d5b3de2b9c7f (diff)
add is_read_only method to structure class
Diffstat (limited to 'webapp')
-rw-r--r--webapp/polls/models.py5
-rw-r--r--webapp/polls/tests/structure_tests.py10
2 files changed, 15 insertions, 0 deletions
diff --git a/webapp/polls/models.py b/webapp/polls/models.py
index a356e92..d254e3b 100644
--- a/webapp/polls/models.py
+++ b/webapp/polls/models.py
@@ -1320,6 +1320,11 @@ class Structure(AbstractObject, ComponentStructure):
# TODO: LOG!
pass
+ def is_read_only(self):
+ """Tells if the structure can be modified."""
+ poll = self.poll
+ return poll.has_result()
+
class NodePollResult(object):
diff --git a/webapp/polls/tests/structure_tests.py b/webapp/polls/tests/structure_tests.py
index 8ec1d21..ebb0f7e 100644
--- a/webapp/polls/tests/structure_tests.py
+++ b/webapp/polls/tests/structure_tests.py
@@ -324,6 +324,16 @@ class StructureTests(MongoTestCase):
def test_it_should_respond_to_ready_only_msg(self):
self.assertTrue(hasattr(Structure, 'READ_ONLY_MSG'))
+ def test_it_should_be_read_only_when_poll_has_results(self):
+ poll = self.poll
+ structure = Structure(data={}, poll=poll)
+ self.assertFalse(poll.has_result())
+ self.assertFalse(structure.is_read_only())
+
+ poll.has_result = Mock(return_value=True)
+ self.assertTrue(poll.has_result())
+ self.assertTrue(structure.is_read_only())
+
class UploadOptionImagesTest(MongoTestCase):