fix some useranswer compare issuses
This commit is contained in:
+6
-11
@@ -35,6 +35,10 @@ def image_directory_path(instance, filename):
|
||||
# file will be uploaded to MEDIA_ROOT/anatomy/picture/<filename>
|
||||
return u"picture/anatomy/{0}".format(filename)
|
||||
|
||||
def get_answer_compare(s: str) -> str:
|
||||
s = s.strip().translate(str.maketrans("", "", string.punctuation)).lower()
|
||||
s = " ".join(s.split())
|
||||
return s
|
||||
|
||||
class BodyPart(models.Model):
|
||||
bodypart = models.CharField(max_length=200)
|
||||
@@ -333,11 +337,7 @@ class Answer(models.Model):
|
||||
def clean(self):
|
||||
if self.answer:
|
||||
self.answer = self.answer.strip()
|
||||
|
||||
s = " ".join(self.answer.lower().split())
|
||||
s = s.translate(str.maketrans("", "", string.punctuation))
|
||||
|
||||
self.answer_compare = s
|
||||
self.answer_compare = get_answer_compare(self.answer)
|
||||
|
||||
# def get_compare_string(self):
|
||||
# s = self.answer.lower().strip()
|
||||
@@ -506,12 +506,7 @@ class UserAnswer(UserAnswerBase):
|
||||
|
||||
def clean(self):
|
||||
if self.answer:
|
||||
self.answer = self.answer.strip()
|
||||
|
||||
s = self.answer.lower()
|
||||
s = s.translate(str.maketrans("", "", string.punctuation)).strip()
|
||||
|
||||
self.answer_compare = s
|
||||
self.answer_compare = get_answer_compare(self.answer)
|
||||
|
||||
# def get_compare_string(self):
|
||||
# # strip here should be unneccasry (providing clean is now working)
|
||||
|
||||
Reference in New Issue
Block a user