new
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
# Generated by Django 6.0.1 on 2026-02-12 12:48
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('community', '0007_announcement'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='activity',
|
||||
name='signup_form_config',
|
||||
field=models.JSONField(blank=True, default=list, help_text='配置报名时需要收集的信息,JSON格式,例如:[{"name": "phone", "label": "手机号", "type": "text", "required": true}]', verbose_name='报名表单配置'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='activitysignup',
|
||||
name='signup_info',
|
||||
field=models.JSONField(blank=True, default=dict, verbose_name='报名信息'),
|
||||
),
|
||||
]
|
||||
@@ -14,6 +14,12 @@ class Activity(models.Model):
|
||||
location = models.CharField(max_length=100, verbose_name="活动地点")
|
||||
max_participants = models.IntegerField(default=50, verbose_name="最大报名人数")
|
||||
is_active = models.BooleanField(default=True, verbose_name="是否启用")
|
||||
signup_form_config = models.JSONField(
|
||||
default=list,
|
||||
verbose_name="报名表单配置",
|
||||
blank=True,
|
||||
help_text='配置报名时需要收集的信息,JSON格式,例如:[{"name": "phone", "label": "手机号", "type": "text", "required": true}]'
|
||||
)
|
||||
created_at = models.DateTimeField(auto_now_add=True, verbose_name="创建时间")
|
||||
|
||||
def clean(self):
|
||||
@@ -55,6 +61,11 @@ class ActivitySignup(models.Model):
|
||||
activity = models.ForeignKey(Activity, on_delete=models.CASCADE, related_name='signups', verbose_name="活动")
|
||||
user = models.ForeignKey(WeChatUser, on_delete=models.CASCADE, related_name='activity_signups', verbose_name="报名用户")
|
||||
signup_time = models.DateTimeField(auto_now_add=True, verbose_name="报名时间")
|
||||
signup_info = models.JSONField(
|
||||
default=dict,
|
||||
verbose_name="报名信息",
|
||||
blank=True
|
||||
)
|
||||
status = models.CharField(max_length=20, choices=STATUS_CHOICES, default='confirmed', verbose_name="状态")
|
||||
|
||||
def __str__(self):
|
||||
|
||||
@@ -10,10 +10,12 @@ class ActivitySerializer(serializers.ModelSerializer):
|
||||
fields = '__all__'
|
||||
|
||||
class ActivitySignupSerializer(serializers.ModelSerializer):
|
||||
activity_info = ActivitySerializer(source='activity', read_only=True)
|
||||
|
||||
class Meta:
|
||||
model = ActivitySignup
|
||||
fields = ['id', 'activity', 'user', 'signup_time', 'status']
|
||||
read_only_fields = ['signup_time', 'status']
|
||||
fields = ['id', 'activity', 'activity_info', 'user', 'signup_time', 'status', 'signup_info']
|
||||
read_only_fields = ['signup_time', 'status', 'user']
|
||||
|
||||
class TopicMediaSerializer(serializers.ModelSerializer):
|
||||
url = serializers.SerializerMethodField()
|
||||
|
||||
@@ -36,8 +36,26 @@ class ActivityViewSet(viewsets.ReadOnlyModelViewSet):
|
||||
|
||||
if activity.signups.count() >= activity.max_participants:
|
||||
return Response({'error': '活动名额已满'}, status=400)
|
||||
|
||||
# Get signup info
|
||||
signup_info = request.data.get('signup_info', {})
|
||||
|
||||
# Basic validation
|
||||
if activity.signup_form_config:
|
||||
required_fields = [f['name'] for f in activity.signup_form_config if f.get('required')]
|
||||
for field in required_fields:
|
||||
# Simple check: field exists and is not empty string (if it's a string)
|
||||
val = signup_info.get(field)
|
||||
if val is None or (isinstance(val, str) and not val.strip()):
|
||||
# Try to find label for better error message
|
||||
label = next((f['label'] for f in activity.signup_form_config if f['name'] == field), field)
|
||||
return Response({'error': f'请填写: {label}'}, status=400)
|
||||
|
||||
signup = ActivitySignup.objects.create(activity=activity, user=user)
|
||||
signup = ActivitySignup.objects.create(
|
||||
activity=activity,
|
||||
user=user,
|
||||
signup_info=signup_info
|
||||
)
|
||||
serializer = ActivitySignupSerializer(signup)
|
||||
return Response(serializer.data, status=201)
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
1
backend/tmp03_zfbds
Normal file
1
backend/tmp03_zfbds
Normal file
File diff suppressed because one or more lines are too long
1
backend/tmp1_d4jq1k
Normal file
1
backend/tmp1_d4jq1k
Normal file
File diff suppressed because one or more lines are too long
1
backend/tmp1vnn2xz8
Normal file
1
backend/tmp1vnn2xz8
Normal file
File diff suppressed because one or more lines are too long
BIN
backend/tmp24154cux
Normal file
BIN
backend/tmp24154cux
Normal file
Binary file not shown.
BIN
backend/tmp3tj2qz45
Normal file
BIN
backend/tmp3tj2qz45
Normal file
Binary file not shown.
BIN
backend/tmp4ckc8bd0
Normal file
BIN
backend/tmp4ckc8bd0
Normal file
Binary file not shown.
1
backend/tmp4gx7ct_g
Normal file
1
backend/tmp4gx7ct_g
Normal file
File diff suppressed because one or more lines are too long
BIN
backend/tmp51ic78xj
Normal file
BIN
backend/tmp51ic78xj
Normal file
Binary file not shown.
1
backend/tmp5_bb2xac
Normal file
1
backend/tmp5_bb2xac
Normal file
File diff suppressed because one or more lines are too long
BIN
backend/tmp5ji9l72c
Normal file
BIN
backend/tmp5ji9l72c
Normal file
Binary file not shown.
BIN
backend/tmp899rmzxr
Normal file
BIN
backend/tmp899rmzxr
Normal file
Binary file not shown.
1
backend/tmp8q9poex7
Normal file
1
backend/tmp8q9poex7
Normal file
File diff suppressed because one or more lines are too long
1
backend/tmp9v8b6en2
Normal file
1
backend/tmp9v8b6en2
Normal file
@@ -0,0 +1 @@
|
||||
{"files": [{"filename": "inflection-0.1.1.tar.gz", "hashes": {"sha256": "70a0014cb3b36f6c8230756ae5c1bdc6aecd1f5beff240d8207f31ba9c13948c"}, "requires-python": null, "size": 7586, "upload-time": "2012-02-24T20:09:17.268105Z", "url": "../../packages/04/68/55d46b34f7d50f96c3bb26582c7334bdeae422c9ac0058ed48d79f7c5ade/inflection-0.1.1.tar.gz", "yanked": false}, {"filename": "inflection-0.1.2.tar.gz", "hashes": {"sha256": "e310c98c69ffac3866cc38b0d869a4b94aa61a59f890102e341d4c8c96d4d228"}, "requires-python": null, "size": 8543, "upload-time": "2012-03-13T21:45:11.124181Z", "url": "../../packages/fb/d8/fb45d4ba177fef3bd87f103edc2b28fcdf24f43952928d47cef73ec6d3f4/inflection-0.1.2.tar.gz", "yanked": false}, {"filename": "inflection-0.2.0.tar.gz", "hashes": {"sha256": "dab6ca89b6a91aecc8ba28ad9376b85a362c413733d108a3ffaae2e0b768e57e"}, "requires-python": null, "size": 8153, "upload-time": "2013-06-15T14:55:27.831074Z", "url": "../../packages/17/17/e063022e2b77cb9f4a83ed4089e5b0debdddbc6b685c679f387b657c73c1/inflection-0.2.0.tar.gz", "yanked": false}, {"filename": "inflection-0.2.1.tar.gz", "hashes": {"sha256": "96e6233bb5b9dcf0a34081bd31b1ca7ea2aea9c7110615acc14fdcaa3e71071f"}, "requires-python": null, "size": 8219, "upload-time": "2014-09-03T14:37:27.192869Z", "url": "../../packages/d4/d5/5ae57400b6c5374fe279c76e220588a554688138945601f5dde4733e22be/inflection-0.2.1.tar.gz", "yanked": false}, {"filename": "inflection-0.3.0.tar.gz", "hashes": {"sha256": "c6ab173181fd3bbee53187b7535f395ed802ef69d9f3bb5f8c2a5cdfb3e92d08"}, "requires-python": null, "size": 8565, "upload-time": "2015-03-01T17:36:33.912921Z", "url": "../../packages/5a/42/489536aac4f16828e19823406e83b943860d30767c71f390511a45ce095d/inflection-0.3.0.tar.gz", "yanked": false}, {"filename": "inflection-0.3.1.tar.gz", "hashes": {"sha256": "18ea7fb7a7d152853386523def08736aa8c32636b047ade55f7578c4edeb16ca"}, "requires-python": null, "size": 8715, "upload-time": "2015-05-03T08:08:12.824777Z", "url": "../../packages/d5/35/a6eb45b4e2356fe688b21570864d4aa0d0a880ce387defe9c589112077f8/inflection-0.3.1.tar.gz", "yanked": false}, {"filename": "inflection-0.4.0-py2.py3-none-any.whl", "hashes": {"sha256": "9a15d3598f01220e93f2207c432cfede50daff53137ce660fb8be838ef1ca6cc"}, "requires-python": ">=3.5", "size": 5789, "upload-time": "2020-04-06T19:35:36.732518Z", "url": "../../packages/52/c1/36be286d85dbd76527fb613527222a795d7c071da195fa916e7bf3cb03cb/inflection-0.4.0-py2.py3-none-any.whl", "yanked": false}, {"filename": "inflection-0.4.0.tar.gz", "hashes": {"sha256": "32a5c3341d9583ec319548b9015b7fbdf8c429cbcb575d326c33ae3a0e90d52c"}, "requires-python": ">=3.5", "size": 14536, "upload-time": "2020-04-06T19:35:37.724962Z", "url": "../../packages/e8/dc/3986343faf9631d8bc61d8a6a1331b5f4f08723dbce3b39f524c367a1621/inflection-0.4.0.tar.gz", "yanked": false}, {"filename": "inflection-0.5.0-py2.py3-none-any.whl", "hashes": {"sha256": "88b101b2668a1d81d6d72d4c2018e53bc6c7fc544c987849da1c7f77545c3bc9"}, "requires-python": ">=3.5", "size": 5840, "upload-time": "2020-06-06T08:04:42.855673Z", "url": "../../packages/d2/cd/f04c661d1b5ba6b7d77008e8fedd28a27a683eeeffcd93c6b2dbe54ea983/inflection-0.5.0-py2.py3-none-any.whl", "yanked": false}, {"filename": "inflection-0.5.0.tar.gz", "hashes": {"sha256": "f576e85132d34f5bf7df5183c2c6f94cfb32e528f53065345cf71329ba0b8924"}, "requires-python": ">=3.5", "size": 14830, "upload-time": "2020-06-06T08:04:44.356715Z", "url": "../../packages/87/41/07fa466e0525635243f0cb94f81b9e99508edc23af7d9bf6c2009e11eadc/inflection-0.5.0.tar.gz", "yanked": false}, {"filename": "inflection-0.5.1-py2.py3-none-any.whl", "hashes": {"sha256": "f38b2b640938a4f35ade69ac3d053042959b62a0f1076a5bbaa1b9526605a8a2"}, "requires-python": ">=3.5", "size": 9454, "upload-time": "2020-08-22T08:16:27.816929Z", "url": "../../packages/59/91/aa6bde563e0085a02a435aa99b49ef75b0a4b062635e606dab23ce18d720/inflection-0.5.1-py2.py3-none-any.whl", "yanked": false}, {"filename": "inflection-0.5.1.tar.gz", "hashes": {"sha256": "1a29730d366e996aaacffb2f1f1cb9593dc38e2ddd30c91250c6dde09ea9b417"}, "requires-python": ">=3.5", "size": 15091, "upload-time": "2020-08-22T08:16:29.139062Z", "url": "../../packages/e1/7e/691d061b7329bc8d54edbf0ec22fbfb2afe61facb681f9aaa9bff7a27d04/inflection-0.5.1.tar.gz", "yanked": false}], "meta": {"api-version": "1.1", "_last-serial": "8016752"}, "name": "inflection", "versions": ["0.1.1", "0.1.2", "0.2.0", "0.2.1", "0.3.0", "0.3.1", "0.4.0", "0.5.0", "0.5.1"]}
|
||||
1
backend/tmp_7r3u7cx
Normal file
1
backend/tmp_7r3u7cx
Normal file
File diff suppressed because one or more lines are too long
BIN
backend/tmp_8j_ohti
Normal file
BIN
backend/tmp_8j_ohti
Normal file
Binary file not shown.
BIN
backend/tmp_s882ns6
Normal file
BIN
backend/tmp_s882ns6
Normal file
Binary file not shown.
BIN
backend/tmpci9az1ug
Normal file
BIN
backend/tmpci9az1ug
Normal file
Binary file not shown.
1
backend/tmpclevfosk
Normal file
1
backend/tmpclevfosk
Normal file
File diff suppressed because one or more lines are too long
BIN
backend/tmpd7_t3u5l
Normal file
BIN
backend/tmpd7_t3u5l
Normal file
Binary file not shown.
BIN
backend/tmpe7h8t1mx
Normal file
BIN
backend/tmpe7h8t1mx
Normal file
Binary file not shown.
BIN
backend/tmpff33bgsu
Normal file
BIN
backend/tmpff33bgsu
Normal file
Binary file not shown.
1
backend/tmpg0cf2uch
Normal file
1
backend/tmpg0cf2uch
Normal file
File diff suppressed because one or more lines are too long
1
backend/tmpg5yf1vug
Normal file
1
backend/tmpg5yf1vug
Normal file
File diff suppressed because one or more lines are too long
BIN
backend/tmpgdqeal4u
Normal file
BIN
backend/tmpgdqeal4u
Normal file
Binary file not shown.
BIN
backend/tmpgwrshcaf
Normal file
BIN
backend/tmpgwrshcaf
Normal file
Binary file not shown.
1
backend/tmpja1tb9xu
Normal file
1
backend/tmpja1tb9xu
Normal file
File diff suppressed because one or more lines are too long
BIN
backend/tmpk9t6y5ru
Normal file
BIN
backend/tmpk9t6y5ru
Normal file
Binary file not shown.
1
backend/tmplk0xax0p
Normal file
1
backend/tmplk0xax0p
Normal file
File diff suppressed because one or more lines are too long
1
backend/tmpmmzl1px4
Normal file
1
backend/tmpmmzl1px4
Normal file
File diff suppressed because one or more lines are too long
1
backend/tmpndp11ryk
Normal file
1
backend/tmpndp11ryk
Normal file
File diff suppressed because one or more lines are too long
BIN
backend/tmpnejw_r50
Normal file
BIN
backend/tmpnejw_r50
Normal file
Binary file not shown.
1
backend/tmpnzxvnw_m
Normal file
1
backend/tmpnzxvnw_m
Normal file
File diff suppressed because one or more lines are too long
BIN
backend/tmpq0dkxu9m
Normal file
BIN
backend/tmpq0dkxu9m
Normal file
Binary file not shown.
1
backend/tmpqtdz0k95
Normal file
1
backend/tmpqtdz0k95
Normal file
File diff suppressed because one or more lines are too long
BIN
backend/tmprmy_tx9e
Normal file
BIN
backend/tmprmy_tx9e
Normal file
Binary file not shown.
1
backend/tmprrcxhd6f
Normal file
1
backend/tmprrcxhd6f
Normal file
File diff suppressed because one or more lines are too long
1
backend/tmptpegm9jm
Normal file
1
backend/tmptpegm9jm
Normal file
File diff suppressed because one or more lines are too long
BIN
backend/tmptqteu95n
Normal file
BIN
backend/tmptqteu95n
Normal file
Binary file not shown.
1
backend/tmpx7xnz5we
Normal file
1
backend/tmpx7xnz5we
Normal file
File diff suppressed because one or more lines are too long
1
backend/tmpx8gmdsbe
Normal file
1
backend/tmpx8gmdsbe
Normal file
File diff suppressed because one or more lines are too long
1
backend/tmpxkfqsuyp
Normal file
1
backend/tmpxkfqsuyp
Normal file
File diff suppressed because one or more lines are too long
BIN
backend/tmpyphiepes
Normal file
BIN
backend/tmpyphiepes
Normal file
Binary file not shown.
BIN
backend/tmpz0f610a7
Normal file
BIN
backend/tmpz0f610a7
Normal file
Binary file not shown.
Reference in New Issue
Block a user