From ac942c95f80c425647e217621a1ee3a7e8f2e55d Mon Sep 17 00:00:00 2001 From: hit172587zpz Date: Wed, 4 Aug 2021 10:09:43 +0800 Subject: [PATCH 01/25] fix issue-183 --- options/locale/locale_en-US.ini | 2 +- options/locale/locale_zh-CN.ini | 1 + templates/status/500.tmpl | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index e809a33e8..b81dc9694 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -90,7 +90,7 @@ loading = Loading… error404_index = Request forbidden by administrative rules error500_index = Internal Server Error error404 = The page you are trying to reach either does not exist or you are not authorized to view it. - +error500= Sorry, the site has encountered some problems, we are trying to fix the page, please try again later. [error] occurred = An error has occurred report_message = An error has occurred diff --git a/options/locale/locale_zh-CN.ini b/options/locale/locale_zh-CN.ini index 9747bc7dc..5ac54f6c8 100755 --- a/options/locale/locale_zh-CN.ini +++ b/options/locale/locale_zh-CN.ini @@ -90,6 +90,7 @@ loading=正在加载... error404_index = 您的访问受限! error500_index = 抱歉!您指定的网页无法访问。 error404=您正尝试访问的页面 不存在您尚未被授权 查看该页面。 +error500=抱歉,站点遇到一些问题,我们正尝试修复网页,请您稍后再试。 [error] occurred=发生错误 diff --git a/templates/status/500.tmpl b/templates/status/500.tmpl index e4ea06d3d..ca7336f82 100644 --- a/templates/status/500.tmpl +++ b/templates/status/500.tmpl @@ -6,7 +6,7 @@

{{.i18n.Tr "error500_index"}}

-

{{.i18n.Tr "error404" | Safe}}

+

{{.i18n.Tr "error500" | Safe}}

From c4cff584dfd284d105b3cbd6b2b47c8173da11d9 Mon Sep 17 00:00:00 2001 From: hit172587zpz Date: Wed, 4 Aug 2021 10:28:11 +0800 Subject: [PATCH 02/25] fix issue-180 --- templates/home.tmpl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/templates/home.tmpl b/templates/home.tmpl index 35790cbba..3ac2935d5 100755 --- a/templates/home.tmpl +++ b/templates/home.tmpl @@ -127,7 +127,7 @@
- 开发要素统一管理 + 开发要素统一管理
平台提供了AI开发四大要素:模型代码、数据集、模型和执行环境的统一管理
@@ -138,7 +138,7 @@
- 数据协同与共享 + 数据协同与共享
通过在项目中上传数据集,项目成员多人协作完成数据预处理;也可以通过将数据设置为公有数据集,与社区开发者共同建立更好的模型
@@ -149,7 +149,7 @@
- 模型管理与共享 + 模型管理与共享
将模型与代码版本建立关联,可以基于代码历史版本,使用不同的方式调整模型,并将结果保存下来;训练好的模型可以开放共享,让更多人的使用模型测试并提出反馈
@@ -160,7 +160,7 @@
- 一次配置,多次使用 + 一次配置,多次使用
提供执行环境共享,一次配置,多次使用,降低模型开发门槛,避免花费重复的时间配置复杂的环境
From f628b36ce8618ab602510d483f506227975bc7e0 Mon Sep 17 00:00:00 2001 From: hit172587zpz Date: Wed, 4 Aug 2021 11:15:56 +0800 Subject: [PATCH 03/25] fix issue-182 --- templates/repo/home.tmpl | 40 ++++++++++++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/templates/repo/home.tmpl b/templates/repo/home.tmpl index 7d632ea14..f1c47167e 100644 --- a/templates/repo/home.tmpl +++ b/templates/repo/home.tmpl @@ -155,37 +155,61 @@
-

简介

+

简介 + +

- {{if .Repository.DescriptionHTML}} - {{.Repository.DescriptionHTML}} - {{else}} - {{.i18n.Tr "repo.no_desc"}} - {{end}} - {{.Repository.Website}} + {{if .Repository.DescriptionHTML}} + {{.Repository.DescriptionHTML}} + {{else}} + {{.i18n.Tr "repo.no_desc"}} + {{end}} +

+
+ + + {{if .Repository.Website}} +

+ + {{.Repository.Website}} +

+ {{else}} + + {{end}} +

{{range .Topics}}{{.Name}}{{end}} {{if and .Permission.IsAdmin (not .Repository.IsArchived)}}{{.i18n.Tr "repo.topic.manage_topics"}}{{end}}

- + {{if .LanguageStats}}

{{range .LanguageStats}} {{.Language}} {{end}}

+ + {{else}} + + {{end}} + {{if .LICENSE}}

{{if .LICENSE}} {{.LICENSE}} {{end}}

+ {{else}} + + {{end}}
From cad94c529c4b190efbffcb32fd04519021cbd95b Mon Sep 17 00:00:00 2001 From: lewis <747342561@qq.com> Date: Wed, 4 Aug 2021 14:33:21 +0800 Subject: [PATCH 04/25] fix --- modules/convert/convert.go | 1 + modules/structs/user.go | 2 ++ 2 files changed, 3 insertions(+) mode change 100644 => 100755 modules/convert/convert.go mode change 100644 => 100755 modules/structs/user.go diff --git a/modules/convert/convert.go b/modules/convert/convert.go old mode 100644 new mode 100755 index ec18b1305..fa2e8f2e7 --- a/modules/convert/convert.go +++ b/modules/convert/convert.go @@ -335,6 +335,7 @@ func ToUser(user *models.User, signed, authed bool) *api.User { AvatarURL: user.AvatarLink(), FullName: markup.Sanitize(user.FullName), Created: user.CreatedUnix.AsTime(), + IsActive: user.IsActive, } // hide primary email if API caller is anonymous or user keep email private if signed && (!user.KeepEmailPrivate || authed) { diff --git a/modules/structs/user.go b/modules/structs/user.go old mode 100644 new mode 100755 index bf52cc9ed..d6e7298cc --- a/modules/structs/user.go +++ b/modules/structs/user.go @@ -26,6 +26,8 @@ type User struct { Language string `json:"language"` // Is the user an administrator IsAdmin bool `json:"is_admin"` + // Is the user active + IsActive bool `json:"is_active"` // swagger:strfmt date-time LastLogin time.Time `json:"last_login,omitempty"` // swagger:strfmt date-time From db6cf3ee40894e1c1d011756bf99a9578c435bc7 Mon Sep 17 00:00:00 2001 From: lewis <747342561@qq.com> Date: Wed, 4 Aug 2021 16:14:15 +0800 Subject: [PATCH 05/25] fix left problem of 186 --- models/user_mail.go | 12 ++++++++++++ routers/user/auth.go | 9 +++++++++ routers/user/setting/profile.go | 12 ++++++++++++ 3 files changed, 33 insertions(+) mode change 100644 => 100755 models/user_mail.go mode change 100644 => 100755 routers/user/setting/profile.go diff --git a/models/user_mail.go b/models/user_mail.go old mode 100644 new mode 100755 index af9602e71..7244ec378 --- a/models/user_mail.go +++ b/models/user_mail.go @@ -80,6 +80,18 @@ func GetEmailAddressByID(uid, id int64) (*EmailAddress, error) { return email, nil } +// GetEmailAddressByIDAndEmail gets a user's email address by ID and email +func GetEmailAddressByIDAndEmail(uid int64, emailAddr string) (*EmailAddress, error) { + // User ID is required for security reasons + email := &EmailAddress{UID: uid, Email: emailAddr} + if has, err := x.Get(email); err != nil { + return nil, err + } else if !has { + return nil, nil + } + return email, nil +} + func isEmailActive(e Engine, email string, userID, emailID int64) (bool, error) { if len(email) == 0 { return true, nil diff --git a/routers/user/auth.go b/routers/user/auth.go index dd66fcb8b..13e338565 100755 --- a/routers/user/auth.go +++ b/routers/user/auth.go @@ -1266,6 +1266,15 @@ func Activate(ctx *context.Context) { log.Error("Error storing session: %v", err) } + email, err := models.GetEmailAddressByIDAndEmail(user.ID, user.Email) + if err != nil || email == nil{ + log.Error("GetEmailAddressByIDAndEmail failed", ctx.Data["MsgID"]) + } else { + if err := email.Activate(); err != nil { + log.Error("Activate failed: %v", err, ctx.Data["MsgID"]) + } + } + ctx.Flash.Success(ctx.Tr("auth.account_activated")) ctx.Redirect(setting.AppSubURL + "/") return diff --git a/routers/user/setting/profile.go b/routers/user/setting/profile.go old mode 100644 new mode 100755 index d6f25f913..a385f2cac --- a/routers/user/setting/profile.go +++ b/routers/user/setting/profile.go @@ -96,6 +96,18 @@ func ProfilePost(ctx *context.Context, form auth.UpdateProfileForm) { ctx.User.Location = form.Location ctx.User.Language = form.Language ctx.User.Description = form.Description + isUsed, err := models.IsEmailUsed(form.Email) + if err != nil { + ctx.ServerError("IsEmailUsed", err) + return + } + + if isUsed { + ctx.Flash.Error(ctx.Tr("form.email_been_used")) + ctx.Redirect(setting.AppSubURL + "/user/settings") + return + } + if err := models.UpdateUserSetting(ctx.User); err != nil { if _, ok := err.(models.ErrEmailAlreadyUsed); ok { ctx.Flash.Error(ctx.Tr("form.email_been_used")) From f1ef62479d1443a1d4e1f0f78c2750a56faf03c9 Mon Sep 17 00:00:00 2001 From: lewis <747342561@qq.com> Date: Wed, 4 Aug 2021 17:35:37 +0800 Subject: [PATCH 06/25] mod err msg --- routers/routes/routes.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routers/routes/routes.go b/routers/routes/routes.go index 100ff009f..b3565878e 100755 --- a/routers/routes/routes.go +++ b/routers/routes/routes.go @@ -1129,7 +1129,7 @@ func RegisterRoutes(m *macaron.Macaron) { //secure api, m.Group("/secure", func() { - m.Post("/user", binding.Bind(structs.CreateUserOption{}), secure.CreateUser) + m.Post("/user", binding.BindIgnErr(structs.CreateUserOption{}), secure.CreateUser) }, reqBasicAuth) m.Group("/api/internal", func() { From 0344e2ca388b346b764d9f69627c7fb2cca571fa Mon Sep 17 00:00:00 2001 From: hit172587zpz Date: Thu, 5 Aug 2021 09:34:31 +0800 Subject: [PATCH 07/25] modified the issue 182 --- package-lock.json | 48 ++++++++++ package.json | 1 + templates/repo/home.tmpl | 2 +- web_src/js/components/EditAboutInfo.vue | 96 +++++++++++++++++++ web_src/js/components/basic/editDialog.vue | 104 +++++++++++++++++++++ web_src/js/index.js | 20 +++- 6 files changed, 269 insertions(+), 2 deletions(-) create mode 100644 web_src/js/components/EditAboutInfo.vue create mode 100644 web_src/js/components/basic/editDialog.vue diff --git a/package-lock.json b/package-lock.json index 2c3c983e6..b0b0acad0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1841,6 +1841,14 @@ "async-done": "^1.2.2" } }, + "async-validator": { + "version": "1.8.5", + "resolved": "https://registry.npmjs.org/async-validator/-/async-validator-1.8.5.tgz", + "integrity": "sha512-tXBM+1m056MAX0E8TL2iCjg8WvSyXu0Zc8LNtYqrVeyoL3+esHRZ4SieE9fKQyyU09uONjnMEjrNBMqT0mbvmA==", + "requires": { + "babel-runtime": "6.x" + } + }, "asynckit": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", @@ -1934,6 +1942,11 @@ } } }, + "babel-helper-vue-jsx-merge-props": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/babel-helper-vue-jsx-merge-props/-/babel-helper-vue-jsx-merge-props-2.0.3.tgz", + "integrity": "sha512-gsLiKK7Qrb7zYJNgiXKpXblxbV5ffSwR0f5whkPAaBAR4fhi6bwRZxX9wBlIc5M/v8CCkXUbXZL4N/nSE97cqg==" + }, "babel-loader": { "version": "8.1.0", "resolved": "https://registry.npmjs.org/babel-loader/-/babel-loader-8.1.0.tgz", @@ -3882,6 +3895,26 @@ "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.437.tgz", "integrity": "sha512-PBQn2q68ErqMyBUABh9Gh8R6DunGky8aB5y3N5lPM7OVpldwyUbAK5AX9WcwE/5F6ceqvQ+iQLYkJYRysAs6Bg==" }, + "element-ui": { + "version": "2.15.5", + "resolved": "https://registry.npmjs.org/element-ui/-/element-ui-2.15.5.tgz", + "integrity": "sha512-B/YCdz2aRY2WnFXzbTRTHPKZHBD/2KV6u88EBnkaARC/Lyxnap+7vpvrcW5UNTyVwjItS5Fj1eQyRy6236lbXg==", + "requires": { + "async-validator": "~1.8.1", + "babel-helper-vue-jsx-merge-props": "^2.0.0", + "deepmerge": "^1.2.0", + "normalize-wheel": "^1.0.1", + "resize-observer-polyfill": "^1.5.0", + "throttle-debounce": "^1.0.1" + }, + "dependencies": { + "deepmerge": { + "version": "1.5.2", + "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-1.5.2.tgz", + "integrity": "sha512-95k0GDqvBjZavkuvzx/YqVLv/6YYa17fz6ILMSf7neqQITCPbnfEnQvEgMPNjH4kgobe7+WIL0yJEHku+H3qtQ==" + } + } + }, "elliptic": { "version": "6.5.4", "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.4.tgz", @@ -9186,6 +9219,11 @@ "resolved": "https://registry.npmjs.org/normalize-url/-/normalize-url-3.3.0.tgz", "integrity": "sha512-U+JJi7duF1o+u2pynbp2zXDW2/PADgC30f0GsHZtRh+HOcXHnw137TrNlyxxRvWW5fjKd3bcLHPxofWuCjaeZg==" }, + "normalize-wheel": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/normalize-wheel/-/normalize-wheel-1.0.1.tgz", + "integrity": "sha1-rsiGr/2wRQcNhWRH32Ls+GFG7EU=" + }, "now-and-later": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/now-and-later/-/now-and-later-2.0.1.tgz", @@ -11687,6 +11725,11 @@ "resolved": "https://registry.npmjs.org/reselect/-/reselect-4.0.0.tgz", "integrity": "sha512-qUgANli03jjAyGlnbYVAV5vvnOmJnODyABz51RdBN7M4WaVu8mecZWgyQNkG8Yqe3KRGRt0l4K4B3XVEULC4CA==" }, + "resize-observer-polyfill": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/resize-observer-polyfill/-/resize-observer-polyfill-1.5.1.tgz", + "integrity": "sha512-LwZrotdHOo12nQuZlHEmtuXdqGoOD0OhaxopaNFxWzInpEgaLWoVuAMbTzixuosCx2nEG58ngzW3vxdWoxIgdg==" + }, "resolve": { "version": "1.17.0", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.17.0.tgz", @@ -13526,6 +13569,11 @@ "resolved": "https://registry.npmjs.org/textextensions/-/textextensions-2.6.0.tgz", "integrity": "sha512-49WtAWS+tcsy93dRt6P0P3AMD2m5PvXRhuEA0kaXos5ZLlujtYmpmFsB+QvWUSxE1ZsstmYXfQ7L40+EcQgpAQ==" }, + "throttle-debounce": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/throttle-debounce/-/throttle-debounce-1.1.0.tgz", + "integrity": "sha512-XH8UiPCQcWNuk2LYePibW/4qL97+ZQ1AN3FNXwZRBNPPowo/NRU5fAlDCSNBJIYCKbioZfuYtMhG4quqoJhVzg==" + }, "through": { "version": "2.3.8", "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", diff --git a/package.json b/package.json index 4afc213e7..bda9843e8 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,7 @@ "cssnano": "4.1.10", "domino": "2.1.5", "dropzone": "5.7.2", + "element-ui": "2.15.5", "esdk-obs-browserjs": "3.20.7", "esdk-obs-nodejs": "3.20.11", "fast-glob": "3.2.2", diff --git a/templates/repo/home.tmpl b/templates/repo/home.tmpl index f1c47167e..5e33aa7be 100644 --- a/templates/repo/home.tmpl +++ b/templates/repo/home.tmpl @@ -155,7 +155,7 @@
-

简介 +

简介 diff --git a/web_src/js/components/EditAboutInfo.vue b/web_src/js/components/EditAboutInfo.vue new file mode 100644 index 000000000..53e4915a0 --- /dev/null +++ b/web_src/js/components/EditAboutInfo.vue @@ -0,0 +1,96 @@ + + + + + diff --git a/web_src/js/components/basic/editDialog.vue b/web_src/js/components/basic/editDialog.vue new file mode 100644 index 000000000..810a73a11 --- /dev/null +++ b/web_src/js/components/basic/editDialog.vue @@ -0,0 +1,104 @@ + + + + diff --git a/web_src/js/index.js b/web_src/js/index.js index 1a4326f7d..e7e57d1b9 100755 --- a/web_src/js/index.js +++ b/web_src/js/index.js @@ -6,6 +6,8 @@ import './publicpath.js'; import './polyfills.js'; import Vue from 'vue'; +import ElementUI from 'element-ui'; +import 'element-ui/lib/theme-chalk/index.css'; import 'jquery.are-you-sure'; import './vendor/semanticdropdown.js'; import {svg} from './utils.js'; @@ -29,8 +31,10 @@ import { } from './features/notification.js'; import {createCodeEditor} from './features/codeeditor.js'; import MinioUploader from './components/MinioUploader.vue'; -import ObsUploader from './components/ObsUploader.vue' +import ObsUploader from './components/ObsUploader.vue'; +import EditAboutInfo from './components/EditAboutInfo.vue'; +Vue.use(ElementUI); const {AppSubUrl, StaticUrlPrefix, csrf} = window.config; function htmlEncode(text) { @@ -2957,6 +2961,7 @@ $(document).ready(async () => { initVueApp(); initVueUploader(); initObsUploader(); + initVueEditAbout(); initTeamSettings(); initCtrlEnterSubmit(); initNavbarContentToggle(); @@ -3642,6 +3647,19 @@ function initVueUploader() { }); } +function initVueEditAbout() { + const el = document.getElementById('about-desc'); + console.log(el) + if (!el) { + return; + } + + new Vue({ + el: '#about-desc', + render: h => h(EditAboutInfo) + }); +} + // 新增 function initObsUploader() { const el = document.getElementById('obsUploader'); From c9f19b30baf5680ef4a6f35734bcb554e2af7995 Mon Sep 17 00:00:00 2001 From: hit172587zpz Date: Thu, 5 Aug 2021 09:37:15 +0800 Subject: [PATCH 08/25] fix bug --- templates/repo/home.tmpl | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/templates/repo/home.tmpl b/templates/repo/home.tmpl index 5e33aa7be..a50b6e83f 100644 --- a/templates/repo/home.tmpl +++ b/templates/repo/home.tmpl @@ -178,8 +178,8 @@ {{.Repository.Website}}

- {{else}} - + {{end}}

@@ -196,19 +196,19 @@ {{end}}

- {{else}} - + {{end}} {{if .LICENSE}}

- {{if .LICENSE}} + {{.LICENSE}} - {{end}} +

- {{else}} - + {{end}}
From f368edf4bdd35266bedbfb7dcdc453a8b4f25431 Mon Sep 17 00:00:00 2001 From: hit172587zpz Date: Thu, 5 Aug 2021 09:42:54 +0800 Subject: [PATCH 09/25] modified the issue --- templates/home.tmpl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/templates/home.tmpl b/templates/home.tmpl index 3ac2935d5..97a2a7fc9 100755 --- a/templates/home.tmpl +++ b/templates/home.tmpl @@ -127,7 +127,7 @@

- 开发要素统一管理 +

开发要素统一管理

平台提供了AI开发四大要素:模型代码、数据集、模型和执行环境的统一管理
@@ -138,7 +138,7 @@
- 数据协同与共享 +

数据协同与共享

通过在项目中上传数据集,项目成员多人协作完成数据预处理;也可以通过将数据设置为公有数据集,与社区开发者共同建立更好的模型
@@ -149,7 +149,7 @@
- 模型管理与共享 +

模型管理与共享

将模型与代码版本建立关联,可以基于代码历史版本,使用不同的方式调整模型,并将结果保存下来;训练好的模型可以开放共享,让更多人的使用模型测试并提出反馈
@@ -160,7 +160,7 @@
- 一次配置,多次使用 +

一次配置,多次使用

提供执行环境共享,一次配置,多次使用,降低模型开发门槛,避免花费重复的时间配置复杂的环境
From b93808dddf02f318905d289c92607376efff06ff Mon Sep 17 00:00:00 2001 From: zouap Date: Thu, 5 Aug 2021 10:48:03 +0800 Subject: [PATCH 10/25] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=B8=B8=E5=AE=A2?= =?UTF-8?q?=E8=AE=BF=E9=97=AE=E6=97=B6=EF=BC=8C=E7=94=A8=E6=88=B7=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E4=B8=BA=E7=A9=BA=E7=9A=84=E6=83=85=E5=86=B5=E5=88=A4?= =?UTF-8?q?=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- routers/repo/attachment.go | 19 ++++++++++--------- routers/repo/dataset.go | 4 ++-- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/routers/repo/attachment.go b/routers/repo/attachment.go index 830f193ee..6fa89420d 100755 --- a/routers/repo/attachment.go +++ b/routers/repo/attachment.go @@ -151,18 +151,19 @@ func DownloadUserIsOrgOrCollaboration(ctx *context.Context, attach *models.Attac log.Info("query repo error.") } else { repo.GetOwner() - if repo.Owner.IsOrganization() { - //log.Info("ower is org.") - if repo.Owner.IsUserPartOfOrg(ctx.User.ID) { - log.Info("org user may visit the attach.") + if ctx.User != nil { + if repo.Owner.IsOrganization() { + if repo.Owner.IsUserPartOfOrg(ctx.User.ID) { + log.Info("org user may visit the attach.") + return true + } + } + isCollaborator, _ := repo.IsCollaborator(ctx.User.ID) + if isCollaborator { + log.Info("Collaborator user may visit the attach.") return true } } - isCollaborator, _ := repo.IsCollaborator(ctx.User.ID) - if isCollaborator { - log.Info("Collaborator user may visit the attach.") - return true - } } } return false diff --git a/routers/repo/dataset.go b/routers/repo/dataset.go index bdadd2066..b2da4b8d8 100755 --- a/routers/repo/dataset.go +++ b/routers/repo/dataset.go @@ -32,13 +32,13 @@ func newFilterPrivateAttachments(ctx *context.Context, list []*models.Attachment repo.GetOwner() } permission := false - if repo.Owner.IsOrganization() { + if repo.Owner.IsOrganization() && ctx.User != nil { if repo.Owner.IsUserPartOfOrg(ctx.User.ID) { log.Info("user is member of org.") permission = true } } - if !permission { + if !permission && ctx.User != nil { isCollaborator, _ := repo.IsCollaborator(ctx.User.ID) if isCollaborator { log.Info("Collaborator user may visit the attach.") From cafa013fa58fdfb95d1c45ec80f82c9a51310663 Mon Sep 17 00:00:00 2001 From: zouap Date: Thu, 5 Aug 2021 11:32:04 +0800 Subject: [PATCH 11/25] =?UTF-8?q?=E5=BD=93=E6=95=B0=E6=8D=AE=E9=9B=86?= =?UTF-8?q?=E6=98=AF=E5=85=AC=E6=9C=89=E6=97=B6=EF=BC=8C=E4=B8=94=E7=99=BB?= =?UTF-8?q?=E5=BD=95=E7=94=A8=E6=88=B7=E5=A6=82=E6=9E=9C=E8=83=BD=E7=9C=8B?= =?UTF-8?q?=E5=88=B0=EF=BC=8C=E9=82=A3=E4=B9=88=E5=B0=B1=E5=8F=AF=E4=BB=A5?= =?UTF-8?q?=E4=B8=8B=E8=BD=BD=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- routers/repo/attachment.go | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/routers/repo/attachment.go b/routers/repo/attachment.go index 6fa89420d..ed9f7c47e 100755 --- a/routers/repo/attachment.go +++ b/routers/repo/attachment.go @@ -177,7 +177,6 @@ func GetAttachment(ctx *context.Context) { ctx.ServerError("checkTypeCloudBrain failed", err) return } - attach, err := models.GetAttachmentByUUID(ctx.Params(":uuid")) if err != nil { if models.IsErrAttachmentNotExist(err) { @@ -187,22 +186,19 @@ func GetAttachment(ctx *context.Context) { } return } - repository, unitType, err := attach.LinkedRepository() if err != nil { ctx.ServerError("LinkedRepository", err) return } - if repository == nil { //If not linked //if !(ctx.IsSigned && attach.UploaderID == ctx.User.ID) && attach.IsPrivate { //We block if not the uploader - if !(ctx.IsSigned && attach.UploaderID == ctx.User.ID) && !DownloadUserIsOrgOrCollaboration(ctx, attach) { //We block if not the uploader + if !(ctx.IsSigned && attach.UploaderID == ctx.User.ID) && attach.IsPrivate && !DownloadUserIsOrgOrCollaboration(ctx, attach) { //We block if not the uploader ctx.Error(http.StatusNotFound) return } } else { //If we have the repository we check access - perm, err := models.GetUserRepoPermission(repository, ctx.User) if err != nil { ctx.Error(http.StatusInternalServerError, "GetUserRepoPermission", err.Error()) @@ -213,7 +209,6 @@ func GetAttachment(ctx *context.Context) { return } } - dataSet, err := attach.LinkedDataSet() if err != nil { ctx.ServerError("LinkedDataSet", err) From eebd5aa32bac4540ac9ac1170c02f0ea30fe0f4d Mon Sep 17 00:00:00 2001 From: zouap Date: Thu, 5 Aug 2021 16:32:31 +0800 Subject: [PATCH 12/25] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E5=88=9B=E5=BB=BA=E8=80=85=E4=B8=8D=E8=83=BD=E4=B8=8B=E8=BD=BD?= =?UTF-8?q?=20=E5=8D=8F=E4=BD=9C=E8=80=85=E4=B8=8A=E4=BC=A0=E7=9A=84?= =?UTF-8?q?=E7=A7=81=E6=9C=89=E6=95=B0=E6=8D=AE=E9=9B=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- routers/repo/attachment.go | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/routers/repo/attachment.go b/routers/repo/attachment.go index ed9f7c47e..cdb73c8a0 100755 --- a/routers/repo/attachment.go +++ b/routers/repo/attachment.go @@ -152,6 +152,7 @@ func DownloadUserIsOrgOrCollaboration(ctx *context.Context, attach *models.Attac } else { repo.GetOwner() if ctx.User != nil { + if repo.Owner.IsOrganization() { if repo.Owner.IsUserPartOfOrg(ctx.User.ID) { log.Info("org user may visit the attach.") @@ -177,6 +178,7 @@ func GetAttachment(ctx *context.Context) { ctx.ServerError("checkTypeCloudBrain failed", err) return } + attach, err := models.GetAttachmentByUUID(ctx.Params(":uuid")) if err != nil { if models.IsErrAttachmentNotExist(err) { @@ -186,22 +188,31 @@ func GetAttachment(ctx *context.Context) { } return } + repository, unitType, err := attach.LinkedRepository() if err != nil { ctx.ServerError("LinkedRepository", err) return } + dataSet, err := attach.LinkedDataSet() + + if repository == nil && dataSet != nil { + repository, _ = models.GetRepositoryByID(dataSet.RepoID) + unitType = models.UnitTypeDatasets + } + if repository == nil { //If not linked //if !(ctx.IsSigned && attach.UploaderID == ctx.User.ID) && attach.IsPrivate { //We block if not the uploader + //log.Info("ctx.IsSigned =" + fmt.Sprintf("%v", ctx.IsSigned)) if !(ctx.IsSigned && attach.UploaderID == ctx.User.ID) && attach.IsPrivate && !DownloadUserIsOrgOrCollaboration(ctx, attach) { //We block if not the uploader ctx.Error(http.StatusNotFound) return } } else { //If we have the repository we check access - perm, err := models.GetUserRepoPermission(repository, ctx.User) - if err != nil { - ctx.Error(http.StatusInternalServerError, "GetUserRepoPermission", err.Error()) + perm, errPermission := models.GetUserRepoPermission(repository, ctx.User) + if errPermission != nil { + ctx.Error(http.StatusInternalServerError, "GetUserRepoPermission", errPermission.Error()) return } if !perm.CanRead(unitType) { @@ -209,12 +220,11 @@ func GetAttachment(ctx *context.Context) { return } } - dataSet, err := attach.LinkedDataSet() + //dataSet, err := attach.LinkedDataSet() if err != nil { ctx.ServerError("LinkedDataSet", err) return } - if dataSet != nil { isPermit, err := models.GetUserDataSetPermission(dataSet, ctx.User) if err != nil { From 495addb579311ca31b46398b34db55a1f766a5e4 Mon Sep 17 00:00:00 2001 From: zouap Date: Thu, 5 Aug 2021 16:50:27 +0800 Subject: [PATCH 13/25] =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E9=9B=86=E7=9A=84=E9=94=99=E8=AF=AF=E5=88=A4=E6=96=AD=E9=80=BB?= =?UTF-8?q?=E8=BE=91=E5=BE=80=E4=B8=8A=E6=8F=90=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- routers/repo/attachment.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/routers/repo/attachment.go b/routers/repo/attachment.go index cdb73c8a0..fea7a3384 100755 --- a/routers/repo/attachment.go +++ b/routers/repo/attachment.go @@ -195,6 +195,10 @@ func GetAttachment(ctx *context.Context) { return } dataSet, err := attach.LinkedDataSet() + if err != nil { + ctx.ServerError("LinkedDataSet", err) + return + } if repository == nil && dataSet != nil { repository, _ = models.GetRepositoryByID(dataSet.RepoID) @@ -220,11 +224,7 @@ func GetAttachment(ctx *context.Context) { return } } - //dataSet, err := attach.LinkedDataSet() - if err != nil { - ctx.ServerError("LinkedDataSet", err) - return - } + if dataSet != nil { isPermit, err := models.GetUserDataSetPermission(dataSet, ctx.User) if err != nil { From abfcb9984cae133935da78c87ca93d9c3ee62d6f Mon Sep 17 00:00:00 2001 From: lewis <747342561@qq.com> Date: Thu, 5 Aug 2021 17:58:49 +0800 Subject: [PATCH 14/25] ignore blockchain error --- models/user.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/models/user.go b/models/user.go index 3dcd2eee9..42e688358 100755 --- a/models/user.go +++ b/models/user.go @@ -976,12 +976,12 @@ func CreateUser(u *User) (err error) { result, err := blockchain.CreateBlockchainAccount() if err != nil { log.Error("createBlockchainAccount failed:", err.Error()) - return err + //return err + } else { + u.PublicKey = result.Payload["publickey"].(string) + u.PrivateKey = result.Payload["privatekey"].(string) } - u.PublicKey = result.Payload["publickey"].(string) - u.PrivateKey = result.Payload["privatekey"].(string) - sess := x.NewSession() defer sess.Close() if err = sess.Begin(); err != nil { From 2202e4b4b90c3145954f10273f30ccc907df2de5 Mon Sep 17 00:00:00 2001 From: hit172587zpz Date: Fri, 6 Aug 2021 09:38:49 +0800 Subject: [PATCH 15/25] fix issue-182 issue-181 and new create the edit about desc link fucntion --- templates/repo/home.tmpl | 16 ++-- web_src/js/components/EditAboutInfo.vue | 96 ++++++++++++++++------ web_src/js/components/basic/editDialog.vue | 9 +- web_src/js/index.js | 4 + 4 files changed, 86 insertions(+), 39 deletions(-) diff --git a/templates/repo/home.tmpl b/templates/repo/home.tmpl index a50b6e83f..ca064b990 100644 --- a/templates/repo/home.tmpl +++ b/templates/repo/home.tmpl @@ -178,8 +178,7 @@ {{.Repository.Website}}

- + {{end}}

@@ -188,7 +187,7 @@ {{if and .Permission.IsAdmin (not .Repository.IsArchived)}}{{.i18n.Tr "repo.topic.manage_topics"}}{{end}}

- {{if .LanguageStats}} +

{{range .LanguageStats}} @@ -196,19 +195,14 @@ {{end}}

- - {{end}} + {{if .LICENSE}}

- - {{.LICENSE}} - + {{.LICENSE}}

- + {{end}}
diff --git a/web_src/js/components/EditAboutInfo.vue b/web_src/js/components/EditAboutInfo.vue index 53e4915a0..76157008f 100644 --- a/web_src/js/components/EditAboutInfo.vue +++ b/web_src/js/components/EditAboutInfo.vue @@ -11,17 +11,19 @@ v-model="editDataDialog" :deleteCallback="editDataFunc" :deleteLoading ="editDataListLoading" + deleteParam = "ruleForm" + @input="initForm" >
- - - + + + - - + +
@@ -30,13 +32,9 @@