summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEvgeny Fadeev <evgeny.fadeev@gmail.com>2011-05-25 14:02:31 -0400
committerEvgeny Fadeev <evgeny.fadeev@gmail.com>2011-05-25 14:19:30 -0400
commit2facc546b9b4bd98e80ad67e615078a5f6175a98 (patch)
treeb896fbb3cdfedc55e87a4e77ef697d2bb05edd0f
parent6d93566f517a45cf1221cd547987fd6ac857674c (diff)
downloadaskbot-2facc546b9b4bd98e80ad67e615078a5f6175a98.tar.gz
askbot-2facc546b9b4bd98e80ad67e615078a5f6175a98.tar.bz2
askbot-2facc546b9b4bd98e80ad67e615078a5f6175a98.zip
fixed an edge case issue for comment and answer url handling
-rw-r--r--askbot/forms.py16
1 files changed, 12 insertions, 4 deletions
diff --git a/askbot/forms.py b/askbot/forms.py
index aa021370..523c76a0 100644
--- a/askbot/forms.py
+++ b/askbot/forms.py
@@ -229,6 +229,12 @@ class DumpUploadForm(forms.Form):
dump_file = forms.FileField()
class ShowQuestionForm(forms.Form):
+ """Cleans data necessary to access answers and comments
+ by the respective comment or answer id - necessary
+ when comments would be normally wrapped and/or displayed
+ on the page other than the first page of answers to a question.
+ Same for the answers that are shown on the later pages.
+ """
answer = forms.IntegerField(required = False)
comment = forms.IntegerField(required = False)
page = forms.IntegerField(required = False)
@@ -241,10 +247,12 @@ class ShowQuestionForm(forms.Form):
def get_pruned_data(self):
nones = ('answer', 'comment', 'page')
for key in nones:
- if self.cleaned_data[key] is None:
- del self.cleaned_data[key]
- if self.cleaned_data['sort'] == '':
- del self.cleaned_data['sort']
+ if key in self.cleaned_data:
+ if self.cleaned_data[key] is None:
+ del self.cleaned_data[key]
+ if 'sort' in self.cleaned_data:
+ if self.cleaned_data['sort'] == '':
+ del self.cleaned_data['sort']
return self.cleaned_data
def clean(self):