photo_point and cppoint were reverted to checkin_point
This commit is contained in:
@ -1100,8 +1100,7 @@ class Location2025(models.Model):
|
||||
location = models.PointField(_('位置'), srid=4326, null=True, blank=True)
|
||||
|
||||
# ポイント情報
|
||||
cp_point = models.IntegerField(_('チェックポイント得点'), default=10)
|
||||
photo_point = models.IntegerField(_('写真ポイント'), default=0)
|
||||
checkin_point = models.IntegerField(_('チェックイン得点'), default=10)
|
||||
buy_point = models.IntegerField(_('買い物ポイント'), default=0)
|
||||
|
||||
# チェックイン設定
|
||||
@ -1171,19 +1170,21 @@ class Location2025(models.Model):
|
||||
@property
|
||||
def total_point(self):
|
||||
"""総得点を計算"""
|
||||
return self.cp_point + self.photo_point + self.buy_point
|
||||
return self.checkin_point + self.buy_point
|
||||
|
||||
@classmethod
|
||||
def import_from_csv(cls, csv_file, event, user=None):
|
||||
"""
|
||||
CSVファイルからチェックポイントデータをインポート
|
||||
CSVファイルからチェックポイントデータをインポート(全フィールド対応)
|
||||
|
||||
CSV形式:
|
||||
cp_number,cp_name,latitude,longitude,cp_point,photo_point,buy_point,address,phone,description
|
||||
cp_number,cp_name,latitude,longitude,checkin_point,buy_point,address,phone,description,
|
||||
sub_loc_id,subcategory,photos,videos,tags,evaluation_value,remark,hidden_location
|
||||
"""
|
||||
import csv
|
||||
import io
|
||||
from django.utils import timezone
|
||||
from django.contrib.gis.geos import Point
|
||||
|
||||
if isinstance(csv_file, str):
|
||||
# ファイルパスの場合
|
||||
@ -1205,16 +1206,42 @@ class Location2025(models.Model):
|
||||
errors.append(f"行{row_num}: CP番号が無効です")
|
||||
continue
|
||||
|
||||
# 緯度経度から位置情報を作成
|
||||
latitude = float(row['latitude']) if row.get('latitude') else None
|
||||
longitude = float(row['longitude']) if row.get('longitude') else None
|
||||
location = None
|
||||
if latitude and longitude:
|
||||
location = Point(longitude, latitude)
|
||||
|
||||
# hidden_locationのブール値変換
|
||||
hidden_location = False
|
||||
if row.get('hidden_location'):
|
||||
hidden_str = row.get('hidden_location', '').lower()
|
||||
hidden_location = hidden_str in ['true', '1', 'yes', 'on']
|
||||
|
||||
defaults = {
|
||||
# 基本フィールド
|
||||
'cp_name': row.get('cp_name', f'CP{cp_number}'),
|
||||
'latitude': float(row['latitude']) if row.get('latitude') else None,
|
||||
'longitude': float(row['longitude']) if row.get('longitude') else None,
|
||||
'cp_point': int(row.get('cp_point', 10)),
|
||||
'photo_point': int(row.get('photo_point', 0)),
|
||||
'latitude': latitude,
|
||||
'longitude': longitude,
|
||||
'location': location,
|
||||
'checkin_point': int(row.get('checkin_point', row.get('cp_point', 10))), # 後方互換性のためcp_pointもサポート
|
||||
'buy_point': int(row.get('buy_point', 0)),
|
||||
'address': row.get('address', ''),
|
||||
'phone': row.get('phone', ''),
|
||||
'description': row.get('description', ''),
|
||||
|
||||
# 新しいフィールド
|
||||
'sub_loc_id': row.get('sub_loc_id', ''),
|
||||
'subcategory': row.get('subcategory', ''),
|
||||
'photos': row.get('photos', ''),
|
||||
'videos': row.get('videos', ''),
|
||||
'tags': row.get('tags', ''),
|
||||
'evaluation_value': row.get('evaluation_value', ''),
|
||||
'remark': row.get('remark', ''),
|
||||
'hidden_location': hidden_location,
|
||||
|
||||
# 管理フィールド
|
||||
'csv_source_file': getattr(csv_file, 'name', 'uploaded_file.csv'),
|
||||
'csv_upload_date': timezone.now(),
|
||||
'csv_upload_user': user,
|
||||
|
||||
Reference in New Issue
Block a user