(c *gin.Context)
| 119 | } |
| 120 | |
| 121 | func createProject(c *gin.Context) { |
| 122 | r := struct { |
| 123 | NodeCount uint16 `json:"node" form:"node" binding:"gt=0"` |
| 124 | }{} |
| 125 | |
| 126 | if err := c.ShouldBind(&r); err != nil { |
| 127 | abortWithError(c, http.StatusBadRequest, err) |
| 128 | return |
| 129 | } |
| 130 | |
| 131 | developer := getDeveloperID(c) |
| 132 | p, err := model.GetMainAccount(model.GetDB(c), developer) |
| 133 | if err != nil { |
| 134 | _ = c.Error(err) |
| 135 | abortWithError(c, http.StatusBadRequest, ErrNoMainAccount) |
| 136 | return |
| 137 | } |
| 138 | |
| 139 | // run task |
| 140 | taskID, err := getTaskManager(c).New(model.TaskCreateProject, developer, p.ID, gin.H{ |
| 141 | "node_count": r.NodeCount, |
| 142 | }) |
| 143 | if err != nil { |
| 144 | _ = c.Error(err) |
| 145 | abortWithError(c, http.StatusInternalServerError, ErrCreateTaskFailed) |
| 146 | return |
| 147 | } |
| 148 | |
| 149 | responseWithData(c, http.StatusOK, gin.H{ |
| 150 | "task_id": taskID, |
| 151 | }) |
| 152 | } |
| 153 | |
| 154 | // CreateProjectTask handles the project creation process. |
| 155 | func CreateProjectTask(ctx context.Context, cfg *config.Config, db *gorp.DbMap, t *model.Task) (r gin.H, err error) { |
nothing calls this directly
no test coverage detected