Add ability to display and edit the team's description
This commit is contained in:
parent
fd68564b3f
commit
97fa69a361
5 changed files with 72 additions and 13 deletions
|
@ -240,25 +240,25 @@ user_files = UserRequestFiles(app.config['AWS_ACCESS_KEY'],
|
|||
app.config['REGISTRY_S3_BUCKET'])
|
||||
|
||||
|
||||
def team_view(orgname, t):
|
||||
view_permission = ViewTeamPermission(orgname, t.name)
|
||||
return {
|
||||
'id': t.id,
|
||||
'name': t.name,
|
||||
'description': t.description,
|
||||
'can_view': view_permission.can()
|
||||
}
|
||||
|
||||
@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,
|
||||
'description': t.description,
|
||||
'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': {t.name : team_view(orgname, t) for t in teams},
|
||||
'is_admin': admin_org.can()
|
||||
}
|
||||
|
||||
|
@ -305,6 +305,26 @@ def member_view(m):
|
|||
'username': m.username
|
||||
}
|
||||
|
||||
|
||||
@app.route('/api/organization/<orgname>/team/<teamname>',
|
||||
methods=['PUT', 'POST'])
|
||||
def update_organization_team(orgname, teamname):
|
||||
edit_permission = AdministerOrganizationPermission(orgname)
|
||||
if edit_permission.can():
|
||||
team = None
|
||||
|
||||
try:
|
||||
team = model.get_organization_team(orgname, teamname)
|
||||
except:
|
||||
abort(404)
|
||||
|
||||
team.description = request.get_json()['description']
|
||||
team.save()
|
||||
return jsonify(team_view(orgname, team))
|
||||
|
||||
abort(403)
|
||||
|
||||
|
||||
@app.route('/api/organization/<orgname>/team/<teamname>/members',
|
||||
methods=['GET'])
|
||||
def get_organization_team_members(orgname, teamname):
|
||||
|
|
|
@ -1404,6 +1404,12 @@ p.editable:hover i {
|
|||
text-transform: capitalize;
|
||||
}
|
||||
|
||||
.org-view .team-listing .team-description {
|
||||
margin-top: 6px;
|
||||
margin-left: 37px;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
/* Overrides for typeahead to work with bootstrap 3. */
|
||||
|
||||
.twitter-typeahead .tt-query,
|
||||
|
|
|
@ -688,7 +688,7 @@ function UserAdminCtrl($scope, $timeout, Restangular, PlanService, UserService,
|
|||
$scope.planUsagePercent = sub.usedPrivateRepos * 100 / $scope.subscribedPlan.privateRepos;
|
||||
|
||||
if (sub.usedPrivateRepos > $scope.subscribedPlan.privateRepos) {
|
||||
$scope.errorMessage = 'You are using more private repositories than your plan allows, please upgrate your subscription to avoid disruptions in your service.';
|
||||
$scope.errorMessage = 'You are using more private repositories than your plan allows, please upgrade your subscription to avoid disruptions in your service.';
|
||||
} else {
|
||||
$scope.errorMessage = null;
|
||||
}
|
||||
|
@ -1131,10 +1131,22 @@ function TeamViewCtrl($rootScope, $scope, Restangular, $routeParams) {
|
|||
});
|
||||
};
|
||||
|
||||
$scope.updateForDescription = function(content) {
|
||||
$scope.organization.teams[teamname].description = content;
|
||||
|
||||
var updateTeam = Restangular.one(getRestUrl('organization', orgname, 'team', teamname));
|
||||
var data = $scope.organization.teams[teamname];
|
||||
updateTeam.customPUT(data).then(function(resp) {
|
||||
}, function() {
|
||||
$('#cannotChangeTeamModal').modal({});
|
||||
});
|
||||
};
|
||||
|
||||
var loadOrganization = function() {
|
||||
var getOrganization = Restangular.one(getRestUrl('organization', orgname))
|
||||
getOrganization.get().then(function(resp) {
|
||||
$scope.organization = resp;
|
||||
$scope.team = $scope.organization.teams[teamname];
|
||||
$scope.loading = !$scope.organization || !$scope.members;
|
||||
}, function() {
|
||||
$scope.organization = null;
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
<div class="org-view container" ng-show="!loading && organization">
|
||||
<div class="organization-header" organization="organization"></div>
|
||||
|
||||
<div class="team-listing" ng-repeat="team in organization.teams">
|
||||
<div class="team-listing" ng-repeat="(name, team) in organization.teams">
|
||||
<div class="team-title">
|
||||
<i class="fa fa-group"></i>
|
||||
<span ng-show="team.can_view">
|
||||
|
@ -19,6 +19,6 @@
|
|||
{{ team.name }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="team-description markdown-view" content="team.description"></div>
|
||||
<div class="team-description markdown-view" content="team.description" first-line-only="true"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -9,6 +9,9 @@
|
|||
<div class="team-view container" ng-show="!loading && organization">
|
||||
<div class="organization-header" organization="organization" team-name="teamname"></div>
|
||||
|
||||
<div class="description markdown-input" content="team.description" can-write="organization.is_admin"
|
||||
content-changed="updateForDescription" field-title="'team description'"></div>
|
||||
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">Team Members
|
||||
<i class="info-icon fa fa-info-circle" data-placement="left" data-content="Users that inherit all permissions delegated to this team"></i>
|
||||
|
@ -39,6 +42,24 @@
|
|||
</div>
|
||||
|
||||
|
||||
<!-- Modal message dialog -->
|
||||
<div class="modal fade" id="cannotChangeTeamModal">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h4 class="modal-title">Cannot change team</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
You do not have permission to change properties 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 -->
|
||||
|
||||
<!-- Modal message dialog -->
|
||||
<div class="modal fade" id="cannotChangeMembersModal">
|
||||
<div class="modal-dialog">
|
||||
|
|
Reference in a new issue