Skip to content

Commit

Permalink
Adjusted comment form styling
Browse files Browse the repository at this point in the history
  • Loading branch information
Ekaterina-Vititneva committed Oct 10, 2024
1 parent 3b6aa38 commit f565eb9
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 57 deletions.
8 changes: 7 additions & 1 deletion project_2/commerce/auctions/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,10 @@ class BidForm(forms.Form):
bid = forms.DecimalField(label="Place Bid", widget=forms.NumberInput(attrs={'class': 'form-control', 'placeholder': '0.00€'}))

class CommentForm(forms.Form):
comment = forms.CharField(widget=forms.Textarea(attrs={'rows': 3, 'placeholder': 'Add a comment...'}))
comment = forms.CharField(
widget=forms.Textarea(attrs={
'class': 'form-control', # Bootstrap class for styling
'rows': 3, # Adjust the number of rows
'placeholder': 'Add a comment...', # Placeholder text
})
)
87 changes: 43 additions & 44 deletions project_2/commerce/auctions/templates/auctions/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,48 +2,47 @@

<!DOCTYPE html>
<html lang="en">
<head>
<title>{% block title %}Auctions{% endblock %}</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css">
<link href="{% static 'auctions/styles.css' %}" rel="stylesheet">
</head>
<body>
<h1>Auctions</h1>
<div>
{% if user.is_authenticated %}
Signed in as <strong>{{ user.username }}</strong>.
{% else %}
Not signed in.
{% endif %}
</div>
<ul class="nav">
<li class="nav-item">
<a class="nav-link" href="{% url 'index' %}">Active Listings</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{% url 'categories' %}">Categories</a>
</li>
{% if user.is_authenticated %}
<li class="nav-item">
<a class="nav-link" href="{% url 'logout' %}">Log Out</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{% url 'watchlist' %}">Watchlist</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{% url 'create_listing' %}">Create Listing</a>
</li>
{% else %}
<li class="nav-item">
<a class="nav-link" href="{% url 'login' %}">Log In</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{% url 'register' %}">Register</a>
</li>
{% endif %}
</ul>
<hr>
{% block body %}
{% endblock %}
</body>
<head>
<title>{% block title %}Auctions{% endblock %}</title>
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css"
/>
<link href="{% static 'auctions/styles.css' %}" rel="stylesheet" />
</head>
<body>
<h1>Auctions</h1>
<div>
{% if user.is_authenticated %} Signed in as <strong>{{ user.username }}</strong>. {% else %}
Not signed in. {% endif %}
</div>
<ul class="nav">
<li class="nav-item">
<a class="nav-link" href="{% url 'index' %}">Active Listings</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{% url 'categories' %}">Categories</a>
</li>
{% if user.is_authenticated %}
<li class="nav-item">
<a class="nav-link" href="{% url 'logout' %}">Log Out</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{% url 'watchlist' %}">Watchlist</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{% url 'create_listing' %}">Create Listing</a>
</li>
{% else %}
<li class="nav-item">
<a class="nav-link" href="{% url 'login' %}">Log In</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{% url 'register' %}">Register</a>
</li>
{% endif %}
</ul>
<hr />
{% block body %} {% endblock %}
</body>
</html>
21 changes: 9 additions & 12 deletions project_2/commerce/auctions/templates/auctions/listing.html
Original file line number Diff line number Diff line change
Expand Up @@ -69,19 +69,16 @@ <h4 class="listing-bid">{{ listing.bid }}€</h4>
<p class="listing-description">{{ listing.description }}</p>
<div class="comments">
<p class="listing-description-heading">Comments</p>

{% if user.is_authenticated %}
<div class="card mt-3">
<div class="card-body">
<form action="{% url 'listing' listing.title %}" method="post">
{% csrf_token %}
<div class="mb-3">
{{ comment_form.comment }}
<!-- This will render the comment field as a textarea -->
</div>
<button type="submit" class="btn btn-primary">Add Comment</button>
</form>
</div>
</div>

<form action="{% url 'listing' listing.title %}" method="post">
{% csrf_token %}
<input type="hidden" name="form_type" value="comment_form" />
<!-- Ensure this is present -->
<div class="mb-3">{{ comment_form.comment }}</div>
<button type="submit" class="btn btn-primary">Add Comment</button>
</form>

{% endif %} {% for comment in comments %}
<div class="card">
Expand Down

0 comments on commit f565eb9

Please sign in to comment.