Esempio n. 1
0
def mygeni(request):
  try:
    user = _validate_and_get_geniuser(request)
  except LoggedInButFailedGetGeniUserError:
    return _show_failed_get_geniuser_page(request)
  
  total_vessel_credits = interface.get_total_vessel_credits(user)
  num_acquired_vessels = len(interface.get_acquired_vessels(user))
  avail_vessel_credits = interface.get_available_vessel_credits(user)
  
  if num_acquired_vessels > total_vessel_credits:
    percent_total_used = 100
    over_vessel_credits = num_acquired_vessels - total_vessel_credits
  else:
    percent_total_used = int((num_acquired_vessels * 1.0 / total_vessel_credits * 1.0) * 100.0)
    over_vessel_credits = 0
  
  # total_vessel_credits, percent_total_used, avail_vessel_credits
  return direct_to_template(request, 'control/mygeni.html',
                            {'username' : user.username,
                             'total_vessel_credits' : total_vessel_credits,
                             'used_vessel_credits' : num_acquired_vessels,
                             'percent_total_used' : percent_total_used,
                             'avail_vessel_credits' : avail_vessel_credits,
                             'over_vessel_credits' : over_vessel_credits})
Esempio n. 2
0
def mygeni(request):
  try:
    user = _validate_and_get_geniuser(request)
  except LoggedInButFailedGetGeniUserError:
    return _show_failed_get_geniuser_page(request)
  
  total_vessel_credits = interface.get_total_vessel_credits(user)
  num_acquired_vessels = len(interface.get_acquired_vessels(user))
  avail_vessel_credits = interface.get_available_vessel_credits(user)
  
  if num_acquired_vessels > total_vessel_credits:
    percent_total_used = 100
    over_vessel_credits = num_acquired_vessels - total_vessel_credits
  else:
    percent_total_used = int((num_acquired_vessels * 1.0 / total_vessel_credits * 1.0) * 100.0)
    over_vessel_credits = 0
  
  # total_vessel_credits, percent_total_used, avail_vessel_credits
  return direct_to_template(request, 'control/mygeni.html',
                            {'username' : user.username,
                             'total_vessel_credits' : total_vessel_credits,
                             'used_vessel_credits' : num_acquired_vessels,
                             'percent_total_used' : percent_total_used,
                             'avail_vessel_credits' : avail_vessel_credits,
                             'over_vessel_credits' : over_vessel_credits})
Esempio n. 3
0
def myvessels(request,
              get_form=False,
              action_summary="",
              action_detail="",
              remove_summary=""):
    try:
        user = _validate_and_get_geniuser(request)
    except LoggedInButFailedGetGeniUserError:
        return _show_failed_get_geniuser_page(request)

    # get_form of None means don't show the form to acquire vessels.
    if interface.get_available_vessel_credits(user) == 0:
        get_form = None
    elif get_form is False:
        get_form = forms.gen_get_form(user)

    # shared vessels that are used by others but which belong to this user (TODO)
    shvessels = []

    # this user's used vessels
    my_vessels_raw = interface.get_acquired_vessels(user)
    my_vessels = interface.get_vessel_infodict_list(my_vessels_raw)

    # this user's number of donations, max vessels, total vessels and free credits
    my_donations = interface.get_donations(user)
    my_max_vessels = interface.get_available_vessel_credits(user)
    my_free_vessel_credits = interface.get_free_vessel_credits_amount(user)
    my_total_vessel_credits = interface.get_total_vessel_credits(user)

    for vessel in my_vessels:
        if vessel["expires_in_seconds"] <= 0:
            # We shouldn't ever get here, but just in case, let's handle it.
            vessel["expires_in"] = "Expired"
        else:
            days = vessel["expires_in_seconds"] / (3600 * 24)
            hours = vessel["expires_in_seconds"] / 3600 % 24
            minutes = vessel["expires_in_seconds"] / 60 % 60
            vessel["expires_in"] = "%dd %dh %dm" % (days, hours, minutes)

    # return the used resources page constructed from a template
    return direct_to_template(
        request, 'control/myvessels.html', {
            'username': user.username,
            'num_vessels': len(my_vessels),
            'my_vessels': my_vessels,
            'sh_vessels': shvessels,
            'get_form': get_form,
            'action_summary': action_summary,
            'action_detail': action_detail,
            'my_donations': len(my_donations),
            'my_max_vessels': my_max_vessels,
            'free_vessel_credits': my_free_vessel_credits,
            'total_vessel_credits': my_total_vessel_credits,
            'remove_summary': remove_summary
        })
Esempio n. 4
0
def myvessels(request, get_form=False, action_summary="", action_detail="", remove_summary=""):
  try:
    user = _validate_and_get_geniuser(request)
  except LoggedInButFailedGetGeniUserError:
    return _show_failed_get_geniuser_page(request)
  
  # get_form of None means don't show the form to acquire vessels.
  if interface.get_available_vessel_credits(user) == 0:
    get_form = None
  elif get_form is False:
    get_form = forms.gen_get_form(user)

  # shared vessels that are used by others but which belong to this user (TODO)
  shvessels = []

  # this user's used vessels
  my_vessels_raw = interface.get_acquired_vessels(user)
  my_vessels = interface.get_vessel_infodict_list(my_vessels_raw)
  
  # this user's number of donations, max vessels, total vessels and free credits
  my_donations = interface.get_donations(user)
  my_max_vessels = interface.get_available_vessel_credits(user)	
  my_free_vessel_credits = interface.get_free_vessel_credits_amount(user)
  my_total_vessel_credits = interface.get_total_vessel_credits(user)

  for vessel in my_vessels:
    if vessel["expires_in_seconds"] <= 0:
      # We shouldn't ever get here, but just in case, let's handle it.
      vessel["expires_in"] = "Expired"
    else:
      days = vessel["expires_in_seconds"] / (3600 * 24)
      hours = vessel["expires_in_seconds"] / 3600 % 24
      minutes = vessel["expires_in_seconds"] / 60 % 60
      vessel["expires_in"] = "%dd %dh %dm" % (days, hours, minutes)

  # return the used resources page constructed from a template
  return direct_to_template(request, 'control/myvessels.html',
                            {'username' : user.username,
                             'num_vessels' : len(my_vessels),
                             'my_vessels' : my_vessels,
                             'sh_vessels' : shvessels,
                             'get_form' : get_form,
                             'action_summary' : action_summary,
                             'action_detail' : action_detail,
                             'my_donations' : len(my_donations),
                             'my_max_vessels' : my_max_vessels, 
                             'free_vessel_credits' : my_free_vessel_credits,
                             'total_vessel_credits' : my_total_vessel_credits,
                             'remove_summary' : remove_summary})
Esempio n. 5
0
 def get_account_info(auth):
   """
   <Purpose>
     Gets a user's account info for a client over XMLRPC.
   <Arguments>
     auth
       An authorization dict.
   <Exceptions>
     None.
   <Returns>
     A dictionary containing account info.
   """
   geni_user = _auth(auth)
   user_port = geni_user.usable_vessel_port
   user_name = geni_user.username
   max_vessels = interface.get_total_vessel_credits(geni_user)
   user_affiliation = geni_user.affiliation
   infodict = {'user_port':user_port, 'user_name':user_name,
               'max_vessels':max_vessels, 'user_affiliation':user_affiliation}
   return infodict