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):
|
||||
|
|
Reference in a new issue