def post(self):

        # upload new material on google drive
        user = UserData.get_current_user()
        if not user.is_server_admin():  # make sure user has an account to create course
            self.redirect('/')

        # [TODO]Benny: scheduled_update_date超醜,要改掉
        # [TODO]Benny: new_feature_performance要搬到CreateFeaturePerformance 這個handler
        scheduled_update_date = self.request.get('scheduled_update_date')
        scheduled_update_date = datetime.datetime.strptime(scheduled_update_date, "%Y-%m-%d")
        logging.info('scheduled_update_date: %s' %scheduled_update_date)
        index = self.request.get('performance_index')
        new_feature_performance = FeaturePerformance(
            scheduled_update_date=scheduled_update_date,
            index=index)
        new_feature_performance.put()

        feature_name = self.request.get('feature-name')
        summary = self.request.get('summary')
        KPIs = self.request.get('KPI')
        new_feature = Feature(name=feature_name,
                            summary=summary,
                            KPIs=KPIs.strip().split(','),
                            performances=[new_feature_performance.key]
                            )
        new_feature.put()



        self.redirect('/show-feature/%s' % new_feature.key.id()) # 
 def post(self):
     data = json.loads(self.request.body)
     value = data['value']
     key_id = data['key_id']
     feature_performance = FeaturePerformance.get_by_id(int(key_id))
     feature_performance.measured_date = datetime.datetime.now()
     feature_performance.value = float(value)
     feature_performance.put()
     return
    def get(self):

        # get all features and feature_performance to be chose
        # form page to create/update feature bet
        features = Feature.query().fetch()
        performances = FeaturePerformance.query().fetch()
        data = {
            'features': features,
        }
        return self.render('feature/create-feature-bet.html', data)
 def post(self):
     data = json.loads(self.request.body)
     index = data['index']
     scheduled_update_date = data['scheduled_update_date']
     scheduled_update_date = datetime.datetime.strptime(scheduled_update_date, "%Y-%m-%d")
     key_id = data['key_id']
     feature_performance = FeaturePerformance.get_by_id(int(key_id))
     if index:
         feature_performance.index = index
     if scheduled_update_date:
         feature_performance.scheduled_update_date = scheduled_update_date
     feature_performance.put()
     return