Merge branch 'orgs' of ssh://bitbucket.org/yackob03/quay into orgs

This commit is contained in:
yackob03 2013-11-04 16:57:26 -05:00
commit 109f09f0d0
5 changed files with 31 additions and 9 deletions

View file

@ -277,6 +277,12 @@ def get_organization_team_members(teamid):
query = joined.where(Team.id == teamid)
return query
def get_teams_within_org(organization):
return Team.select().where(Team.organization == organization)
def get_user_teams_within_org(username, organization):
joined = Team.select().join(TeamMember).join(User)
return joined.where(Team.organization == organization,

View file

@ -241,28 +241,33 @@ user_files = UserRequestFiles(app.config['AWS_ACCESS_KEY'],
@app.route('/api/organization/<orgname>', methods=['GET'])
def get_organization(orgname):
user = current_user.db_user()
def team_view(t):
view_permission = ViewTeamPermission(orgname, t.name)
return {
'id': t.id,
'name': t.name
'name': t.name,
'can_view': view_permission.can()
}
def org_view(o, teams):
admin_org = AdministerOrganizationPermission(orgname)
return {
'name': o.username,
'gravatar': compute_hash(o.email),
'teams': [team_view(t) for t in teams]
'teams': [team_view(t) for t in teams],
'is_admin': admin_org.can()
}
if current_user.is_anonymous():
abort(404)
user = current_user.db_user()
org = model.get_organization(orgname)
if not org:
abort(404)
teams = model.get_user_teams_within_org(user.username, org)
teams = model.get_teams_within_org(org)
return jsonify(org_view(org, teams))

View file

@ -204,7 +204,6 @@ quayApp = angular.module('quay', ['restangular', 'angularMoment', 'angulartics',
when('/organization/:orgname', {templateUrl: '/static/partials/org-view.html', controller: OrgViewCtrl}).
when('/organization/:orgname/admin', {templateUrl: '/static/partials/org-admin.html', controller: OrgAdminCtrl}).
when('/organization/:orgname/teams', {templateUrl: '/static/partials/org-teams.html', controller: OrgTeamsCtrl}).
when('/organization/:orgname/teams/:teamname', {templateUrl: '/static/partials/team-view.html', controller: TeamViewCtrl}).
when('/v1/', {title: 'Activation information', templateUrl: '/static/partials/v1-page.html', controller: V1Ctrl}).

View file

@ -1197,10 +1197,6 @@ function OrgAdminCtrl($scope, Restangular, $routeParams) {
var orgname = $routeParams.orgname;
}
function OrgTeamsCtrl($scope, Restangular, $routeParams) {
var orgname = $routeParams.orgname;
}
function TeamViewCtrl($rootScope, $scope, Restangular, $routeParams) {
$('.info-icon').popover({
'trigger': 'hover',
@ -1242,6 +1238,8 @@ function TeamViewCtrl($rootScope, $scope, Restangular, $routeParams) {
$scope.organization = resp;
$scope.loading = !$scope.organization || !$scope.members;
}, function() {
$scope.organization = null;
$scope.members = null;
$scope.loading = false;
});
};
@ -1254,6 +1252,8 @@ function TeamViewCtrl($rootScope, $scope, Restangular, $routeParams) {
$scope.loading = !$scope.organization || !$scope.members;
$rootScope.title = teamname + ' (' + orgname + ')';
}, function() {
$scope.organization = null;
$scope.members = null;
$scope.loading = false;
});
};

View file

@ -8,4 +8,16 @@
<div class="org-view container" ng-show="!loading && organization">
<div class="organization-header" organization="organization"></div>
<div ng-repeat="team in organization.teams">
<i class="fa fa-group"></i>
<span ng-show="team.can_view">
<a href="/organization/{{ organization.name }}/teams/{{ team.name }}">{{ team.name }}</a>
</span>
<span ng-show="!team.can_view">
{{ team.name }}
</span>
</div>
</div>