This commit is contained in:
Sharad Ahlawat 2020-03-10 15:21:18 -07:00
parent a85a288278
commit 0f240692d2
4 changed files with 38 additions and 41 deletions

View File

@ -5,9 +5,9 @@
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content=""> <meta name="description" content="Product Hunt">
<meta name="author" content="Mark Otto, Jacob Thornton, and Bootstrap contributors"> <meta name="author" content="Sharad Ahlawat">
<meta name="generator" content="Jekyll v3.8.6"> <meta name="generator" content="django">
<title>Product Hunt</title> <title>Product Hunt</title>
<link rel="canonical" href="https://getbootstrap.com/docs/4.4/examples/album/"> <link rel="canonical" href="https://getbootstrap.com/docs/4.4/examples/album/">
@ -44,39 +44,39 @@
<body> <body>
<header> <header>
<nav class="navbar navbar-expand-lg navbar-light bg-light"> <nav class="navbar navbar-expand-lg navbar-light bg-light">
<div class="container"> <div class="container">
<a class="navbar-brand" href="{% url 'home' %}"> <a class="navbar-brand" href="{% url 'home' %}">
<img src="{% static 'logo.png' %}" height="30" width="30" class="d-inline-block"/>roduct Hunt</a> <img src="{% static 'logo.png' %}" height="30" width="30" class="d-inline-block"/>roduct Hunt</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavAltMarkup" <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavAltMarkup"
aria-controls="navbarNavAltMarkup" aria-expanded="false" aria-label="Toggle navigation"> aria-controls="navbarNavAltMarkup" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span> <span class="navbar-toggler-icon"></span>
</button> </button>
<div class="collapse navbar-collapse" id="navbarNavAltMarkup"> <div class="collapse navbar-collapse" id="navbarNavAltMarkup">
<div class="navbar-nav ml-auto"> <div class="navbar-nav ml-auto">
{% if user.is_authenticated %} {% if user.is_authenticated %}
<a class="nav-item nav-link" href="{% url 'create' %}"><span class="oi oi-plus"></span></a> <a class="nav-item nav-link" href="{% url 'create' %}"><span class="oi oi-plus"></span></a>
<a class="nav-item nav-link" href="javascript:{document.getElementById('logout').submit()}">Logout</a> <a class="nav-item nav-link" href="javascript:{document.getElementById('logout').submit()}">Logout</a>
<form id="logout" method="POST" action="{% url 'logout' %}"> <form id="logout" method="POST" action="{% url 'logout' %}">
{% csrf_token %} {% csrf_token %}
<input type="hidden" /> <input type="hidden"/>
</form> </form>
{% else %} {% else %}
<a class="nav-item nav-link" href="{% url 'signup' %}">Sign Up</a> <a class="nav-item nav-link" href="{% url 'signup' %}">Sign Up</a>
<a class="nav-item nav-link" href="{% url 'login' %}">Login</a> <a class="nav-item nav-link" href="{% url 'login' %}">Login</a>
{% endif %} {% endif %}
</div>
</div> </div>
</div> </div>
</div>
</nav> </nav>
</header> </header>
<div class="container"> <div class="container">
<br /> <br/>
{% block content %} {% block content %}
{% endblock %} {% endblock %}
<br /> <br/>
</div> </div>

View File

@ -2,8 +2,8 @@
{% block content %} {% block content %}
{% if error %} {% if error %}
{{ error }} {{ error }}
<br /> <br/>
<br /> <br/>
{% endif %} {% endif %}
<h1>Create</h1> <h1>Create</h1>
<form method="POST" action="{% url 'create' %}" enctype="multipart/form-data"> <form method="POST" action="{% url 'create' %}" enctype="multipart/form-data">
@ -27,7 +27,7 @@
Body: Body:
<br/> <br/>
<input type="textbox" name="body"/> <input type="textbox" name="body"/>
<br/><br /> <br/><br/>
<input type="submit" value="Add Product" class="btn btn-primary"> <input type="submit" value="Add Product" class="btn btn-primary">
</form> </form>
{% endblock %} {% endblock %}

View File

@ -13,8 +13,7 @@
<a href="{{ product.url }}"><h1>{{ product.title }}</h1></a> <a href="{{ product.url }}"><h1>{{ product.title }}</h1></a>
</div> </div>
</div> </div>
<hr/> <div class="row pt-3">
<div class="row">
<div class="col-8"> <div class="col-8">
<img src="{{ product.image.url }}" class="img-fluid" \> <img src="{{ product.image.url }}" class="img-fluid" \>
</div> </div>
@ -25,17 +24,15 @@
</a> </a>
</div> </div>
</div> </div>
<hr/> <div class="row pt-3">
<div class="row">
<div class="col-4"> <div class="col-4">
<h4>Hunted by: {{ product.hunter.username }}</h4> <h4><span class="oi oi-magnifying-glass"></span> Hunted by: {{ product.hunter.username }}</h4>
</div> </div>
<div class="col-4 text-right"> <div class="col-4 text-right">
<h4>{{ product.pubdate_pretty }}</h4> <h4><span class="oi oi-clock"></span> {{ product.pubdate_pretty }}</h4>
</div> </div>
</div> </div>
<hr/> <div class="row pt-3">
<div class="row">
<div class="col-8"> <div class="col-8">
<p>{{ product.body }}</p> <p>{{ product.body }}</p>
</div> </div>

View File

@ -9,7 +9,7 @@ def home(request):
return render(request, 'products/home.html', {'products': products}) return render(request, 'products/home.html', {'products': products})
@login_required() @login_required(login_url='/accounts/signup')
def create(request): def create(request):
if request.method == 'POST': if request.method == 'POST':
if request.POST['title'] and request.POST['url'] and request.FILES['image'] and request.FILES['icon'] and \ if request.POST['title'] and request.POST['url'] and request.FILES['image'] and request.FILES['icon'] and \
@ -38,7 +38,7 @@ def detail(request, product_id):
return render(request, 'products/detail.html', {'product': product}) return render(request, 'products/detail.html', {'product': product})
@login_required() @login_required(login_url='/accounts/signup')
def upvote(request, product_id): def upvote(request, product_id):
if request.method == 'POST': if request.method == 'POST':
product = get_object_or_404(Product, pk=product_id) product = get_object_or_404(Product, pk=product_id)