From bf5f82e5557d54c94ac191d75935772a65570ba6 Mon Sep 17 00:00:00 2001 From: jiayuan929 <252461528@qq.com> Date: Wed, 31 Aug 2022 19:33:08 +0800 Subject: [PATCH] =?UTF-8?q?bugfix:admin=E4=B8=AD=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E5=BA=94=E7=94=A8=E4=BF=A1=E6=81=AF=E5=90=8Elogo=E8=B7=AF?= =?UTF-8?q?=E5=BE=84=E9=94=99=E8=AF=AF=20#2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/models.py | 55 ------------------------------------------- 1 file changed, 55 deletions(-) diff --git a/backend/app/models.py b/backend/app/models.py index c7ee3b6..948faba 100644 --- a/backend/app/models.py +++ b/backend/app/models.py @@ -166,61 +166,6 @@ def _del_exist_file(self, name): if os.path.exists(_file): os.remove(_file) - def save(self, *args, **kwargs): - """ - 保存前修改 logo 存放路径 - """ - if not self.logo: - return super(App, self).save(*args, **kwargs) - # 修改图片名称 - logo_ext = ".png" - # 判断logo名称 - if self.logo.name.find("\\") >= 0: - logo_name = APP_LOGO_IMG_RELATED + "\\" + str(self.code) + logo_ext - elif self.logo.name.find("/") >= 0: - logo_name = APP_LOGO_IMG_RELATED + "/" + str(self.code) + logo_ext - else: - logo_name = APP_LOGO_IMG_RELATED + "/" + str(self.code) + logo_ext - # 判断图片路径与旧图路径名称是否相同 - if cmp(logo_name, self.logo.name): - logo_name = APP_LOGO_IMG_RELATED + "/" + str(self.code) + logo_ext - self._del_exist_file(logo_name) - # 指定图片名称 - self.logo.name = APP_LOGO_IMG_RELATED + "/" + str(self.code) + logo_ext - # 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: - 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) - return "%simg/app_logo/default.png" % settings.STATIC_URL - def tag_name(self): if self.tags and self.tags.name_display: return self.tags.name_display