Example #1
0
 def post(self):
     plan_id = int(self.request.get('plan_id'))
     plan = Plan.get_by_id(plan_id)
     user = plan.user
     if user.owner != current_user:
         return
     plan.delete()
     json.dump(get_user_plans(user), self.response.out)
Example #2
0
def get_user_plans(user):
    return [{
        'plan_id': plan.key().id(),
        'status': plan.status,
        'plan_time':
            (plan.plan_time + utc_fix).strftime('%Y-%m-%d %H:%M'),
        'exec_time':
            (plan.exec_time + utc_fix).strftime('%Y-%m-%d %H:%M')
                        if plan.exec_time else None,
        'interval': plan.interval,
        'result': plan.result,
        } for plan in
              Plan.all().filter('user ='******'-plan_time')]
Example #3
0
    def post(self):
        user_id = self.request.get('user_id')
        users = User.all().filter('owner =', current_user)
        the_user = users.filter('user_id =', user_id)
        if not the_user.count():
            return
        the_user = the_user.fetch(1)[0]
        plans = Plan.all().filter('user ='******'users': convert_users_list(users),
                'plans': get_user_plans(users[0]) if users else [],
                }
        json.dump(data, self.response.out)
Example #4
0
 def post(self):
     plan_id = int(self.request.get('plan_id'))
     plan = Plan.get_by_id(plan_id)
     if not plan:
         return
     user = plan.user
     if user.owner != current_user:
         return
     status = self.request.get('status')
     if status:
         plan_time = datetime.strptime(self.request.get('plan_time'), 
                                       '%Y-%m-%d %H:%M') - utc_fix
         interval = int(self.request.get('interval'))
         if interval and plan_time <= datetime.now():
             plan_time = next_time(plan_time, interval)
         plan.status = status
         plan.plan_time = plan_time
         plan.interval = interval
         plan.put()
     json.dump(get_user_plans(user), self.response.out)