This repository has been archived by the owner on Jun 16, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 32
CSOC TASK 2 #3
Open
atpug22
wants to merge
8
commits into
COPS-IITBHU:master
Choose a base branch
from
atpug22:master
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
CSOC TASK 2 #3
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
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
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,3 +0,0 @@ | ||
from django.contrib import admin | ||
|
||
# Register your models here. | ||
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,3 +0,0 @@ | ||
from django.db import models | ||
|
||
# Create your models here. | ||
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,15 @@ | ||
{% extends "store/base.html" %} | ||
|
||
{% block content %} | ||
<h1>Login here :</h1> | ||
<form method="post" action="{% url 'login' %}"> | ||
{% csrf_token %} | ||
{# A more "HTML" way of creating the login form#} | ||
<label for="username">Username:</label> | ||
<input type="text" name="username" placeholder="Username"> | ||
<label for="password">Password:</label> | ||
<input type="password" name="password" placeholder="Password"> | ||
<input type="submit" name="" value="Login"> | ||
<div id="error" style="color: red;">{%if error%}{{error}}{%endif%}</div> | ||
</form> | ||
{% endblock %} |
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,6 @@ | ||
{% extends "store/base.html" %} | ||
|
||
{% block content %} | ||
<h2>Logged Out</h2> | ||
<p>You have been logged out. You may <a href="{% url 'login' %}">log back in</a>.</p> | ||
{% endblock %} |
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,34 @@ | ||
{% extends "store/base.html" %} | ||
|
||
{% block content %} | ||
<h2>Sign up</h2> | ||
<form method="post"> | ||
{% csrf_token %} | ||
<div class="form-group"> | ||
<label>First Name:</label> | ||
<input type="text" name="firstname" class="form-control" placeholder="Enter First Name" id="inputFirstname" required/> | ||
</div> | ||
<div class="form-group"> | ||
<label>Last Name:</label> | ||
<input type="text" name="lastname" class="form-control" placeholder="Enter Last Name" id="inputLastname" required/> | ||
</div> | ||
<div class="form-group"> | ||
<label>Username:</label> | ||
<input type="text" class="form-control" placeholder="Enter Username" name="username" id="inputusername" required/> | ||
</div> | ||
<div class="form-group"> | ||
<label >Email:</label> | ||
<input type="email" class="form-control" placeholder="Enter Email" name="email" id="inputEmail"> | ||
</div> | ||
<div class="form-group"> | ||
<label>Password:</label> | ||
<input type="password" class="form-control" placeholder="Enter password" name="password1" id="inputPassword1" required/> | ||
</div> | ||
<div class="form-group"> | ||
<label>Enter Password Again:</label> | ||
<input type="password" class="form-control" placeholder="Re-Enter password" name="password2" id="inputPassword2" required/> | ||
</div> | ||
<button type="submit" class="btn btn-primary">Sign Up</button> | ||
{% if msg %}<script>alert("{{msg}}")</script>{% endif %} | ||
</form> | ||
{% endblock %} |
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,8 @@ | ||
from django.urls import path | ||
from authentication.views import * | ||
|
||
urlpatterns = [ | ||
path('login/', 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,59 @@ | ||
from django.shortcuts import render | ||
from django.shortcuts import render,redirect | ||
from django.contrib.auth import login,logout,authenticate | ||
from django.http import HttpResponseRedirect, HttpResponse | ||
from django.urls import reverse | ||
from django.contrib.auth.decorators import login_required | ||
from django.contrib.auth.models import User | ||
# Create your views here. | ||
|
||
|
||
def loginView(request): | ||
pass | ||
|
||
if request.method == 'POST': | ||
username = request.POST.get('username') | ||
password = request.POST.get('password') | ||
user = authenticate(username=username, password=password) | ||
if user: | ||
login(request,user) | ||
return redirect('/') | ||
else: | ||
return render(request, 'registration/login.html', {'error':"Invalid UserName or Password"}) | ||
else: | ||
return render(request, 'registration/login.html', {}) | ||
@login_required | ||
def logoutView(request): | ||
pass | ||
logout(request) | ||
return redirect('/') | ||
|
||
def registerView(request): | ||
pass | ||
if request.method=="POST": | ||
try: | ||
username=request.POST['username'] | ||
password1=request.POST['password1'] | ||
password2=request.POST['password2'] | ||
firstname=request.POST['firstname'] | ||
lastname=request.POST['lastname'] | ||
email=request.POST['email'] | ||
except: | ||
return render(request,'registration/register.html',{'msg':"Fill All The Fields"}) | ||
if password1 != password2: | ||
return render(request, 'registration/register.html', { 'msg': "Passwords not matching" }) | ||
try: | ||
user = User.objects.create_user( | ||
username = username, | ||
first_name = firstname, | ||
last_name = lastname, | ||
email = email, | ||
password = password1 | ||
) | ||
user.save() | ||
except: | ||
return render(request, 'registration/register.html', { 'msg': "Username already exists" }) | ||
user = authenticate(request, username=username, password=password1) | ||
if user is not None: | ||
login(request, user) | ||
return redirect('/') | ||
else: | ||
return render(request, 'registration/register.html', { 'msg': "User created Successfully" }) | ||
else: | ||
return render(request, 'registration/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
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,51 @@ | ||
function global:deactivate ([switch]$NonDestructive) { | ||
# Revert to original values | ||
if (Test-Path function:_OLD_VIRTUAL_PROMPT) { | ||
copy-item function:_OLD_VIRTUAL_PROMPT function:prompt | ||
remove-item function:_OLD_VIRTUAL_PROMPT | ||
} | ||
|
||
if (Test-Path env:_OLD_VIRTUAL_PYTHONHOME) { | ||
copy-item env:_OLD_VIRTUAL_PYTHONHOME env:PYTHONHOME | ||
remove-item env:_OLD_VIRTUAL_PYTHONHOME | ||
} | ||
|
||
if (Test-Path env:_OLD_VIRTUAL_PATH) { | ||
copy-item env:_OLD_VIRTUAL_PATH env:PATH | ||
remove-item env:_OLD_VIRTUAL_PATH | ||
} | ||
|
||
if (Test-Path env:VIRTUAL_ENV) { | ||
remove-item env:VIRTUAL_ENV | ||
} | ||
|
||
if (!$NonDestructive) { | ||
# Self destruct! | ||
remove-item function:deactivate | ||
} | ||
} | ||
|
||
deactivate -nondestructive | ||
|
||
$env:VIRTUAL_ENV="C:\Users\gupta\csoc-2020-task-2\myvenv" | ||
|
||
if (! $env:VIRTUAL_ENV_DISABLE_PROMPT) { | ||
# Set the prompt to include the env name | ||
# Make sure _OLD_VIRTUAL_PROMPT is global | ||
function global:_OLD_VIRTUAL_PROMPT {""} | ||
copy-item function:prompt function:_OLD_VIRTUAL_PROMPT | ||
function global:prompt { | ||
Write-Host -NoNewline -ForegroundColor Green '(myvenv) ' | ||
_OLD_VIRTUAL_PROMPT | ||
} | ||
} | ||
|
||
# Clear PYTHONHOME | ||
if (Test-Path env:PYTHONHOME) { | ||
copy-item env:PYTHONHOME env:_OLD_VIRTUAL_PYTHONHOME | ||
remove-item env:PYTHONHOME | ||
} | ||
|
||
# Add the venv to the PATH | ||
copy-item env:PATH env:_OLD_VIRTUAL_PATH | ||
$env:PATH = "$env:VIRTUAL_ENV\Scripts;$env:PATH" |
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,76 @@ | ||
# This file must be used with "source bin/activate" *from bash* | ||
# you cannot run it directly | ||
|
||
deactivate () { | ||
# reset old environment variables | ||
if [ -n "${_OLD_VIRTUAL_PATH:-}" ] ; then | ||
PATH="${_OLD_VIRTUAL_PATH:-}" | ||
export PATH | ||
unset _OLD_VIRTUAL_PATH | ||
fi | ||
if [ -n "${_OLD_VIRTUAL_PYTHONHOME:-}" ] ; then | ||
PYTHONHOME="${_OLD_VIRTUAL_PYTHONHOME:-}" | ||
export PYTHONHOME | ||
unset _OLD_VIRTUAL_PYTHONHOME | ||
fi | ||
|
||
# This should detect bash and zsh, which have a hash command that must | ||
# be called to get it to forget past commands. Without forgetting | ||
# past commands the $PATH changes we made may not be respected | ||
if [ -n "${BASH:-}" -o -n "${ZSH_VERSION:-}" ] ; then | ||
hash -r | ||
fi | ||
|
||
if [ -n "${_OLD_VIRTUAL_PS1:-}" ] ; then | ||
PS1="${_OLD_VIRTUAL_PS1:-}" | ||
export PS1 | ||
unset _OLD_VIRTUAL_PS1 | ||
fi | ||
|
||
unset VIRTUAL_ENV | ||
if [ ! "${1:-}" = "nondestructive" ] ; then | ||
# Self destruct! | ||
unset -f deactivate | ||
fi | ||
} | ||
|
||
# unset irrelevant variables | ||
deactivate nondestructive | ||
|
||
VIRTUAL_ENV="C:\Users\gupta\csoc-2020-task-2\myvenv" | ||
export VIRTUAL_ENV | ||
|
||
_OLD_VIRTUAL_PATH="$PATH" | ||
PATH="$VIRTUAL_ENV/Scripts:$PATH" | ||
export PATH | ||
|
||
# unset PYTHONHOME if set | ||
# this will fail if PYTHONHOME is set to the empty string (which is bad anyway) | ||
# could use `if (set -u; : $PYTHONHOME) ;` in bash | ||
if [ -n "${PYTHONHOME:-}" ] ; then | ||
_OLD_VIRTUAL_PYTHONHOME="${PYTHONHOME:-}" | ||
unset PYTHONHOME | ||
fi | ||
|
||
if [ -z "${VIRTUAL_ENV_DISABLE_PROMPT:-}" ] ; then | ||
_OLD_VIRTUAL_PS1="${PS1:-}" | ||
if [ "x(myvenv) " != x ] ; then | ||
PS1="(myvenv) ${PS1:-}" | ||
else | ||
if [ "`basename \"$VIRTUAL_ENV\"`" = "__" ] ; then | ||
# special case for Aspen magic directories | ||
# see http://www.zetadev.com/software/aspen/ | ||
PS1="[`basename \`dirname \"$VIRTUAL_ENV\"\``] $PS1" | ||
else | ||
PS1="(`basename \"$VIRTUAL_ENV\"`)$PS1" | ||
fi | ||
fi | ||
export PS1 | ||
fi | ||
|
||
# This should detect bash and zsh, which have a hash command that must | ||
# be called to get it to forget past commands. Without forgetting | ||
# past commands the $PATH changes we made may not be respected | ||
if [ -n "${BASH:-}" -o -n "${ZSH_VERSION:-}" ] ; then | ||
hash -r | ||
fi |
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,33 @@ | ||
@echo off | ||
|
||
rem This file is UTF-8 encoded, so we need to update the current code page while executing it | ||
for /f "tokens=2 delims=:." %%a in ('"%SystemRoot%\System32\chcp.com"') do ( | ||
set _OLD_CODEPAGE=%%a | ||
) | ||
if defined _OLD_CODEPAGE ( | ||
"%SystemRoot%\System32\chcp.com" 65001 > nul | ||
) | ||
|
||
set VIRTUAL_ENV=C:\Users\gupta\csoc-2020-task-2\myvenv | ||
|
||
if not defined PROMPT set PROMPT=$P$G | ||
|
||
if defined _OLD_VIRTUAL_PROMPT set PROMPT=%_OLD_VIRTUAL_PROMPT% | ||
if defined _OLD_VIRTUAL_PYTHONHOME set PYTHONHOME=%_OLD_VIRTUAL_PYTHONHOME% | ||
|
||
set _OLD_VIRTUAL_PROMPT=%PROMPT% | ||
set PROMPT=(myvenv) %PROMPT% | ||
|
||
if defined PYTHONHOME set _OLD_VIRTUAL_PYTHONHOME=%PYTHONHOME% | ||
set PYTHONHOME= | ||
|
||
if defined _OLD_VIRTUAL_PATH set PATH=%_OLD_VIRTUAL_PATH% | ||
if not defined _OLD_VIRTUAL_PATH set _OLD_VIRTUAL_PATH=%PATH% | ||
|
||
set PATH=%VIRTUAL_ENV%\Scripts;%PATH% | ||
|
||
:END | ||
if defined _OLD_CODEPAGE ( | ||
"%SystemRoot%\System32\chcp.com" %_OLD_CODEPAGE% > nul | ||
set _OLD_CODEPAGE= | ||
) |
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,21 @@ | ||
@echo off | ||
|
||
if defined _OLD_VIRTUAL_PROMPT ( | ||
set "PROMPT=%_OLD_VIRTUAL_PROMPT%" | ||
) | ||
set _OLD_VIRTUAL_PROMPT= | ||
|
||
if defined _OLD_VIRTUAL_PYTHONHOME ( | ||
set "PYTHONHOME=%_OLD_VIRTUAL_PYTHONHOME%" | ||
set _OLD_VIRTUAL_PYTHONHOME= | ||
) | ||
|
||
if defined _OLD_VIRTUAL_PATH ( | ||
set "PATH=%_OLD_VIRTUAL_PATH%" | ||
) | ||
|
||
set _OLD_VIRTUAL_PATH= | ||
|
||
set VIRTUAL_ENV= | ||
|
||
:END |
Binary file not shown.
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,5 @@ | ||
#!c:\users\gupta\csoc-2020-task-2\myvenv\scripts\python.exe | ||
from django.core import management | ||
|
||
if __name__ == "__main__": | ||
management.execute_from_command_line() |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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,3 @@ | ||
home = C:\Users\gupta\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0 | ||
include-system-site-packages = false | ||
version = 3.7.7 |
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.
Looks good!