Fixes a couple of issues + better UX

master
Laurent 6 years ago
parent 9f1776a257
commit 9525b61e8b
  1. BIN
      db.sqlite3
  2. BIN
      news/__pycache__/views.cpython-37.pyc
  3. 1
      news/static/news/css/app.css
  4. 20
      news/templates/news/post.html
  5. 4
      news/views.py

Binary file not shown.

@ -127,6 +127,7 @@ a h1 {
.quote {
padding: 15px;
background-color: #333;
margin-bottom: 8px;
}
@media print, screen and (min-width: 40em) {
.quote {

@ -47,13 +47,15 @@
<script type="text/javascript">
function myFunction(divID) {
var x = document.getElementById(divID);
if (x.style.display === "none") {
x.style.display = "block";
} else {
x.style.display = "none";
var x = document.getElementById("div_" + divID);
if (x.style.display === "none") {
x.style.display = "block";
window.location.hash = "sub_" + divID;
document.getElementById("text_" + divID).focus();
} else {
x.style.display = "none";
}
}
}
</script>
<br/>
@ -81,13 +83,13 @@
</form>
{% endif %}
<button class="secondary_button inline" onclick="myFunction('div_{{ comment.id }}')">reply</button>
<button class="secondary_button inline" onclick="myFunction('{{ comment.id }}')">reply</button>
<div id="div_{{ comment.id }}" class="inline reply_form" style="display:none">
<form action="{% url 'news:comment_with_parent' post.id comment.id %}" method="post">
{% csrf_token %}
<textarea name="body" rows="3" cols="50"></textarea>
<button class="primary_button" type="submit">Submit</button>
<textarea id="text_{{ comment.id}}" name="body" rows="3" cols="50"></textarea>
<button id="sub_{{ comment.id}}" class="primary_button" type="submit">Submit</button>
</form>
</div>

@ -1,4 +1,4 @@
from django.shortcuts import render, get_object_or_404
from django.shortcuts import render, get_object_or_404, redirect
from django.http import HttpResponse, Http404, HttpResponseRedirect
from django.template import loader
from django.urls import reverse
@ -163,4 +163,4 @@ def upvote(request, comment_id):
comment.voters.add(request.user)
comment.save()
post = comment.post
return render(request, 'news/post.html', {'post': post, 'comments': post.flat_comments(request.user) })
return HttpResponseRedirect(reverse('news:post', args=(post.id,)))

Loading…
Cancel
Save