Ejemplo n.º 1
0
def index(request):
    user_count = User.all().count(999999)
    schedule_count = Schedule.all().count(999999)
    log_count = Log.all().count(999999)
    processes = Process.all().order('-created_at').fetch(1)
    process = processes[0] if len(processes) > 0 else None
    return render_to_response('index/index.html', {
        'user_count': user_count,
        'schedule_count': schedule_count,
        'log_count': log_count,
        'process': process,
    })
Ejemplo n.º 2
0
def summary_daily_schedules(request):
    if request.method == "POST":
        # プロセス名を取得
        process_name = request.values.get("name")
        process = Process(name=process_name, is_processed=False)
        process.put()

        # 対象日を取得
        target_date = request.values.get("date")
        if not target_date:
            raise BadRequest
        # 日付に変換
        date = datetime.strptime(target_date, "%Y%m%d")

        # 対象となるスケジュールを取得
        schedules = Schedule.schedules_from_date(date)
        logging.debug(schedules)

        # blobに書き込む
        file_name = files.blobstore.create(mime_type="application/octet-stream")
        with files.open(file_name, "a") as f:
            for schedule in schedules:
                f.write("user:%s date:%s\n" % (schedule.user.name, schedule.schedule_at))
        files.finalize(file_name)

        # blobキーを取得
        blob_key = files.blobstore.get_blob_key(file_name)
        process.content = str(blob_key)
        process.put()

    return Response(status=200)