Exemple #1
0
    def add_outline():
        """
        TOPページから練習概要の日付、開始・終了時間、時間帯、IDを追加
        """

        # フォームからデータを取得
        outline_id = int(datetime.strftime(datetime.now(), '%Y%m%d%H%M%S'))
        date = request.form.get('date')
        time_category = request.form.get('time_category')

        # DataStoreに格納
        if date and time_category:
            key1 = client.key('Outline')
            outline1 = datastore.Entity(key1)
            outline1.update({
                'outline_id': outline_id,
                'date': date,
                'time_category': time_category
            })
            client.put(outline1)

            key2 = client.key('Outline_yacht_player')
            outline2 = datastore.Entity(key2)
            outline2.update({'outline_id': outline_id})
            client.put(outline2)

        #TOPページで、入力せずに追加ボタンを押した場合は、TOPに戻る
        else:
            return redirect(url_for('top'))

        outline_selections = query.get_outline_selections()
        target_entities = query.get_outline_entities(outline_id)

        return render_template('show_outline.html', title="練習概要入力",\
                                target_entities=target_entities, outline_selections=outline_selections)
Exemple #2
0
    def show_outline(target_outline_id):
        """
        練習概要ページの内容を変更する画面に移動
        """

        outline_selections = query.get_outline_selections()
        target_entities = query.get_outline_entities(target_outline_id)

        return render_template('show_outline.html', title='練習概要変更',\
                                target_entities=target_entities, outline_selections=outline_selections)
Exemple #3
0
    def outline_detail(target_outline_id):
        """
        練習概要ページを表示する
        """

        # target_entities = self.outline_contents.get_outline_entities(target_outline_id)

        target_entities = query.get_outline_entities(target_outline_id)

        return render_template('outline_detail.html',\
                                title='練習概要', target_entities=target_entities)
Exemple #4
0
    def del_outline(target_outline_id):
        """
        練習概要ページの削除(動作テスト未)
        """

        # #Outline Kindと、Outline_yacht_player Kindのデータ
        # target_entities = self.outline_contents.get_outline_entities(target_outline_id)

        target_entities = query.get_outline_entities(target_outline_id)

        key1 = target_entities[0].key.id  #idを取得
        client.delete(key1)

        for outline2 in target_entities[1]:
            key2 = outline2.key.id
            client.delete(key2)

        return redirect(url_for('top'))
Exemple #5
0
    def mod_outline(target_outline_id):
        """
        練習概要ページのデータを修正・更新
        """

        target_entities = query.get_outline_entities(target_outline_id)

        #日付、時間、風、波、練習メニューの値をshow_outline.htmlから取得
        date = request.form.get('date')
        starttime = request.form.get('starttime')
        endtime = request.form.get('endtime')
        timecategory = request.form.get('timecategory')
        windspeedmin = request.form.get('windspeedmin')
        windspeedmax = request.form.get('windspeedmax')
        winddirectionmin = request.form.get('winddirectionmin')
        winddirectionmax = request.form.get('winddirectionmax')
        windspeedchange = request.form.get('windspeedchange')
        seasurface = request.form.get('seasurface')
        swell = request.form.get('swell')
        training1 = request.form.get('training1')
        training2 = request.form.get('training2')
        training3 = request.form.get('training3')
        training4 = request.form.get('training4')
        training5 = request.form.get('training5')
        training6 = request.form.get('training6')
        training7 = request.form.get('training7')
        training8 = request.form.get('training8')
        training9 = request.form.get('training9')
        training10 = request.form.get('training10')
        training11 = request.form.get('training11')
        training12 = request.form.get('training12')
        training13 = request.form.get('training13')
        training14 = request.form.get('training14')
        training15 = request.form.get('training15')

        if not target_entities[0]:
            raise ValueError('Outline {} does not exist.'.format(outline1))

        target_entities[0].update({
            'date': date,
            'start_time': starttime,
            'end_time': endtime,
            'time_category': timecategory,
            'wind_speed_min': int(windspeedmin),
            'wind_speed_max': int(windspeedmax),
            'wind_direction_min': int(winddirectionmin),
            'wind_direction_max': int(winddirectionmax),
            'wind_speed_change': str(windspeedchange),
            'sea_surface': str(seasurface),
            'swell': str(swell),
            'training1': training1,
            'training2': training2,
            'training3': training3,
            'training4': training4,
            'training5': training5,
            'training6': training6,
            'training7': training7,
            'training8': training8,
            'training9': training9,
            'training10': training10,
            'training11': training11,
            'training12': training12,
            'training13': training13,
            'training14': training14,
            'training15': training15
        })

        client.put(target_entities[0])

        #show_outline.htmlから取得した値を変数に代入
        for i, outline2 in enumerate(target_entities[1]):
            yachtnumber = request.form.get('yachtnumber' + str(i))
            devicename = request.form.get('devicename' + str(i))
            skipper1 = request.form.get('skipper1' + str(i))
            skipper2 = request.form.get('skipper2' + str(i))
            skipper3 = request.form.get('skipper3' + str(i))
            crew1 = request.form.get('crew1' + str(i))
            crew2 = request.form.get('crew2' + str(i))
            crew3 = request.form.get('crew3' + str(i))

            if not outline2:
                raise ValueError('Outline {} does not exist.'.format(outline2))

            outline2.update({
                'yacht_number': int(yachtnumber),
                'device_name': str(devicename),
                'skipper1': str(skipper1),
                'skipper2': str(skipper2),
                'skipper3': str(skipper3),
                'crew1': str(crew1),
                'crew2': str(crew2),
                'crew3': str(crew3)
            })

            client.put(outline2)

        return redirect(url_for('top'))