This commit is contained in:
Sharad Ahlawat 2020-03-10 14:55:24 -07:00
parent f79c29b7e0
commit a85a288278
3 changed files with 30 additions and 5 deletions

View File

@ -13,16 +13,19 @@
<a href="{{ product.url }}"><h1>{{ product.title }}</h1></a>
</div>
</div>
<hr />
<hr/>
<div class="row">
<div class="col-8">
<img src="{{ product.image.url }}" class="img-fluid" \>
</div>
<div class="col-4">
<a href="javascript:{document.getElementById('upvote').submit()}"><button class="btn btn-primary btn-lg btn-block"><span class="oi oi-caret-top"></span> Up Vote : {{ product.votes_total }}</button></a>
<a href="javascript:{document.getElementById('upvote').submit()}">
<button class="btn btn-primary btn-lg btn-block"><span class="oi oi-caret-top"></span> Up Vote
: {{ product.votes_total }}</button>
</a>
</div>
</div>
<hr />
<hr/>
<div class="row">
<div class="col-4">
<h4>Hunted by: {{ product.hunter.username }}</h4>
@ -31,7 +34,7 @@
<h4>{{ product.pubdate_pretty }}</h4>
</div>
</div>
<hr />
<hr/>
<div class="row">
<div class="col-8">
<p>{{ product.body }}</p>

View File

@ -5,4 +5,25 @@
<br/>
<br/>
{% endif %}
{% for product in products.all %}
<div class="row pt-3">
<div class="col-2" onclick="window.location='{% url 'detail' product.id %}';" style="cursor:pointer;">
<img src="{{ product.icon.url }}" class="img-fluid" \>
</div>
<div class="col-6" onclick="window.location='{% url 'detail' product.id %}';" style="cursor:pointer;">
<h1>{{ product.title }}</h1>
<p>{{ product.summary }}</p>
</div>
<div class="col-4">
<a href="javascript:{document.getElementById('upvote{{ product.id }}').submit()}">
<button class="btn btn-primary btn-lg btn-block"><span class="oi oi-caret-top"></span> Up Vote
: {{ product.votes_total }}</button>
</a>
</div>
</div>
<form id="upvote{{ product.id }}" method="POST" action="{% url 'upvote' product.id %}">
{% csrf_token %}
<input type="hidden">
</form>
{% endfor %}
{% endblock %}

View File

@ -5,7 +5,8 @@ from django.utils import timezone
def home(request):
return render(request, 'products/home.html')
products = Product.objects
return render(request, 'products/home.html', {'products': products})
@login_required()