From be5b3a426db65c0b7a5310078b1984e32625eccc Mon Sep 17 00:00:00 2001 From: Amy Gale Ruth Bowersox Date: Fri, 17 Oct 2025 13:16:14 -0600 Subject: [PATCH] moved System Administration link back into Administration community, fixed up some bugs around that --- community.go | 10 +++++++++- database/servicedefs.yaml | 9 +++++++++ sysadmin.go | 1 - ui/amcontext.go | 30 +++++++++++++++++++++--------- ui/menudefs.yaml | 3 --- userdata.go | 2 +- 6 files changed, 40 insertions(+), 15 deletions(-) diff --git a/community.go b/community.go index 69bd019..b328d97 100644 --- a/community.go +++ b/community.go @@ -19,6 +19,14 @@ import ( "golang.org/x/text/language/display" ) +/* ShowCommunity renders the community profile display. + * Parameters: + * ctxt - The AmContext for the request. + * Returns: + * Command string dictating what to be rendered. + * Data as a parameter for the command string. + * Standard Go error status. + */ func ShowCommunity(ctxt ui.AmContext) (string, any, error) { me := ctxt.CurrentUser() prefs, err := me.Prefs() @@ -103,7 +111,7 @@ func ShowCommunity(ctxt ui.AmContext) (string, any, error) { ctxt.VarMap().Set("addrLast", b.String()) if ci.Country != nil && *ci.Country != "" { country := countries.ByName(*ci.Country) - ctxt.VarMap().Set("country", country.String()) + ctxt.VarMap().Set("country", country.Emoji()+" "+country.String()) } tag, err := comm.LanguageTag() if err == nil && tag != nil { diff --git a/database/servicedefs.yaml b/database/servicedefs.yaml index d145ef0..bef23ea 100644 --- a/database/servicedefs.yaml +++ b/database/servicedefs.yaml @@ -27,6 +27,15 @@ domains: linkSequence: 5000 link: "/TODO/comm/[CID]/admin" title: "Administration" + - id: "SysAdmin" + index: 2 + default: false + locked: true + requirePermission: "Global.SysAdminAccess" + requireRole: "" + linkSequence: 10000 + link: "/sysadmin" + title: "System Administration" - id: "Conference" index: 3 default: true diff --git a/sysadmin.go b/sysadmin.go index 58aa681..5269a9f 100644 --- a/sysadmin.go +++ b/sysadmin.go @@ -32,7 +32,6 @@ func SysAdminMenu(ctxt ui.AmContext) (string, any, error) { ctxt.SetRC(http.StatusForbidden) return ui.ErrorPage(ctxt, errors.New("you are not authorized access to this page")) } - ctxt.SetLeftMenu("top") menu := ui.AmMenu("sysadmin") ctxt.VarMap().Set("menu", menu) ctxt.VarMap().Set("amsterdam_pageTitle", menu.Title) diff --git a/ui/amcontext.go b/ui/amcontext.go index 1cd5cf8..3340a07 100644 --- a/ui/amcontext.go +++ b/ui/amcontext.go @@ -12,6 +12,7 @@ package ui import ( "bytes" + "fmt" "mime/multipart" "net/http" "strconv" @@ -279,15 +280,20 @@ func (c *amContext) SetCommunityContext(param string) error { if err != nil { return err } - mbr, lock, level, err := comm.Membership(c.CurrentUser()) - if err != nil { - return err - } - c.community = comm - c.isMember = mbr - c.isMemberLocked = lock - if level > c.effectiveLevel { - c.effectiveLevel = level + if c.community == nil || c.community.Id != comm.Id { + mbr, lock, level, err := comm.Membership(c.CurrentUser()) + if err != nil { + return err + } + c.community = comm + c.isMember = mbr + c.isMemberLocked = lock + if level > c.effectiveLevel { + c.effectiveLevel = level + } + if mbr { + c.session.Values["lastCommunity"] = comm.Id + } } return nil } @@ -421,6 +427,12 @@ func AmCreateContext(ctxt echo.Context) (AmContext, error) { rc.user = nil rc.effectiveLevel = database.AmRole("NotInList").Level() } + if !rc.user.IsAnon { + cp, ok := sess.Values["lastCommunity"] + if ok { + rc.SetCommunityContext(fmt.Sprintf("%d", cp)) + } + } return rc, err } diff --git a/ui/menudefs.yaml b/ui/menudefs.yaml index 15adb0a..ba97e3f 100644 --- a/ui/menudefs.yaml +++ b/ui/menudefs.yaml @@ -26,9 +26,6 @@ menudefs: disabled: true - text: "About Amsterdam" link: "/about" - - text: "System Administration" - link: "/sysadmin" - permission: "Global.SysAdminAccess" - id: "sysadmin" title: "System Administration" permSet: "user" diff --git a/userdata.go b/userdata.go index f2bebd8..bbd4ce3 100644 --- a/userdata.go +++ b/userdata.go @@ -416,7 +416,7 @@ func ShowProfile(ctxt ui.AmContext) (string, any, error) { ctxt.VarMap().Set("addrLast", b.String()) if ci.Country != nil { country := countries.ByName(*ci.Country) - ctxt.VarMap().Set("country", country.String()) + ctxt.VarMap().Set("country", country.Emoji()+" "+country.String()) } if !pvtPhone && ci.Phone != nil { ctxt.VarMap().Set("phone", *ci.Phone)