##// END OF EJS Templates
Implemented #638 permissions overview to groups
marcink -
r2987:4150c45b beta
parent child Browse files
Show More
@@ -40,10 +40,12 b' from rhodecode.lib.base import BaseContr'
40
40
41 from rhodecode.model.users_group import UsersGroupModel
41 from rhodecode.model.users_group import UsersGroupModel
42
42
43 from rhodecode.model.db import User, UsersGroup
43 from rhodecode.model.db import User, UsersGroup, UsersGroupToPerm,\
44 UsersGroupRepoToPerm, UsersGroupRepoGroupToPerm
44 from rhodecode.model.forms import UsersGroupForm
45 from rhodecode.model.forms import UsersGroupForm
45 from rhodecode.model.meta import Session
46 from rhodecode.model.meta import Session
46 from rhodecode.lib.utils import action_logger
47 from rhodecode.lib.utils import action_logger
48 from sqlalchemy.orm import joinedload
47
49
48 log = logging.getLogger(__name__)
50 log = logging.getLogger(__name__)
49
51
@@ -102,6 +104,38 b' class UsersGroupsController(BaseControll'
102 # url('new_users_group')
104 # url('new_users_group')
103 return render('admin/users_groups/users_group_add.html')
105 return render('admin/users_groups/users_group_add.html')
104
106
107 def _load_data(self, id):
108 c.users_group.permissions = {
109 'repositories': {},
110 'repositories_groups': {}
111 }
112
113 ugroup_repo_perms = UsersGroupRepoToPerm.query()\
114 .options(joinedload(UsersGroupRepoToPerm.permission))\
115 .options(joinedload(UsersGroupRepoToPerm.repository))\
116 .filter(UsersGroupRepoToPerm.users_group_id == id)\
117 .all()
118
119 for gr in ugroup_repo_perms:
120 c.users_group.permissions['repositories'][gr.repository.repo_name] \
121 = gr.permission.permission_name
122
123 ugroup_group_perms = UsersGroupRepoGroupToPerm.query()\
124 .options(joinedload(UsersGroupRepoGroupToPerm.permission))\
125 .options(joinedload(UsersGroupRepoGroupToPerm.group))\
126 .filter(UsersGroupRepoGroupToPerm.users_group_id == id)\
127 .all()
128
129 for gr in ugroup_group_perms:
130 c.users_group.permissions['repositories_groups'][gr.group.group_name] \
131 = gr.permission.permission_name
132
133 c.group_members_obj = [x.user for x in c.users_group.members]
134 c.group_members = [(x.user_id, x.username) for x in
135 c.group_members_obj]
136 c.available_members = [(x.user_id, x.username) for x in
137 User.query().all()]
138
105 def update(self, id):
139 def update(self, id):
106 """PUT /users_groups/id: Update an existing item"""
140 """PUT /users_groups/id: Update an existing item"""
107 # Forms posted to this method should contain a hidden field:
141 # Forms posted to this method should contain a hidden field:
@@ -111,13 +145,8 b' class UsersGroupsController(BaseControll'
111 # method='put')
145 # method='put')
112 # url('users_group', id=ID)
146 # url('users_group', id=ID)
113
147
114 c.users_group = UsersGroup.get(id)
148 c.users_group = UsersGroup.get_or_404(id)
115 c.group_members_obj = [x.user for x in c.users_group.members]
149 self._load_data(id)
116 c.group_members = [(x.user_id, x.username) for x in
117 c.group_members_obj]
118
119 c.available_members = [(x.user_id, x.username) for x in
120 User.query().all()]
121
150
122 available_members = [safe_unicode(x[0]) for x in c.available_members]
151 available_members = [safe_unicode(x[0]) for x in c.available_members]
123
152
@@ -189,13 +218,8 b' class UsersGroupsController(BaseControll'
189 # url('edit_users_group', id=ID)
218 # url('edit_users_group', id=ID)
190
219
191 c.users_group = UsersGroup.get_or_404(id)
220 c.users_group = UsersGroup.get_or_404(id)
221 self._load_data(id)
192
222
193 c.users_group.permissions = {}
194 c.group_members_obj = [x.user for x in c.users_group.members]
195 c.group_members = [(x.user_id, x.username) for x in
196 c.group_members_obj]
197 c.available_members = [(x.user_id, x.username) for x in
198 User.query().all()]
199 ug_model = UsersGroupModel()
223 ug_model = UsersGroupModel()
200 defaults = c.users_group.get_dict()
224 defaults = c.users_group.get_dict()
201 defaults.update({
225 defaults.update({
@@ -3935,12 +3935,13 b' div#legend_container table td,div#legend'
3935
3935
3936
3936
3937 .group_members_wrap{
3937 .group_members_wrap{
3938
3938 min-height: 85px;
3939 padding-left: 20px;
3939 }
3940 }
3940
3941
3941 .group_members .group_member{
3942 .group_members .group_member{
3942 height: 30px;
3943 height: 30px;
3943 padding:0px 0px 0px 10px;
3944 padding:0px 0px 0px 0px;
3944 }
3945 }
3945
3946
3946 .reviewers_member{
3947 .reviewers_member{
@@ -145,20 +145,83 b''
145 <div class="title">
145 <div class="title">
146 <h5>${_('Group members')}</h5>
146 <h5>${_('Group members')}</h5>
147 </div>
147 </div>
148
148 <div class="group_members_wrap">
149 <div class="group_members_wrap">
150 % if c.group_members_obj:
149 <ul class="group_members">
151 <ul class="group_members">
150 %for user in c.group_members_obj:
152 %for user in c.group_members_obj:
151 <li>
153 <li>
152 <div class="group_member">
154 <div class="group_member">
153 <div class="gravatar"><img alt="gravatar" src="${h.gravatar_url(user.email,24)}"/> </div>
155 <div class="gravatar"><img alt="gravatar" src="${h.gravatar_url(user.email,24)}"/> </div>
154 <div>${user.username}</div>
156 <div>${h.link_to(user.username, h.url('edit_user',id=user.user_id))}</div>
155 <div>${user.full_name}</div>
157 <div>${user.full_name}</div>
156 </div>
158 </div>
157 </li>
159 </li>
158 %endfor
160 %endfor
159 </ul>
161 </ul>
162 %else:
163 <span class="empty_data">${_('No members yet')}</span>
164 %endif
160 </div>
165 </div>
161 </div>
166 </div>
167
168 <div class="box box-left">
169 <!-- box / title -->
170 <div class="title">
171 <h5>${_('Permissions defined for this group')}</h5>
172 </div>
173 ## permissions overview
174 <div id="perms" class="table">
175 %for section in sorted(c.users_group.permissions.keys()):
176 <div class="perms_section_head">${section.replace("_"," ").capitalize()}</div>
177 %if not c.users_group.permissions:
178 <span class="empty_data">${_('No permissions set yet')}</span>
179 %else:
180 <div id='tbl_list_wrap_${section}' class="yui-skin-sam">
181 <table id="tbl_list_repository">
182 <thead>
183 <tr>
184 <th class="left">${_('Name')}</th>
185 <th class="left">${_('Permission')}</th>
186 <th class="left">${_('Edit Permission')}</th>
187 </thead>
188 <tbody>
189 %for k in c.users_group.permissions[section]:
190 <%
191 section_perm = c.users_group.permissions[section].get(k)
192 _perm = section_perm.split('.')[-1]
193 %>
194 <tr>
195 <td>
196 %if section == 'repositories':
197 <a href="${h.url('summary_home',repo_name=k)}">${k}</a>
198 %elif section == 'repositories_groups':
199 <a href="${h.url('repos_group_home',group_name=k)}">${k}</a>
200 %endif
201 </td>
202 <td>
203 <span class="perm_tag ${_perm}">${section_perm}</span>
204 </td>
205 <td>
206 %if section == 'repositories':
207 <a href="${h.url('edit_repo',repo_name=k,anchor='permissions_manage')}">${_('edit')}</a>
208 %elif section == 'repositories_groups':
209 <a href="${h.url('edit_repos_group',id=k,anchor='permissions_manage')}">${_('edit')}</a>
210 %else:
211 --
212 %endif
213 </td>
214 </tr>
215 %endfor
216 </tbody>
217 </table>
218 </div>
219 %endif
220 %endfor
221 </div>
222 </div>
223
224
162 <script type="text/javascript">
225 <script type="text/javascript">
163 MultiSelectWidget('users_group_members','available_members','edit_users_group');
226 MultiSelectWidget('users_group_members','available_members','edit_users_group');
164 </script>
227 </script>
General Comments 0
You need to be logged in to leave comments. Login now