Beispiel #1
0
 def post(self):
   username = self.request.get('email')
   
   accounts = None
   if not username:
     accounts = accounts_dao.get_all_accounts()
   else:
     entity = accounts_dao.get(username)
     if not entity:
       self.error(400)
       return
     accounts = []
     accounts.append(entity)
   
   alldata = {'usage':[]}
   ''' retrieve all usage information summary (just API calls) '''
   for acc in accounts:
     q = APICountBatch.all().filter("account_key =", acc.key().name())
     values = {"success": "true", "email" : acc.email}
     res = q.fetch(1000) 
     values['total'] = q.count() or 1
     monthsdict = {}
     for ii in res:
       monthyear = ii.date.strftime('%Y-%m')
       curr=monthsdict.get(monthyear)
       if not curr:
         curr = 0
       curr += int(ii.counter)
       monthsdict[monthyear] = curr
     values['months'] = monthsdict
     alldata['usage'].append(values)
   
   self.response.out.write(simplejson.dumps(alldata))
Beispiel #2
0
 def post(self):
   username = self.request.get('email')
   
   accounts = None
   if not username:
     accounts = accounts_dao.get_all_accounts()
   else:
     entity = accounts_dao.get(username)
     if not entity:
       self.error(400)
       return
     accounts = []
     accounts.append(entity)
   
   alldata = {'usage':[]}
   ''' retrieve all usage information summary (just API calls) '''
   for acc in accounts:
     q = APICountBatch.all().filter("account_key =", acc.key().name())
     values = {"success": "true", "email" : acc.email}
     res = q.fetch(1000) 
     values['total'] = q.count() or 1
     monthsdict = {}
     for ii in res:
       monthyear = ii.date.strftime('%Y-%m')
       curr=monthsdict.get(monthyear)
       if not curr:
         curr = 0
       curr += int(ii.counter)
       monthsdict[monthyear] = curr
     values['months'] = monthsdict
     alldata['usage'].append(values)
   
   self.response.out.write(json.dumps(alldata))
Beispiel #3
0
 def get(self):
     created_logs = ""
     for ii in constants.TEST_ACCOUNTS:
         acc = accounts_dao.get(ii)
         if acc:
             self.fill_with_api_logs(acc)
             created_logs = acc.key().name()
     if created_logs:
         self.response.out.write("Created logs for test account " + created_logs)
     else:
         self.response.out.write("Did not create any logs, create a test account first")
Beispiel #4
0
 def get(self):
     created_logs = ""
     for ii in constants.TEST_ACCOUNTS:
         acc = accounts_dao.get(ii)
         if acc:
             self.fill_with_api_logs(acc)
             created_logs = acc.key().name()
     if created_logs:
         self.response.out.write("Created logs for test account " +
                                 created_logs)
     else:
         self.response.out.write(
             "Did not create any logs, create a test account first")
def groom_account(email):
  """ 
      Check the account and make sure accounts are updated with newest 
      parameters, widgets, users, etc
  """
  acc = accounts_dao.get(email)
  if not acc:
    logging.error("Unable to locate account ref for " + str(email))
    return 

  if not check_or_create_anonymous_user(acc):
    logging.error("Unable to get/create anonymous user for " + str(email))
    return 

  if not has_milestone_widget(acc):
    logging.error("Unable to get/create milestone wildget for" + str(email))
    return 
Beispiel #6
0
def groom_account(email):
    """ 
      Check the account and make sure accounts are updated with newest 
      parameters, widgets, users, etc
  """
    acc = accounts_dao.get(email)
    if not acc:
        logging.error("Unable to locate account ref for " + str(email))
        return

    if not check_or_create_anonymous_user(acc):
        logging.error("Unable to get/create anonymous user for " + str(email))
        return

    if not has_milestone_widget(acc):
        logging.error("Unable to get/create milestone wildget for" +
                      str(email))
        return
Beispiel #7
0
 def getQuery(self, context, obj):
     account_key = context['account_key']
     account_ref = accounts_dao.get(account_key)
     return Badges.all().filter('creator =', account_ref)
Beispiel #8
0
 def getQuery(self, context, obj):
   account_key = context['account_key']
   account_ref = accounts_dao.get(account_key)
   return Badges.all().filter('creator =', account_ref)