← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 21087: tracker-capture: if program has no user role, then not accessible

 

------------------------------------------------------------
revno: 21087
committer: Abyot Asalefew Gizaw <abyota@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2015-11-17 14:20:40 +0100
message:
  tracker-capture: if program has no user role, then not accessible
modified:
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/i18n/i18n_app.properties
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/controllers.js
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/services.js


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/i18n/i18n_app.properties'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/i18n/i18n_app.properties	2015-11-10 04:32:05 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/i18n/i18n_app.properties	2015-11-17 13:20:40 +0000
@@ -276,6 +276,7 @@
 no_enity_for_tracker_associate_attribute=Selected attribute has invalid tracked entity
 error=Error
 success=Success
+access_denied=Access is Denied
 registration_complete=Registration is completed
 validation_error=Validation Error
 validation_warnings=Validation Warnings

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/controllers.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/controllers.js	2015-10-07 15:13:26 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/controllers.js	2015-11-17 13:20:40 +0000
@@ -152,8 +152,7 @@
                 $scope.selectedProgram = response.selectedProgram;
                 $scope.trackedEntityList = null;
                 $scope.selectedSearchMode = $scope.searchMode.listAll;
-                $scope.processAttributes();                
-                //$scope.search($scope.searchMode.listAll);
+                $scope.processAttributes();
             });
         }        
     };
@@ -275,7 +274,7 @@
                                             $scope.attributeUrl.url,
                                             $scope.pager,
                                             true).then(function(data){            
-            if( data.metaData && data.metaData.pager ){
+            if( data && data.metaData && data.metaData.pager ){
                 $scope.pager = data.metaData.pager;
                 $scope.pager.toolBarDisplay = 5;
 

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/services.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/services.js	2015-11-10 04:32:05 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/services.js	2015-11-17 13:20:40 +0000
@@ -250,7 +250,7 @@
         var hasRole = false;
 
         if($.isEmptyObject(program.userRoles)){
-            return !hasRole;
+            return hasRole;
         }
 
         for(var i=0; i < userRoles.length && !hasRole; i++){
@@ -261,7 +261,7 @@
             if(!hasRole && userRoles[i].authorities && userRoles[i].authorities.indexOf('ALL') !== -1){
                 hasRole = true;
             }
-        }        
+        } 
         return hasRole;        
     };
     
@@ -607,7 +607,7 @@
 })
 
 /* Service for getting tracked entity instances */
-.factory('TEIService', function($http, $q, AttributesFactory) {
+.factory('TEIService', function($http, $q, AttributesFactory, DialogService ) {
     
     return {
         get: function(entityUid, optionSets, attributesById){
@@ -649,8 +649,16 @@
                 url = url + '&paging=false';
             }
             
-            var promise = $http.get( url ).then(function(response){                                
+            var promise = $http.get( url ).then(function(response){
                 return response.data;
+            }, function(error){
+                if(error && error.status === 403){
+                    var dialogOptions = {
+                        headerText: 'error',
+                        bodyText: 'access_denied'
+                    };		
+                    DialogService.showDialog({}, dialogOptions);
+                }
             });            
             return promise;
         },