diff --git a/docker-compose.yaml b/docker-compose.yaml index 44e07a1..7bda0b7 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -53,7 +53,9 @@ services: - type: volume source: nginx_logs target: /var/log/nginx - - media_data:/app/media:ro + - type: bind + source: ./media + target: /usr/share/nginx/html/media ports: - "80:80" depends_on: @@ -73,4 +75,3 @@ volumes: geoserver-data: static_volume: nginx_logs: - media_data: diff --git a/rog/.views.py.swp b/rog/.models.py.swp similarity index 56% rename from rog/.views.py.swp rename to rog/.models.py.swp index d010457..e03a747 100644 Binary files a/rog/.views.py.swp and b/rog/.models.py.swp differ diff --git a/rog/.serializers.py.swp b/rog/.serializers.py.swp deleted file mode 100644 index cb59a7d..0000000 Binary files a/rog/.serializers.py.swp and /dev/null differ diff --git a/rog/.urls.py.swp b/rog/.urls.py.swp deleted file mode 100644 index 6b690aa..0000000 Binary files a/rog/.urls.py.swp and /dev/null differ diff --git a/rog/models.py b/rog/models.py index 4339589..d418fea 100644 --- a/rog/models.py +++ b/rog/models.py @@ -323,6 +323,8 @@ class NewEvent2(models.Model): class_solo_male = models.BooleanField(default=True) class_solo_female = models.BooleanField(default=True) + self_rogaining = models.BooleanField(default=False) + def __str__(self): return f"{self.event_name} - From:{self.start_datetime} To:{self.end_datetime}" diff --git a/rog/views.py b/rog/views.py index 16a4e23..ddf7b18 100644 --- a/rog/views.py +++ b/rog/views.py @@ -2362,6 +2362,12 @@ def get_team_info(request, zekken_number): entry = Entry.objects.select_related('team','event').get(zekken_number=zekken_number) members = Member.objects.filter(team=entry.team) + start_datetime = entry.event.start_datetime #イベントの規定スタート時刻 + if entry.event.self_rogaining: + #get_checkinsの中で、 + # start_datetime = -1(ロゲ開始)のcreate_at + logger.debug(f"self.rogaining={entry.event.self_rogaining} => start_datetime = -1(ロゲ開始)のcreate_at") + # チームのゴール時間を取得 goal_record = GoalImages.objects.filter( team_name=entry.team.team_name, @@ -2373,7 +2379,8 @@ def get_team_info(request, zekken_number): 'members': ', '.join([f"{m.lastname} {m.firstname}" for m in members]), 'event_code': entry.event.event_name, 'start_datetime': entry.event.start_datetime, - 'end_datetime': goal_record.goaltime if goal_record else None + 'end_datetime': goal_record.goaltime if goal_record else None, + 'duration': entry.category.duration.total_seconds() }) def create(self, request, *args, **kwargs): diff --git a/supervisor/html/.index.html.swp b/supervisor/html/.index.html.swp index 56342d9..bbe3145 100644 Binary files a/supervisor/html/.index.html.swp and b/supervisor/html/.index.html.swp differ diff --git a/supervisor/html/index.html b/supervisor/html/index.html index 7fed476..e9ddc9b 100755 --- a/supervisor/html/index.html +++ b/supervisor/html/index.html @@ -6,24 +6,25 @@
| 走行順 | -規定写真 | -撮影写真 | -CP名称 | -通過時刻 | -通過審査 | -買物審査 | -獲得点数 | ++ | 走行順 | +規定写真 | +撮影写真 | +CP名称 | +通過時刻 | +買物申請 | +通過審査 | +獲得点数 | ${checkin.path_order} | -+ | + + | +${checkin.path_order} | +
${checkin.photos ?
` ${checkin.photos}
|
- + |
${checkin.image_address ?
- ` ${checkin.image_address}
- ${checkin.receipt_address}
+ ` |
- + |
${checkin.sub_loc_id}
${checkin.location_name}
|
- ${checkin.create_at || '不明'} | -+ | ${checkin.create_at || '不明'} | ++ ${checkin.buy_point > 0 ? ` + + ` : ''} + | +- | - ${checkin.buy_point > 0 ? ` - - ` : ''} - | -${checkin.points} | +${calculatePointsForCheckin(checkin)} | `; tbody.appendChild(tr); - if (checkin.points) { - if (checkin.buy_flag) { - buyPoints += checkin.points; - } else { - totalPoints += checkin.points; - } - } + // 合計計算 + //if (checkin.points) { + // if (checkin.buy_flag) { + // buyPoints += checkin.points; + // } else { + // totalPoints += checkin.points; + // } + //} }); + updatePathOrders(); // 合計ポイントの更新 - document.getElementById('totalPoints').textContent = totalPoints; - document.getElementById('buyPoints').textContent = buyPoints; - document.getElementById('latePoints').textContent = teamData.late_points || 0; - document.getElementById('finalPoints').textContent = - totalPoints + buyPoints - (teamData.late_points || 0); + //document.getElementById('totalPoints').textContent = totalPoints; + //document.getElementById('buyPoints').textContent = buyPoints; + //document.getElementById('latePoints').textContent = teamData.late_points || 0; + //document.getElementById('finalPoints').textContent = + // totalPoints + buyPoints + (teamData.late_points || 0); + calculatePoints(); // 総合ポイントの計算 } catch (error) { console.error('Error loading team info:', error); @@ -329,20 +541,61 @@ } } - function loadTeamData_old(zekkenNumber) { - // チーム情報とチェックインデータを取得 - Promise.all([ - fetch(`${API_BASE_URL}/team_info/${zekkenNumber}`), - fetch(`${API_BASE_URL}/checkins/${zekkenNumber}`) - ]).then(responses => Promise.all(responses.map(r => r.json()))) - .then(([teamInfo, checkins]) => { - updateTeamInfo(teamInfo); - updateCheckinList(checkins); - calculatePoints(); - }); + // ゴール時刻表示を更新する関数 + function updateGoalTimeDisplay(endDateTime) { + const goalTimeDisplay = document.getElementById('goalTimeDisplay'); + const goalTimeInput = document.getElementById('goalTimeInput'); + + if (!goalTimeDisplay || !goalTimeInput) { + console.error('Goal time elements not found'); + return; + } + + let displayText = '-'; + if (endDateTime) { + try { + const date = new Date(endDateTime); + displayText = date.toLocaleString(); + // input要素の値も更新 + goalTimeInput.value = date.toISOString().slice(0, 16); + } catch (e) { + console.error('Error formatting date:', e); + } + } + + goalTimeDisplay.textContent = displayText; + goalTimeDisplay.onclick = () => editGoalTime(goalTimeDisplay); } - function updateTeamInfo(teamInfo) { + // UI要素をリセットする関数 + function resetUIElements() { + const elements = { + 'goalTimeDisplay': '-', + 'teamName': '-', + 'members': '-', + 'startTime': '-', + 'totalPoints': '0', + 'buyPoints': '0', + 'latePoints': '0', + 'finalPoints': '0' + }; + + for (const [id, defaultValue] of Object.entries(elements)) { + const element = document.getElementById(id); + if (element) { + element.textContent = defaultValue; + } + } + + // チェックインリストをクリア + const checkinList = document.getElementById('checkinList'); + if (checkinList) { + checkinList.innerHTML = ''; + } + } + + // チーム情報の表示...使われていない + function nouse_updateTeamInfo(teamInfo) { document.getElementById('teamName').textContent = teamInfo.team_name; document.getElementById('members').textContent = teamInfo.members; document.getElementById('startTime').textContent = teamInfo.start_time; @@ -350,7 +603,8 @@ document.getElementById('latePoints').textContent = teamInfo.late_points; } - function updateCheckinList(checkins) { + // 通過リストの表示...呼ばれていない + function nouse_updateCheckinList(checkins) { const tbody = document.getElementById('checkinList'); tbody.innerHTML = ''; @@ -395,8 +649,46 @@ calculateTotalPoints(); } + // 削除機能 + async function deleteCheckin(id) { + if (!confirm('このチェックインを削除してもよろしいですか?')) { + return; + } + + try { + const response = await fetch(`${API_BASE_URL}/checkins/${id}`, { + method: 'DELETE', + }) + + if (response.ok) { + const row = document.querySelector(`tr[data-id="${id}"]`); + row.remove(); + calculatePoints(); // 総合ポイントを再計算 + } else { + throw new Error('Delete failed'); + } + } catch (error) { + console.error('Error deleting checkin:', error); + alert('削除に失敗しました'); + } + } + + // ポイント計算関数 + function calculatePointsForCheckin(checkin) { + let points = 0; + if (checkin.validate_location) { + if(checkin.buy_flag){ + points += Number(checkin.buy_point) || 0; + }else{ + points += Number(checkin.checkin_point) || 0; + } + } + return points; + } + + // ポイント更新関数 - function updatePoints(checkbox) { + function old_updatePoints(checkbox) { const tr = checkbox.closest('tr'); const pointCell = tr.querySelector('.point-value'); const cpNumber = tr.dataset.cpNumber; @@ -410,8 +702,41 @@ }); } + // 審査チェックボックス更新関数 + function updatePoints(checkbox) { + const tr = checkbox.closest('tr'); + const pointCell = tr.querySelector('.point-value'); + const cpNumber = tr.dataset.cpNumber; + const buyPoint = tr.dataset.buyPoint; + const checkinPoint = tr.dataset.checkinPoint; + const validateCheckbox = tr.querySelector('.validate-checkbox'); + const buyCheckbox = tr.querySelector('.buy-checkbox'); + let checkin = { + validate_location: validateCheckbox ? validateCheckbox.checked : false, + buy_flag: buyCheckbox ? buyCheckbox.checked : false, + points: 0 + }; + + if (checkin.validate_location) { + // チェックボックスがONの場合 + if (checkin.buy_flag) { + checkin.points = buyPoint || 0; + } else { + checkin.points = checkinPoint || 0; + } + + } else { + // チェックボックスがOFFの場合 + checkin.points = 0; + } + // ポイントを表示 + pointCell.textContent = checkin.points; + calculatePoints(); // 総合ポイントの計算 + + } + // 買い物ポイント更新関数 - function updateBuyPoints(checkbox) { + function old_updateBuyPoints(checkbox) { const tr = checkbox.closest('tr'); const pointCell = tr.querySelector('.point-value'); const cpNumber = tr.dataset.cpNumber; @@ -425,6 +750,36 @@ }); } + // 買い物チェックボックス更新関数 + function updateBuyPoints(checkbox) { + const tr = checkbox.closest('tr'); + const pointCell = tr.querySelector('.point-value'); + const cpNumber = tr.dataset.cpNumber; + const validateCheckbox = tr.querySelector('.validate-checkbox'); + let checkin = { + validate_location: validateCheckbox.checked, + buy_flag: checkbox.checked, + points: 0 + }; + + fetch(`${API_BASE_URL}/location/${cpNumber}/`) + .then(response => response.json()) + .then(location => { + if (checkin.validate_location) { + // 通過審査がONの場合 + checkin.points = checkbox.checked ? location.buy_point : location.checkin_point; + } else { + // 通過審査がOFFの場合 + checkin.points = 0; + } + + // ポイントを表示 + pointCell.textContent = checkin.points; + calculatePoints(); // 総合ポイントの計算 + }) + } + + // 画像拡大表示用のモーダル関数 function showLargeImage(src) { const modal = document.createElement('div'); @@ -505,29 +860,42 @@ function updatePathOrders() { const rows = Array.from(document.getElementById('checkinList').children); rows.forEach((row, index) => { - row.children[0].textContent = index + 1; + row.children[1].textContent = index + 1; }); } + // 総合ポイントの計算 function calculatePoints() { + console.info('calculatePoints'); const rows = Array.from(document.getElementById('checkinList').children); - let totalPoints = 0; - let buyPoints = 0; + let totalPoints = 0; // チェックインポイントの合計をクリア + let cpPoints = 0; // チェックインポイントの合計をクリア + let buyPoints = 0; // 買い物ポイントの合計をクリア + // 各行のチェックインポイント及び買い物ポイントを合算 rows.forEach(row => { - const points = parseInt(row.children[4].textContent); - if (!isNaN(points)) { - totalPoints += points; - if (row.dataset.buyFlag === 'true') { - buyPoints += points; - } + const buybox = row.children[6].querySelector('input[type="checkbox"]'); + const checkbox = row.children[7].querySelector('input[type="checkbox"]'); + const point = parseInt(row.children[8].textContent); + if (checkbox) { + totalPoints += point; + if (buybox && buybox.checked) { + buyPoints += point; + }else{ + cpPoints += point; + } } }); + // 遅刻ポイントの計算=ゴール時刻がEventのゴール時刻を超えていたら1分につき-50点を加算する。 const latePoints = parseInt(document.getElementById('latePoints').textContent) || 0; - const finalPoints = totalPoints + buyPoints - latePoints; + // 総合得点を計算 + const finalPoints = totalPoints + latePoints; - document.getElementById('totalPoints').textContent = totalPoints; + // 判定を更新。順位を表示、ゴール時刻を15分経過したら失格 + console.info('calculatePoints:totalPoints=',cpPoints,',buyPoints=',buyPoints,',finalPoints=',finalPoints); + + document.getElementById('totalPoints').textContent = cpPoints; document.getElementById('buyPoints').textContent = buyPoints; document.getElementById('finalPoints').textContent = finalPoints; }
|---|