新增材料上传进度,一楼活动全员可见仅作记录并支持成员补充材料

This commit is contained in:
2026-11-11 18:31:00 +08:00
parent d2cb824fa2
commit 04fd4b9bfc
12 changed files with 389 additions and 57 deletions
+5 -3
View File
@@ -83,7 +83,7 @@ class CenterTests(ApiTestCase):
record=(await c.get('/api/center/checks',headers=auth(owner['token']))).json()['items'][0]
self.assertEqual(record['details'][0]['expected'],5);self.assertEqual(record['details'][0]['actual'],4)
async def test_photos_required_private_and_category_filter(self):
async def test_photos_required_all_members_visible_and_category_filter(self):
owner,other=await self.setup_people(); c=self.client
raw=io.BytesIO();Image.new('RGB',(10,10),'red').save(raw,'PNG')
with tempfile.TemporaryDirectory() as directory, patch.object(self.m,'_db_path',Path(directory)/'test.db'):
@@ -92,15 +92,17 @@ class CenterTests(ApiTestCase):
with zipfile.ZipFile(package,'w') as archive:archive.writestr('活动照片.png',raw.getvalue());archive.writestr('材料说明.txt','活动材料')
material=(await c.post('/api/center/materials',headers=auth(owner['token']),content=package.getvalue())).json()
photo=material['photo_ids'][0]
self.assertEqual((await c.get('/api/center/materials/'+material['id'],headers=auth(other['token']))).status_code,403)
payload={'title':'一楼活动','start_at':self.m.now_ms(),'record_type':'center','visibility':'private'}
self.assertEqual((await c.post('/api/activities',headers=auth(owner['token']),json=payload)).status_code,422)
response=await c.post('/api/activities',headers=auth(owner['token']),json={**payload,'material_id':material['id']})
self.assertEqual(response.status_code,200,response.text); activity=response.json()['activity']
self.assertEqual(activity['record_type'],'center')
self.assertEqual(activity['location'],'赋能中心一楼')
self.assertEqual((await c.get('/api/center/materials/'+material['id'],headers=auth(other['token']))).status_code,403)
self.assertEqual(activity['visibility'],'public')
self.assertEqual((await c.get('/api/center/materials/'+material['id'],headers=auth(other['token']))).status_code,200)
self.assertEqual((await c.get(f'/api/center/photos/{photo}')).status_code,401)
self.assertEqual((await c.get(f'/api/center/photos/{photo}',headers=auth(other['token']))).status_code,403)
self.assertEqual((await c.get(f'/api/center/photos/{photo}',headers=auth(other['token']))).status_code,200)
self.assertEqual((await c.get(f'/api/center/photos/{photo}',headers=auth(owner['token']))).status_code,200)
self.assertEqual(len((await c.get('/api/activities?record_type=center',headers=auth(owner['token']))).json()['items']),1)
self.assertEqual(len((await c.get('/api/activities?record_type=normal',headers=auth(owner['token']))).json()['items']),0)