def club_picture(cid, request=('qrcode', 'latest', 'mixed')): '得到图片板块的图片' dict_render = {} sname = ClubSnap.sname_find_by_cid(cid) img_qry = ShareSnap.image_list_by_aid('club', cid) if 'qrcode' in request: #二维码 dict_render['qrcode'] = QrcodeSnap.qrcode_find(sname, "club") if len(img_qry) == 0: dict_render['latest'] = None dict_render['mixed'] = None return dict_render if 'latest' in request: #获取最新 dict_render['latest'] = ShareSnap.url_find_by_attach(img_qry[0]) if 'mixed' in request: #获取杂烩 dict_render['mixed'] = ShareSnap.mix_find(sname) return dict_render
def attach_wrap(suid): '通过 qry 中的 attach_uuid 找到附件并计算 dict_render' if not suid: return [] if not ShareInfo.objects.filter(attach_uuid=suid, status=0).exists(): return [] qry = ShareAttach.objects.filter(attach_uuid=suid) attach_list = [] for index, i in enumerate(qry, 1): url = ShareSnap.url_find_by_attach(i) attach_list.append({ 'url': url, 'data': i, 'name': i.name_raw, 'thumbnail': ShareSnap.thumbnail_find \ (suid, 'exlarge', i.second_uuid), 'index2': index % 2, 'index3': index % 3, 'index4': index % 4, }) return attach_list