@@ -2,6 +2,7 @@  | 
            ||
| 2 | 2 | 
                 | 
            
| 3 | 3 | 
                from __future__ import division  | 
            
| 4 | 4 | 
                 | 
            
| 5 | 
                +import itertools  | 
            |
| 5 | 6 | 
                import os  | 
            
| 6 | 7 | 
                import random  | 
            
| 7 | 8 | 
                 | 
            
                @@ -585,13 +586,18 @@ def flyimg_upload_api(request):  | 
            ||
| 585 | 586 | 
                status=True,  | 
            
| 586 | 587 | 
                pk__gt=max(current_id, group_user.current_id),  | 
            
| 587 | 588 | 
                ).order_by(  | 
            
| 589 | 
                + '-session_id',  | 
            |
| 588 | 590 | 
                '-pk'  | 
            
| 589 | 591 | 
                )  | 
            
| 592 | 
                + # 最新照片  | 
            |
| 590 | 593 | 
                latest_photo = group_photos.first()  | 
            
| 594 | 
                + # 照片按照 session_id 分组  | 
            |
| 595 | 
                +    group_photos = map(lambda x: {'session_id': x[0], 'photos': [y.photo_info(user_id) for y in x[1]]},
               | 
            |
| 596 | 
                + itertools.groupby(group_photos, lambda x: x.session_id))  | 
            |
| 591 | 597 | 
                 | 
            
| 592 | 598 | 
                     return response(200, 'Flyimg Upload Success', u'飞图上传成功', {
               | 
            
| 593 | 599 | 
                'current_id': latest_photo and latest_photo.pk or current_id,  | 
            
| 594 | 
                - 'photos': [photo.photo_info(user_id) for photo in group_photos],  | 
            |
| 600 | 
                + 'photos': group_photos,  | 
            |
| 595 | 601 | 
                })  | 
            
| 596 | 602 | 
                 | 
            
| 597 | 603 | 
                 |