# Path: data_model.py
# class PhoneLog(db.Model):
#   phone       = db.StringProperty()
#   to          = db.StringProperty(multiline=True)
#   date        = db.DateTimeProperty(auto_now_add=True)
#   body        = db.StringProperty(multiline=True,indexed=False)
#   smsID       = db.StringProperty(indexed=False)
#   outboundSMS = db.StringProperty(multiline=True,indexed=False)
# 
# Path: data_model.py
# class Caller(db.Model):
# 	# caller's phone number requests are sent from
# 	phone   = db.StringProperty(indexed=True)
#     # the SMB service number Caller has permission to use
# 	service = db.StringProperty()
# 	
# 	created = db.DateProperty(auto_now_add=True)
# 	expires = db.DateProperty()


import os
import logging
import webapp2
import twilio
import config
import paywall
from operator import itemgetter
from datetime import date
from datetime import timedelta
from google.appengine.api.labs.taskqueue import Task
from google.appengine.ext import db
from google.appengine.ext.webapp import template
from data_model import PhoneLog
from data_model import Caller
            task = Task(url='/loggingtask', params={'from':phone,
                                                    'to':phone,
                                                    'inboundBody':text,
                                                    'sid':'admin request',
                                                    'outboundBody':text,})
            task.add('eventlogger')

            # send the SMS out...
            task = Task(url='/admin/sendsms', params={'phone':phone,
                                                    'sid':'admin console',
                                                    'text':text,})
            task.add('smssender')

            return('Sent!')
        elif user:
            logging.error("illegal access to the admin console for sending sms messages!?! %s" % user.email())
            return('Not so fast!')

## end

class Histogram(webapp2.RequestHandler):
    def get(self):
      histogram = dict()
      output = ''

      startDate = date.today() - timedelta(days=7)
      endDate = date.today()
      for i in range(1,51):
          week = 'week'+str(i)
          s = startDate.isoformat()

# Path: data_model.py
# class PhoneLog(db.Model):
#   phone       = db.StringProperty()
#   to          = db.StringProperty(multiline=True)
#   date        = db.DateTimeProperty(auto_now_add=True)
#   body        = db.StringProperty(multiline=True,indexed=False)
#   smsID       = db.StringProperty(indexed=False)
#   outboundSMS = db.StringProperty(multiline=True,indexed=False)
# 
# Path: data_model.py
# class Caller(db.Model):
# 	# caller's phone number requests are sent from
# 	phone   = db.StringProperty(indexed=True)
#     # the SMB service number Caller has permission to use
# 	service = db.StringProperty()
# 	
# 	created = db.DateProperty(auto_now_add=True)
# 	expires = db.DateProperty()


# Path: admin.py
import os
import logging
import webapp2
import twilio
import config
import paywall
from operator import itemgetter
from datetime import date
from datetime import timedelta
from google.appengine.api.labs.taskqueue import Task
from google.appengine.ext import db
from google.appengine.ext.webapp import template
from data_model import PhoneLog
from data_model import Caller

            task = Task(url='/loggingtask', params={'from':phone,
                                                    'to':phone,
                                                    'inboundBody':text,
                                                    'sid':'admin request',
                                                    'outboundBody':text,})
            task.add('eventlogger')

            # send the SMS out...
            task = Task(url='/admin/sendsms', params={'phone':phone,
                                                    'sid':'admin console',
                                                    'text':text,})
            task.add('smssender')

            return('Sent!')
        elif user:
            logging.error("illegal access to the admin console for sending sms messages!?! %s" % user.email())
            return('Not so fast!')

## end

class Histogram(webapp2.RequestHandler):
    def get(self):
      histogram = dict()
      output = ''

      startDate = date.today() - timedelta(days=7)
      endDate = date.today()
      for i in range(1,51):
          week = 'week'+str(i)
          s = startDate.isoformat()

          e = endDate.isoformat()