From 1d11e1006f9875a0be63b4d381ecce78dda817aa Mon Sep 17 00:00:00 2001 From: your_github_username Date: Sun, 13 Aug 2023 12:13:13 +0530 Subject: [PATCH 1/3] all changes done which are given in the module 1 --- server/db.sqlite3 | Bin 0 -> 131072 bytes .../djangoapp/templates/djangoapp/about.html | 5 +++ .../templates/djangoapp/contact.html | 15 +++++++++ .../djangoapp/templates/djangoapp/index.html | 31 +++++++++++++++++- server/djangoapp/urls.py | 2 ++ server/djangoapp/views.py | 10 +++++- 6 files changed, 61 insertions(+), 2 deletions(-) create mode 100644 server/db.sqlite3 create mode 100644 server/djangoapp/templates/djangoapp/about.html create mode 100644 server/djangoapp/templates/djangoapp/contact.html diff --git a/server/db.sqlite3 b/server/db.sqlite3 new file mode 100644 index 0000000000000000000000000000000000000000..73fe8075e6930e68f48375982bab0cccec09ed7b GIT binary patch literal 131072 zcmeI5Yiu0Xb;ozO%Uv$X-Qh#jsIg=YSEj8EMRVWe%1vWhT1%`c%A%;+1ZqrYcZbx< z`=EB0dcZ*2rDZ2@+5%0G04dPAC{Un9`=L(+MG~M$Q50>_CN1IueWYkVxebt{Xp!VY zYM|%dncaEpEV&}2LZJRMJetS3Xa47R@7$R=_YQgO>T0Q}$y>F0MQzGS&zMILJTJ=>^8KzvR$w3?lkoE zQc>SjXeFCUrelRzLD{XAZaK{-&#&i}H*)gzwUw*abMngCh1~0M#A$Va(};X!t-DY} zJ`>@>O2x=oIl|?Uo=CKHZag4uXN8t(MxY=rw(uHh7 zCyXep^1F3qy=IbDRtdbgi0TeC^-bDF+mqb6l@L%}{1rmC5< zRgJ}@P^&hzYEx<6+tFB)N^GSTGg>OotH!hwUFyUGwgdF{%EymozcRep7S z+^N;6Mc!8Hg&S)9Ogym^?KDejBxSYH zRLZsOQZ*tM)uz@gRW$4IQbTF%Qo~@4G$Q9~wX*dn+snED(|!mVU&>7j z9^M@`Zk6eAO`(b+dwRZMYsLdkyt6v8w>A`zvRUE&qFKLsTQaXM{le(l8+57pE~7&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|Ai10E{vu{mv9kxeYE0dkg()w*{}nQ)(ukNhZvP z4DQ<*&IuzNm*)*v`%eG4&)FU%P`ci1o+$FkV*%+Z^_FQz;QYm;VNU&{44P*;`_9L9}oZm5C8!X009sH0T2KI5C8!X0D(tD zVAAjNoO;UmOKc6}-=_wBp4rpJU*>4u+tC`9^--VCGd0EjOaS|n1|ctPNo +

+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..289c139c79 --- /dev/null +++ b/server/djangoapp/templates/djangoapp/contact.html @@ -0,0 +1,15 @@ + + + +
+

+ Contact information +

+
+
    Phone No: 555 834 6626
+
    Email: EpicCars11@gmail.com"
+
    Address:1818 West Way Ct.
+
+
+ + \ No newline at end of file diff --git a/server/djangoapp/templates/djangoapp/index.html b/server/djangoapp/templates/djangoapp/index.html index 1a9ee6e39a..e2492bc7dd 100644 --- a/server/djangoapp/templates/djangoapp/index.html +++ b/server/djangoapp/templates/djangoapp/index.html @@ -15,9 +15,38 @@ - This is the index page of your Django app! + + diff --git a/server/djangoapp/urls.py b/server/djangoapp/urls.py index 37b1c89d01..e633acd957 100644 --- a/server/djangoapp/urls.py +++ b/server/djangoapp/urls.py @@ -11,8 +11,10 @@ # 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 for login diff --git a/server/djangoapp/views.py b/server/djangoapp/views.py index 61cc664da0..a9761900cc 100644 --- a/server/djangoapp/views.py +++ b/server/djangoapp/views.py @@ -21,10 +21,18 @@ # def about(request): # ... - +def about(request): + context={} + if request.method == 'GET': + return render(request , 'djangoapp/about.html' , context) # Create a `contact` view to return a static contact page #def contact(request): +def contact(request): + context={} + if request.method == 'GET': + return render(request , 'djangoapp/contact.html' , context) + # Create a `login_request` view to handle sign in request # def login_request(request): # ... From 708afe20d15b610c124a99b8cf251dd4cda617e5 Mon Sep 17 00:00:00 2001 From: your_github_username Date: Mon, 21 Aug 2023 22:38:32 +0530 Subject: [PATCH 2/3] Completed the secound module --- server/db.sqlite3 | Bin 131072 -> 131072 bytes .../djangoapp/templates/djangoapp/index.html | 10 +- .../templates/djangoapp/registration.html | 116 +++++++++++++++++- server/djangoapp/urls.py | 3 + server/djangoapp/views.py | 48 ++++++-- 5 files changed, 164 insertions(+), 13 deletions(-) diff --git a/server/db.sqlite3 b/server/db.sqlite3 index 73fe8075e6930e68f48375982bab0cccec09ed7b..3b7acd05c3b4f238ebd2ba94526d28166541a50d 100644 GIT binary patch delta 866 zcmah{%Wl&^6t!st2_iMD0X2wLVv}^nb|#*PqE4H4BrH-VaqZYnVkfTMc#~A! zbp>C*k{uFsfy9;{=m&Jw4IjV{5LyXU*>rR_qpN$*x#yhuJUE{RKR&17rx&|4{C4c-c-OtnjsWJE?z|v%)>$0`@P2|3SIbmBJ$bB=`9SxSIVUibO z7;q@gKBg#&X8ur%dUWyZ@HZ2Fva%NXzw-M$@H9v>=M;0ksw^)4usWkR#Iq`yK;P{< zx-nHctgaee)0whpV8OVpIU~+Y#FWCxfu2rFUZ0dJN_&^p2r8B(zE=`_gQT-|#g@%n z%XEv514akO9Ot%OzA@}nVN_1|{9bb~Mqry_FS5 z0e{DoIN&+#&;fBuR9)vLL)_C04UPCtf55AW?il*2aIAL*W>4Y34eTCFRz*-nDQV~# zf}k~wlH8O0BVV(?7`7WDg~L9{)l2foc*A*1uzV8WSR5mO@vWOz6m!M=Sh)F>$!y$b z)PvV6V(31iix@=C0+(L`mvm$ihii(tW_~RIelp3mB{sLoyb|t4H&Mo!QEp>`ojxPS=K1=m2Af$PunRD {{ user.first_name }}({{ user.username }}) - Logout + Logout {% else %}
  • -
    + {% csrf_token %}
    - - + + - Sign Up + Sign Up
  • diff --git a/server/djangoapp/templates/djangoapp/registration.html b/server/djangoapp/templates/djangoapp/registration.html index ae11ea4b71..fc1d36d174 100644 --- a/server/djangoapp/templates/djangoapp/registration.html +++ b/server/djangoapp/templates/djangoapp/registration.html @@ -4,8 +4,122 @@ {% load static %} + - +
    +
    +
    + {% csrf_token %} +
    +

    Register

    +
    +
    +
    +
    +
    + +
    +
    + +
    +
    +
    +
    + +
    +
    + +
    +
    +
    +
    +
    +
    + +
    +
    + +
    +
    +
    +
    + +
    +
    + +
    +
    +
    +
    +
    + +
    +
    + + Show Password +
    +
    +
    + +
    + +
    +
    +
    + + + + + \ No newline at end of file diff --git a/server/djangoapp/urls.py b/server/djangoapp/urls.py index e633acd957..92b1f162e5 100644 --- a/server/djangoapp/urls.py +++ b/server/djangoapp/urls.py @@ -16,6 +16,9 @@ path(route='contact/', view=views.contact , name='contact'), # path for registration + path(route="register/", view=views.registration_request , name='registration_request'), + path(route="logout/" , view= views.logout_request, name="logout"), + path(route="login/",view=views.login_request,name="login_request"), # path for login diff --git a/server/djangoapp/views.py b/server/djangoapp/views.py index a9761900cc..eb1636d552 100644 --- a/server/djangoapp/views.py +++ b/server/djangoapp/views.py @@ -34,17 +34,51 @@ def contact(request): return render(request , 'djangoapp/contact.html' , context) # Create a `login_request` view to handle sign in request -# def login_request(request): -# ... +def login_request(request): + context = {} + if request.method == 'POST': + username = request.POST['Username'] + password = request.POST['Password'] + + user = authenticate(username=username , password = password) + if user is not None: + login(request,user) + return render(request,"djangoapp/index.html",context) + else: + return render(request,"djangoapp/index.html",context) + else: + return render(request,"djangoapp/index.html",context) # Create a `logout_request` view to handle sign out request -# def logout_request(request): -# ... +def logout_request(request): + print(f"User is logged out {request.user.username}") + logout(request) + return redirect("djangoapp:index") + # Create a `registration_request` view to handle sign up request -# def registration_request(request): -# ... - +def registration_request(request): + context={} + if request.method == 'GET': + return render(request ,'djangoapp/registration.html',context) + elif request.method == "POST": + username = request.POST['username'] + email = request.POST['email'] + password = request.POST['password'] + user_exits = False + try: + User.object.get(username=username) + user_exits = True + except: + logger.debug(f"{username} is a new user") + if not user_exits: + user = User.objects.create_user(username=username,password=password,email=email) + login(request,user) + return redirect('djangoapp:index') + else: + return render(request,'djangoapp/registration.html',context) + else: + return render(request,'djangoapp/registration.html',context) # Update the `get_dealerships` view to render the index page with a list of dealerships def get_dealerships(request): context = {} From 7238ce1b3574202039db6381f18174b1ea58e470 Mon Sep 17 00:00:00 2001 From: your_github_username Date: Mon, 21 Aug 2023 23:09:51 +0530 Subject: [PATCH 3/3] Created super user --- server/db.sqlite3 | Bin 131072 -> 131072 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/server/db.sqlite3 b/server/db.sqlite3 index 3b7acd05c3b4f238ebd2ba94526d28166541a50d..46df19cc21bde8b808e8df7b83bcf11d11dc72e6 100644 GIT binary patch delta 263 zcmZo@;Am*zm>|t)G*QNx(P(4BB6*Qn3~c;m4E!(ouki2YFXQj#U&CLqSn>1kSEN`#VpSV7hw`-W;SM=e2_xeWY{d~-J| zDoo_#ZB%69WoWcz;FRTc>gp5Zk?8C0QI(Wg6rL7R5Nu(YY#UINn(JU|t)I8nx#(QsqJB6*P&3~c;m4E!(ouki2YFXQj#pT%FXSFX-P(WX>n>10|SFF2bfooT9lhvT%4IN&dhAgIQbxt@aD_