|
|
@ -35,11 +35,12 @@ def user_groups(token): |
|
|
|
for group in user.groups: |
|
|
|
for group in user.groups: |
|
|
|
groups[group.id] = {'id': group.id, |
|
|
|
groups[group.id] = {'id': group.id, |
|
|
|
'name': group.name, |
|
|
|
'name': group.name, |
|
|
|
'admin': group.owner.username == user.username} |
|
|
|
'admin': group.owner == user.username} |
|
|
|
|
|
|
|
|
|
|
|
return jsonify(status='OK', |
|
|
|
return jsonify(status='OK', |
|
|
|
groups=groups.values()) |
|
|
|
groups=groups.values()) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@groups.route('<token>/', methods=['PUT']) |
|
|
|
@groups.route('<token>/', methods=['PUT']) |
|
|
|
@ForceJSON(required=['name']) |
|
|
|
@ForceJSON(required=['name']) |
|
|
|
def create_group(token): |
|
|
|
def create_group(token): |
|
|
@ -58,6 +59,7 @@ def create_group(token): |
|
|
|
new_group = Group(name=json['name'], |
|
|
|
new_group = Group(name=json['name'], |
|
|
|
owner=user.username) |
|
|
|
owner=user.username) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LOG.debug('Current user groups: {groups}'.format(groups=user.groups)) |
|
|
|
user.groups.append(new_group) |
|
|
|
user.groups.append(new_group) |
|
|
|
|
|
|
|
|
|
|
|
db.session.add(new_group) |
|
|
|
db.session.add(new_group) |
|
|
|