Пример #1
0
    def createFTPAccount(self, domain, userName, password, owner):
        try:

            result = FTPUtilities.submitFTPCreation(domain, userName, password,
                                                    'None', owner)
            if result[0] == 1:
                self.printStatus(1, 'None')
            else:
                self.printStatus(1, result[1])
        except BaseException, msg:
            logger.writeforCLI(str(msg), "Error", stack()[0][3])
            self.printStatus(0, str(msg))
Пример #2
0
    def submitFTPCreation(self):
        try:
            userID = self.request.session['userID']
            currentACL = ACLManager.loadedACL(userID)

            if ACLManager.currentContextPermission(currentACL, 'createFTPAccount') == 0:
                return ACLManager.loadErrorJson('creatFTPStatus', 0)

            data = json.loads(self.request.body)
            userName = data['ftpUserName']
            password = data['passwordByPass']

            domainName = data['ftpDomain']

            admin = Administrator.objects.get(pk=userID)

            if ACLManager.checkOwnership(domainName, admin, currentACL) == 1:
                pass
            else:
                return ACLManager.loadError()

            try:
                api = data['api']
            except:
                api = '0'

            admin = Administrator.objects.get(id=userID)

            try:
                path = data['path']
                if len(path) > 0:
                    pass
                else:
                    path = 'None'
            except:
                path = 'None'


            result = FTPUtilities.submitFTPCreation(domainName, userName, password, path, admin.userName, api)

            if result[0] == 1:
                data_ret = {'status': 1, 'creatFTPStatus': 1, 'error_message': 'None'}
                json_data = json.dumps(data_ret)
                return HttpResponse(json_data)
            else:
                data_ret = {'status': 0, 'creatFTPStatus': 0, 'error_message': result[1]}
                json_data = json.dumps(data_ret)
                return HttpResponse(json_data)

        except BaseException, msg:
            data_ret = {'status': 0, 'creatFTPStatus': 0, 'error_message': str(msg)}
            json_data = json.dumps(data_ret)
            return HttpResponse(json_data)