Пример #1
0
 def on_submit(self, event, params, vars=None):
     if params[0] == 'dlgEdit':
         v = vars.getvalue('value', '')
         if vars.getvalue('action', '') == 'OK':
             if self._editing == 'adduser':
                 backend.add_user(v)
                 self._selected_user = v
             if self._editing == 'addgrp':
                 backend.add_group(v)
                 self._selected_group = v
             if self._editing == 'login':
                 backend.change_user_login(self._selected_user, v)
                 self._selected_user = v
             if self._editing == 'uid':
                 backend.change_user_uid(self._selected_user, v)
             if self._editing == 'gid':
                 backend.change_user_gid(self._selected_user, v)
             if self._editing == 'shell':
                 backend.change_user_shell(self._selected_user, v)
             if self._editing == 'password':
                 backend.change_user_password(self._selected_user, v)
             if self._editing == 'home':
                 backend.change_user_home(self._selected_user, v)
             if self._editing == 'name':
                 backend.change_group_name(self._selected_group, v)
                 self._selected_group = v
             if self._editing == 'ggid':
                 backend.change_group_gid(self._selected_group, v)
         self._editing = ''
     if params[0] == 'dlgEditUser':
         self._selected_user = ''
     if params[0] == 'dlgEditGroup':
         self._selected_group = ''
Пример #2
0
 def on_submit(self, event, params, vars=None):
     if params[0] == 'dlgEdit':
         v = vars.getvalue('value', '')
         if vars.getvalue('action', '') == 'OK':
             if self._editing == 'adduser':
                 backend.add_user(v)
                 self._selected_user = v
             if self._editing == 'addgrp':
                 backend.add_group(v)
                 self._selected_group = v
             if self._editing == 'login':
                 backend.change_user_login(self._selected_user, v)
                 self._selected_user = v
             if self._editing == 'uid':
                 backend.change_user_uid(self._selected_user, v)
             if self._editing == 'gid':
                 backend.change_user_gid(self._selected_user, v)
             if self._editing == 'shell':
                 backend.change_user_shell(self._selected_user, v)
             if self._editing == 'password':
                 backend.change_user_password(self._selected_user, v)
             if self._editing == 'home':
                 backend.change_user_home(self._selected_user, v)
             if self._editing == 'name':
                 backend.change_group_name(self._selected_group, v)
                 self._selected_group = v
             if self._editing == 'ggid':
                 backend.change_group_gid(self._selected_group, v)
         self._editing = ''
     if params[0] == 'dlgEditUser':
         self._selected_user = ''
     if params[0] == 'dlgEditGroup':
         self._selected_group = ''
Пример #3
0
 def post(self):
     """Post request for adding a new user.
     Returns code - 201 if user has been successful added,
     code - 400 if user hasn't been successful added"""
     username = self.parser.parse_args()['username']
     if backend.add_user(username):
         return {"message": "user has been successful created"}, 201
     else:
         return {"error": "user has been exist."}, 400
Пример #4
0
def add_user(request):
    import backend
    return backend.add_user(request)
Пример #5
0
def add_new_user():
    jsonresponse = request.get_json()
    status = backend.add_user(jsonresponse)
    return json.dumps(status)
Пример #6
0
 def test_15_add_user(self):
     self.assertFalse(backend.add_user('test'))