created form for editing and used it in view
authornishanth
Thu, 01 Jul 2010 16:55:22 +0530
changeset 85 451be7b1de20
parent 84 08af9e4ada78
child 86 404e9c1b8cff
created form for editing and used it in view
event/forms.py
event/views.py
templates/list_questions.html
--- a/event/forms.py	Thu Jul 01 16:44:17 2010 +0530
+++ b/event/forms.py	Thu Jul 01 16:55:22 2010 +0530
@@ -30,3 +30,8 @@
     def clean_topics(self):
 
         return self.cleaned_data["topics"]
+
+class EditQuestionForm(forms.ModelForm):
+
+    class Meta:
+        model = QuestionBank
--- a/event/views.py	Thu Jul 01 16:44:17 2010 +0530
+++ b/event/views.py	Thu Jul 01 16:55:22 2010 +0530
@@ -207,7 +207,7 @@
 
     for question in questions:
         question.topic_name = topic_num2name[question.topic]
-    return render_to_response("list_questions.html", {"questions":questions})
+        return render_to_response("list_questions.html", {"questions":questions, "admin_key":ADMIN_KEY})
 
 def edit_question(request, qid):
     """ Show the question and then edit it.
@@ -218,5 +218,11 @@
     except QuestionBank.DoesNotExist:
         raise Http404
 
+    if request.medhod == "POST":
+        pass
+    else:
+        form = EditQuestionForm(q.get_values())
+        return render_to_response("edit_question.html", {"form":form,"admin_key":ADMIN_KEY})
 
 
+
--- a/templates/list_questions.html	Thu Jul 01 16:44:17 2010 +0530
+++ b/templates/list_questions.html	Thu Jul 01 16:55:22 2010 +0530
@@ -8,7 +8,7 @@
 		</tr>
 		{% for question in questions %}
 		<tr>
-				<td><a href="/quiz/questions/edit/ditchax/{{question.id}}">{{question.description}}</a></td>
+				<td><a href="/quiz/questions/edit/{{admin_key}}/{{question.id}}">{{question.description}}</a></td>
 <td>{{question.topic_name}}</td>
 </tr>
 {% endfor %}