This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
# Generated by Django 6.0.1 on 2026-02-23 08:31
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('community', '0010_activity_is_paid_activity_price_activitysignup_order'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='activity',
|
||||
name='auto_confirm',
|
||||
field=models.BooleanField(default=False, help_text='开启后,付费活动支付成功或免费活动报名后直接显示报名成功,不需要审核', verbose_name='无需审核'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='activitysignup',
|
||||
name='status',
|
||||
field=models.CharField(choices=[('unpaid', '待支付'), ('pending', '审核中'), ('confirmed', '报名成功'), ('cancelled', '已取消')], default='confirmed', max_length=20, verbose_name='状态'),
|
||||
),
|
||||
]
|
||||
@@ -19,6 +19,7 @@ class Activity(models.Model):
|
||||
price = models.DecimalField(max_digits=10, decimal_places=2, default=0, verbose_name="报名费用")
|
||||
|
||||
is_active = models.BooleanField(default=True, verbose_name="是否启用")
|
||||
auto_confirm = models.BooleanField(default=False, verbose_name="无需审核", help_text="开启后,付费活动支付成功或免费活动报名后直接显示报名成功,不需要审核")
|
||||
|
||||
# 常用报名信息开关
|
||||
ask_name = models.BooleanField(default=False, verbose_name="收集姓名")
|
||||
@@ -72,6 +73,7 @@ class ActivitySignup(models.Model):
|
||||
活动报名记录
|
||||
"""
|
||||
STATUS_CHOICES = (
|
||||
('unpaid', '待支付'),
|
||||
('pending', '审核中'),
|
||||
('confirmed', '报名成功'),
|
||||
('cancelled', '已取消'),
|
||||
|
||||
@@ -156,13 +156,14 @@ class ActivityViewSet(viewsets.ReadOnlyModelViewSet):
|
||||
if pending_signup:
|
||||
pending_signup.signup_info = signup_info
|
||||
pending_signup.order = order
|
||||
pending_signup.status = 'unpaid' # Explicitly set to unpaid
|
||||
pending_signup.save()
|
||||
else:
|
||||
ActivitySignup.objects.create(
|
||||
activity=activity,
|
||||
user=user,
|
||||
signup_info=signup_info,
|
||||
status='pending',
|
||||
status='unpaid',
|
||||
order=order
|
||||
)
|
||||
|
||||
@@ -177,11 +178,14 @@ class ActivityViewSet(viewsets.ReadOnlyModelViewSet):
|
||||
return Response({'error': '支付接口调用失败', 'detail': result}, status=500)
|
||||
|
||||
# Free Activity Signup
|
||||
# Check auto_confirm
|
||||
status_val = 'confirmed' if activity.auto_confirm else 'pending'
|
||||
|
||||
signup = ActivitySignup.objects.create(
|
||||
activity=activity,
|
||||
user=user,
|
||||
signup_info=signup_info,
|
||||
status='confirmed'
|
||||
status=status_val
|
||||
)
|
||||
serializer = ActivitySignupSerializer(signup)
|
||||
return Response(serializer.data, status=201)
|
||||
|
||||
@@ -100,8 +100,8 @@ DATABASES = {
|
||||
}
|
||||
|
||||
# 从环境变量获取数据库配置 (Docker 环境会自动注入这些变量)
|
||||
#DB_HOST = os.environ.get('DB_HOST', '121.43.104.161')
|
||||
DB_HOST = os.environ.get('DB_HOST', '6.6.6.66')
|
||||
DB_HOST = os.environ.get('DB_HOST', '121.43.104.161')
|
||||
#DB_HOST = os.environ.get('DB_HOST', '6.6.6.66')
|
||||
if DB_HOST:
|
||||
DATABASES['default'] = {
|
||||
'ENGINE': 'django.db.backends.postgresql',
|
||||
@@ -109,8 +109,8 @@ if DB_HOST:
|
||||
'USER': os.environ.get('DB_USER', 'market'),
|
||||
'PASSWORD': os.environ.get('DB_PASSWORD', '123market'),
|
||||
'HOST': DB_HOST,
|
||||
#'PORT': os.environ.get('DB_PORT', '6433'),
|
||||
'PORT': os.environ.get('DB_PORT', '5432'),
|
||||
'PORT': os.environ.get('DB_PORT', '6433'),
|
||||
#'PORT': os.environ.get('DB_PORT', '5432'),
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -515,9 +515,11 @@ def payment_finish(request):
|
||||
from community.models import ActivitySignup
|
||||
signup = ActivitySignup.objects.filter(order=order).first()
|
||||
if signup:
|
||||
signup.status = 'confirmed'
|
||||
# Determine status based on activity setting
|
||||
new_status = 'confirmed' if signup.activity.auto_confirm else 'pending'
|
||||
signup.status = new_status
|
||||
signup.save()
|
||||
print(f"活动报名状态已更新: {signup.id}")
|
||||
print(f"活动报名状态已更新: {signup.id} -> {new_status}")
|
||||
except Exception as e:
|
||||
print(f"更新活动报名状态失败: {str(e)}")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user