| @@ -180,8 +180,8 @@ func CreateOrganization(org, owner *User) (err error) { | |||||
| // Add initial creator to organization and owner team. | // Add initial creator to organization and owner team. | ||||
| if _, err = sess.Insert(&OrgUser{ | if _, err = sess.Insert(&OrgUser{ | ||||
| UID: owner.ID, | |||||
| OrgID: org.ID, | |||||
| UID: owner.ID, | |||||
| OrgID: org.ID, | |||||
| IsPublic: setting.Service.DefaultOrgMemberVisible, | IsPublic: setting.Service.DefaultOrgMemberVisible, | ||||
| }); err != nil { | }); err != nil { | ||||
| return fmt.Errorf("insert org-user relation: %v", err) | return fmt.Errorf("insert org-user relation: %v", err) | ||||
| @@ -324,3 +324,16 @@ func SaveTopics(repoID int64, topicNames ...string) error { | |||||
| return sess.Commit() | return sess.Commit() | ||||
| } | } | ||||
| func GetOrgTopics(orgId int64) ([]Topic, error) { | |||||
| result := make([]Topic, 0) | |||||
| sql := "select 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" | |||||
| if e := x.SQL(sql, orgId).Find(&result); e != nil { | |||||
| return nil, e | |||||
| } | |||||
| return result, nil | |||||
| } | |||||
| @@ -94,6 +94,13 @@ func Home(ctx *context.Context) { | |||||
| recommendCourseKeyWords, _ := repository.GetRecommendCourseKeyWords() | recommendCourseKeyWords, _ := repository.GetRecommendCourseKeyWords() | ||||
| ctx.Data["CoursesKeywords"] = recommendCourseKeyWords | 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{ | repos, count, err = models.SearchRepository(&models.SearchRepoOptions{ | ||||