Browse Source

Merge pull request '#fix-1250 通过标签将组织(如盘古大模型)生态项目关联起来' (#1603) from fix-1250 into V20220314

Reviewed-on: https://git.openi.org.cn/OpenI/aiforge/pulls/1603
Reviewed-by: lewis <747342561@qq.com>
Reviewed-by: zhoupzh <zhoupzh@pcl.ac.cn>
pull/1610/head
chenyifan01 3 years ago
parent
commit
38561eba2e
9 changed files with 121 additions and 30 deletions
  1. +2
    -2
      models/org.go
  2. +13
    -0
      models/topic.go
  3. +6
    -0
      modules/repository/fork.go
  4. +3
    -0
      options/locale/locale_en-US.ini
  5. +3
    -0
      options/locale/locale_zh-CN.ini
  6. +7
    -0
      routers/org/home.go
  7. +48
    -3
      templates/org/home.tmpl
  8. +4
    -24
      templates/org/home_courses.tmpl
  9. +35
    -1
      web_src/less/openi.less

+ 2
- 2
models/org.go View File

@@ -180,8 +180,8 @@ func CreateOrganization(org, owner *User) (err error) {

// Add initial creator to organization and owner team.
if _, err = sess.Insert(&OrgUser{
UID: owner.ID,
OrgID: org.ID,
UID: owner.ID,
OrgID: org.ID,
IsPublic: setting.Service.DefaultOrgMemberVisible,
}); err != nil {
return fmt.Errorf("insert org-user relation: %v", err)


+ 13
- 0
models/topic.go View File

@@ -324,3 +324,16 @@ func SaveTopics(repoID int64, topicNames ...string) error {

return sess.Commit()
}

func GetOrgTopics(orgId int64) ([]Topic, error) {
result := make([]Topic, 0)
sql := "select distinct(t.*) from repository r " +
"inner join repo_topic rt on rt.repo_id = r.id " +
"inner join topic t on rt.topic_id = t.id " +
"where r.owner_id = ? order by repo_count desc limit 50"
if e := x.SQL(sql, orgId).Find(&result); e != nil {
return nil, e
}

return result, nil
}

+ 6
- 0
modules/repository/fork.go View File

@@ -86,5 +86,11 @@ func ForkRepository(doer, owner *models.User, oldRepo *models.Repository, name,
if err := models.CopyLanguageStat(oldRepo, repo); err != nil {
log.Error("Copy language stat from oldRepo failed")
}
//inherit parent repo's topics
if len(oldRepo.Topics) > 0 {
if err := models.SaveTopics(repo.ID, oldRepo.Topics...); err != nil {
log.Error("SaveTopics failed when fork,e=%v", err)
}
}
return repo, models.CopyLFS(ctx, repo, oldRepo)
}

+ 3
- 0
options/locale/locale_en-US.ini View File

@@ -2089,6 +2089,7 @@ team_unit_disabled = (Disabled)
selected_couse=Selected Courses
release_course = Publish Course
all_keywords=All keywords
all_org_topics=All
max_selectedPro= Select up to 9 public projects
custom_select_courses = Customize selected courses
recommend_remain_pro = Remain
@@ -2097,6 +2098,8 @@ select_again = Select more than 9, please select again!
custom_select_projects = Customize selected projects
customize = Customize
selected_project=Selected Projects
fold = Fold
unfold = Unfold

form.name_reserved = The organization name '%s' is reserved.
form.name_pattern_not_allowed = The pattern '%s' is not allowed in an organization name.


+ 3
- 0
options/locale/locale_zh-CN.ini View File

@@ -2096,6 +2096,7 @@ team_unit_disabled=(已禁用)
selected_couse=精选课程
release_course = 发布课程
all_keywords=全部关键字
all_org_topics=全部
max_selectedPro= 最多可选9个公开项目
custom_select_courses = 自定义精选课程
recommend_remain_pro = 还能推荐
@@ -2104,6 +2105,8 @@ select_again = 选择超过9个,请重新选择!
custom_select_projects = 自定义精选项目
customize = 自定义
selected_project=精选项目
fold = 折叠
unfold = 展开

form.name_reserved=组织名称 '%s' 是被保留的。
form.name_pattern_not_allowed=组织名称中不允许使用 "%s"。


+ 7
- 0
routers/org/home.go View File

@@ -94,6 +94,13 @@ func Home(ctx *context.Context) {
recommendCourseKeyWords, _ := repository.GetRecommendCourseKeyWords()
ctx.Data["CoursesKeywords"] = recommendCourseKeyWords

} else {
orgTopics, err := models.GetOrgTopics(org.ID)
if err != nil {
ctx.Error(500, "GetOrgTopics failed")
return
}
ctx.Data["OrgTopics"] = orgTopics
}

repos, count, err = models.SearchRepository(&models.SearchRepoOptions{


+ 48
- 3
templates/org/home.tmpl View File

@@ -23,21 +23,50 @@
{{template "org/navber" .}}
{{template "org/select_pro" .}}
<div class="ui stackable grid">
<div class="ui sixteen wide computer column">
<div class="ui mobile reversed stackable grid">
<div class="ui sixteen wide tablet sixteen wide computer column margin-top20 pad-botom maxheight" id='key_tag'>
{{if .OrgTopics}}
<a class="{{if eq $.Keyword "" }} tag_bg {{end}} tag_key ui small tag_lable topic omit" href="{{$.Link}}?" >{{$.i18n.Tr "org.all_org_topics"}}</span></a>
{{end}}

{{range .OrgTopics}}
{{if ne .Name ""}}
<a class="{{if eq $.Keyword .Name }} tag_bg {{end}} tag_key ui small tag_lable topic omit" href="{{$.Link}}?q={{.Name}}" >
{{.Name}}
</a>
{{end}}
{{end}}
</div>
<div style="width: 100%;margin:5px 5px 10px;">
<a class="text-right" onclick="isUnfold()" id="icon_btn"><i class="ri-arrow-down-s-line" style="display:inline-block;vertical-align:top"></i>&nbsp{{.i18n.Tr "org.unfold"}}</a>
</div>
</div>
</div>
</div>
<div class="ui stackable grid">
<div class="ui sixteen wide computer column">
<div class="ui mobile reversed stackable grid">
<div class="ui ten wide tablet eleven wide computer column">
{{if .CanCreateOrgRepo}}
<!-- {{if .CanCreateOrgRepo}}
<div class="text right">
<a class="ui green button" href="{{AppSubUrl}}/repo/create?org={{.Org.ID}}">{{.i18n.Tr "new_repo"}}</a>
</div>
{{end}}
{{end}} -->
{{template "org/repo_list" .}}
{{template "base/paginate" .}}
</div>

<div class="ui sixteen wide mobile six wide tablet five wide computer column">
<h4 class="ui top attached header">
{{if .CanCreateOrgRepo}}
<div class="text right">
<a class="ui green button" href="{{AppSubUrl}}/repo/create?org={{.Org.ID}}">{{.i18n.Tr "new_repo"}}</a>
</div>
{{end}}
<h4 class="ui top attached header" style="margin-top: 10px;">
<strong>{{.i18n.Tr "org.people"}}</strong>
<div class="ui right">
<a class="text grey" href="{{.OrgLink}}/members">{{.MembersTotal}} {{svg "octicon-chevron-right" 16}}</a>
@@ -99,3 +128,19 @@
</div>
</div>
{{template "base/footer" .}}

<script>

function isUnfold(){
var isContain= document.querySelector("#key_tag").classList.contains("maxheight");
if(isContain){
document.querySelector("#key_tag").classList.remove("maxheight");
document.getElementById("icon_btn").innerHTML="<i class=\"ri-arrow-up-s-line\" style=\"display:inline-block;vertical-align:top\"></i> &nbsp {{.i18n.Tr "org.fold"}}"
}else{
document.querySelector("#key_tag").classList.add("maxheight");
document.getElementById("icon_btn").innerHTML="<i class=\"ri-arrow-down-s-line\" style=\"display:inline-block;vertical-align:top\"></i> &nbsp {{.i18n.Tr "org.unfold"}}"


}
}
</script>

+ 4
- 24
templates/org/home_courses.tmpl View File

@@ -32,27 +32,13 @@
.organization-info >.container {
padding-bottom:0px !important;
}
.tag_bg{
background-color: #0366D6 !important;
color:#FFFFFF !important;
}
.course{
padding:10px 0 15px !important;
}
.course_color{
color: #FA8C16;
}
.tag_lable{
border: 1px solid rgba(232, 232, 232, 100) ;
border-radius: 4px;
color: rgba(65, 80, 88, 100);
font-family: Microsoft Yahei;
font-size: 14px;
padding: 0.3em 0.5em;
height: 30px;
text-align: center;
margin: 0.2em;
}
.tag_lable_first{
border: 1px solid rgba(232, 232, 232, 100) ;
border-radius: 4px;
@@ -65,17 +51,11 @@
margin: 0.2em;
margin-left: none;
}
.tag_key{
max-width:100%;
margin: 3px 3px;
display:inline-flex;
}

.bpadding{
padding:10px 40px
}
.omit{
overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}

.noborder{
border: none !important;
}
@@ -83,7 +63,7 @@
text-align: center;
margin-top: 5px;
margin-top: 10px;
}
}
</style>


+ 35
- 1
web_src/less/openi.less View File

@@ -734,4 +734,38 @@ display: block;
}
.el-pagination.is-background .el-pager li:hover {
color: #5bb973 !important;
}
}

.tag_key{
max-width:100%;
margin: 3px 3px;
display:inline-flex;
}
.tag_lable{
border: 1px solid rgba(232, 232, 232, 100) ;
border-radius: 4px;
color: rgba(65, 80, 88, 100);
font-family: Microsoft Yahei;
font-size: 14px;
padding: 0.3em 0.5em;
height: 30px;
text-align: center;
margin: 0.2em;
}
.omit{
overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
.tag_bg{
background-color: #0366D6 !important;
color:#FFFFFF !important;
}
.margin-top20{
margin-top: 20px;
}
.maxheight{
max-height: 88px;
overflow: hidden;
}
.pad-botom{
padding-bottom:0px !important;
}

Loading…
Cancel
Save