- apps/weather 新規作成(WeatherRecord モデル、5種APIエンドポイント) - GET /api/weather/records/ 日次データ一覧 - GET /api/weather/summary/ 月別・年間集計 - GET /api/weather/gdd/ 有効積算温度(GDD)計算 - GET /api/weather/similarity/ 類似年分析(開花・収穫予測の基礎) - POST /api/weather/sync/ Windmill向け日次更新(APIキー認証) - management command: fetch_weather(初回一括・差分取得) - Crop.base_temp フィールド追加(GDD基準温度、default=0.0℃) - docker-compose.yml: MAIL_API_KEY 環境変数を追加(ローカルテスト修正) - requirements.txt: requests>=2.31 追加 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
61 lines
2.8 KiB
Python
61 lines
2.8 KiB
Python
"""
|
|
URL configuration for keinasystem project.
|
|
|
|
The `urlpatterns` list routes URLs to views. For more information please see:
|
|
https://docs.djangoproject.com/en/5.2/topics/http/urls/
|
|
Examples:
|
|
Function views
|
|
1. Add an import: from my_app import views
|
|
2. Add a URL to urlpatterns: path('', views.home, name='home')
|
|
Class-based views
|
|
1. Add an import: from other_app.views import Home
|
|
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
|
|
Including another URLconf
|
|
1. Import the include() function: from django.urls import include, path
|
|
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
|
"""
|
|
from django.contrib import admin
|
|
from django.urls import path, include
|
|
from rest_framework.routers import DefaultRouter
|
|
from rest_framework_simplejwt.views import TokenObtainPairView, TokenRefreshView
|
|
from apps.fields.views import OfficialKyosaiFieldViewSet, OfficialChusankanFieldViewSet
|
|
from rest_framework.views import APIView
|
|
from rest_framework.response import Response
|
|
from rest_framework import status
|
|
from rest_framework.permissions import IsAuthenticated
|
|
|
|
|
|
class ChangePasswordView(APIView):
|
|
permission_classes = [IsAuthenticated]
|
|
|
|
def post(self, request):
|
|
user = request.user
|
|
current_password = request.data.get('current_password', '')
|
|
new_password = request.data.get('new_password', '')
|
|
if not current_password or not new_password:
|
|
return Response({'error': '現在のパスワードと新しいパスワードを入力してください'}, status=status.HTTP_400_BAD_REQUEST)
|
|
if not user.check_password(current_password):
|
|
return Response({'error': '現在のパスワードが正しくありません'}, status=status.HTTP_400_BAD_REQUEST)
|
|
if len(new_password) < 8:
|
|
return Response({'error': 'パスワードは8文字以上にしてください'}, status=status.HTTP_400_BAD_REQUEST)
|
|
user.set_password(new_password)
|
|
user.save()
|
|
return Response({'status': 'ok'})
|
|
|
|
master_router = DefaultRouter()
|
|
master_router.register(r'kyosai-fields', OfficialKyosaiFieldViewSet, basename='kyosai-field')
|
|
master_router.register(r'chusankan-fields', OfficialChusankanFieldViewSet, basename='chusankan-field')
|
|
|
|
urlpatterns = [
|
|
path('admin/', admin.site.urls),
|
|
path('api/fields/', include('apps.fields.urls')),
|
|
path('api/', include(master_router.urls)),
|
|
path('api/plans/', include('apps.plans.urls')),
|
|
path('api/reports/', include('apps.reports.urls')),
|
|
path('api/auth/jwt/create/', TokenObtainPairView.as_view(), name='token_obtain_pair'),
|
|
path('api/auth/jwt/refresh/', TokenRefreshView.as_view(), name='token_refresh'),
|
|
path('api/auth/change-password/', ChangePasswordView.as_view(), name='change-password'),
|
|
path('api/mail/', include('apps.mail.urls')),
|
|
path('api/weather/', include('apps.weather.urls')),
|
|
]
|