0
0
Fork 0
mirror of https://github.com/go-gitea/gitea synced 2024-11-19 00:11:24 +01:00

some fixes, but not done yet!

This commit is contained in:
Unknwon 2015-02-13 02:56:42 -05:00
parent 6b7d35eade
commit 25f5a8d798

View file

@ -88,6 +88,11 @@ func maxAccessMode(modes ...AccessMode) AccessMode {
return max
}
func (repo *Repository) recalculateTeamAccesses(e Engine, mode AccessMode) error {
return nil
}
func (repo *Repository) recalculateAccesses(e Engine) error {
accessMap := make(map[int64]AccessMode, 20)
@ -111,6 +116,8 @@ func (repo *Repository) recalculateAccesses(e Engine) error {
for _, team := range repo.Owner.Teams {
if !(team.IsOwnerTeam() || team.HasRepository(repo)) {
continue
} else if team.IsOwnerTeam() {
team.Authorize = ACCESS_MODE_OWNER
}
if err = team.getMembers(e); err != nil {
@ -129,22 +136,20 @@ func (repo *Repository) recalculateAccesses(e Engine) error {
newAccesses := make([]Access, 0, len(accessMap))
for userID, mode := range accessMap {
if userID == repo.OwnerId || mode <= minMode {
if mode < minMode {
continue
}
newAccesses = append(newAccesses, Access{
UserID: userID,
RepoID: repo.Id,
Mode: mode})
Mode: mode,
})
}
// Delete old accesses for repository
// Delete old accesses and insert new ones for repository.
if _, err = e.Delete(&Access{RepoID: repo.Id}); err != nil {
return err
}
// And insert the new ones
if _, err = e.Insert(newAccesses); err != nil {
} else if _, err = e.Insert(newAccesses); err != nil {
return err
}