Skip to content

Commit

Permalink
implement(fixed)
Browse files Browse the repository at this point in the history
  • Loading branch information
Maksym-Turenko committed Sep 13, 2024
1 parent f1595b2 commit 7ed1d81
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
8 changes: 0 additions & 8 deletions taxi/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,6 @@ class DriverListView(LoginRequiredMixin, generic.ListView):
model = Driver
paginate_by = 5

def get_queryset(self):
queryset = super().get_queryset()
for driver in queryset:
if driver == self.request.user:
driver.is_current_user = True
else:
driver.is_current_user = False
return queryset


class DriverDetailView(LoginRequiredMixin, generic.DetailView):
Expand Down
4 changes: 3 additions & 1 deletion templates/taxi/driver_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ <h1>Driver list</h1>
<li>
<a href="{% url "taxi:driver-detail" pk=driver.id %}">{{ driver.username }}</a>
({{ driver.first_name }} {{ driver.last_name }})
{% if driver.is_current_user %}(Me){% endif %}
{% if driver == request.user %}
(Me)
{% endif %}
</li>
{% endfor %}
</ul>
Expand Down

0 comments on commit 7ed1d81

Please sign in to comment.