Skip to content

Commit

Permalink
bugfix:admin中更新应用信息后logo路径错误 #2
Browse files Browse the repository at this point in the history
  • Loading branch information
jiayuan929 committed Aug 30, 2022
1 parent f63852c commit 4113231
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions backend/app/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,25 @@ def save(self, *args, **kwargs):
# save操作
super(App, self).save(*args, **kwargs)

@property
def logo_url(self):
if self.logo:
return "%s?v=%s" % (self.logo.url, time.time())
else:
# 判断 以 app_code 命名的 logo 图片是否存在
logo_name = "%s/%s.png" % (APP_LOGO_IMG_RELATED, self.code)
logo_path = os.path.join(settings.MEDIA_ROOT, logo_name)
if os.path.exists(logo_path):
return "%s%s" % (settings.MEDIA_URL, logo_name)

# 判断是否是上传saas解压生成的文件, 存在的话使用之(saas内置应用上传包中带的logo)
logo_name = "%s/%s.png" % (SAAS_APP_LOGO_IMG_RELATED, self.code)
logo_path = os.path.join(settings.MEDIA_ROOT, logo_name)
if os.path.exists(logo_path):
return "%s%s" % (settings.MEDIA_URL, logo_name)

return "%simg/app_logo/default.png" % settings.STATIC_URL

@property
def get_logo_url(self):
if self.logo:
Expand Down

0 comments on commit 4113231

Please sign in to comment.