mirror of
				https://codeberg.org/forgejo/forgejo.git
				synced 2025-11-04 00:11:04 +00:00 
			
		
		
		
	Fix project counter in organization/individual profile (#28068)
Fix #28052 Before:   After:  
This commit is contained in:
		
					parent
					
						
							
								e31c6cfe6e
							
						
					
				
			
			
				commit
				
					
						e88377470a
					
				
			
		
					 3 changed files with 23 additions and 0 deletions
				
			
		| 
						 | 
					@ -7,6 +7,7 @@ import (
 | 
				
			||||||
	"code.gitea.io/gitea/models/db"
 | 
						"code.gitea.io/gitea/models/db"
 | 
				
			||||||
	"code.gitea.io/gitea/models/organization"
 | 
						"code.gitea.io/gitea/models/organization"
 | 
				
			||||||
	access_model "code.gitea.io/gitea/models/perm/access"
 | 
						access_model "code.gitea.io/gitea/models/perm/access"
 | 
				
			||||||
 | 
						project_model "code.gitea.io/gitea/models/project"
 | 
				
			||||||
	repo_model "code.gitea.io/gitea/models/repo"
 | 
						repo_model "code.gitea.io/gitea/models/repo"
 | 
				
			||||||
	"code.gitea.io/gitea/models/unit"
 | 
						"code.gitea.io/gitea/models/unit"
 | 
				
			||||||
	user_model "code.gitea.io/gitea/models/user"
 | 
						user_model "code.gitea.io/gitea/models/user"
 | 
				
			||||||
| 
						 | 
					@ -134,5 +135,21 @@ func LoadHeaderCount(ctx *context.Context) error {
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	ctx.Data["RepoCount"] = repoCount
 | 
						ctx.Data["RepoCount"] = repoCount
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						var projectType project_model.Type
 | 
				
			||||||
 | 
						if ctx.ContextUser.IsOrganization() {
 | 
				
			||||||
 | 
							projectType = project_model.TypeOrganization
 | 
				
			||||||
 | 
						} else {
 | 
				
			||||||
 | 
							projectType = project_model.TypeIndividual
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						projectCount, err := project_model.CountProjects(ctx, project_model.SearchOptions{
 | 
				
			||||||
 | 
							OwnerID:  ctx.ContextUser.ID,
 | 
				
			||||||
 | 
							IsClosed: util.OptionalBoolOf(false),
 | 
				
			||||||
 | 
							Type:     projectType,
 | 
				
			||||||
 | 
						})
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						ctx.Data["ProjectCount"] = projectCount
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return nil
 | 
						return nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -9,6 +9,9 @@
 | 
				
			||||||
		{{if .CanReadProjects}}
 | 
							{{if .CanReadProjects}}
 | 
				
			||||||
		<a class="{{if .PageIsViewProjects}}active {{end}}item" href="{{$.Org.HomeLink}}/-/projects">
 | 
							<a class="{{if .PageIsViewProjects}}active {{end}}item" href="{{$.Org.HomeLink}}/-/projects">
 | 
				
			||||||
			{{svg "octicon-project-symlink"}} {{ctx.Locale.Tr "user.projects"}}
 | 
								{{svg "octicon-project-symlink"}} {{ctx.Locale.Tr "user.projects"}}
 | 
				
			||||||
 | 
								{{if .ProjectCount}}
 | 
				
			||||||
 | 
									<div class="ui small label">{{.ProjectCount}}</div>
 | 
				
			||||||
 | 
								{{end}}
 | 
				
			||||||
		</a>
 | 
							</a>
 | 
				
			||||||
		{{end}}
 | 
							{{end}}
 | 
				
			||||||
		{{if and .IsPackageEnabled .CanReadPackages}}
 | 
							{{if and .IsPackageEnabled .CanReadPackages}}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -13,6 +13,9 @@
 | 
				
			||||||
	{{if or .ContextUser.IsIndividual (and .ContextUser.IsOrganization .CanReadProjects)}}
 | 
						{{if or .ContextUser.IsIndividual (and .ContextUser.IsOrganization .CanReadProjects)}}
 | 
				
			||||||
	<a href="{{.ContextUser.HomeLink}}/-/projects" class="{{if .PageIsViewProjects}}active {{end}}item">
 | 
						<a href="{{.ContextUser.HomeLink}}/-/projects" class="{{if .PageIsViewProjects}}active {{end}}item">
 | 
				
			||||||
		{{svg "octicon-project-symlink"}} {{ctx.Locale.Tr "user.projects"}}
 | 
							{{svg "octicon-project-symlink"}} {{ctx.Locale.Tr "user.projects"}}
 | 
				
			||||||
 | 
							{{if .ProjectCount}}
 | 
				
			||||||
 | 
								<div class="ui small label">{{.ProjectCount}}</div>
 | 
				
			||||||
 | 
							{{end}}
 | 
				
			||||||
	</a>
 | 
						</a>
 | 
				
			||||||
	{{end}}
 | 
						{{end}}
 | 
				
			||||||
	{{if and .IsPackageEnabled (or .ContextUser.IsIndividual (and .ContextUser.IsOrganization .CanReadPackages))}}
 | 
						{{if and .IsPackageEnabled (or .ContextUser.IsIndividual (and .ContextUser.IsOrganization .CanReadPackages))}}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue