debugged community creation process
This commit is contained in:
+2
-2
@@ -383,7 +383,7 @@ func CreateCommunityForm(ctxt ui.AmContext) (string, any, error) {
|
|||||||
return ui.ErrorPage(ctxt, errors.New("you are not permitted to create a community"))
|
return ui.ErrorPage(ctxt, errors.New("you are not permitted to create a community"))
|
||||||
}
|
}
|
||||||
dlg, err := ui.AmLoadDialog("create_comm")
|
dlg, err := ui.AmLoadDialog("create_comm")
|
||||||
if err != nil {
|
if err == nil {
|
||||||
dlg.Field("language").Value = "en-US"
|
dlg.Field("language").Value = "en-US"
|
||||||
dlg.Field("country").Value = "US"
|
dlg.Field("country").Value = "US"
|
||||||
return dlg.Render(ctxt)
|
return dlg.Render(ctxt)
|
||||||
@@ -406,7 +406,7 @@ func CreateCommunity(ctxt ui.AmContext) (string, any, error) {
|
|||||||
return ui.ErrorPage(ctxt, errors.New("you are not permitted to create a community"))
|
return ui.ErrorPage(ctxt, errors.New("you are not permitted to create a community"))
|
||||||
}
|
}
|
||||||
dlg, err := ui.AmLoadDialog("create_comm")
|
dlg, err := ui.AmLoadDialog("create_comm")
|
||||||
if err != nil {
|
if err == nil {
|
||||||
dlg.LoadFromForm(ctxt)
|
dlg.LoadFromForm(ctxt)
|
||||||
action := dlg.WhichButton(ctxt)
|
action := dlg.WhichButton(ctxt)
|
||||||
if action == "cancel" {
|
if action == "cancel" {
|
||||||
|
|||||||
@@ -571,14 +571,6 @@ func AmCreateCommunity(name string, alias string, hostUid int32, language *strin
|
|||||||
AmStoreAudit(ar)
|
AmStoreAudit(ar)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
unlock := true
|
|
||||||
amdb.Exec("LOCK TABLES communities WRITE, commftrs WRITE, commmember WRITE;")
|
|
||||||
defer func() {
|
|
||||||
if unlock {
|
|
||||||
amdb.Exec("UNLOCK TABLES;")
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
// validate alias does not already exist
|
// validate alias does not already exist
|
||||||
rs, err := amdb.Query("SELECT commid FROM communities WHERE alias = ?", alias)
|
rs, err := amdb.Query("SELECT commid FROM communities WHERE alias = ?", alias)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -623,9 +615,6 @@ func AmCreateCommunity(name string, alias string, hostUid int32, language *strin
|
|||||||
}
|
}
|
||||||
stuffMembership(comm.Id, hostUid, true, true, AmDefaultRole("Community.Creator").Level())
|
stuffMembership(comm.Id, hostUid, true, true, AmDefaultRole("Community.Creator").Level())
|
||||||
|
|
||||||
amdb.Exec("UNLOCK TABLES;")
|
|
||||||
unlock = false
|
|
||||||
|
|
||||||
// operation was a success - add an audit record
|
// operation was a success - add an audit record
|
||||||
ar = AmNewAudit(AuditCommunityCreate, hostUid, remoteIP, fmt.Sprintf("id=%d", comm.Id),
|
ar = AmNewAudit(AuditCommunityCreate, hostUid, remoteIP, fmt.Sprintf("id=%d", comm.Id),
|
||||||
fmt.Sprintf("name=%s", comm.Name), fmt.Sprintf("alias=%s", comm.Alias))
|
fmt.Sprintf("name=%s", comm.Name), fmt.Sprintf("alias=%s", comm.Alias))
|
||||||
|
|||||||
Reference in New Issue
Block a user