Show More
@@ -71,4 +71,4 class BaseModel(object): | |||||
71 | if sa is not None: |
|
71 | if sa is not None: | |
72 | self.sa = sa |
|
72 | self.sa = sa | |
73 | else: |
|
73 | else: | |
74 |
self.sa = meta.Session |
|
74 | self.sa = meta.Session |
@@ -95,14 +95,12 class RepoModel(BaseModel): | |||||
95 | def update(self, repo_name, form_data): |
|
95 | def update(self, repo_name, form_data): | |
96 | try: |
|
96 | try: | |
97 | cur_repo = self.get_by_repo_name(repo_name, cache=False) |
|
97 | cur_repo = self.get_by_repo_name(repo_name, cache=False) | |
98 | user_model = UserModel(self.sa) |
|
|||
99 |
|
98 | |||
100 | #update permissions |
|
99 | #update permissions | |
101 | for member, perm, member_type in form_data['perms_updates']: |
|
100 | for member, perm, member_type in form_data['perms_updates']: | |
102 | if member_type == 'user': |
|
101 | if member_type == 'user': | |
103 | r2p = self.sa.query(RepoToPerm)\ |
|
102 | r2p = self.sa.query(RepoToPerm)\ | |
104 |
.filter(RepoToPerm.user == |
|
103 | .filter(RepoToPerm.user == User.by_username(member))\ | |
105 | get_by_username(member))\ |
|
|||
106 | .filter(RepoToPerm.repository == cur_repo)\ |
|
104 | .filter(RepoToPerm.repository == cur_repo)\ | |
107 | .one() |
|
105 | .one() | |
108 |
|
106 | |||
@@ -127,7 +125,7 class RepoModel(BaseModel): | |||||
127 | if member_type == 'user': |
|
125 | if member_type == 'user': | |
128 | r2p = RepoToPerm() |
|
126 | r2p = RepoToPerm() | |
129 | r2p.repository = cur_repo |
|
127 | r2p.repository = cur_repo | |
130 |
r2p.user = |
|
128 | r2p.user = User.by_username(member) | |
131 |
|
129 | |||
132 | r2p.permission = self.sa.query(Permission)\ |
|
130 | r2p.permission = self.sa.query(Permission)\ | |
133 | .filter(Permission. |
|
131 | .filter(Permission. | |
@@ -138,7 +136,6 class RepoModel(BaseModel): | |||||
138 | g2p = UsersGroupRepoToPerm() |
|
136 | g2p = UsersGroupRepoToPerm() | |
139 | g2p.repository = cur_repo |
|
137 | g2p.repository = cur_repo | |
140 | g2p.users_group = UsersGroup.get_by_group_name(member) |
|
138 | g2p.users_group = UsersGroup.get_by_group_name(member) | |
141 |
|
||||
142 | g2p.permission = self.sa.query(Permission)\ |
|
139 | g2p.permission = self.sa.query(Permission)\ | |
143 | .filter(Permission. |
|
140 | .filter(Permission. | |
144 | permission_name == perm)\ |
|
141 | permission_name == perm)\ | |
@@ -148,7 +145,7 class RepoModel(BaseModel): | |||||
148 | #update current repo |
|
145 | #update current repo | |
149 | for k, v in form_data.items(): |
|
146 | for k, v in form_data.items(): | |
150 | if k == 'user': |
|
147 | if k == 'user': | |
151 |
cur_repo.user = |
|
148 | cur_repo.user = User.by_username(v) | |
152 | elif k == 'repo_name': |
|
149 | elif k == 'repo_name': | |
153 | cur_repo.repo_name = form_data['repo_name_full'] |
|
150 | cur_repo.repo_name = form_data['repo_name_full'] | |
154 | elif k == 'repo_group': |
|
151 | elif k == 'repo_group': |
General Comments 0
You need to be logged in to leave comments.
Login now