1
0
Fork 0

Display all organization from user settings (#1739)

* Display all organization from user settings

* fix Tab selection

* Update locale_en-US.ini

* Add a condition for display Create organization button

* Remove french translation

* Remove unnecessary admin flag
This commit is contained in:
Rémy Boulanouar 2017-06-02 10:43:44 +02:00 committed by Bo-Yi Wu
parent 976c2a05fa
commit 62f600cf1c
5 changed files with 56 additions and 0 deletions

View file

@ -298,6 +298,7 @@ orgs = Organizations
delete = Delete Account
twofa = Two-Factor Authentication
account_link = External Accounts
organization = Organization
uid = Uid
public_profile = Public Profile
@ -431,6 +432,8 @@ remove_account_link = Remove linked account
remove_account_link_desc = Removing this linked account will revoke all related access using this account. Do you want to continue?
remove_account_link_success = Account link has been removed successfully!
orgs_none = You are not a member of any organizations.
delete_account = Delete Your Account
delete_prompt = The operation will delete your account permanently, and <strong>CANNOT</strong> be undone!
confirm_delete_account = Confirm Deletion

View file

@ -223,6 +223,7 @@ func RegisterRoutes(m *macaron.Macaron) {
m.Post("/applications/delete", user.SettingsDeleteApplication)
m.Route("/delete", "GET,POST", user.SettingsDelete)
m.Combo("/account_link").Get(user.SettingsAccountLinks).Post(user.SettingsDeleteAccountLink)
m.Get("/organization", user.SettingsOrganization)
m.Group("/two_factor", func() {
m.Get("", user.SettingsTwoFactor)
m.Post("/regenerate_scratch", user.SettingsTwoFactorRegenerateScratch)

View file

@ -38,6 +38,7 @@ const (
tplSettingsTwofa base.TplName = "user/settings/twofa"
tplSettingsTwofaEnroll base.TplName = "user/settings/twofa_enroll"
tplSettingsAccountLink base.TplName = "user/settings/account_link"
tplSettingsOrganization base.TplName = "user/settings/organization"
tplSettingsDelete base.TplName = "user/settings/delete"
tplSecurity base.TplName = "user/security"
)
@ -771,3 +772,16 @@ func SettingsDelete(ctx *context.Context) {
ctx.HTML(200, tplSettingsDelete)
}
// SettingsOrganization render all the organization of the user
func SettingsOrganization(ctx *context.Context) {
ctx.Data["Title"] = ctx.Tr("settings")
ctx.Data["PageIsSettingsOrganization"] = true
orgs, err := models.GetOrgsByUserID(ctx.User.ID, ctx.IsSigned)
if err != nil {
ctx.Handle(500, "GetOrgsByUserID", err)
return
}
ctx.Data["Orgs"] = orgs
ctx.HTML(200, tplSettingsOrganization)
}

View file

@ -28,6 +28,9 @@
<a class="{{if .PageIsSettingsAccountLink}}active{{end}} item" href="{{AppSubUrl}}/user/settings/account_link">
{{.i18n.Tr "settings.account_link"}}
</a>
<a class="{{if .PageIsSettingsOrganization}}active{{end}} item" href="{{AppSubUrl}}/user/settings/organization">
{{.i18n.Tr "settings.organization"}}
</a>
<a class="{{if .PageIsSettingsDelete}}active{{end}} item" href="{{AppSubUrl}}/user/settings/delete">
{{.i18n.Tr "settings.delete"}}
</a>

View file

@ -0,0 +1,35 @@
{{template "base/head" .}}
<div class="user settings account_link">
{{template "user/settings/navbar" .}}
<div class="ui container">
{{template "base/alert" .}}
<h4 class="ui top attached header">
{{.i18n.Tr "settings.orgs"}}
{{if .SignedUser.CanCreateOrganization}}
<div class="ui right">
<a class="ui black tiny button" href="{{AppSubUrl}}/org/create">{{.i18n.Tr "admin.orgs.new_orga"}}</a>
</div>
{{end}}
</h4>
<div class="ui attached segment orgs">
{{if .Orgs}}
<div class="ui middle aligned divided list">
{{range .Orgs}}
<div class="item">
<div class="right floated content">
<a class="ui blue small button" href="{{AppSubUrl}}/org/{{.Name}}/members/action/leave?uid={{.ID}}">{{$.i18n.Tr "org.members.leave"}}</a>
</div>
<img class="ui mini image" src="{{.RelAvatarLink}}">
<div class="content">
<a href="{{.HomeLink}}">{{.Name}}</a>
</div>
</div>
{{end}}
</div>
{{else}}
{{.i18n.Tr "settings.orgs_none"}}
{{end}}
</div>
</div>
</div>
{{template "base/footer" .}}