:art: Support QINIU_FILE_URL_HTTPS

huangqimin001 2 years ago
parent
commit
3d4da8390e
2 changed files with 9 additions and 2 deletions
  1. 1 0
      kodo/settings.py
  2. 8 2
      member/models.py

+ 1 - 0
kodo/settings.py

@@ -261,6 +261,7 @@ QINIU = {
261 261
 
262 262
 # 图片链接设置
263 263
 FILE_URL_TYPE = 'AUTO'  # QINIU / SERVER / AUTO
264
+QINIU_FILE_URL_HTTPS = True
264 265
 
265 266
 # 图片设置
266 267
 FILE_UPLOAD_MAX_MEMORY_SIZE = 5242880  # InMemoryUploadedFile 文件最大值

+ 8 - 2
member/models.py

@@ -460,6 +460,12 @@ class MemberActivityInfo(BaseModelMixin, BrandInfoMixin):
460 460
         except MemberActivityContributionWelfareInfo.DoesNotExist:
461 461
             return []
462 462
 
463
+    @property
464
+    def final_content_rich_text(self):
465
+        if settings.QINIU_FILE_URL_HTTPS:
466
+            return self.content_rich_text
467
+        return self.content_rich_text.replace('https://img.tamron.kodo.com.cn/', 'http://img.tamron.kodo.com.cn/')
468
+
463 469
     def data(self, user_id):
464 470
         return {
465 471
             'id': self.activity_id,
@@ -512,7 +518,7 @@ class MemberActivityInfo(BaseModelMixin, BrandInfoMixin):
512 518
             'slider_image': self.slider_image_url,
513 519
             'cover_url': self.cover_url,
514 520
             'limit_image_num': self.limit_image_num,
515
-            'content_rich_text': self.content_rich_text,
521
+            'content_rich_text': self.final_content_rich_text,
516 522
             'share_img_link': self.share_img_link,
517 523
             'share_h5_link': self.share_h5_link,
518 524
             'state': self.final_state,
@@ -586,7 +592,7 @@ class MemberActivityInfo(BaseModelMixin, BrandInfoMixin):
586 592
             'cover_path': self.cover_path,
587 593
             'cover_url': self.cover_url,
588 594
             'limit_image_num': self.limit_image_num,
589
-            'content_rich_text': self.content_rich_text,
595
+            'content_rich_text': self.final_content_rich_text,
590 596
             'share_img_link': self.share_img_link,
591 597
             'share_h5_link': self.share_h5_link,
592 598
             'state': self.final_state,