summaryrefslogtreecommitdiffstats
path: root/askbot/forms.py
diff options
context:
space:
mode:
authorZafer CAKMAK <mzcakmak@gmail.com>2013-04-23 20:45:37 +0000
committerZafer CAKMAK <mzcakmak@gmail.com>2013-04-23 20:45:37 +0000
commit81af591ee3a3517caa2b70a85f526084385d2474 (patch)
treeb5775039dc45a92ec449171788d4095ab9b3d658 /askbot/forms.py
parent909b1786a1b0d42e7cb39cf6b18fffe2bc020652 (diff)
downloadaskbot-81af591ee3a3517caa2b70a85f526084385d2474.tar.gz
askbot-81af591ee3a3517caa2b70a85f526084385d2474.tar.bz2
askbot-81af591ee3a3517caa2b70a85f526084385d2474.zip
answer view is more customizable now
- answer view takes an optional form parameter to override default form. ASKBOT_NEW_ANSWER_FORM settings still works. - save logic goes to form from view so people can save extra parameters without override view.
Diffstat (limited to 'askbot/forms.py')
-rw-r--r--askbot/forms.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/askbot/forms.py b/askbot/forms.py
index e214e908..1eaf3cbe 100644
--- a/askbot/forms.py
+++ b/askbot/forms.py
@@ -1,6 +1,7 @@
"""Forms, custom form fields and related utility functions
used in AskBot"""
import re
+import datetime
from django import forms
from askbot import const
from askbot.const import message_keys
@@ -1131,6 +1132,21 @@ class AnswerForm(PostAsSomeoneForm, PostPrivatelyForm):
self.fields['email_notify'].widget.attrs['id'] = \
'question-subscribe-updates'
+ #People can override this function to save their additional fields to db
+ def save(self, question, user):
+ wiki = self.cleaned_data['wiki'],
+ text = self.cleaned_data['text']
+ follow = self.cleaned_data['email_notify']
+ is_private = self.cleaned_data['post_privately']
+
+ return user.post_answer(
+ question = question,
+ body_text = text,
+ follow = follow,
+ wiki = wiki,
+ is_private = is_private,
+ timestamp = datetime.datetime.now(),
+ )
class VoteForm(forms.Form):
"""form used in ajax vote view (only comment_upvote so far)