def add_account(request):
  if not(request.user.is_authenticated()):
         return HttpResponseRedirect('/login/')
  url=request.GET.get('url','')
  #to rem trail 
  if url.endswith('/'):
        url=url.rpartition('/')[0]
  upref='http://'
  if(not(upref in url)):
        url=upref+url
  try:
	site= Website.objects.get(url=url)
  except:
  	site=get_site(url)
  if site==None:
  	return HttpResponseRedirect('/home/')
  user=request.user
  acnm  = request.GET.get('accname','')
  if acnm == '':
	acnm=url
  uname = request.GET.get('uname','')
  pwd=request.GET.get('pwd','')
  pwd=myencrypt(pwd, request.session["MKD1597"])
  st=Account(user=user,accname=acnm,site=site,username=uname,password=pwd)
  st.save()
  return HttpResponseRedirect('/home/')
Exemple #2
0
def add_account(request):
  if not(request.user.is_authenticated()):
          return HttpResponseRedirect('/loggedout/')
  url=request.POST.get('url','')
  if(url==''):
	return render_to_response("Uid/addsite.html",{'user':request.user})
  uname = request.POST.get('uname','')
  pwd=request.POST.get('pwd','')
  if(uname=='' or pwd==''):
	return render_to_response("Uid/addsite.html",{'Errstatus':"Fields should be filled",'url':url,'user':request.user})
  #to rem trail 
  if url.endswith('/'):
        url=url.rpartition('/')[0]
  url=url.rpartition("http://")[2]
  url=url.rpartition("https://")[2]
  url=url.rpartition("www.")[2]
  
  #if(not('http://' in url) and not('https://' in url)):
  #      url='http://'+url

  try:
	site= Website.objects.get(url=url)
  except:
  	site=get_site(url)
  if site==None:
	return render_to_response("Uid/addsite.html",{'Errstatus':"Some error Occured.Check whether the url has a login form",'url':url,'user':request.user})
  	#return HttpResponseRedirect('/home/')
  user=request.user
  acnm  = request.POST.get('accname','')
  if acnm == '' or acnm == 'Optional-Url used if blank':
	acnm=url.partition('://')[2].partition('/')[0]
  pwd=myencrypt(pwd, request.session["MKD1597"])
  st=Account(user=user,accname=acnm,site=site,username=uname,password=pwd)
  st.save()
  return HttpResponseRedirect('/home/')