Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Bonnegent Sebastien
vehicules
Commits
ba6cbcbe
Commit
ba6cbcbe
authored
Nov 14, 2018
by
Bonnegent Sebastien
Browse files
cours ok
parent
2ec5c4c0
Changes
6
Hide whitespace changes
Inline
Side-by-side
conf/settings.py
View file @
ba6cbcbe
...
...
@@ -110,5 +110,3 @@ USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.1/howto/static-files/
STATIC_URL
=
'/static/'
LOGOUT_REDIRECT_URL
=
'/'
LOGIN_REDIRECT_URL
=
'/'
conf/urls.py
View file @
ba6cbcbe
...
...
@@ -14,10 +14,8 @@ Including another URLconf
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from
django.contrib
import
admin
from
django.urls
import
path
,
include
from
django.urls
import
path
urlpatterns
=
[
path
(
'admin/'
,
admin
.
site
.
urls
),
path
(
'accounts/'
,
include
(
'django.contrib.auth.urls'
)),
path
(
''
,
include
(
'garage.urls'
)),
]
garage/admin.py
View file @
ba6cbcbe
from
django.contrib
import
admin
from
.models
import
Garage
,
Vehicule
,
AFaire
,
Entretien
class
GarageAdmin
(
admin
.
ModelAdmin
):
list_display
=
(
'nom'
,
'mail'
,
'telephone'
)
search_fields
=
[
'nom'
]
class
VehiculeAdmin
(
admin
.
ModelAdmin
):
list_display
=
(
'marque'
,
'modele'
,
'proprietaire'
,
'visible'
)
search_fields
=
[
'marque'
,
'modele'
,
'proprietaire__username'
]
class
AFaireAdmin
(
admin
.
ModelAdmin
):
list_display
=
(
'vehicule'
,
'date'
,
'kms'
)
date_hierarchy
=
'date'
class
EntretienAdmin
(
admin
.
ModelAdmin
):
list_display
=
(
'vehicule'
,
'kms'
,
'date'
,
'montant'
)
date_hierarchy
=
'date'
# ordering = ['date'] >> class Meta
search_fields
=
[
'vehicule__marque'
,
'vehicule__modele'
]
admin
.
site
.
register
(
Garage
,
GarageAdmin
)
admin
.
site
.
register
(
Vehicule
,
VehiculeAdmin
)
admin
.
site
.
register
(
AFaire
,
AFaireAdmin
)
admin
.
site
.
register
(
Entretien
,
EntretienAdmin
)
garage/templates/garage/home.html
deleted
100644 → 0
View file @
2ec5c4c0
{% load static %}
<!doctype html>
<html
lang=
"fr"
><head>
<meta
charset=
"utf-8"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1, shrink-to-fit=no"
>
<title>
Garage
</title>
<link
rel=
"stylesheet"
href=
"{% static 'bootstrap/css/bootstrap.min.css' %}"
>
<script
defer
src=
"{% static 'fontawesome/js/fontawesome-all.min.js' %}"
></script>
</head><body>
<nav
class=
"navbar navbar-expand-lg navbar-dark bg-dark"
>
<a
class=
"navbar-brand"
href=
"/"
>
Garage
</a>
<button
class=
"navbar-toggler"
type=
"button"
data-toggle=
"collapse"
data-target=
"#navbarNavAltMarkup"
aria-controls=
"navbarNavAltMarkup"
aria-expanded=
"false"
aria-label=
"Toggle navigation"
>
<span
class=
"navbar-toggler-icon"
></span>
</button>
<div
class=
"collapse navbar-collapse"
id=
"navbarNavAltMarkup"
>
<ul
class=
"navbar-nav mr-auto"
>
<li
class=
"nav-item active"
><a
class=
"nav-link"
href=
"/"
>
Accueil
</a></li>
<li
class=
"nav-item"
><a
class=
"nav-item nav-link"
href=
"#"
>
Véhicules
</a></li>
</ul>
<ul
class=
"navbar-nav navbar-right"
>
{% if user.is_authenticated %}
{% if user.is_staff %}
<li
class=
"nav-item"
><a
class=
"nav-link"
href=
"/admin"
>
Admin
</a></li>
{% endif %}
<li
class=
"nav-item"
><a
class=
"nav-link"
href=
"{% url 'logout' %}"
>
Déconnexion
</a></li>
{% else %}
<li
class=
"nav-item"
><a
class=
"nav-link"
href=
"{% url 'login' %}"
>
Connexion
</a></li>
{% endif %}
</ul>
</div>
</nav>
<div
class=
"container-fluid"
>
{% block content %}
<p>
Bienvenue !
</p>
{% endblock %}
</div>
<script
src=
"{% static 'bootstrap/js/jquery.min.js' %}"
></script>
<script
src=
"{% static 'bootstrap/js/bootstrap.min.js' %}"
></script>
</body></html>
garage/templates/registration/login.html
deleted
100644 → 0
View file @
2ec5c4c0
{% extends "garage/home.html" %}
{% block content %}
{% if form.errors %}
<p>
Your username and password didn't match. Please try again.
</p>
{% endif %}
{% if next %}
{% if user.is_authenticated %}
<p>
Your account doesn't have access to this page. To proceed,
please login with an account that has access.
</p>
{% else %}
<p>
Please login to see this page.
</p>
{% endif %}
{% endif %}
<form
method=
"post"
action=
"{% url 'login' %}"
>
{% csrf_token %}
<table>
<tr>
<td>
{{ form.username.label_tag }}
</td>
<td>
{{ form.username }}
</td>
</tr>
<tr>
<td>
{{ form.password.label_tag }}
</td>
<td>
{{ form.password }}
</td>
</tr>
</table>
<input
type=
"submit"
value=
"login"
>
<input
type=
"hidden"
name=
"next"
value=
"{{ next }}"
>
</form>
{# Assumes you setup the password_reset view in your URLconf #}
<p><a
href=
"{% url 'password_reset' %}"
>
Lost password?
</a></p>
{% endblock %}
garage/urls.py
deleted
100644 → 0
View file @
2ec5c4c0
from
django.urls
import
path
from
.
import
views
urlpatterns
=
[
path
(
''
,
views
.
home
,
name
=
'home'
),
]
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment