@@ -0,0 +1,34 @@  | 
            ||
| 1 | 
                +# -*- coding: utf-8 -*-  | 
            |
| 2 | 
                +from __future__ import unicode_literals  | 
            |
| 3 | 
                +  | 
            |
| 4 | 
                +from django.db import models, migrations  | 
            |
| 5 | 
                +  | 
            |
| 6 | 
                +  | 
            |
| 7 | 
                +class Migration(migrations.Migration):  | 
            |
| 8 | 
                +  | 
            |
| 9 | 
                + dependencies = [  | 
            |
| 10 | 
                +        ('group', '0013_groupinfo_group_default_avatar'),
               | 
            |
| 11 | 
                + ]  | 
            |
| 12 | 
                +  | 
            |
| 13 | 
                + operations = [  | 
            |
| 14 | 
                + migrations.AddField(  | 
            |
| 15 | 
                + model_name='groupphotoinfo',  | 
            |
| 16 | 
                + name='photo_h',  | 
            |
| 17 | 
                + field=models.IntegerField(default=0, help_text='\u7167\u7247\u9ad8\u5ea6', verbose_name='photo_h'),  | 
            |
| 18 | 
                + ),  | 
            |
| 19 | 
                + migrations.AddField(  | 
            |
| 20 | 
                + model_name='groupphotoinfo',  | 
            |
| 21 | 
                + name='photo_thumbnail_h',  | 
            |
| 22 | 
                + field=models.IntegerField(default=0, help_text='\u7167\u7247\u7f29\u7565\u56fe\u9ad8\u5ea6', verbose_name='photo_thumbnail_h'),  | 
            |
| 23 | 
                + ),  | 
            |
| 24 | 
                + migrations.AddField(  | 
            |
| 25 | 
                + model_name='groupphotoinfo',  | 
            |
| 26 | 
                + name='photo_thumbnail_w',  | 
            |
| 27 | 
                + field=models.IntegerField(default=0, help_text='\u7167\u7247\u7f29\u7565\u56fe\u5bbd\u5ea6', verbose_name='photo_thumbnail_w'),  | 
            |
| 28 | 
                + ),  | 
            |
| 29 | 
                + migrations.AddField(  | 
            |
| 30 | 
                + model_name='groupphotoinfo',  | 
            |
| 31 | 
                + name='photo_w',  | 
            |
| 32 | 
                + field=models.IntegerField(default=0, help_text='\u7167\u7247\u5bbd\u5ea6', verbose_name='photo_w'),  | 
            |
| 33 | 
                + ),  | 
            |
| 34 | 
                + ]  | 
            
                @@ -116,7 +116,11 @@ class GroupPhotoInfo(CreateUpdateMixin):  | 
            ||
| 116 | 116 | 
                user_id = models.CharField(_(u'user_id'), max_length=255, blank=True, null=True, help_text=u'用户唯一标识')  | 
            
| 117 | 117 | 
                nickname = models.CharField(_(u'nickname'), max_length=255, blank=True, null=True, help_text=u'用户群组昵称')  | 
            
| 118 | 118 | 
                photo_path = models.CharField(_(u'photo_path'), max_length=255, blank=True, null=True, help_text=u'照片存放路径')  | 
            
| 119 | 
                + photo_w = models.IntegerField(_(u'photo_w'), default=0, help_text=u'照片宽度')  | 
            |
| 120 | 
                + photo_h = models.IntegerField(_(u'photo_h'), default=0, help_text=u'照片高度')  | 
            |
| 119 | 121 | 
                photo_thumbnail_path = models.CharField(_(u'photo_thumbnail_path'), max_length=255, blank=True, null=True, help_text=u'照片缩略图存放路径')  | 
            
| 122 | 
                + photo_thumbnail_w = models.IntegerField(_(u'photo_thumbnail_w'), default=0, help_text=u'照片缩略图宽度')  | 
            |
| 123 | 
                + photo_thumbnail_h = models.IntegerField(_(u'photo_thumbnail_h'), default=0, help_text=u'照片缩略图高度')  | 
            |
| 120 | 124 | 
                comment_num = models.IntegerField(_(u'comment_num'), default=0, help_text=u'照片评论数量')  | 
            
| 121 | 125 | 
                thumbup_num = models.IntegerField(_(u'thumbup_num'), default=0, help_text=u'照片点赞数量')  | 
            
| 122 | 126 | 
                 | 
            
                @@ -141,7 +145,11 @@ class GroupPhotoInfo(CreateUpdateMixin):  | 
            ||
| 141 | 145 | 
                'user_id': self.user_id,  | 
            
| 142 | 146 | 
                'photo_id': self.pk,  | 
            
| 143 | 147 | 
                'photo_url': self.photo_url,  | 
            
| 148 | 
                + 'photo_w': self.photo_w,  | 
            |
| 149 | 
                + 'photo_h': self.photo_h,  | 
            |
| 144 | 150 | 
                'photo_thumbnail_url': self.photo_thumbnail_url,  | 
            
| 151 | 
                + 'photo_thumbnail_w': self.photo_thumbnail_w,  | 
            |
| 152 | 
                + 'photo_thumbnail_h': self.photo_thumbnail_h,  | 
            |
| 145 | 153 | 
                'comment_num': self.comment_num,  | 
            
| 146 | 154 | 
                'thumbup_num': self.thumbup_num,  | 
            
| 147 | 155 | 
                }  | 
            
                @@ -402,7 +402,7 @@ def flyimg_upload_api(request):  | 
            ||
| 402 | 402 | 
                default_storage.delete(photo_thumbnail_path)  | 
            
| 403 | 403 | 
                default_storage.save(photo_thumbnail_path, photo)  | 
            
| 404 | 404 | 
                 | 
            
| 405 | 
                - make_thumb(  | 
            |
| 405 | 
                + photo_w, photo_h, photo_thumbnail_w, photo_thumbnail_h = make_thumb(  | 
            |
| 406 | 406 | 
                             os.path.join(settings.MEDIA_ROOT, photo_thumbnail_path).replace('\\', '/'),
               | 
            
| 407 | 407 | 
                settings.THUMBNAIL_MAX_WIDTH  | 
            
| 408 | 408 | 
                )  | 
            
                @@ -412,7 +412,11 @@ def flyimg_upload_api(request):  | 
            ||
| 412 | 412 | 
                user_id=user_id,  | 
            
| 413 | 413 | 
                nickname=nickname,  | 
            
| 414 | 414 | 
                photo_path=photo_path,  | 
            
| 415 | 
                + photo_w=photo_w,  | 
            |
| 416 | 
                + photo_h=photo_h,  | 
            |
| 415 | 417 | 
                photo_thumbnail_path=photo_thumbnail_path,  | 
            
| 418 | 
                + photo_thumbnail_w=photo_thumbnail_w,  | 
            |
| 419 | 
                + photo_thumbnail_h=photo_thumbnail_h,  | 
            |
| 416 | 420 | 
                )  | 
            
| 417 | 421 | 
                 | 
            
| 418 | 422 | 
                group_photos = GroupPhotoInfo.objects.filter(  | 
            
                @@ -649,7 +653,7 @@ def pai2_home_api(request):  | 
            ||
| 649 | 653 | 
                     num = int(request.POST.get('num', settings.PAI2_HOME_PER_PAGE))
               | 
            
| 650 | 654 | 
                 | 
            
| 651 | 655 | 
                cursor = connection.cursor()  | 
            
| 652 | 
                -    cursor.execute(r"select T1.group_id, T2.group_name, T2.group_default_avatar, T2.group_avatar, T3.photo_thumbnail_path, T3.comment_num, T3.thumbup_num, T3.created_at from (select * from group_groupuserinfo where user_id='{user_id}') as T1 left outer join group_groupinfo as T2 on T1.group_id = T2.group_id left outer join group_groupphotoinfo as T3 on T1.group_id = T3.group_id and T3.id > T1.current_id order by T3.id desc, T3.thumbup_num desc limit {offset}, {rows};".format(
               | 
            |
| 656 | 
                +    cursor.execute(r"select T1.group_id, T2.group_name, T2.group_default_avatar, T2.group_avatar, T3.photo_thumbnail_path, T3.photo_thumbnail_w, T3.photo_thumbnail_h, T3.comment_num, T3.thumbup_num, T3.created_at from (select * from group_groupuserinfo where user_id='{user_id}') as T1 left outer join group_groupinfo as T2 on T1.group_id = T2.group_id left outer join group_groupphotoinfo as T3 on T1.group_id = T3.group_id and T3.id > T1.current_id order by T3.id desc, T3.thumbup_num desc limit {offset}, {rows};".format(
               | 
            |
| 653 | 657 | 
                user_id=user_id,  | 
            
| 654 | 658 | 
                offset=0,  | 
            
| 655 | 659 | 
                rows=settings.PAI2_HOME_MAX_ROWS,  | 
            
                @@ -664,9 +668,11 @@ def pai2_home_api(request):  | 
            ||
| 664 | 668 | 
                'group_default_avatar': row[2],  | 
            
| 665 | 669 | 
                'group_avatar': row[3],  | 
            
| 666 | 670 | 
                         'photo_thumbnail_url': u'{0}/{1}'.format(settings.IMG_DOMAIN, row[4]) if row[4] else '',
               | 
            
| 667 | 
                - 'comment_num': row[5],  | 
            |
| 668 | 
                - 'thumbup_num': row[6],  | 
            |
| 669 | 
                - 'created_at': row[7],  | 
            |
| 671 | 
                + 'photo_thumbnail_w': row[5],  | 
            |
| 672 | 
                + 'photo_thumbnail_h': row[6],  | 
            |
| 673 | 
                + 'comment_num': row[7],  | 
            |
| 674 | 
                + 'thumbup_num': row[8],  | 
            |
| 675 | 
                + 'created_at': row[9],  | 
            |
| 670 | 676 | 
                } for row in rows]  | 
            
| 671 | 677 | 
                 | 
            
| 672 | 678 | 
                     return JsonResponse({
               | 
            
                @@ -15,3 +15,4 @@ def make_thumb(im_path, max_width=360):  | 
            ||
| 15 | 15 | 
                thumb_height = height / width * thumb_width  | 
            
| 16 | 16 | 
                im.thumbnail((thumb_width, thumb_height))  | 
            
| 17 | 17 | 
                im.save(im_path, im.format or 'JPEG')  | 
            
| 18 | 
                + return width, height, thumb_width, thumb_height  |