supervisor step3
This commit is contained in:
Binary file not shown.
BIN
rog/.urls.py.swp
BIN
rog/.urls.py.swp
Binary file not shown.
Binary file not shown.
@ -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}"
|
||||
|
||||
|
||||
51
rog/views.py
51
rog/views.py
@ -40,6 +40,7 @@ from rest_framework.response import Response
|
||||
from rest_framework.parsers import JSONParser, MultiPartParser
|
||||
from .serializers import LocationSerializer
|
||||
from django.http import JsonResponse
|
||||
from rest_framework.authentication import TokenAuthentication
|
||||
from rest_framework.permissions import IsAuthenticated
|
||||
from django.contrib.gis.db.models import Extent, Union
|
||||
|
||||
@ -52,7 +53,7 @@ from django.db.models import Q
|
||||
|
||||
from rest_framework import permissions
|
||||
from rest_framework.views import APIView
|
||||
from rest_framework.decorators import api_view, permission_classes
|
||||
from rest_framework.decorators import api_view, permission_classes, authentication_classes
|
||||
from rest_framework.parsers import JSONParser, MultiPartParser
|
||||
from django.views.decorators.csrf import csrf_exempt
|
||||
from django.shortcuts import render
|
||||
@ -2318,6 +2319,8 @@ class UserLastGoalTimeView(APIView):
|
||||
# ----- for Supervisor -----
|
||||
|
||||
@api_view(['GET'])
|
||||
@authentication_classes([TokenAuthentication])
|
||||
@permission_classes([IsAuthenticated])
|
||||
def debug_urls(request):
|
||||
"""デバッグ用:利用可能なURLパターンを表示"""
|
||||
resolver = get_resolver()
|
||||
@ -2330,6 +2333,8 @@ def debug_urls(request):
|
||||
return JsonResponse({'urls': urls})
|
||||
|
||||
@api_view(['GET'])
|
||||
@authentication_classes([TokenAuthentication])
|
||||
@permission_classes([IsAuthenticated])
|
||||
def get_events(request):
|
||||
logger.debug(f"get_events was called. Path: {request.path}")
|
||||
try:
|
||||
@ -2340,6 +2345,7 @@ def get_events(request):
|
||||
'name': event.event_name,
|
||||
'start_datetime': event.start_datetime,
|
||||
'end_datetime': event.end_datetime,
|
||||
'self_rogaining': event.self_rogaining,
|
||||
} for event in events])
|
||||
logger.debug(f"Returning data: {data}") # デバッグ用ログ
|
||||
return JsonResponse(data, safe=False)
|
||||
@ -2349,7 +2355,10 @@ def get_events(request):
|
||||
{"error": "Failed to retrieve events"},
|
||||
status=status.HTTP_500_INTERNAL_SERVER_ERROR
|
||||
)
|
||||
|
||||
@api_view(['GET'])
|
||||
@authentication_classes([TokenAuthentication])
|
||||
@permission_classes([IsAuthenticated])
|
||||
def get_zekken_numbers(request, event_code):
|
||||
entries = Entry.objects.filter(
|
||||
event__event_name=event_code,
|
||||
@ -2358,6 +2367,8 @@ def get_zekken_numbers(request, event_code):
|
||||
return Response([entry.zekken_number for entry in entries])
|
||||
|
||||
@api_view(['GET'])
|
||||
@authentication_classes([TokenAuthentication])
|
||||
@permission_classes([IsAuthenticated])
|
||||
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)
|
||||
@ -2373,7 +2384,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,
|
||||
'self_rogaining': entry.event.self_rogaining,
|
||||
})
|
||||
|
||||
def create(self, request, *args, **kwargs):
|
||||
@ -2396,6 +2408,8 @@ def get_image_url(image_path):
|
||||
|
||||
|
||||
@api_view(['GET'])
|
||||
@authentication_classes([TokenAuthentication])
|
||||
@permission_classes([IsAuthenticated])
|
||||
def get_checkins(request, *args, **kwargs):
|
||||
#def get_checkins(request, zekken_number, event_code):
|
||||
try:
|
||||
@ -2442,20 +2456,19 @@ def get_checkins(request, *args, **kwargs):
|
||||
|
||||
data.append({
|
||||
'id': c.id,
|
||||
'path_order': c.path_order,
|
||||
'cp_number': c.cp_number,
|
||||
'sub_loc_id': location.sub_loc_id if location else f"#{c.cp_number}",
|
||||
'location_name': location.location_name if location else None,
|
||||
'create_at': formatted_time, #(c.create_at + timedelta(hours=9)).strftime('%H:%M:%S') if c.create_at else None,
|
||||
'validate_location': c.validate_location,
|
||||
'points': c.points or 0,
|
||||
'buy_flag': c.buy_flag,
|
||||
'photos': location.photos if location else None,
|
||||
'image_address': get_image_url(c.image_address),
|
||||
'receipt_address': get_image_url(c.image_receipt),
|
||||
'location_name': location.location_name if location else None,
|
||||
'checkin_point': location.checkin_point if location else None,
|
||||
'buy_point': location.buy_point
|
||||
'path_order': c.path_order, # 通過順序
|
||||
'cp_number': c.cp_number, # 通過ポイント
|
||||
'sub_loc_id': location.sub_loc_id if location else f"#{c.cp_number}", # アプリ上のチェックポイント番号+点数
|
||||
'location_name': location.location_name if location else None, # アプリ上のチェックポイント名
|
||||
'create_at': formatted_time, # 通過時刻
|
||||
'validate_location': c.validate_location, # 通過審査結果
|
||||
'points': c.points or 0, # 審査後の公式得点
|
||||
'buy_flag': c.buy_flag, # お買い物撮影で TRUE
|
||||
'photos': location.photos if location else None, # アプリ上の規定写真
|
||||
'image_address': get_image_url(c.image_address), # 撮影写真
|
||||
'receipt_address': get_image_url(c.image_receipt), # まだ使われていない
|
||||
'checkin_point': location.checkin_point if location else None, # アプリ上の規定ポイント
|
||||
'buy_point': location.buy_point if location else None, # アプリ上の規定買い物ポイント
|
||||
})
|
||||
|
||||
#logger.debug(f"data={data}")
|
||||
@ -2469,6 +2482,8 @@ def get_checkins(request, *args, **kwargs):
|
||||
)
|
||||
|
||||
@api_view(['POST'])
|
||||
@authentication_classes([TokenAuthentication])
|
||||
@permission_classes([IsAuthenticated])
|
||||
def update_checkins(request):
|
||||
with transaction.atomic():
|
||||
for update in request.data:
|
||||
@ -2479,6 +2494,8 @@ def update_checkins(request):
|
||||
return Response({'status': 'success'})
|
||||
|
||||
@api_view(['GET'])
|
||||
@authentication_classes([TokenAuthentication])
|
||||
@permission_classes([IsAuthenticated])
|
||||
def export_excel(request, zekken_number):
|
||||
# エントリー情報の取得
|
||||
entry = Entry.objects.select_related('team').get(zekken_number=zekken_number)
|
||||
@ -2528,6 +2545,8 @@ def export_excel(request, zekken_number):
|
||||
# ----- for Supervisor -----
|
||||
|
||||
@api_view(['GET'])
|
||||
@authentication_classes([TokenAuthentication])
|
||||
@permission_classes([IsAuthenticated])
|
||||
def test_api(request):
|
||||
logger.debug("Test API endpoint called")
|
||||
return JsonResponse({"status": "API is working"})
|
||||
|
||||
Reference in New Issue
Block a user