summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUnknwon <joe2010xtmf@163.com>2015-02-13 02:56:42 -0500
committerUnknwon <joe2010xtmf@163.com>2015-02-13 02:56:42 -0500
commit25f5a8d7986a710cef01d02725071d2de0a6b143 (patch)
treee48b23a58445f0824979602bd5ec8d130dccf612
parent6b7d35eade921058654207abf30bd718389d11f1 (diff)
downloadgitea-25f5a8d7986a710cef01d02725071d2de0a6b143.tar.gz
gitea-25f5a8d7986a710cef01d02725071d2de0a6b143.zip
some fixes, but not done yet!
-rw-r--r--models/access.go19
1 files changed, 12 insertions, 7 deletions
diff --git a/models/access.go b/models/access.go
index e9742b318d..1e1c0114ed 100644
--- a/models/access.go
+++ b/models/access.go
@@ -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
}