Work in progress: Start on org view and finish up the team members view

This commit is contained in:
Joseph Schorr 2013-11-04 16:21:49 -05:00
parent e6fadbca05
commit 61e9b1629d
4 changed files with 51 additions and 7 deletions

View file

@ -298,8 +298,8 @@ def get_organization_team_members(orgname, teamname):
if current_user.is_anonymous():
abort(404)
# TODO: determine whether the user has permission to view the team members of this team
# (i.e. they are a member of the team [maybe??] OR they are an admin of the org)
# TODO: determine whether the user has permission to view the members of this team
# (i.e. they are a member of the team OR they are an admin of the org)
user = current_user.db_user()
team = None
@ -309,8 +309,11 @@ def get_organization_team_members(orgname, teamname):
abort(404)
members = model.get_organization_team_members(team.id)
# TODO: determine whether the user has permission to *edit* the members of this team.
return jsonify({
'members': { m.username : member_view(m) for m in members }
'members': { m.username : member_view(m) for m in members },
'can_edit': True
})

View file

@ -1179,6 +1179,18 @@ function NewRepoCtrl($scope, $location, $http, $timeout, UserService, Restangula
function OrgViewCtrl($scope, Restangular, $routeParams) {
var orgname = $routeParams.orgname;
var loadOrganization = function() {
var getOrganization = Restangular.one(getRestUrl('organization', orgname));
getOrganization.get().then(function(resp) {
$scope.organization = resp;
$scope.loading = false;
}, function() {
$scope.loading = false;
});
};
loadOrganization();
}
function OrgAdminCtrl($scope, Restangular, $routeParams) {
@ -1238,6 +1250,7 @@ function TeamViewCtrl($rootScope, $scope, Restangular, $routeParams) {
var getMembers = Restangular.one(getRestUrl('organization', orgname, 'team', teamname, 'members'));
getMembers.get().then(function(resp) {
$scope.members = resp.members;
$scope.canEditMembers = resp.can_edit;
$scope.loading = !$scope.organization || !$scope.members;
$rootScope.title = teamname + ' (' + orgname + ')';
}, function() {

View file

@ -0,0 +1,11 @@
<div class="loading" ng-show="loading">
<i class="fa fa-spinner fa-spin fa-3x"></i>
</div>
<div class="loading" ng-show="!loading && !organization">
No matching organization found
</div>
<div class="org-view container" ng-show="!loading && organization">
<div class="organization-header" organization="organization"></div>
</div>

View file

@ -21,14 +21,14 @@
<span>{{ member.username }}</span>
</td>
<td>
<span class="delete-ui" tabindex="0" title="Remove User">
<span class="delete-ui" tabindex="0" title="Remove User" ng-show="canEditMembers">
<span class="delete-ui-button" ng-click="removeMember(member.username)"><button class="btn btn-danger">Remove</button></span>
<i class="fa fa-times"></i>
</span>
</td>
</tr>
<tr>
<tr ng-show="canEditMembers">
<td colspan="2">
<span class="entity-search" organization="''" input-title="'Add a user...'" entity-selected="addNewMember"></span>
</td>
@ -36,6 +36,23 @@
</table>
</div>
</div>
</div>
<!-- Modal message dialog -->
<div class="modal fade" id="cannotChangeMembersModal">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title">Cannot change members</h4>
</div>
<div class="modal-body">
You do not have permission to change the members of this team.
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->