Skip to content

Commit 439a454

Browse files
committed
latest feature: Event Reviews
1 parent b8d542d commit 439a454

File tree

6 files changed

+291
-163
lines changed

6 files changed

+291
-163
lines changed
Lines changed: 32 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,34 @@
11
<div>
2-
<h4 class="fst-italic">Reviews</h4>
3-
<span class="badge text-bg-primary rounded-pill">{{rating.rating__avg}} / 5</span>
4-
<ul class="list-unstyled">
5-
{% for review in reviews %}
6-
<li>
7-
<p class="d-flex flex-column flex-lg-row gap-3 align-items-start align-items-lg-center py-3 link-body-emphasis text-decoration-none border-top">
8-
<div class="col-lg-8">
9-
<strong class="d-inline-block mb-2 text-primary-emphasis">{{review.rating}} / 5</strong>
10-
<p class="card-text mb-auto">{{review.comment}}
11-
<p class="mb-1 text-body-secondary">{{review.reviewer}} - {{review.created_at|date:"M d, Y" }}</p>
12-
</div>
13-
</p>
14-
{% if review.reviewer == user %}
15-
<a hrefclass="btn btn-primary rounded-pill px-3" >Edit</a>
16-
<form
17-
action="{% url 'delete_event' event.id %}?next={{ request.path }}"
18-
method="POST"
19-
style="display: inline"
20-
>
21-
{% csrf_token %}
22-
<button
23-
type="submit"
24-
class="btn btn-danger btn-sm"
25-
onclick="return confirm('Are you sure you want to delete this event?');"
2+
<h4 class="fst-italic">Reviews</h4>
3+
<span class="badge text-bg-primary rounded-pill">{{ rating.rating__avg }} / 5</span>
4+
<ul class="list-unstyled">
5+
{% for review in reviews %}
6+
<li>
7+
<div class="d-flex flex-column flex-lg-row gap-3 align-items-start align-items-lg-center py-3 link-body-emphasis text-decoration-none border-top my-3">
8+
<div class="col-lg-8">
9+
<strong class="d-inline-block mb-2 text-primary-emphasis">{{ review.rating }} / 5</strong>
10+
<p class="card-text mb-auto">{{ review.comment }}</p>
11+
<p class="mb-1 text-body-secondary">{{ review.reviewer }} - {{ review.created_at|date:"M d, Y" }}</p>
12+
</div>
13+
{% if review.reviewer == user %}
14+
<a href="{% url 'edit_review' review.id %}?next={{ request.path }}" class="btn btn-primary btn-sm">Edit</a>
15+
<form
16+
action="{% url 'delete_review' review.id %}?next={{ request.path }}"
17+
method="POST"
18+
style="display: inline"
2619
>
27-
Delete
28-
</button>
29-
</form>
30-
<a class="btn btn-danger rounded-pill px-3" >Delete</a>
31-
{% endif %}
32-
</li>
33-
{% endfor %}
34-
</ul>
35-
</div>
20+
{% csrf_token %}
21+
<button
22+
type="submit"
23+
class="btn btn-danger btn-sm"
24+
onclick="return confirm('Are you sure you want to delete this event?');"
25+
>
26+
Delete
27+
</button>
28+
</form>
29+
{% endif %}
30+
</div>
31+
</li>
32+
{% endfor %}
33+
</ul>
34+
</div>

event_manager/events/templates/events/dashboard.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ <h1>Dashboard</h1>
77
<li class="list-group-item d-flex justify-content-between align-items-center">
88
<div>
99
<h5>{{ event.name }}</h5>
10-
<p>{{ event.date }} | {{ event.status }}</p>
10+
<p>{{ event.date }}</p>
1111
</div>
1212
<div>
1313
<!-- Details Button -->
Lines changed: 98 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -1,115 +1,114 @@
11
{% extends "events/base.html" %}
2+
23
{% block content %}
3-
<div>
4-
<div class="row g-5">
5-
<div class="col-md-8">
6-
<article class="blog-post">
7-
<h2 class="display-5 link-body-emphasis mb-1">{{ event.name }}</h2>
8-
<p class="blog-post-meta">{{ event.date }} by {{ event.organizer }}</p>
4+
<div class="row g-5">
5+
<div class="col-md-8">
6+
<article class="blog-post">
7+
<h2 class="display-5 link-body-emphasis mb-1">{{ event.name }}</h2>
8+
<p class="blog-post-meta">{{ event.date }} by {{ event.organizer }}</p>
99

10-
<p>{{ event.description }}</p>
11-
<hr>
10+
<p>{{ event.description }}</p>
11+
<hr>
1212

13-
<h2>Location</h2>
14-
<p>{{ event.location }}</p>
13+
<h2>Location</h2>
14+
<p>{{ event.location }}</p>
1515

16-
<h3>Number of Participants</h3>
17-
<p>{{ event.max_participants }}</p>
16+
<h3>Number of Participants</h3>
17+
<p>{{ event.max_participants }}</p>
1818

19-
<h3>Venue Details</h3>
20-
<dl>
21-
<dt>Name</dt>
22-
<dd>{{ event.venue.name }}</dd>
23-
<dt>Address</dt>
24-
<dd>
25-
{% if event.venue.is_virtual %}
26-
Virtual
27-
{% else %}
28-
{{ event.venue.address }}
29-
{% endif %}
30-
</dd>
31-
</dl>
32-
</article>
33-
</div>
19+
<h3>Venue Details</h3>
20+
<dl>
21+
<dt>Name</dt>
22+
<dd>{{ event.venue.name }}</dd>
23+
<dt>Address</dt>
24+
<dd>
25+
{% if event.venue.is_virtual %}
26+
Virtual
27+
{% else %}
28+
{{ event.venue.address }}
29+
{% endif %}
30+
</dd>
31+
</dl>
32+
</article>
33+
</div>
3434

35-
<div class="col-md-4">
36-
<div class="position-sticky" style="top: 2rem;">
37-
<div class="p-4">
38-
<ol class="list-unstyled">
39-
{% if not past_event %}
40-
<p class="my-2">Spots Left: {{ tickets }}</p>
41-
{% endif %}
35+
<div class="col-md-4">
36+
<div class="position-sticky" style="top: 2rem;">
37+
<div class="p-4">
38+
<ol class="list-unstyled">
39+
{% if not past_event %}
40+
<p class="my-2">Spots Left: {{ tickets }}</p>
41+
{% endif %}
4242

43-
{% if user %}
44-
{% if event.organizer != user %}
45-
<li>
46-
{% if tickets == 0 or past_event %}
47-
Finished
48-
{% else %}
49-
<a class="w-100 btn my-2 btn-lg btn-primary"
50-
href="{% url 'buy-ticket' event.id %}">
51-
{% if ticket %}
52-
Registered
53-
{% else %}
54-
Get Spot
55-
{% endif %}
56-
</a>
57-
{% endif %}
58-
</li>
59-
{% endif %}
43+
{% if user %}
44+
{% if event.organizer != user %}
45+
<li>
46+
{% if tickets == 0 or past_event %}
47+
Finished
48+
{% else %}
49+
<a class="w-100 btn btn-lg btn-primary my-2" href="{% url 'buy-ticket' event.id %}">
50+
{% if ticket %}
51+
Registered
52+
{% else %}
53+
Get Spot
54+
{% endif %}
55+
</a>
56+
{% endif %}
57+
</li>
58+
{% endif %}
6059

61-
{% if event.organizer == user %}
62-
<li>
63-
<a class="w-100 btn my-2 btn-lg btn-primary"
64-
href="{% url 'edit_event' event.id %}">
65-
Edit Event
66-
</a>
67-
</li>
68-
<form action="{% url 'delete_event' event.id %}" method="POST" style="display: inline;">
69-
{% csrf_token %}
70-
<button type="submit" class="w-100 btn my-2 btn-lg btn-danger"
71-
onclick="return confirm('Are you sure you want to delete this event?');">
72-
Delete Event
73-
</button>
74-
</form>
75-
{% endif %}
76-
{% else %}
77-
<li>
78-
<a class="w-100 btn my-2 btn-lg btn-primary"
79-
href="{% url 'buy-ticket' event.id %}"
80-
{% if tickets == 0 %} disabled {% endif %}>
81-
Get Spot
82-
</a>
83-
</li>
84-
{% endif %}
85-
</ol>
86-
</div>
87-
</div>
88-
</div>
60+
{% if event.organizer == user %}
61+
<li>
62+
<a class="w-100 btn btn-lg btn-primary my-2" href="{% url 'edit_event' event.id %}">
63+
Edit Event
64+
</a>
65+
</li>
66+
<form action="{% url 'delete_event' event.id %}" method="POST" style="display: inline;">
67+
{% csrf_token %}
68+
<button type="submit" class="w-100 btn btn-lg btn-danger my-2" onclick="return confirm('Are you sure you want to delete this event?');">
69+
Delete Event
70+
</button>
71+
</form>
72+
{% endif %}
73+
{% else %}
74+
<li>
75+
<a class="w-100 btn btn-lg btn-primary my-2" href="{% url 'buy-ticket' event.id %}" {% if tickets == 0 %} disabled {% endif %}>
76+
Get Spot
77+
</a>
78+
</li>
79+
{% endif %}
80+
</ol>
81+
</div>
8982
</div>
90-
91-
<hr/>
83+
</div>
84+
</div>
9285

93-
{% if past_event and ticket%}
94-
{% include "events/components/reviews_event.html" with reviews=reviews rating=rating user=user%}
95-
{% if not review%}
96-
<form class="needs-validation my-4" method="post" action="{% url 'add-review' event.id %}?next={{ request.path }}">
97-
{% csrf_token %}
86+
<hr />
9887

99-
<div>
100-
<label class="form-label" for="review">Review:</label>
101-
<textarea class="form-control" id="review" name="review" required></textarea>
102-
</div>
88+
{% if past_event and ticket %}
89+
{% include "events/components/reviews_event.html" with reviews=reviews rating=rating user=user %}
90+
{% endif %}
10391

104-
105-
<div>
106-
<label class="form-label" for="rating">Rating on 5:</label>
107-
<input class="form-control" type="number" id="rating" name="rating" required min="1" max="5" />
108-
</div>
92+
{% if past_event %}
93+
{% if event.organizer != user %}
94+
{% if not review or review.reviewer != user %}
95+
<form class="needs-validation my-4" method="post" action="{% url 'add-review' event.id %}?next={{ request.path }}">
96+
{% csrf_token %}
10997

110-
<button class="mt-4 w-100 btn btn-primary btn-sm" type="submit">Submit</button>
111-
</form>
112-
{% endif %}
98+
<div class="mb-3">
99+
<label for="review" class="form-label">Review:</label>
100+
<textarea class="form-control" id="review" name="review" required></textarea>
101+
</div>
102+
103+
<div class="mb-3">
104+
<label for="rating" class="form-label">Rating on 5:</label>
105+
<input class="form-control" type="number" id="rating" name="rating" required min="1" max="5" />
106+
</div>
107+
108+
<button class="mt-4 w-100 btn btn-primary btn-sm" type="submit">Submit</button>
109+
</form>
113110
{% endif %}
114-
</div>
111+
{% endif %}
112+
{% endif %}
113+
115114
{% endblock %}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
{% extends "events/base.html" %}
2+
3+
{% block content %}
4+
<h1>Edit Review</h1>
5+
<div class="container">
6+
<main>
7+
<p>{{ review.event.name }}</p>
8+
{% if error_message %}
9+
<div class="alert alert-danger" role="alert">{{ error_message }}</div>
10+
{% endif %}
11+
<div class="row g-5 mt-4">
12+
<div class="col-md-7 col-lg-8">
13+
<form
14+
class="needs-validation"
15+
method="post"
16+
action="{% url 'edit_review' review.pk %}?next={{ request.GET.next }}"
17+
>
18+
{% csrf_token %}
19+
<div class="mb-3">
20+
<label for="rating" class="form-label">Rating:</label>
21+
<input
22+
type="number"
23+
class="form-control"
24+
id="rating"
25+
name="rating"
26+
min="1"
27+
max="5"
28+
value="{{ review.rating }}"
29+
required
30+
/>
31+
</div>
32+
<div class="mb-3">
33+
<label for="review" class="form-label">Comment:</label>
34+
<textarea
35+
class="form-control"
36+
id="review"
37+
name="review"
38+
required
39+
>{{ review.comment }}</textarea>
40+
</div>
41+
<button class="btn btn-primary btn-lg w-100 mt-4" type="submit">Save Changes</button>
42+
</form>
43+
</div>
44+
</div>
45+
</main>
46+
47+
<footer class="my-5 pt-5 text-body-secondary text-center text-small">
48+
<p class="mb-1">© 2017–2024 Company Name</p>
49+
<ul class="list-inline">
50+
<li class="list-inline-item"><a href="#">Privacy</a></li>
51+
<li class="list-inline-item"><a href="#">Terms</a></li>
52+
<li class="list-inline-item"><a href="#">Support</a></li>
53+
</ul>
54+
</footer>
55+
</div>
56+
{% endblock %}

event_manager/events/urls.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
path("", views.IndexView.as_view(), name="index"),
77
path("edit-event/<int:pk>/", views.EditEvent, name="edit_event"),
88
path("delete-event/<int:pk>/", views.DeleteEvent, name="delete_event"),
9+
path("delete_review/<int:pk>", views.DeleteReview, name="delete_review"),
10+
path("edit_review/<int:pk>", views.EditReview, name="edit_review"),
911
path("dash/", views.DashView.as_view(), name="dash"),
1012
path("login/", views.LoginView, name="login"),
1113
path("register/", views.RegisterView, name="register"),

0 commit comments

Comments
 (0)