-
Notifications
You must be signed in to change notification settings - Fork 853
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Solution #879
base: master
Are you sure you want to change the base?
Solution #879
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
from django.urls import path | ||
from django.contrib.auth import views as auth_views | ||
|
||
from .views import ( | ||
index, | ||
|
@@ -20,7 +21,19 @@ | |
path("cars/<int:pk>/", CarDetailView.as_view(), name="car-detail"), | ||
path("drivers/", DriverListView.as_view(), name="driver-list"), | ||
path( | ||
"drivers/<int:pk>/", DriverDetailView.as_view(), name="driver-detail" | ||
"drivers/<int:pk>/", DriverDetailView.as_view(), name="driver-detail", | ||
), | ||
path( | ||
"login/", | ||
auth_views.LoginView.as_view(template_name="registration/login.html"), | ||
name="login" | ||
), | ||
path( | ||
"logout/", | ||
auth_views.LogoutView.as_view( | ||
template_name="registration/logout.html" | ||
Comment on lines
+33
to
+34
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
), | ||
name="logout" | ||
), | ||
] | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,19 @@ | ||
<ul class="sidebar-nav"> | ||
<li><a href="{% url "taxi:index" %}">Home page</a></li> | ||
<li><a href="{% url "taxi:manufacturer-list" %}">Manufacturers</a></li> | ||
<li><a href="{% url "taxi:car-list" %}">Cars</a></li> | ||
<li><a href="{% url "taxi:driver-list" %}">Drivers</a></li> | ||
</ul> | ||
<div class="sidebar"> | ||
{% if user.is_authenticated %} | ||
<p>Welcome, | ||
<a href="{% url 'taxi:driver-detail' user.id %}"> | ||
{{ user.username }} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ensure that the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ensure that |
||
</a>! | ||
</p> | ||
<a href="{% url "taxi:logout" %}">Logout</a> | ||
{% else %} | ||
<a href="{% url "taxi:login" %}">Login</a> | ||
{% endif %} | ||
<br> | ||
<ul class="sidebar-nav"> | ||
<li><a href="{% url "taxi:index" %}">Home page</a></li> | ||
<li><a href="{% url "taxi:manufacturer-list" %}">Manufacturers</a></li> | ||
<li><a href="{% url "taxi:car-list" %}">Cars</a></li> | ||
<li><a href="{% url "taxi:driver-list" %}">Drivers</a></li> | ||
</ul> | ||
</div> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{% extends "base.html" %} | ||
|
||
{% block content %} | ||
<h1>Login</h1> | ||
{% if form.errors %} | ||
<p style="color: red;">Invalid username or password</p> | ||
{% endif %} | ||
<form method="post"> | ||
{% csrf_token %} | ||
{{ form.as_p }} | ||
<button type="submit">Login</button> | ||
</form> | ||
{% endblock %} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{% extends "base.html" %} | ||
|
||
{% block content %} | ||
<h1>Logged out</h1> | ||
<p>You have been logged out. <a href="{% url "taxi:login" %}">Login again?</a></p> | ||
{% endblock %} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,9 @@ <h1>Driver list</h1> | |
<ul> | ||
{% for driver in driver_list%} | ||
<li> | ||
<a href="{% url "taxi:driver-detail" pk=driver.id %}">{{ driver.username }}</a> | ||
<a href="{% url "taxi:driver-detail" pk=driver.id %}"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ensure that |
||
{{ driver.username }} {% if driver == current_user %}(Me){% endif %} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ensure that |
||
</a> | ||
({{ driver.first_name }} {{ driver.last_name }}) | ||
</li> | ||
{% endfor %} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
LogoutView
does not require atemplate_name
because it doesn't render a template. It simply logs the user out and redirects them. Consider removing thetemplate_name
argument.