Skip to content

Update views.py #94

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

Open
wants to merge 1 commit into
base: haris989-patch-1
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 9 additions & 14 deletions textutils/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,22 @@ def analyze(request):
newlineremover = request.POST.get('newlineremover', 'off')
extraspaceremover = request.POST.get('extraspaceremover', 'off')
numberremover = request.POST.get('numberremover','off')

purpose = []
#Check which checkbox is on
if removepunc == "on":
punctuations = '''!()-[]{};:'"\,<>./?@#$%^&*_~'''
analyzed = ""
for char in djtext:
if char not in punctuations:
analyzed = analyzed + char

params = {'purpose':'Removed Punctuations', 'analyzed_text': analyzed}
purpose.append('Removed Punctuations')
djtext = analyzed

if(fullcaps=="on"):
analyzed = ""
for char in djtext:
analyzed = analyzed + char.upper()

params = {'purpose': 'Changed to Uppercase', 'analyzed_text': analyzed}
purpose.append('Changed to Uppercase')
djtext = analyzed

if(extraspaceremover=="on"):
Expand All @@ -47,17 +45,16 @@ def analyze(request):

elif not(djtext[index] == " " and djtext[index+1]==" "):
analyzed = analyzed + char

params = {'purpose': 'Removed NewLines', 'analyzed_text': analyzed}
purpose.append('Removed Extra Spaces')
djtext = analyzed

if (newlineremover == "on"):
analyzed = ""
for char in djtext:
if char != "\n" and char!="\r":
analyzed = analyzed + char

params = {'purpose': 'Removed NewLines', 'analyzed_text': analyzed}
purpose.append('Removed NewLines')
djtext = analyzed

if (numberremover == "on"):
analyzed = ""
Expand All @@ -66,15 +63,13 @@ def analyze(request):
for char in djtext:
if char not in numbers:
analyzed = analyzed + char

params = {'purpose': 'Removed NewLines', 'analyzed_text': analyzed}
djtext = analyzed

purpose.append('Removed Number')
params = {'purpose': purpose, 'analyzed_text': analyzed}

if(removepunc != "on" and newlineremover!="on" and extraspaceremover!="on" and fullcaps!="on" and numberremover != "on"):
return HttpResponse("please select any operation and try again")

return render(request, 'analyze.html', params)

def about(request):
return render(request, 'about.html')
return render(request, 'about.html')