diff options
Diffstat (limited to 'webapp/polls/models.py')
-rw-r--r-- | webapp/polls/models.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/webapp/polls/models.py b/webapp/polls/models.py index 66c8e25..a0bf45e 100644 --- a/webapp/polls/models.py +++ b/webapp/polls/models.py @@ -21,6 +21,7 @@ from django.core.files.uploadedfile import InMemoryUploadedFile from utils.mongo_connection import get_db from utils.mongo_document import Document +from utils.strings import multiple_replace from pollster.models import Pollster @@ -79,6 +80,21 @@ class Poll(Document, AbstracErrorObject): self.creation_date = data.get('creation_date', None) self.modification_date = data.get('modification_date', None) + @staticmethod + def clean_question(question_name): + new_string = question_name.encode('ascii', 'ignore') + to_replace = [ + (" ", ''), + ("#", ''), + (".", ''), + (":", ''), + ("?", ''), + (",", ''), + ('"', ''), + ("'", '') + ] + return multiple_replace(new_string, to_replace) + def clone(self): clone_data = self.to_python() if clone_data.get('_id', None): |