Merge branch 'orgs' of ssh://bitbucket.org/yackob03/quay into orgs
This commit is contained in:
commit
109f09f0d0
5 changed files with 31 additions and 9 deletions
|
@ -277,6 +277,12 @@ def get_organization_team_members(teamid):
|
||||||
query = joined.where(Team.id == teamid)
|
query = joined.where(Team.id == teamid)
|
||||||
return query
|
return query
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def get_teams_within_org(organization):
|
||||||
|
return Team.select().where(Team.organization == organization)
|
||||||
|
|
||||||
|
|
||||||
def get_user_teams_within_org(username, organization):
|
def get_user_teams_within_org(username, organization):
|
||||||
joined = Team.select().join(TeamMember).join(User)
|
joined = Team.select().join(TeamMember).join(User)
|
||||||
return joined.where(Team.organization == organization,
|
return joined.where(Team.organization == organization,
|
||||||
|
|
|
@ -241,28 +241,33 @@ user_files = UserRequestFiles(app.config['AWS_ACCESS_KEY'],
|
||||||
|
|
||||||
@app.route('/api/organization/<orgname>', methods=['GET'])
|
@app.route('/api/organization/<orgname>', methods=['GET'])
|
||||||
def get_organization(orgname):
|
def get_organization(orgname):
|
||||||
|
user = current_user.db_user()
|
||||||
|
|
||||||
def team_view(t):
|
def team_view(t):
|
||||||
|
view_permission = ViewTeamPermission(orgname, t.name)
|
||||||
return {
|
return {
|
||||||
'id': t.id,
|
'id': t.id,
|
||||||
'name': t.name
|
'name': t.name,
|
||||||
|
'can_view': view_permission.can()
|
||||||
}
|
}
|
||||||
|
|
||||||
def org_view(o, teams):
|
def org_view(o, teams):
|
||||||
|
admin_org = AdministerOrganizationPermission(orgname)
|
||||||
return {
|
return {
|
||||||
'name': o.username,
|
'name': o.username,
|
||||||
'gravatar': compute_hash(o.email),
|
'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():
|
if current_user.is_anonymous():
|
||||||
abort(404)
|
abort(404)
|
||||||
|
|
||||||
user = current_user.db_user()
|
|
||||||
org = model.get_organization(orgname)
|
org = model.get_organization(orgname)
|
||||||
if not org:
|
if not org:
|
||||||
abort(404)
|
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))
|
return jsonify(org_view(org, teams))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -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', {templateUrl: '/static/partials/org-view.html', controller: OrgViewCtrl}).
|
||||||
when('/organization/:orgname/admin', {templateUrl: '/static/partials/org-admin.html', controller: OrgAdminCtrl}).
|
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('/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}).
|
when('/v1/', {title: 'Activation information', templateUrl: '/static/partials/v1-page.html', controller: V1Ctrl}).
|
||||||
|
|
|
@ -1197,10 +1197,6 @@ function OrgAdminCtrl($scope, Restangular, $routeParams) {
|
||||||
var orgname = $routeParams.orgname;
|
var orgname = $routeParams.orgname;
|
||||||
}
|
}
|
||||||
|
|
||||||
function OrgTeamsCtrl($scope, Restangular, $routeParams) {
|
|
||||||
var orgname = $routeParams.orgname;
|
|
||||||
}
|
|
||||||
|
|
||||||
function TeamViewCtrl($rootScope, $scope, Restangular, $routeParams) {
|
function TeamViewCtrl($rootScope, $scope, Restangular, $routeParams) {
|
||||||
$('.info-icon').popover({
|
$('.info-icon').popover({
|
||||||
'trigger': 'hover',
|
'trigger': 'hover',
|
||||||
|
@ -1242,6 +1238,8 @@ function TeamViewCtrl($rootScope, $scope, Restangular, $routeParams) {
|
||||||
$scope.organization = resp;
|
$scope.organization = resp;
|
||||||
$scope.loading = !$scope.organization || !$scope.members;
|
$scope.loading = !$scope.organization || !$scope.members;
|
||||||
}, function() {
|
}, function() {
|
||||||
|
$scope.organization = null;
|
||||||
|
$scope.members = null;
|
||||||
$scope.loading = false;
|
$scope.loading = false;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -1254,6 +1252,8 @@ function TeamViewCtrl($rootScope, $scope, Restangular, $routeParams) {
|
||||||
$scope.loading = !$scope.organization || !$scope.members;
|
$scope.loading = !$scope.organization || !$scope.members;
|
||||||
$rootScope.title = teamname + ' (' + orgname + ')';
|
$rootScope.title = teamname + ' (' + orgname + ')';
|
||||||
}, function() {
|
}, function() {
|
||||||
|
$scope.organization = null;
|
||||||
|
$scope.members = null;
|
||||||
$scope.loading = false;
|
$scope.loading = false;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -8,4 +8,16 @@
|
||||||
|
|
||||||
<div class="org-view container" ng-show="!loading && organization">
|
<div class="org-view container" ng-show="!loading && organization">
|
||||||
<div class="organization-header" organization="organization"></div>
|
<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>
|
</div>
|
||||||
|
|
Reference in a new issue