Finish basic API implementation
This commit is contained in:
@ -329,6 +329,9 @@ def checkin_from_rogapp(request):
|
||||
- team_name: チーム名
|
||||
- cp_number: チェックポイント番号
|
||||
- image: 画像URL
|
||||
- buy_flag: 購入フラグ (新規)
|
||||
- gps_coordinates: GPS座標情報 (新規)
|
||||
- camera_metadata: カメラメタデータ (新規)
|
||||
"""
|
||||
logger.info("checkin_from_rogapp called")
|
||||
|
||||
@ -338,6 +341,11 @@ def checkin_from_rogapp(request):
|
||||
cp_number = request.data.get('cp_number')
|
||||
image_url = request.data.get('image')
|
||||
|
||||
# API変更要求書対応: 新パラメータ追加
|
||||
buy_flag = request.data.get('buy_flag', False)
|
||||
gps_coordinates = request.data.get('gps_coordinates', {})
|
||||
camera_metadata = request.data.get('camera_metadata', {})
|
||||
|
||||
logger.debug(f"Parameters: event_code={event_code}, team_name={team_name}, "
|
||||
f"cp_number={cp_number}, image={image_url}")
|
||||
|
||||
@ -420,6 +428,37 @@ def checkin_from_rogapp(request):
|
||||
|
||||
# 獲得ポイントの計算(イベントCPが定義されている場合)
|
||||
point_value = event_cp.cp_point if event_cp else 0
|
||||
bonus_points = 0
|
||||
scoring_breakdown = {
|
||||
"base_points": point_value,
|
||||
"camera_bonus": 0,
|
||||
"total_points": point_value
|
||||
}
|
||||
|
||||
# カメラボーナス計算
|
||||
if image_url and event_cp and hasattr(event_cp, 'evaluation_value'):
|
||||
if event_cp.evaluation_value == "1": # 写真撮影必須ポイント
|
||||
bonus_points += 5
|
||||
scoring_breakdown["camera_bonus"] = 5
|
||||
scoring_breakdown["total_points"] += 5
|
||||
|
||||
# 拡張情報があれば保存
|
||||
if gps_coordinates or camera_metadata:
|
||||
try:
|
||||
from ..models import CheckinExtended
|
||||
CheckinExtended.objects.create(
|
||||
gpslog=checkpoint,
|
||||
gps_latitude=gps_coordinates.get('latitude'),
|
||||
gps_longitude=gps_coordinates.get('longitude'),
|
||||
gps_accuracy=gps_coordinates.get('accuracy'),
|
||||
gps_timestamp=gps_coordinates.get('timestamp'),
|
||||
camera_capture_time=camera_metadata.get('capture_time'),
|
||||
device_info=camera_metadata.get('device_info'),
|
||||
bonus_points=bonus_points,
|
||||
scoring_breakdown=scoring_breakdown
|
||||
)
|
||||
except Exception as ext_error:
|
||||
logger.warning(f"Failed to save extended checkin info: {ext_error}")
|
||||
|
||||
return Response({
|
||||
"status": "OK",
|
||||
@ -428,7 +467,11 @@ def checkin_from_rogapp(request):
|
||||
"cp_number": cp_number,
|
||||
"checkpoint_id": checkpoint.id,
|
||||
"checkin_time": checkpoint.checkin_time.strftime("%Y-%m-%d %H:%M:%S"),
|
||||
"point_value": point_value
|
||||
"point_value": point_value,
|
||||
"bonus_points": bonus_points,
|
||||
"scoring_breakdown": scoring_breakdown,
|
||||
"validation_status": "pending",
|
||||
"requires_manual_review": bool(gps_coordinates.get('accuracy', 0) > 10) # 10m以上は要審査
|
||||
})
|
||||
|
||||
except Exception as e:
|
||||
|
||||
Reference in New Issue
Block a user