Permalink
Browse files

In list_room I changed UI for adding custom questions

  • Loading branch information...
1 parent cf09a77 commit dca8f7626c9c675291d5e16f8c0ff0bf8ac0e7ae @ptrklly ptrklly committed Apr 6, 2012
Binary file not shown.
@@ -326,4 +326,8 @@ color:#27AAE1;
#create_survey_main {
min-height: 680px;
+}
+
+.hidden {
+display:none;
}
@@ -12,4 +12,7 @@ $(document).ready(function() {
$('.dropdown').click(function() {
$(this).next().slideToggle();
});
- });
+ });
+
+
+
@@ -0,0 +1,42 @@
+document.getElementById("addanother1").onclick = function(){
+ document.getElementById("ques2").className = document.getElementById("ques2").className.replace ( /(?:^|\s)hidden(?!\S)/, '' )
+ document.getElementById("addanother1").className += " hidden";
+ document.createsurveyform.check1.checked=true
+}
+
+document.getElementById("addanother2").onclick = function(){
+ document.getElementById("ques3").className = document.getElementById("ques3").className.replace ( /(?:^|\s)hidden(?!\S)/, '' )
+ document.getElementById("addanother2").className += " hidden";
+ document.createsurveyform.check2.checked=true
+}
+
+document.getElementById("addanother3").onclick = function(){
+ document.getElementById("ques4").className = document.getElementById("ques4").className.replace ( /(?:^|\s)hidden(?!\S)/, '' )
+ document.getElementById("addanother3").className += " hidden";
+ document.createsurveyform.check3.checked=true
+}
+
+document.getElementById("addanother4").onclick = function(){
+ document.getElementById("ques5").className = document.getElementById("ques5").className.replace ( /(?:^|\s)hidden(?!\S)/, '' )
+ document.getElementById("addanother4").className += " hidden";
+ document.createsurveyform.check4.checked=true
+}
+
+
+document.getElementById("addanother5").onclick = function(){
+ document.getElementById("ques6").className = document.getElementById("ques6").className.replace ( /(?:^|\s)hidden(?!\S)/, '' )
+ document.getElementById("addanother5").className += " hidden";
+ document.createsurveyform.check5.checked=true
+}
+
+document.getElementById("addanother6").onclick = function(){
+ document.getElementById("ques7").className = document.getElementById("ques7").className.replace ( /(?:^|\s)hidden(?!\S)/, '' )
+ document.getElementById("addanother6").className += " hidden";
+ document.createsurveyform.check6.checked=true
+}
+
+document.getElementById("addanother7").onclick = function(){
+ document.getElementById("ques8").className = document.getElementById("ques8").className.replace ( /(?:^|\s)hidden(?!\S)/, '' )
+ document.getElementById("addanother7").className += " hidden";
+ document.createsurveyform.check7.checked=true
+}
@@ -6,11 +6,11 @@
<h2>List a room</h2>
</div><!--closes page_title-->
-<form action="." method="post" enctype="multipart/form-data">
+<form action="." method="post" enctype="multipart/form-data" name="createsurveyform">
{% csrf_token %}
{{form.non_field_errors}}
<h4>1. What do you want to know about your roommates?</h4>
- <h6 class="blue">Create a custom survey that your potential roommates will answer here.</h6>
+ <h7 class="blue">Create a custom survey that your potential roommates will answer:</h7>
<br/>
<div class="ten columns">
<p>Choose from our standard questions:</p>
@@ -22,32 +22,63 @@ <h6 class="blue">Create a custom survey that your potential roommates will answe
<!-- <h5 class="pointer clickable dropdown">Click here to add your own questions</h5>-->
</div><!--closes left-->
<div class="ten columns">
- <p>Or add your own question:</p>
- <input type="checkbox" />
- <input type="text" name="q1" />
- <button>Add Another</button>
- <br />
- <label>Question 2 (optional)</label>
- <input type="text" name="q2" />
- <label>Question 3 (optional)</label>
- <input type="text" name="q3" />
- <label>Question 4 (optional)</label>
- <input type="text" name="q4" />
- <label>Question 5 (optional)</label>
- <input type="text" name="q5" />
- <label>Question 6 (optional)</label>
- <input type="text" name="q6" />
- <label>Question 7 (optional)</label>
- <input type="text" name="q7" />
- <label>Question 8 (optional)</label>
- <input type="text" name="q8" />
- <label>Question 9 (optional)</label>
- <input type="text" name="q9" />
- <label>Question 10 (optional)</label>
- <input type="text" name="q10" />
+ <p>Or add your own question:</p>
+ <div id="ques1" class="userquestion">
+ <input type="checkbox" name="check1" />
+ <input type="text" name="q1" />
+ <button id="addanother1" type="button">Add Another</button>
+ <br />
+ </div>
+ <div id="ques2" class="userquestion hidden">
+ <input type="checkbox" name="check2" />
+ <input type="text" name="q1" />
+ <button id="addanother2" type="button">Add Another</button>
+ <br />
+ </div>
+ <div id="ques3" class="userquestion hidden"">
+ <input type="checkbox" name="check3" />
+ <input type="text" name="q3" />
+ <button id="addanother3" type="button">Add Another</button>
+ <br />
+ </div>
+ <div id="ques4" class="userquestion hidden">
+ <input type="checkbox" name="check4" />
+ <input type="text" name="q4" />
+ <button id="addanother4" type="button">Add Another</button>
+ <br />
+ </div>
+ <div id="ques5" class="userquestion hidden">
+ <input type="checkbox" name="check5" />
+ <input type="text" name="q5" />
+ <button id="addanother5" type="button">Add Another</button>
+ <br />
+ </div>
+ <div id="ques6" class="userquestion hidden">
+ <input type="checkbox" name="check6" />
+ <input type="text" name="q6" />
+ <button id="addanother6" type="button">Add Another</button>
+ <br />
+ </div>
+ <div id="ques7" class="userquestion hidden">
+ <input type="checkbox" name="check7" />
+ <input type="text" name="q7" />
+ <button id="addanother7" type="button">Add Another</button>
+ <br />
+ </div>
+ <div id="ques8" class="userquestion hidden">
+ <input type="checkbox" name="check8" />
+ <input type="text" name="q8" />
+<!-- <button id="addanother8" type="button">Add Another</button> -->
+ <br />
+ </div>
+
+
+
+
+
</div>
<br/>
- <div id="tell_room">
+ <div id="tell_room" class="ten columns">
<h4 class="pointer clickable">2. Tell us about the room</h4>
<dd>
<label>{{form.price.label}} ($)</label>
@@ -72,7 +103,7 @@ <h4 class="pointer clickable">2. Tell us about the room</h4>
</dd>
</div><!--closes tell_room-->
<br/>
- <div id="create_account">
+ <div id="create_account" class="ten columns">
<h4 class="pointer clickable">3. Create an account</h4>
<dd>
<label>{{form.username.label}}</label>
@@ -87,7 +118,8 @@ <h4 class="pointer clickable">3. Create an account</h4>
</dd>
</div><!--closes create_account-->
<br/>
- <div id="tell_yourself">
+
+ <div id="tell_yourself" class="ten columns">
<h4 class="pointer clickable">4. Tell us a bit about yourself</h4>
<dd>
<label>{{form.name.label}}</label>
@@ -118,6 +150,10 @@ <h4 class="pointer clickable">4. Tell us a bit about yourself</h4>
</div><!--closes tell_yourself-->
</form>
</div><!--closes container-->
+<script src="{% get_static_prefix %}js/pk.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="{% get_static_prefix %}js/dropdown.js"></script>
+
+
+
{% endblock main %}
@@ -7,7 +7,7 @@
<link rel="stylesheet" href="{% get_static_prefix %}css/skeleton.css">
<link rel="stylesheet" href="{% get_static_prefix %}css/backend.css">
<style type="text/css">
- body {background-image:url("/static/images/fabric_plaid.png")}
+/* body {background-image:url("/static/images/fabric_plaid.png")} */
</style>
</head>
@@ -14,15 +14,21 @@
class UploadForm(forms.Form):
file = forms.ImageField(label='Upload your pic')
+
def create_survey(request):
standard_questions = Question.objects.filter(standard=True)
if not request.method == "POST":
form = ListRegForm()
- return render_to_response('create_survey.html', {"form":form, "standard":standard_questions}, context_instance=RequestContext(request))
+ return render_to_response('create_survey.html',
+ {"form":form, "standard":standard_questions},
+ context_instance=RequestContext(request)
+ )
form = ListRegForm(request.POST, request.FILES)
if not form.is_valid():
- return render_to_response('create_survey.html', {"form":form, "standard":standard_questions}, context_instance=RequestContext(request))
-
+ return render_to_response('create_survey.html',
+ {"form":form, "standard":standard_questions},
+ context_instance=RequestContext(request)
+ )
file = request.FILES["file"]
store_in_s3(file)
p = PhotoUrl(url="http://roommater.s3.amazonaws.com/"+str(file))
@@ -125,6 +131,7 @@ def submit_create_survey(request, room):
survey.questions.add(q)
survey.save()
i+=1
+
#adds survey to UserProfile, this may require a request context for security down the line
user_profile = request.user.get_profile()
user_profile.survey = Survey.objects.get(name=str(survey))

0 comments on commit dca8f76

Please sign in to comment.