This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository mum. See http://git.chorem.org/mum.git commit 3dbc9efd1a3a198d99af2e21aa47e98c46ec0c5e Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Wed Mar 25 13:22:03 2015 +0100 profile: affichage et modif des parametres de l'utilisateur --- app/modules/storage_modules/shelve_db.py | 44 ++++++++++++++++++++++++++++++++ static/js/controllers/profileCtrl.js | 28 +++++++++++++++++--- views/profile.html | 22 +++++++++------- 3 files changed, 82 insertions(+), 12 deletions(-) diff --git a/app/modules/storage_modules/shelve_db.py b/app/modules/storage_modules/shelve_db.py index e7f62fa..d24133a 100644 --- a/app/modules/storage_modules/shelve_db.py +++ b/app/modules/storage_modules/shelve_db.py @@ -988,6 +988,50 @@ class shelve_db: self.close_db() return res + def get_user_settings(self, args): + """ + Called by the profile page. + :param args: a dictionary containing: + { 'username': string } + :return: a dictionary containing: + { + 'settings':{ + 'email': string, + ... + }} + """ + res = {} + res['settings'] = {} + self.open_db() + try: + res['settings'] = self.db['users'][args['username']]['settings'] + except Exception as e: + print e.__str__() + finally: + self.close_db() + return res + + def update_user_settings(self, args): + """ + Called from the profile page. Replaces the current settings of a given user. + :param args: a dictionary containing: + { + 'username': string, + 'settings':{ + 'email': string, + ... + } + } + :return: + """ + self.open_db() + try: + self.db['users'][args['username']]['settings'] = args['settings'] + except Exception as e: + print e.__str__() + finally: + self.close_db() + def remove_user(self, args): """ Removes a user from the database. If the user is registered to a host or a group, diff --git a/static/js/controllers/profileCtrl.js b/static/js/controllers/profileCtrl.js index dd3e3ab..fa3bbb9 100644 --- a/static/js/controllers/profileCtrl.js +++ b/static/js/controllers/profileCtrl.js @@ -1,9 +1,12 @@ -mumApp.controller('profileCtrl', function($scope, $rootScope){ +mumApp.controller('profileCtrl', function($scope, $rootScope, $route){ $scope.users = {}; $scope.selected_user = ""; + $scope.email = ""; + $scope.sms_url = ""; + $rootScope.$broadcast("sendViaWs", JSON.stringify({"CALL_FUNC_DB": {'func': 'get_users', 'args': null}})); // receiving the user list @@ -13,14 +16,33 @@ mumApp.controller('profileCtrl', function($scope, $rootScope){ $scope.users = args.res; }); } + if(args.func == 'get_user_settings'){ + $scope.$apply(function(){ + $scope.email = args.res.settings.email; + $scope.sms_url = args.res.settings.sms_url; + }); + } + if(args.func == 'update_user_settings'){ + $route.reload(); + } }); $scope.get_user_settings = function(){ - args = {}; + var args = {}; if($scope.selected_user != ''){ args['username'] = $scope.selected_user; } - $rootScope.$broadcast("sendViaWs", JSON.stringify({"CALL_FUNC_DB": {'func': 'get_users', 'args': null}})); + $rootScope.$broadcast("sendViaWs", JSON.stringify({"CALL_FUNC_DB": {'func': 'get_user_settings', 'args': args}})); + } + + $scope.save_settings = function(){ + var args = {}; + args['username'] = $scope.selected_user; + args['settings'] = {}; + args['settings']['email'] = $scope.email; + args['settings']['sms_url'] = $scope.sms_url; + + $rootScope.$broadcast("sendViaWs", JSON.stringify({"CALL_FUNC_DB": {'func': 'update_user_settings', 'args': args}})); } }); \ No newline at end of file diff --git a/views/profile.html b/views/profile.html index 61553d3..074c630 100644 --- a/views/profile.html +++ b/views/profile.html @@ -12,29 +12,33 @@ <h3>Personal informations</h3> <div class="col-xs-3"> <label for="username">Username</label> - <input type="text" class="form-control" id="username" placeholder="Username"> + <input type="text" class="form-control" id="username" + disabled + ng-model="selected_user"> </div> <div class="row"></div> <div class="col-xs-3"> <label for="pswd">Change password</label> - <input type="password" class="form-control" id="pswd" placeholder="New password"> + <input type="password" class="form-control" id="pswd" disabled> </div> <div class="col-xs-3"> <label for="pswd2">Repeat new password</label> - <input type="password" class="form-control" id="pswd2" placeholder="Repeat new password"> + <input type="password" class="form-control" id="pswd2" disabled> </div> <div class="row"></div> <div class="col-xs-4"> <label for="mail">Email address</label> - <input type="email" class="form-control" id="mail" placeholder="Enter email"> + <input type="email" class="form-control" id="mail" ng-model="email"> </div> <div class="row"></div> <div class="col-xs-4"> <label for="cellphone">SMS URL</label> - <input type="email" class="form-control" id="cellphone"> + <input type="text" class="form-control" id="cellphone" ng-model="sms_url"> </div> </div> - <h3>Preferences</h3> + + <button type="button" class="btn btn-primary" ng-click="save_settings()">Save changes</button> + <!--<h3>Preferences</h3> <div class="checkbox"> <label for="minornotif">Send minor notifications by :</label> @@ -68,10 +72,10 @@ </label> </div> - <button type="button" class="btn btn-primary">Save changes</button> +--> </form> - <h3>Summary of notification subscriptions</h3> + <!--<h3>Summary of notification subscriptions</h3> <p>Number of notifications between your last login</p> <table class="table table-hover"> <thead> @@ -117,5 +121,5 @@ <td class="success">5</td> </tr> </tbody> - </table> + </table>--> </div> \ No newline at end of file -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.