Example #1
0
File: views.py Project: brownplt/k3
 def delete(self, grantable):
   grants = grantable.my_grants()
   if len(grants) == 0:
     return logWith404(logger, 'ARDeleteHandler fatal error: no grant')
   area = grantable.area
   area.delete()
   return bcap.bcapNullResponse()
Example #2
0
File: views.py Project: brownplt/k3
 def delete(self, grantable):
   grants = grantable.my_grants()
   if len(grants) == 0:
     return logWith404(logger, 'UnverifiedUserDeleteHandler fatal error: no grant')
   uu = grantable.unverifieduser
   uu.delete()
   return bcap.bcapNullResponse()
Example #3
0
File: views.py Project: brownplt/k3
 def delete(self, grantable):
   grants = Grant.objects.filter(db_entity=grantable)
   if len(grants) == 0:
     return logWith404(logger, 'UnverifiedUserDeleteHandler fatal error: no grant')
   uu = grantable.unverifieduser
   uu.delete()
   return bcap.bcapNullResponse()
Example #4
0
File: views.py Project: brownplt/k3
 def delete(self, grantable):
   grants = Grant.objects.filter(db_entity=grantable)
   if len(grants) == 0:
     return logWith404(logger, 'ARDeleteHandler fatal error: no grant')
   area = grantable.area
   area.delete()
   return bcap.bcapNullResponse()
Example #5
0
File: views.py Project: brownplt/k3
def glogin_landing(request):
  if request.method == 'GET':
    d = request.GET
  else:
    d = request.POST
  maybe_client_key = check_pending(request.path_info)
  if not maybe_client_key:
    return logWith404(logger, "Bad pending: %s" % request.path_info, level='error')

  # 11.4.2 Verifying directly with the OpenID Provider
  # 11.4.2.1.  Request Parameters
  #   . openid.mode
  #         Value: "check_authentication"
  #   . Exact copies of all fields from the authentication response, except
  #     for "openid.mode".
  # http://openid.net/specs/openid-authentication-2_0.html#check_auth
  verify = {}
  for e in d:
    verify[e] = d[e]
  verify['openid.mode'] = 'check_authentication'

  try:
    f = urllib2.urlopen("https://www.google.com/accounts/o8/ud", urllib.urlencode(verify))
    beginning = str(f.read()[0:13]) 
    
    if(beginning != 'is_valid:true'):
      return bcap.bcapResponse('fail')
  except urllib2.HTTPError as e:
    logger.error("ErrorResponse: %s" % e.read())
    return bcap.bcapNullResponse()
    
  identity = d['openid.identity']
  email = d['openid.ext1.value.email']

  q = GoogleCredentials.objects.filter(identity=identity)
  if len(q) == 0:
    station_cap = newStationCap()
    account = BelayAccount(station_url=station_cap.serialize())
    account.save()

    gc = GoogleCredentials(account=account, identity=identity)
    gc.save()
  else:
    account = q[0].account

  session_id = str(uuid.uuid4())
  session = BelaySession(account=account, session_id=session_id)
  session.save()

  response = render_to_response('glogin.html', {
    'clientkey': maybe_client_key,
    'station': account.station_url,
    'make_stash': bcap.regrant('make-stash', account).serialize(),
    'site_name': settings.SITE_NAME,
    'email': email
  })
  return response
Example #6
0
File: views.py Project: brownplt/k3
 def delete(self, grantable):
   grants = grantable.my_grants()
   if len(grants) == 0:
     return logWith404(logger, 'ScoreCategoryDeleteHandler fatal error: no grant')
   grantable.scorecategory.delete()
   return bcap.bcapNullResponse()
Example #7
0
File: views.py Project: brownplt/k3
 def delete(self, grantable):
   grants = Grant.objects.filter(db_entity=grantable)
   if len(grants) == 0:
     return logWith404(logger, 'ScoreCategoryDeleteHandler fatal error: no grant')
   grantable.scorecategory.delete()
   return bcap.bcapNullResponse()
Example #8
0
File: views.py Project: brownplt/k3
 def delete(self, granted):
   granted.stash.delete()
   return bcap.bcapNullResponse()
Example #9
0
File: views.py Project: brownplt/k3
 def put(self, granted, args):
   stash = granted.stash
   pd = bcap.dataPreProcess(args['private_data'])
   stash.stashed_content = pd
   stash.save()
   return bcap.bcapNullResponse()