@@ -16,20 +16,20 @@ import (
1616)
1717
1818func  innerCreateProject (ctx  * context.APIContext , projectType  project_model.Type ) {
19- 	form  :=  web .GetForm (ctx ).(* api.NewProjectPayload )
19+ 	form  :=  web .GetForm (ctx ).(* api.NewProjectOption )
2020	project  :=  & project_model.Project {
21- 		RepoID :       0 ,
22- 		OwnerID :      ctx .Doer .ID ,
23- 		Title :        form .Title ,
24- 		Description :  form .Description ,
21+ 		Title :        form .Name ,
22+ 		Description :  form .Body ,
2523		CreatorID :    ctx .Doer .ID ,
26- 		TemplateType : project_model .TemplateType (form .BoardType ),
24+ 		TemplateType : project_model .ToTemplateType (form .TemplateType ),
2725		Type :         projectType ,
2826	}
2927
30- 	if  ctx .ContextUser  !=  nil  {
31- 		project .OwnerID  =  ctx .ContextUser .ID 
28+ 	if  ctx .ContextUser  ==  nil  {
29+ 		ctx .APIError (http .StatusForbidden , "Not authenticated" )
30+ 		return 
3231	}
32+ 	project .OwnerID  =  ctx .ContextUser .ID 
3333
3434	if  projectType  ==  project_model .TypeRepository  {
3535		project .RepoID  =  ctx .Repo .Repository .ID 
@@ -67,7 +67,7 @@ func CreateUserProject(ctx *context.APIContext) {
6767	//   - name: project 
6868	//     in: body 
6969	//     required: true 
70- 	//     schema: { "$ref": "#/definitions/NewProjectPayload " } 
70+ 	//     schema: { "$ref": "#/definitions/NewProjectOption " } 
7171	// responses: 
7272	//  "201": 
7373	//    "$ref": "#/responses/Project" 
@@ -95,7 +95,7 @@ func CreateOrgProject(ctx *context.APIContext) {
9595	//   - name: project 
9696	//     in: body 
9797	//     required: true 
98- 	//     schema: { "$ref": "#/definitions/NewProjectPayload " } 
98+ 	//     schema: { "$ref": "#/definitions/NewProjectOption " } 
9999	// responses: 
100100	//  "201": 
101101	//    "$ref": "#/responses/Project" 
@@ -128,7 +128,7 @@ func CreateRepoProject(ctx *context.APIContext) {
128128	//   - name: project 
129129	//     in: body 
130130	//     required: true 
131- 	//     schema: { "$ref": "#/definitions/NewProjectPayload " } 
131+ 	//     schema: { "$ref": "#/definitions/NewProjectOption " } 
132132	// responses: 
133133	//  "201": 
134134	//    "$ref": "#/responses/Project" 
@@ -158,7 +158,7 @@ func GetProject(ctx *context.APIContext) {
158158	//    "$ref": "#/responses/forbidden" 
159159	//  "404": 
160160	//    "$ref": "#/responses/notFound" 
161- 	project , err  :=  project_model .GetProjectByID (ctx , ctx .FormInt64 (": id" ))
161+ 	project , err  :=  project_model .GetProjectByID (ctx , ctx .FormInt64 ("id" ))
162162	if  err  !=  nil  {
163163		if  project_model .IsErrProjectNotExist (err ) {
164164			ctx .APIError (http .StatusNotFound , err )
@@ -193,15 +193,15 @@ func UpdateProject(ctx *context.APIContext) {
193193	//   - name: project 
194194	//     in: body 
195195	//     required: true 
196- 	//     schema: { "$ref": "#/definitions/UpdateProjectPayload " } 
196+ 	//     schema: { "$ref": "#/definitions/UpdateProjectOption " } 
197197	// responses: 
198198	//  "200": 
199199	//    "$ref": "#/responses/Project" 
200200	//  "403": 
201201	//    "$ref": "#/responses/forbidden" 
202202	//  "404": 
203203	//    "$ref": "#/responses/notFound" 
204- 	form  :=  web .GetForm (ctx ).(* api.UpdateProjectPayload )
204+ 	form  :=  web .GetForm (ctx ).(* api.UpdateProjectOption )
205205	project , err  :=  project_model .GetProjectByID (ctx , ctx .FormInt64 ("id" ))
206206	if  err  !=  nil  {
207207		if  project_model .IsErrProjectNotExist (err ) {
@@ -211,11 +211,11 @@ func UpdateProject(ctx *context.APIContext) {
211211		}
212212		return 
213213	}
214- 	if  project .Title  !=  form .Title  {
215- 		project .Title  =  form .Title 
214+ 	if  project .Title  !=  form .Name  {
215+ 		project .Title  =  form .Name 
216216	}
217- 	if  project .Description  !=  form .Description  {
218- 		project .Description  =  form .Description 
217+ 	if  project .Description  !=  form .Body  {
218+ 		project .Description  =  form .Body 
219219	}
220220
221221	err  =  project_model .UpdateProject (ctx , project )
@@ -249,7 +249,7 @@ func DeleteProject(ctx *context.APIContext) {
249249	//  "404": 
250250	//    "$ref": "#/responses/notFound" 
251251
252- 	if  err  :=  project_model .DeleteProjectByID (ctx , ctx .FormInt64 (": id" )); err  !=  nil  {
252+ 	if  err  :=  project_model .DeleteProjectByID (ctx , ctx .FormInt64 ("id" )); err  !=  nil  {
253253		ctx .APIErrorInternal (err )
254254		return 
255255	}
0 commit comments