From 46a5355377dd3069de46b58ca22598cffd58d53c Mon Sep 17 00:00:00 2001 From: kevgliss Date: Tue, 1 Sep 2015 14:05:32 -0700 Subject: [PATCH] Allows authorities to have editable owners and descriptions --- lemur/authorities/service.py | 5 +++- lemur/authorities/views.py | 25 +++++++++++++------ .../{authorityEdit.tpl.html => edit.tpl.html} | 25 ++++++++++++++++++- .../app/angular/authorities/view/view.js | 21 +++++++++++++++- .../angular/authorities/view/view.tpl.html | 2 +- lemur/static/app/angular/roles/services.js | 2 -- 6 files changed, 67 insertions(+), 13 deletions(-) rename lemur/static/app/angular/authorities/authority/{authorityEdit.tpl.html => edit.tpl.html} (59%) diff --git a/lemur/authorities/service.py b/lemur/authorities/service.py index 23961ede..5a1f4341 100644 --- a/lemur/authorities/service.py +++ b/lemur/authorities/service.py @@ -22,7 +22,7 @@ from lemur.certificates.models import Certificate from lemur.plugins.base import plugins -def update(authority_id, active=None, roles=None): +def update(authority_id, description=None, owner=None, active=None, roles=None): """ Update a an authority with new values. @@ -37,6 +37,9 @@ def update(authority_id, active=None, roles=None): if active: authority.active = active + + authority.description = description + authority.owner = owner return database.update(authority) diff --git a/lemur/authorities/views.py b/lemur/authorities/views.py index f449a837..43a65fe5 100644 --- a/lemur/authorities/views.py +++ b/lemur/authorities/views.py @@ -20,6 +20,7 @@ from lemur.common.utils import paginated_parser, marshal_items FIELDS = { 'name': fields.String, + 'owner': fields.String, 'description': fields.String, 'options': fields.Raw, 'pluginName': fields.String, @@ -264,7 +265,9 @@ class Authorities(AuthenticatedResource): { "roles": [], - "active": false + "active": false, + "owner": "bob@example.com", + "description": "this is authority1" } **Example response**: @@ -279,12 +282,12 @@ class Authorities(AuthenticatedResource): "id": 1, "name": "authority1", "description": "this is authority1", - "pluginname": null, + "pluginName": null, "chain": "-----begin ...", "body": "-----begin ...", "active": false, - "notbefore": "2015-06-05t17:09:39", - "notafter": "2015-06-10t17:09:39" + "notBefore": "2015-06-05t17:09:39", + "notAfter": "2015-06-10t17:09:39" "options": null } @@ -292,8 +295,10 @@ class Authorities(AuthenticatedResource): :statuscode 200: no error :statuscode 403: unauthenticated """ - self.reqparse.add_argument('roles', type=list, location='json') - self.reqparse.add_argument('active', type=str, location='json') + self.reqparse.add_argument('roles', type=list, default=[], location='json') + self.reqparse.add_argument('active', type=str, location='json', required=True) + self.reqparse.add_argument('owner', type=str, location='json', required=True) + self.reqparse.add_argument('description', type=str, location='json', required=True) args = self.reqparse.parse_args() authority = service.get(authority_id) @@ -315,7 +320,13 @@ class Authorities(AuthenticatedResource): return dict(message="You are not allowed to associate a role which you are not a member of"), 400 if permission.can(): - return service.update(authority_id, active=args['active'], roles=args['roles']) + return service.update( + authority_id, + owner=args['owner'], + description=args['description'], + active=args['active'], + roles=args['roles'] + ) return dict(message="You are not authorized to update this authority"), 403 diff --git a/lemur/static/app/angular/authorities/authority/authorityEdit.tpl.html b/lemur/static/app/angular/authorities/authority/edit.tpl.html similarity index 59% rename from lemur/static/app/angular/authorities/authority/authorityEdit.tpl.html rename to lemur/static/app/angular/authorities/authority/edit.tpl.html index f100ba1b..fe3d3eac 100644 --- a/lemur/static/app/angular/authorities/authority/authorityEdit.tpl.html +++ b/lemur/static/app/angular/authorities/authority/edit.tpl.html @@ -1,9 +1,32 @@