12345678910111213141516171819202122232425262728293031323334353637 |
- import itertools
- from group.models import GroupPhotoInfo
- def get_current_photos(group_id, user_id, current_id, request=None):
-
- group_photos = GroupPhotoInfo.objects.filter(
- group_id=group_id,
- status=True,
- pk__gt=current_id,
- )
-
- group_tmp_photos = group_photos.order_by(
- '-pk',
- )
- latest_photo = group_tmp_photos.first()
-
-
-
-
-
-
- group_photos = group_photos.order_by(
- '-pk',
- )
- if request and request.weixin:
- group_photos = group_photos[:30]
- group_photos = map(lambda x: {'session_id': x[0], 'photos': [y.photo_info(user_id) for y in x[1]]},
- itertools.groupby(group_photos, lambda x: x.session_id))
- return {
- 'current_id': latest_photo and latest_photo.pk or current_id,
- 'photos': group_photos,
- }
|