forked from forgejo/forgejo
Support org/user level projects (#22235)
Fix #13405 <img width="1151" alt="image" src="https://user-images.githubusercontent.com/81045/209442911-7baa3924-c389-47b6-b63b-a740803e640e.png"> Co-authored-by: 6543 <6543@obermui.de>
This commit is contained in:
parent
0c048e554b
commit
6fe3c8b398
30 changed files with 1556 additions and 176 deletions
|
@ -70,7 +70,7 @@ func Projects(ctx *context.Context) {
|
|||
total = repo.NumClosedProjects
|
||||
}
|
||||
|
||||
projects, count, err := project_model.GetProjects(ctx, project_model.SearchOptions{
|
||||
projects, count, err := project_model.FindProjects(ctx, project_model.SearchOptions{
|
||||
RepoID: repo.ID,
|
||||
Page: page,
|
||||
IsClosed: util.OptionalBoolOf(isShowClosed),
|
||||
|
@ -112,7 +112,7 @@ func Projects(ctx *context.Context) {
|
|||
pager.AddParam(ctx, "state", "State")
|
||||
ctx.Data["Page"] = pager
|
||||
|
||||
ctx.Data["CanWriteProjects"] = ctx.Repo.Permission.CanWrite(unit.TypeProjects)
|
||||
ctx.Data["CanWriteProjects"] = true
|
||||
ctx.Data["IsShowClosed"] = isShowClosed
|
||||
ctx.Data["IsProjectsPage"] = true
|
||||
ctx.Data["SortType"] = sortType
|
||||
|
@ -653,47 +653,3 @@ func MoveIssues(ctx *context.Context) {
|
|||
"ok": true,
|
||||
})
|
||||
}
|
||||
|
||||
// CreateProject renders the generic project creation page
|
||||
func CreateProject(ctx *context.Context) {
|
||||
ctx.Data["Title"] = ctx.Tr("repo.projects.new")
|
||||
ctx.Data["ProjectTypes"] = project_model.GetProjectsConfig()
|
||||
ctx.Data["CanWriteProjects"] = ctx.Repo.Permission.CanWrite(unit.TypeProjects)
|
||||
|
||||
ctx.HTML(http.StatusOK, tplGenericProjectsNew)
|
||||
}
|
||||
|
||||
// CreateProjectPost creates an individual and/or organization project
|
||||
func CreateProjectPost(ctx *context.Context, form forms.UserCreateProjectForm) {
|
||||
user := checkContextUser(ctx, form.UID)
|
||||
if ctx.Written() {
|
||||
return
|
||||
}
|
||||
|
||||
ctx.Data["ContextUser"] = user
|
||||
|
||||
if ctx.HasError() {
|
||||
ctx.Data["CanWriteProjects"] = ctx.Repo.Permission.CanWrite(unit.TypeProjects)
|
||||
ctx.HTML(http.StatusOK, tplGenericProjectsNew)
|
||||
return
|
||||
}
|
||||
|
||||
projectType := project_model.TypeIndividual
|
||||
if user.IsOrganization() {
|
||||
projectType = project_model.TypeOrganization
|
||||
}
|
||||
|
||||
if err := project_model.NewProject(&project_model.Project{
|
||||
Title: form.Title,
|
||||
Description: form.Content,
|
||||
CreatorID: user.ID,
|
||||
BoardType: form.BoardType,
|
||||
Type: projectType,
|
||||
}); err != nil {
|
||||
ctx.ServerError("NewProject", err)
|
||||
return
|
||||
}
|
||||
|
||||
ctx.Flash.Success(ctx.Tr("repo.projects.create_success", form.Title))
|
||||
ctx.Redirect(setting.AppSubURL + "/")
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue