-
Notifications
You must be signed in to change notification settings - Fork 42
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
All tasks done #14
Open
RainaJain5
wants to merge
1
commit into
COPS-IITBHU:master
Choose a base branch
from
RainaJain5:myBranch
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
All tasks done #14
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<title>Login</title> | ||
<link href="//netdna.bootstrapcdn.com/bootstrap/3.1.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"> | ||
<script src="//netdna.bootstrapcdn.com/bootstrap/3.1.0/js/bootstrap.min.js"></script> | ||
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script> | ||
|
||
</head> | ||
<body class="text-center"> | ||
<div class="container my-4"> | ||
<hr> | ||
<div id="loginbox" style="margin-top:50px;" class="mainbox col-md-6 col-md-offset-3 col-sm-8 col-sm-offset-2"> | ||
<div class="panel panel-info" > | ||
<div class="panel-heading"> | ||
<div class="panel-title">Sign In</div> | ||
|
||
</div> | ||
|
||
<div style="padding-top:30px" class="panel-body" > | ||
|
||
<div style="display:none" id="login-alert" class="alert alert-danger col-sm-12"></div> | ||
|
||
<form id="loginform" class="form-horizontal" role="form" method="post" action="/"> | ||
{% csrf_token %} | ||
|
||
<div style="margin-bottom: 25px" class="input-group"> | ||
<span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span> | ||
<input id="login-username" type="text" class="form-control" name="username" value="" placeholder="username"> | ||
</div> | ||
|
||
<div style="margin-bottom: 25px" class="input-group"> | ||
<span class="input-group-addon"><i class="glyphicon glyphicon-lock"></i></span> | ||
<input id="login-password" type="password" class="form-control" name="password" placeholder="password"> | ||
</div> | ||
|
||
<div style="margin-top:10px" class="form-group"> | ||
<!-- Button --> | ||
|
||
<div class="col-sm-12 controls"> | ||
<button id="btn-login" class="btn btn-success">Login</button> | ||
</div> | ||
</div> | ||
{% if messages %} | ||
{% for message in messages %} | ||
{% if message.tags %} <script>alert("{{ message }}")</script> {% endif %} | ||
{% endfor %} | ||
{% endif %} | ||
<div class="form-group"> | ||
<div class="col-md-12 control"> | ||
<div style="border-top: 1px solid#888; padding-top:15px; font-size:85%" > | ||
Don't have an account! | ||
<a href="/register"> | ||
Sign Up Here </a> | ||
</div> | ||
</div> | ||
</div> | ||
</form> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<title>Login</title> | ||
<link href="//netdna.bootstrapcdn.com/bootstrap/3.1.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"> | ||
<script src="//netdna.bootstrapcdn.com/bootstrap/3.1.0/js/bootstrap.min.js"></script> | ||
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script> | ||
|
||
</head> | ||
<body class="text-center"> | ||
<div class="container my-4"> | ||
<hr> | ||
<div id="signupbox" style="margin-top:50px;" class="mainbox col-md-6 col-md-offset-3 col-sm-8 col-sm-offset-2"> | ||
<div class="panel panel-info" > | ||
<div class="panel-heading"> | ||
<div class="panel-title">Sign Up</div> | ||
|
||
</div> | ||
|
||
<div style="padding-top:30px" class="panel-body" > | ||
<div style="display:none" id="login-alert" class="alert alert-danger col-sm-12"></div> | ||
|
||
<form id="signupform" class="form-horizontal" role="form" method="post" action="/register"> | ||
{% csrf_token %} | ||
|
||
<div id="signupalert" style="display:none" class="alert alert-danger"> | ||
<p>Error:</p> | ||
<span></span> | ||
</div> | ||
<div class="form-group"> | ||
<label for="email" class="col-md-3 control-label">Username</label> | ||
<div class="col-md-9"> | ||
<input type="text" class="form-control" name="regusername" placeholder="Username"> | ||
</div> | ||
</div> | ||
<div class="form-group"> | ||
<label for="firstname" class="col-md-3 control-label">First Name</label> | ||
<div class="col-md-9"> | ||
<input type="text" class="form-control" name="firstname" placeholder="First Name"> | ||
</div> | ||
</div> | ||
<div class="form-group"> | ||
<label for="firstname" class="col-md-3 control-label">Last Name</label> | ||
<div class="col-md-9"> | ||
<input type="text" class="form-control" name="lastname" placeholder="Last Name"> | ||
</div> | ||
</div> | ||
<div class="form-group"> | ||
<label for="lastname" class="col-md-3 control-label">Email</label> | ||
<div class="col-md-9"> | ||
<input type="email" class="form-control" name="email" placeholder="Email"> | ||
</div> | ||
</div> | ||
<div class="form-group"> | ||
<label for="password" class="col-md-3 control-label">Password</label> | ||
<div class="col-md-9"> | ||
<input type="password" class="form-control" name="regpassword" placeholder="Password"> | ||
</div> | ||
</div> | ||
|
||
<div class="form-group"> | ||
<!-- Button --> | ||
<div class="col-md-offset-3 col-md-9"> | ||
<button id="btn-signup" class="btn btn-info"><i class="icon-hand-right"></i> Sign Up</button> | ||
</div> | ||
</div> | ||
{% if messages %} | ||
{% for message in messages %} | ||
{% if message.tags %} <script>alert("{{ message }}")</script> {% endif %} | ||
{% endfor %} | ||
{% endif %} | ||
|
||
<div style="border-top: 1px solid #999; padding-top:20px" class="form-group" font-size:85%" > | ||
Already have an account? | ||
<a href="/"> | ||
Sign In</a> | ||
</div> | ||
</div> | ||
</form> | ||
</div> | ||
</div> | ||
</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from django.contrib import admin | ||
from django.urls import path, include | ||
from authentication.views import * | ||
|
||
urlpatterns = [ | ||
path('',loginView, name="login"), | ||
path('logout',logoutView, name="logout"), | ||
path('register',registerView, name="register"), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,66 @@ | ||
from django.shortcuts import render | ||
from django.shortcuts import redirect, render | ||
from django.contrib.auth import login,logout,authenticate | ||
from django.contrib.auth.models import User | ||
from django.views.decorators.cache import cache_control | ||
from django.contrib.auth.decorators import login_required | ||
from django.contrib import messages | ||
from django.http import * | ||
# Create your views here. | ||
|
||
|
||
def loginView(request): | ||
pass | ||
username = password = '' | ||
if request.POST: | ||
username= request.POST.get('username') | ||
password= request.POST.get('password') | ||
|
||
if(username=="" or password==""): | ||
messages.info(request, 'Please fill all fields') | ||
return redirect("/") | ||
|
||
user = authenticate(username=username, password=password) | ||
if user is not None: | ||
login(request, user) | ||
return redirect("/store") | ||
|
||
else: | ||
messages.info(request, 'Inavlid Username/Password') | ||
return redirect("/") | ||
|
||
return render(request,'login.html') | ||
|
||
@cache_control(no_cache=True, must_revalidate=True, no_store=True) | ||
@login_required | ||
def logoutView(request): | ||
pass | ||
|
||
logout(request) | ||
return render(request,'login.html') | ||
|
||
def registerView(request): | ||
pass | ||
if request.POST: | ||
reg_username= request.POST.get('regusername') | ||
reg_email = request.POST.get('email') | ||
reg_password = request.POST.get('regpassword') | ||
reg_name = request.POST.get('firstname') | ||
|
||
if(reg_username=="" or reg_password=="" or reg_email=="" or reg_name==""): | ||
messages.info(request, 'Please fill all fields') | ||
return redirect("/register") | ||
|
||
if User.objects.filter(username=reg_username).exists(): | ||
messages.info(request, 'Username already exists') | ||
return redirect("/register") | ||
|
||
if User.objects.filter(email=reg_email).exists(): | ||
messages.info(request, 'Email already exists') | ||
return redirect("/register") | ||
|
||
user = User.objects.create_user(reg_username, reg_email, reg_password) | ||
user.first_name = reg_name | ||
user.email = reg_email | ||
user.save() | ||
user = authenticate(username=reg_username, password=reg_password) | ||
if user is not None: | ||
login(request, user) | ||
return redirect("/store") | ||
|
||
return render(request,'register.html') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ | |
|
||
admin.site.register(Book) | ||
admin.site.register(BookCopy) | ||
admin.site.register(BookRating) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Generated by Django 2.2.1 on 2021-07-18 10:29 | ||
|
||
from django.conf import settings | ||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
('store', '0002_auto_20190607_1302'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='bookcopy', | ||
name='borrow_date', | ||
field=models.DateField(blank=True, null=True), | ||
), | ||
migrations.AlterField( | ||
model_name='bookcopy', | ||
name='borrower', | ||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='borrower', to=settings.AUTH_USER_MODEL), | ||
), | ||
migrations.CreateModel( | ||
name='BookRating', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('rating', models.IntegerField(default=0)), | ||
('book', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='store.Book')), | ||
('user', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='user', to=settings.AUTH_USER_MODEL)), | ||
], | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great use of validators here.