Skip to content

Commit

Permalink
third commit
Browse files Browse the repository at this point in the history
  • Loading branch information
tanaynaik2001 committed Jul 2, 2020
1 parent 2df1f20 commit 777be07
Show file tree
Hide file tree
Showing 13 changed files with 184 additions and 4 deletions.
Binary file modified CODEMIX/CODEMIX/__pycache__/settings.cpython-38.pyc
Binary file not shown.
Binary file added CODEMIX/CODEMIX/__pycache__/urls.cpython-38.pyc
Binary file not shown.
Binary file added CODEMIX/CODEMIX/__pycache__/wsgi.cpython-38.pyc
Binary file not shown.
3 changes: 2 additions & 1 deletion CODEMIX/CODEMIX/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import os


# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

Expand Down Expand Up @@ -54,7 +55,7 @@
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'DIRS': [os.path.join(BASE_DIR,'templates')],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
Expand Down
3 changes: 2 additions & 1 deletion CODEMIX/CODEMIX/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path
from django.urls import path,include

urlpatterns = [
path('',include('farmer.urls')),
path('admin/', admin.site.urls),
]
File renamed without changes.
Binary file added CODEMIX/farmer/__pycache__/__init__.cpython-38.pyc
Binary file not shown.
Binary file added CODEMIX/farmer/__pycache__/urls.cpython-38.pyc
Binary file not shown.
Binary file added CODEMIX/farmer/__pycache__/views.cpython-38.pyc
Binary file not shown.
7 changes: 7 additions & 0 deletions CODEMIX/farmer/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from django.urls import path
from . import views

urlpatterns=[
path('',views.farmer,name='farmer'),
path('farmerlogin',views.farmerlogin,name='farmerlogin')
]
42 changes: 40 additions & 2 deletions CODEMIX/farmer/views.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,41 @@
from django.shortcuts import render

from django.shortcuts import render,redirect
from django.contrib.auth.models import User,auth
from django.contrib import messages
# Create your views here.

def farmerlogin(request):
if request.method == 'POST':
first_name = request.POST['first_name']
# aadhar = request.POST['aadhar']
password=request.POST['password1']

user = auth.authenticate(first_name=first_name,password=password)

if user is not None:
auth.login(request, user)
return redirect('/')

else:
messages.info(request, 'Enter the correct password')
return redirect('farmerlogin')
else:
return render(request,'farmerlogin.html')
def farmer(request):
if request.method=='POST':
first_name=request.POST['first_name']
last_name=request.POST['last_name']
aadhar=request.POST['aadhar']
password1=request.POST['password1']
password2=request.POST['password2']

if password1==password2:
user=User.objets.create_user(first_name=first_name,last_name=last_name,email=aadhar,password=password1)
user.save()
return redirect('farmerlogin')

else:
messages.info(request, 'Password not matching')
return redirect('farmer')
return redirect('/')
else:
return render(request,'farmer.html')
71 changes: 71 additions & 0 deletions CODEMIX/templates/farmer.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<!DOCTYPE html>
<html>
<head>
<!--Import Google Icon Font-->
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<!--Import materialize.css-->

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css">


<!--Let browser know website is optimized for mobile-->
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<style>
@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@300&display=swap');

.nav-wrapper{
background-image: linear-gradient(to right, #434343 0%, black 100%);
}
#btn{
background-color: #333;
}
form{
margin-top: 100px;
}
</style>
</head>

<body>

<nav>
<div class="nav-wrapper">
<a href="/" class="brand-logo center">SELLBUY</a>
<!-- <a href="" class="sidenav-trigger" data-target='mobile-demo'><i class="material-icons right">menu</i></a>
<ul class="right hide-on-med-and-down">
<li><a href=""></a></li>
</ul> -->

</div>
</nav>
<div class="container">
<h3>Create Account</h3>
<form action="farmer" class="col s12">
{% csrf_token %}
<div class="input-field">
<input type="text" name="first_name">
<label for="">First Name</label>
</div>
<div class="input-field">
<input type="text" name="last_name">
<label for="">Last Name</label>
</div>
<div class="input-field">
<input type="text" name="aadhar">
<label for="">Aadhar Card number</label>
</div>
<div class="input-field">
<input type="password" name="password1" id="">
<label for="">Enter password</label>
</div>
<div class="input-field">
<input type="password" name="password2" id="">
<label for="">Confirm password1</label>
</div>
<input type="submit" value="Submit" class="btn" id="btn">

</form>
</div>
<!--JavaScript at end of body for optimized loading-->
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
</body>
</html>
62 changes: 62 additions & 0 deletions CODEMIX/templates/farmerlogin.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<!DOCTYPE html>
<html>
<head>
<!--Import Google Icon Font-->
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<!--Import materialize.css-->

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css">


<!--Let browser know website is optimized for mobile-->
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<style>
@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@300&display=swap');

.nav-wrapper{
background-image: linear-gradient(to right, #434343 0%, black 100%);
}
#btn{
background-color: #333;
}
form{
margin-top: 100px;
}
</style>
</head>

<body>

<nav>
<div class="nav-wrapper">
<a href="/" class="brand-logo center">SELLBUY</a>
<!-- <a href="" class="sidenav-trigger" data-target='mobile-demo'><i class="material-icons right">menu</i></a>
<ul class="right hide-on-med-and-down">
<li><a href=""></a></li>
</ul> -->

</div>
</nav>
<div class="container">
<h3>Create Account</h3>
<form action="farmerlogin" class="col s12">
{% csrf_token %}
<div class="input-field">
<input type="text" name="first_name">
<label for="">First Name</label>
</div>


<div class="input-field">
<input type="password" name="password1" id="">
<label for="">Enter password</label>
</div>

<input type="submit" value="Submit" class="btn" id="btn">

</form>
</div>
<!--JavaScript at end of body for optimized loading-->
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
</body>
</html>

0 comments on commit 777be07

Please sign in to comment.