Skip to content
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

Test 1 #179

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions server/djangoapp/templates/djangoapp/about.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<html>
<h1>
Welcome to Best Cars dealership, home to the best cars in North America. We sell domestic and imported cars at reasonable prices.
</h1>
</html>
34 changes: 34 additions & 0 deletions server/djangoapp/templates/djangoapp/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,44 @@
</head>

<body>
<<<<<<< HEAD

<!--Add a nav bar here -->
<nav class="navbar navbar-light bg-light">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="#">Dealership Review</a>
<a class="navbar-brand" href="{% url 'djangoapp:contact' %}">Contact</a>
<a class="navbar-brand" href="{% url 'djangoapp:about' %}">About</a>
</div>
<ul class="nav navbar-nav navbar-right">
{% if user.is_authenticated %}
<li>
<a class="btn btn-link" href="#">{{ user.first_name }}({{ user.username }})</a>
<a class="btn btn-link" href="{% url 'djangoapp:logout' %}">Logout</a>
</li>
{% else %}
<li>
<form class="form-inline" action="{% url 'djangoapp:login' %}" method="post">
{% csrf_token %}
<div class="input-group">
<input type="text" class="form-control" placeholder="Username" name="username" >
<input type="password" class="form-control" placeholder="Password" name="password" >
<button class="btn btn-primary" type="submit">Login</button>
<a class="btn btn-link" href="{% url 'djangoapp:registration' %}">Sign Up</a>
</div>
</form>
</li>
{% endif %}
</ul>
</div>
</nav>
=======
<!-- Remove this line the first time you edit this file -->
This is the index page of your Django app!
<!--Add a nav bar here -->

>>>>>>> 7673487c52ef44f161bbed07aa02bf1930211b6b
<!--Add a dealer table here -->

</body>
Expand Down
26 changes: 26 additions & 0 deletions server/djangoapp/templates/djangoapp/registration.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,32 @@
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
</head>
<body>
<<<<<<< HEAD
<form action="{% url 'djangoapp:registration' %}" method="post">
<div class="container"> <!--Style root div with .container class -->
{% csrf_token %}
<h1>Sign Up</h1>
<hr>
<div class="form-group"> <!--Style second div with .form-group class -->
<label for="username"><b>User Name</b></label>
<input type="text" class="form-control" placeholder="Enter User Name: " name="username" required> <!--Style input with .form-control class -->
<label for="firstname"><b>First Name</b></label>
<input type="text" class="form-control" placeholder="Enter First Name: " name="firstname" required> <!--Style input with .form-control class -->
<label for="lastname"><b>Last Name</b></label>
<input type="text" class="form-control" placeholder="Enter Last Name: " name="lastname" required> <!--Style input with .form-control class -->
<label for="password"><b>Password</b></label>
<input type="password" class="form-control" placeholder="Enter password: " name="password" required> <!--Style input with .form-control class -->
{% if message %}
<div class="alert alert-warning"> <!--Style the message paragraph with .alert and .alert-warning class -->
{{ message }}
</div>
{% endif %}
<button class="btn btn-primary" type="submit">Sign up</button> <!--Style button with .btn and .btn-primary class -->
</div>
</div>
</form>
=======
<!--Add a registration form here -->
>>>>>>> 7673487c52ef44f161bbed07aa02bf1930211b6b
</body>
</html>
17 changes: 17 additions & 0 deletions server/djangoapp/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,22 @@
# name the URL

# path for about view
<<<<<<< HEAD
path(route='about', view=views.about, name='about'),
# path for contact us view

# path for registration
path('registration/', views.registration_request, name='registration'),

# path for login
path('login/', views.login_request, name='login'),

# path for logout
path('logout/', views.logout_request, name='logout'),

# path for index view
path('', views.get_dealerships, name='index'),
=======

# path for contact us view

Expand All @@ -20,6 +36,7 @@
# path for logout

path(route='', view=views.get_dealerships, name='index'),
>>>>>>> 7673487c52ef44f161bbed07aa02bf1930211b6b

# path for dealer reviews view

Expand Down
37 changes: 37 additions & 0 deletions server/djangoapp/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,42 @@

# Create your views here.

<<<<<<< HEAD
# Create an `about` view to render a static about page
def about(request):
return render(request, 'djangoapp/about.html')

# Create a `contact` view to return a static contact page
def contact(request):
return render(request,'djangoapp/about.html' )

# Create a `login_request` view to handle sign in request
def login_request(request):
context = {}
if request.method == 'POST':
username = request.POST['username']
password = request.POST['password']
user = authenticate(request, username=username, password=password)
if user is not None:
login(request, user)
return render(request, 'djangoapp/index.html', context)
else:
messages.error(request, 'Invalid login credentials')
return render(request, 'djangoapp/login.html')

# Create a `logout_request` view to handle sign out request
def logout_request(request):
logout(request)
return render(request, 'djangoapp/index.html')

# Create a `registration_request` view to handle sign up request
def registration_request(request):
context = {}
if request.method == 'POST':
messages.success(request, 'Registration successful. Please log in.')
return render(request, 'djangoapp/index.html', context)
return render(request, 'djangoapp/registration.html')
=======

# Create an `about` view to render a static about page
# def about(request):
Expand All @@ -36,6 +72,7 @@
# Create a `registration_request` view to handle sign up request
# def registration_request(request):
# ...
>>>>>>> 7673487c52ef44f161bbed07aa02bf1930211b6b

# Update the `get_dealerships` view to render the index page with a list of dealerships
def get_dealerships(request):
Expand Down
Empty file modified server/manage.py
100755 → 100644
Empty file.
Loading