completed the Conference Members function by adding the "Update" functionality
This commit is contained in:
+45
-19
@@ -262,25 +262,19 @@ func ConferenceMembers(ctxt ui.AmContext) (string, any, error) {
|
|||||||
ctxt.VarMap().Set("amsterdam_pageTitle", fmt.Sprintf("Membership in Conference: %s", conf.Name))
|
ctxt.VarMap().Set("amsterdam_pageTitle", fmt.Sprintf("Membership in Conference: %s", conf.Name))
|
||||||
|
|
||||||
// Get the search parameter values and adjust them.
|
// Get the search parameter values and adjust them.
|
||||||
mode := ctxt.Parameter("mode")
|
mode := "conf"
|
||||||
field := ctxt.Parameter("field")
|
field := "name"
|
||||||
oper := ctxt.Parameter("oper")
|
oper := "st"
|
||||||
term := ctxt.Parameter("term")
|
term := ""
|
||||||
offsetStr := ctxt.Parameter("ofs")
|
|
||||||
if mode == "" {
|
|
||||||
mode = "conf"
|
|
||||||
}
|
|
||||||
if field == "" {
|
|
||||||
field = "name"
|
|
||||||
}
|
|
||||||
if oper == "" {
|
|
||||||
oper = "st"
|
|
||||||
}
|
|
||||||
offset := 0
|
offset := 0
|
||||||
if offsetStr != "" {
|
if ctxt.Verb() == "POST" {
|
||||||
var err error
|
mode = ctxt.FormField("mode")
|
||||||
offset, err = strconv.Atoi(offsetStr)
|
field = ctxt.FormField("field")
|
||||||
if err != nil {
|
oper = ctxt.FormField("oper")
|
||||||
|
term = ctxt.FormField("term")
|
||||||
|
var e1 error
|
||||||
|
offset, e1 = ctxt.FormFieldInt("ofs")
|
||||||
|
if e1 != nil {
|
||||||
offset = 0
|
offset = 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -302,7 +296,39 @@ func ConferenceMembers(ctxt ui.AmContext) (string, any, error) {
|
|||||||
ctxt.VarMap().Set("max", maxPage)
|
ctxt.VarMap().Set("max", maxPage)
|
||||||
|
|
||||||
if ctxt.FormFieldIsSet("update") {
|
if ctxt.FormFieldIsSet("update") {
|
||||||
// TODO: update the levels
|
// Parse out the list of valid UIDs.
|
||||||
|
uids := util.Map(strings.Split(ctxt.FormField("validUids"), "|"), func(in string) int32 {
|
||||||
|
rc, err := strconv.Atoi(in)
|
||||||
|
if err != nil {
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
return int32(rc)
|
||||||
|
})
|
||||||
|
for _, uid := range uids {
|
||||||
|
if uid > 0 {
|
||||||
|
// Get old and new access levels from the form.
|
||||||
|
tmp, err := ctxt.FormFieldInt(fmt.Sprintf("old_%d", uid))
|
||||||
|
if err == nil {
|
||||||
|
oldLevel := uint16(tmp)
|
||||||
|
tmp, err = ctxt.FormFieldInt(fmt.Sprintf("new_%d", uid))
|
||||||
|
if err == nil {
|
||||||
|
newLevel := uint16(tmp)
|
||||||
|
if oldLevel != newLevel {
|
||||||
|
// Update the level for this user.
|
||||||
|
var u *database.User
|
||||||
|
u, err = database.AmGetUser(ctxt.Ctx(), uid)
|
||||||
|
if err == nil {
|
||||||
|
err = conf.SetMembership(ctxt.Ctx(), u, newLevel, ctxt.CurrentUser(), ctxt.RemoteIP())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
return ui.ErrorPage(ctxt, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ctxt.VarMap().Set("updated", true)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the member list for the conference.
|
// Get the member list for the conference.
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ _(italicized items can be deferred)_
|
|||||||
- ~~Manage aliases~~
|
- ~~Manage aliases~~
|
||||||
- ~~Remove alias~~
|
- ~~Remove alias~~
|
||||||
- ~~Add alias~~
|
- ~~Add alias~~
|
||||||
- Manage members
|
- ~~Manage members~~
|
||||||
- Custom appearance
|
- Custom appearance
|
||||||
- Activity reports
|
- Activity reports
|
||||||
- E-mail
|
- E-mail
|
||||||
|
|||||||
@@ -75,6 +75,7 @@ type AmContext interface {
|
|||||||
URLParamInt(string) (int, error)
|
URLParamInt(string) (int, error)
|
||||||
URLPath() string
|
URLPath() string
|
||||||
VarMap() jet.VarMap
|
VarMap() jet.VarMap
|
||||||
|
Verb() string
|
||||||
}
|
}
|
||||||
|
|
||||||
/*----------------------------------------------------------------------------
|
/*----------------------------------------------------------------------------
|
||||||
@@ -435,6 +436,15 @@ func (c *amContext) VarMap() jet.VarMap {
|
|||||||
return c.rendervars
|
return c.rendervars
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Verb returns the HTTP method (verb) for this request.
|
||||||
|
func (c *amContext) Verb() string {
|
||||||
|
rc := c.echoContext.Request().Method
|
||||||
|
if rc == "" {
|
||||||
|
rc = "GET"
|
||||||
|
}
|
||||||
|
return rc
|
||||||
|
}
|
||||||
|
|
||||||
// defoptions is the default options for the HTTP session.
|
// defoptions is the default options for the HTTP session.
|
||||||
var defoptions *AmSessionOptions = &AmSessionOptions{
|
var defoptions *AmSessionOptions = &AmSessionOptions{
|
||||||
Path: "/",
|
Path: "/",
|
||||||
|
|||||||
@@ -133,6 +133,9 @@
|
|||||||
<div class="flex items-start gap-3">
|
<div class="flex items-start gap-3">
|
||||||
<button type="submit" name="update"
|
<button type="submit" name="update"
|
||||||
class="bg-blue-600 hover:bg-blue-700 text-white px-8 py-2 rounded font-medium transition-colors">Update</button>
|
class="bg-blue-600 hover:bg-blue-700 text-white px-8 py-2 rounded font-medium transition-colors">Update</button>
|
||||||
|
{{ if isset(updated) }}
|
||||||
|
<span class="text-lg text-green font-bold">✅ Updated!</span>
|
||||||
|
{{ end }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user