Commits

edanm committed 4fde7ca

Everything pretty much working

Comments (0)

Files changed (8)

stack2blog/stack2blogapp/static_media/img/mark_as_posted.jpg

Added
New image

stack2blog/stack2blogapp/static_media/img/pos.jpg

Added
New image

stack2blog/stack2blogapp/static_media/style.css

 	max-height: 200px;
 }
 
-#userpage_container .published_answers_table_header {
+#userpage_container .post_button {
+	float: right;
+}
+
+#userpage_container .published_answers_header {
 	margin-top:40px;
+}
 
-}
+
+/***********************
+ Postanswer page stylings
+ ***********************/
+#postanswer_container .answer_body {
+	background:#b6c8e9;
+
+}
+
+#postanswer_container .mark_as_posted {
+	margin-top:40px;
+}
+

stack2blog/stack2blogapp/templates/post.html

-<html>
-<head>
-	<title>Stack2Blog - Post your answer</title>
-</head>
-<body>
-	Answer {{ postid }} is being posted
-</body>
-</html>

stack2blog/stack2blogapp/templates/post_answer.html

+{% extends "superpage.html" %}
+
+{% block title %} Posting answer - Stack2Blog {% endblock %}
+
+
+{% block head %}
+{% endblock %}
+
+{% block content %}
+
+<div id="postanswer_container" class="container_12">
+
+	<h1 class="grid_12" class="display_name"> Posting answer: Answer id {{answer.id}} </h1>
+	<div class="clear"></div>
+
+	<p class="grid_12">
+	To post this answer, simply copy the following code into wordpress (in the html tab).
+	</p>
+	<div class="clear"></div>
+
+	<div class="grid_12 answer_body">
+	{{answer.body}}
+	</div>
+	<div class="clear"></div>
+
+	<div class="mark_as_posted">
+		<div class="grid_4">
+
+			<a href="/perform_post/{{answer.id}}">
+				<img src="{{MEDIA_URL}}stack2blog_media/static_media/img/mark_as_posted.jpg" alt="Mark as Posted" />
+			</a>
+		</div>
+		<div class="grid_4">
+			<p>
+			This will make the answer show up in the posted table on your userpage.
+			</P>
+			<p>
+			Use this after you've actually posted this answer.
+			</p>
+		</div>
+	</div>
+</div>
+
+{% endblock %}

stack2blog/stack2blogapp/templates/userpage.html

 			<div class="grid_1 votecount"> {{answer.score}} </div>
 			<div class="grid_3 question_title"> {{answer.title}} </div>
 			<div class="grid_5 answer_body"> {{answer.body_blurb|safe}} </div>
+			<div class="post_button"> <a href="/answer/{{answer.id}}/"> <img src="{{MEDIA_URL}}stack2blog_media/static_media/img/pos.jpg" alt="Post to Blog" /></a> </div>
 
 			<div class="clear"></div>
 		</div>
 
 
 	<!-- Published answers -->
-	<h2 class="grid_12">Answers you've already published ({{ published_answers|length }}):</h2>
+	<h2 class="grid_12 published_answers_header">Answers you've already published ({{ published_answers|length }}):</h2>
 	<div class="clear"></div>
 
 	<!-- The headers -->
 	<ul class="answers_table_header published_answers_table_header">
 		<li class="grid_1">Votes</li>
-		<li class="grid_4">Question Title</li>ah
-		<li class="grid_2">Answer</li>
+		<li class="grid_3">Question Title</li>
+		<li class="grid_5">Answer</li>
 		<div class="clear"></div>
 	</ul>
 
 	{% for answer in published_answers %}
 		<div class="answer unposted_answer">
-			<div class="grid_1" class="votecount"> {{answer.score}} </div>
-			<div class="grid_4" class="question_title"> {{answer.title}} </div>
-			<div class="grid_4" class="answer_body"> {{answer.body_blurb}} </div>
+			<div class="grid_1 votecount"> {{answer.score}} </div>
+			<div class="grid_3 question_title"> {{answer.title}} </div>
+			<div class="grid_5 answer_body"> {{answer.body_blurb|safe}} </div>
 
 			<div class="clear"></div>
 		</div>

stack2blog/stack2blogapp/views.py

 
 	return render_to_response('userpage.html', locals(), context_instance=RequestContext(request))
 
-def post_answer(request):
+def post_answer(request, answer_id):
 	try:
-		postid = int(request.GET.get("postid", ""))
-	except:
-		return "Bad ID" # Make a bad answer option in main page.
+		answer_id = int(answer_id)
+	except ValueError:
+		raise Http404 # Send back to homepage with an error.
 
-	post = PublishedPost(postid = postid)
+	site = stackexchange.Site(stackexchange.StackOverflow, app_key = "SL5xzbpFYUCSae3tqVlL7A")
+	site.be_inclusive()
+	answer = site.answer(answer_id)
+
+	return render_to_response('post_answer.html', locals(), context_instance=RequestContext(request))
+
+def perform_post(request, answer_id):
+	try:
+		answer_id = int(answer_id)
+	except ValueError:
+		raise Http404 # Send back to homepage with an error.
+
+	post = PublishedPost(postid = answer_id)
 	post.save()
 
-	return render_to_response('post.html', locals(), context_instance=RequestContext(request))
+	userid = request.session["so_userid"]
+
+	return HttpResponseRedirect("/userpage/" + str(userid))

stack2blog/urls.py

 
     (r'^$', home_page),
     (r'^userpage/(\d*)/?$', userpage),
-    (r'post', post_answer),
+    (r'^answer/(\d*)/?$', post_answer),
+    (r'^perform_post/(\d*)/?$', perform_post),
 )
 
 if settings.DEBUG: