(c *gin.Context)
| 603 | } |
| 604 | |
| 605 | func updateProjectMiscConfig(c *gin.Context) { |
| 606 | r := struct { |
| 607 | DB proto.DatabaseID `json:"db" json:"project" form:"db" form:"project" uri:"db" uri:"project" binding:"required,len=64"` |
| 608 | model.ProjectMiscConfig |
| 609 | // additional parameters, see ProjectMiscConfig structure |
| 610 | }{} |
| 611 | |
| 612 | _ = c.ShouldBindUri(&r) |
| 613 | |
| 614 | if err := c.ShouldBind(&r); err != nil { |
| 615 | abortWithError(c, http.StatusBadRequest, err) |
| 616 | return |
| 617 | } |
| 618 | |
| 619 | _, projectDB, err := getProjectDB(c, r.DB) |
| 620 | if err != nil { |
| 621 | _ = c.Error(err) |
| 622 | abortWithError(c, http.StatusForbidden, ErrLoadProjectDatabaseFailed) |
| 623 | return |
| 624 | } |
| 625 | |
| 626 | cfg := &r.ProjectMiscConfig |
| 627 | |
| 628 | // alias goes to project config, also set backup to project database |
| 629 | if cfg.Alias != "" { |
| 630 | // set alias to project database |
| 631 | err = model.SetProjectAlias(model.GetDB(c), r.DB, getDeveloperID(c), cfg.Alias) |
| 632 | if err != nil { |
| 633 | _ = c.Error(err) |
| 634 | abortWithError(c, http.StatusInternalServerError, ErrSetProjectAliasFailed) |
| 635 | return |
| 636 | } |
| 637 | } |
| 638 | |
| 639 | // other goes to config in project database |
| 640 | var ( |
| 641 | p *model.ProjectConfig |
| 642 | pmc *model.ProjectMiscConfig |
| 643 | ) |
| 644 | p, pmc, err = model.GetProjectMiscConfig(projectDB) |
| 645 | if err != nil { |
| 646 | // not exists, create |
| 647 | p, err = model.AddProjectConfig(projectDB, model.ProjectConfigMisc, "", cfg) |
| 648 | if err != nil { |
| 649 | _ = c.Error(err) |
| 650 | abortWithError(c, http.StatusInternalServerError, ErrAddProjectMiscConfigFailed) |
| 651 | return |
| 652 | } |
| 653 | pmc = cfg |
| 654 | } else { |
| 655 | if cfg.Alias != "" { |
| 656 | pmc.Alias = cfg.Alias |
| 657 | } |
| 658 | if cfg.Enabled != nil { |
| 659 | pmc.Enabled = cfg.Enabled |
| 660 | } |
| 661 | if cfg.EnableSignUp != nil { |
| 662 | pmc.EnableSignUp = cfg.EnableSignUp |
nothing calls this directly
no test coverage detected