mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
Allow everyone to read or write a wiki by a repo unit setting (#30495)
Replace #6312 Help #5833 Wiki solution for #639
This commit is contained in:
@@ -336,7 +336,7 @@ func ToTeams(ctx context.Context, teams []*organization.Team, loadOrgs bool) ([]
|
||||
Description: t.Description,
|
||||
IncludesAllRepositories: t.IncludesAllRepositories,
|
||||
CanCreateOrgRepo: t.CanCreateOrgRepo,
|
||||
Permission: t.AccessMode.String(),
|
||||
Permission: t.AccessMode.ToString(),
|
||||
Units: t.GetUnitNames(),
|
||||
UnitsMap: t.GetUnitsMap(),
|
||||
}
|
||||
|
@@ -25,12 +25,13 @@ func ToRepo(ctx context.Context, repo *repo_model.Repository, permissionInRepo a
|
||||
func innerToRepo(ctx context.Context, repo *repo_model.Repository, permissionInRepo access_model.Permission, isParent bool) *api.Repository {
|
||||
var parent *api.Repository
|
||||
|
||||
if permissionInRepo.Units == nil && permissionInRepo.UnitsMode == nil {
|
||||
// If Units and UnitsMode are both nil, it means that it's a hard coded permission,
|
||||
// like access_model.Permission{AccessMode: perm.AccessModeAdmin}.
|
||||
// So we need to load units for the repo, or UnitAccessMode will always return perm.AccessModeNone.
|
||||
if !permissionInRepo.HasUnits() && permissionInRepo.AccessMode > perm.AccessModeNone {
|
||||
// If units is empty, it means that it's a hard-coded permission, like access_model.Permission{AccessMode: perm.AccessModeAdmin}
|
||||
// So we need to load units for the repo, otherwise UnitAccessMode will just return perm.AccessModeNone.
|
||||
// TODO: this logic is still not right (because unit modes are not correctly prepared)
|
||||
// the caller should prepare a proper "permission" before calling this function.
|
||||
_ = repo.LoadUnits(ctx) // the error is not important, so ignore it
|
||||
permissionInRepo.Units = repo.Units
|
||||
permissionInRepo.SetUnitsWithDefaultAccessMode(repo.Units, permissionInRepo.AccessMode)
|
||||
}
|
||||
|
||||
cloneLink := repo.CloneLink()
|
||||
|
@@ -103,7 +103,7 @@ func User2UserSettings(user *user_model.User) api.UserSettings {
|
||||
func ToUserAndPermission(ctx context.Context, user, doer *user_model.User, accessMode perm.AccessMode) api.RepoCollaboratorPermission {
|
||||
return api.RepoCollaboratorPermission{
|
||||
User: ToUser(ctx, user, doer),
|
||||
Permission: accessMode.String(),
|
||||
RoleName: accessMode.String(),
|
||||
Permission: accessMode.ToString(),
|
||||
RoleName: accessMode.ToString(),
|
||||
}
|
||||
}
|
||||
|
@@ -134,6 +134,7 @@ type RepoSettingForm struct {
|
||||
EnableWiki bool
|
||||
EnableExternalWiki bool
|
||||
DefaultWikiBranch string
|
||||
DefaultWikiEveryoneAccess string
|
||||
ExternalWikiURL string
|
||||
EnableIssues bool
|
||||
EnableExternalTracker bool
|
||||
|
Reference in New Issue
Block a user