diff --git a/server/db.sqlite3 b/server/db.sqlite3 new file mode 100644 index 0000000000..ac3fc956d9 Binary files /dev/null and b/server/db.sqlite3 differ diff --git a/server/djangoapp/templates/djangoapp/about.html b/server/djangoapp/templates/djangoapp/about.html new file mode 100644 index 0000000000..bb525d5275 --- /dev/null +++ b/server/djangoapp/templates/djangoapp/about.html @@ -0,0 +1,5 @@ + +

+Welcome to Best Cars dealership, home to the best cars in North America. We sell domestic and imported cars at reasonable prices. +

+ \ No newline at end of file diff --git a/server/djangoapp/templates/djangoapp/contact.html b/server/djangoapp/templates/djangoapp/contact.html new file mode 100644 index 0000000000..be232cf600 --- /dev/null +++ b/server/djangoapp/templates/djangoapp/contact.html @@ -0,0 +1,6 @@ + +

Address

+

30 street departement 5

+

Phone

+

1111111111

+ \ No newline at end of file diff --git a/server/djangoapp/templates/djangoapp/djangotemplete.html b/server/djangoapp/templates/djangoapp/djangotemplete.html new file mode 100644 index 0000000000..5e1c309dae --- /dev/null +++ b/server/djangoapp/templates/djangoapp/djangotemplete.html @@ -0,0 +1 @@ +Hello World \ No newline at end of file diff --git a/server/djangoapp/templates/djangoapp/index.html b/server/djangoapp/templates/djangoapp/index.html index 1a9ee6e39a..de4d4558d3 100644 --- a/server/djangoapp/templates/djangoapp/index.html +++ b/server/djangoapp/templates/djangoapp/index.html @@ -10,16 +10,57 @@ - + - This is the index page of your Django app! - + - + diff --git a/server/djangoapp/templates/djangoapp/login.html b/server/djangoapp/templates/djangoapp/login.html new file mode 100644 index 0000000000..d60fcadf23 --- /dev/null +++ b/server/djangoapp/templates/djangoapp/login.html @@ -0,0 +1,28 @@ + + + + + {% load static %} + + + + + + +
+ {% csrf_token %} +
+

Login

+ + + + +
+ +
+
+
+ + + + \ No newline at end of file diff --git a/server/djangoapp/templates/djangoapp/registration.html b/server/djangoapp/templates/djangoapp/registration.html index ae11ea4b71..40b98bd152 100644 --- a/server/djangoapp/templates/djangoapp/registration.html +++ b/server/djangoapp/templates/djangoapp/registration.html @@ -3,9 +3,30 @@ {% load static %} + + - - +
+
+

Sign Up

+
+ + + + + + + + +
+ {% csrf_token %} + +
+
+
+ + + \ No newline at end of file diff --git a/server/djangoapp/urls.py b/server/djangoapp/urls.py index 37b1c89d01..730898441e 100644 --- a/server/djangoapp/urls.py +++ b/server/djangoapp/urls.py @@ -10,17 +10,21 @@ # name the URL # path for about view + path(route='about', view=views.about, name='about'), # path for contact us view + path(route='contact', view=views.contact, name='contact'), # path for registration + path(route='registeration', view=views.registration_request, name='registeration'), # path for login + path(route='login', view=views.login_request, name='login'), # path for logout - + path(route='logout', view=views.logout_request, name='logout'), path(route='', view=views.get_dealerships, name='index'), - + path(route='django/', view=views.get_templete, name='django'), # path for dealer reviews view # path for add a review view diff --git a/server/djangoapp/views.py b/server/djangoapp/views.py index 61cc664da0..e807fcbbf8 100644 --- a/server/djangoapp/views.py +++ b/server/djangoapp/views.py @@ -16,27 +16,47 @@ # Create your views here. - +def get_templete(request): + return render (request,'djangoapp/djangotemplete.html') # Create an `about` view to render a static about page -# def about(request): -# ... +def about(request): + return render (request,'djangoapp/about.html') # Create a `contact` view to return a static contact page -#def contact(request): +def contact(request): + return render (request,'djangoapp/contact.html') # Create a `login_request` view to handle sign in request -# def login_request(request): -# ... - +def login_request(request): + if request.method == "POST": + username = request.POST['username'] + password = request.POST['psw'] + user = authenticate(username=username, password=password) + if user is not None: + login(request, user) + return redirect('/djangoapp/about') + else: + return render(request,'djangoapp/login.html') + else: + return render(request, 'djangoapp/login.html') # Create a `logout_request` view to handle sign out request -# def logout_request(request): -# ... - +def logout_request(request): + logout(request) + return redirect('/djangoapp/login') # Create a `registration_request` view to handle sign up request -# def registration_request(request): -# ... - +def registration_request(request): + if request.method == 'GET': + return render(request, 'djangoapp/registration.html') + elif request.method == 'POST': + username = request.POST['username'] + password = request.POST['psw'] + first_name = request.POST['firstname'] + last_name = request.POST['lastname'] + user = User.objects.create_user(username=username, first_name=first_name, last_name=last_name, + password=password) + return render(request, 'djangoapp/login.html') + return render(request, 'djangoapp/registration.html') # Update the `get_dealerships` view to render the index page with a list of dealerships def get_dealerships(request): context = {}