示例#1
0
 def to_json(self):
     return {
         "code": self._coupon.code,
         "description": self._coupon.description,
         "striple_plan_id": self.stripe_plan_id,
         "valid": self.valid,
         "valid_thru": datetime_to_timestamp_ms(self.valid_thru),
     }
示例#2
0
 def get_json_for_day_framework_id(self, day_framework_id):
     if day_framework_id is None:
         return {}
     _day_framework = self.day_framework_id_to_obj[day_framework_id]
     return {
         "js_isoweekday": _day_framework.js_isoweekday,
         "cardio_level": _day_framework.level,
         "utc_date_timestamp": datetime_to_timestamp_ms(_day_framework.datetime)
     }
示例#3
0
 def _get_dynamo_for_user(cls, user_id):
     conn = dynamodb2.connect_to_region(
         REGION,
         aws_access_key_id=os.environ['AWS_ACCESS_KEY_ID'],
         aws_secret_access_key=os.environ['AWS_SECRET_ACCESS_KEY'],
     )
     table = Table(
         TABLE_NAME,
         connection=conn
     )
     results = table.query_2(
         user_id_hash__eq="workout_%s" % user_id,
         timestamp__between=[
             datetime_to_timestamp_ms(datetime.datetime.utcnow() - datetime.timedelta(days=7)),
             datetime_to_timestamp_ms(datetime.datetime.utcnow())
         ]
     )
     for dynamo_item in results:
         return dynamo_item.get("message", "")
     return "This is a test\n   this is a test"
     return ""