Skip to content

Commit f7f3b43

Browse files
committed
superuser abilities on test instances
1 parent b6cd7f9 commit f7f3b43

File tree

4 files changed

+34
-5
lines changed

4 files changed

+34
-5
lines changed

model_validation_api/views.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1499,8 +1499,9 @@ def put(self, request, format=None):
14991499
return Response("To edit a test instance, you need to give an id, or a test_definition_id with a version, or a test_definition_alias with a version ", status=status.HTTP_400_BAD_REQUEST)
15001500

15011501
#check if version is editable
1502-
if not _are_test_code_editable(test_code):
1503-
return Response("This version is no longer editable as there is at least one result associated with it", status=status.HTTP_400_BAD_REQUEST)
1502+
if not is_authorised(request,settings.ADMIN_COLLAB_ID):
1503+
if not _are_test_code_editable(test_code):
1504+
return Response("This version is no longer editable as there is at least one result associated with it", status=status.HTTP_400_BAD_REQUEST)
15041505

15051506
#check if versions are unique
15061507
if not _are_test_code_version_unique(test_code) :

validation_service/app/css/Model_catalog.css

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,30 @@
3030
background-color: #e1ebf0;
3131
}
3232

33+
.superuser-button {
34+
white-space: nowrap;
35+
padding: 2px 10px;
36+
cursor: pointer;
37+
background-color: #c43427;
38+
border: 2px solid #c43427;
39+
color: white;
40+
text-align: center;
41+
text-decoration: none;
42+
font-weight: bold;
43+
outline: none;
44+
border-radius: 6px;
45+
}
46+
47+
.superuser-button:hover {
48+
background-color: #c43427;
49+
color: white;
50+
}
51+
52+
.superuser-button:active {
53+
background-color: #c43427;
54+
transform: translateY(1px);
55+
}
56+
3357
.button-MC {
3458
white-space: nowrap;
3559
padding: 2px 10px;

validation_service/app/js/controller.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -305,9 +305,9 @@ testApp.directive("precision", function() {
305305
};
306306
});
307307

308-
testApp.controller('ValTestDetailCtrl', ['$scope', '$rootScope', '$http', '$location', '$stateParams', '$state', 'ValidationTestDefinitionRest', 'ValidationTestCodeRest', 'CollabParameters', 'TestCommentRest', "IsCollabMemberRest", "Graphics", "Context", 'TestTicketRest', 'AuthorizedCollabParameterRest', 'ValidationTestAliasRest', 'NotificationRest', 'AreVersionsEditableRest', 'DataHandler',
308+
testApp.controller('ValTestDetailCtrl', ['$scope', '$rootScope', '$http', '$location', '$stateParams', '$state', 'ValidationTestDefinitionRest', 'ValidationTestCodeRest', 'CollabParameters', 'TestCommentRest', "IsCollabMemberRest", "Graphics", "Context", 'TestTicketRest', 'AuthorizedCollabParameterRest', 'ValidationTestAliasRest', 'NotificationRest', 'AreVersionsEditableRest', 'DataHandler', 'IsSuperUserRest',
309309

310-
function($scope, $rootScope, $http, $location, $stateParams, $state, ValidationTestDefinitionRest, ValidationTestCodeRest, CollabParameters, TestCommentRest, IsCollabMemberRest, Graphics, Context, TestTicketRest, AuthorizedCollabParameterRest, ValidationTestAliasRest, NotificationRest, AreVersionsEditableRest, DataHandler) {
310+
function($scope, $rootScope, $http, $location, $stateParams, $state, ValidationTestDefinitionRest, ValidationTestCodeRest, CollabParameters, TestCommentRest, IsCollabMemberRest, Graphics, Context, TestTicketRest, AuthorizedCollabParameterRest, ValidationTestAliasRest, NotificationRest, AreVersionsEditableRest, DataHandler, IsSuperUserRest) {
311311

312312
$scope.init_graph, $scope.graphic_data, $scope.init_checkbox, $scope.graphic_options;
313313
$scope.data_for_table;
@@ -644,6 +644,8 @@ testApp.controller('ValTestDetailCtrl', ['$scope', '$rootScope', '$http', '$loca
644644
$scope.ctx = Context.getCtx();
645645
$scope.app_id = Context.getAppID();
646646

647+
$scope.isSuperUser = IsSuperUserRest.get({ app_id: $scope.app_id })
648+
647649
CollabParameters.setService($scope.ctx).then(function() {
648650

649651
$scope.detail_test = ValidationTestDefinitionRest.get({ app_id: $scope.app_id, id: $stateParams.uuid });
@@ -1549,7 +1551,7 @@ ModelCatalogApp.controller('ModelCatalogEditCtrl', ['$scope', '$rootScope', '$ht
15491551

15501552
$scope.version_is_editable = [];
15511553
$scope.model = ScientificModelRest.get({ app_id: $scope.app_id, id: $stateParams.uuid });
1552-
console.log("model", $scope.model)
1554+
15531555
$scope.model.$promise.then(function(model) {
15541556
$scope.change_collab_url_to_real_url();
15551557
});

validation_service/app/templates/validation_framework/validation_test_detail.tpl.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,8 @@ <h3 style="font-size:1.5em" align=center><b>Code versions</b></h3><br>
162162
<td style="width:5%">
163163
<button ng-if="isInArray(code_version.id, version_is_editable)" ng-click="editVersion(code_version.id)" class="button-MC glyphicon glyphicon-pencil">
164164
</button>
165+
<button ng-if="!isInArray(code_version.id, version_is_editable) && isSuperUser.is_superuser" ng-click="editVersion(code_version.id)" class="glyphicon glyphicon-pencil superuser-button">
166+
</button>
165167
</td>
166168

167169
<td>

0 commit comments

Comments
 (0)