diff --git a/applications/admin/controllers/pythonanywhere.py b/applications/admin/controllers/pythonanywhere.py index 50efc519c..e10e40207 100644 --- a/applications/admin/controllers/pythonanywhere.py +++ b/applications/admin/controllers/pythonanywhere.py @@ -17,18 +17,32 @@ def deploy(): return {} -def crossdomainproxy(): +def create_account(): + """ Create a PythonAnywhere account """ if not request.vars: raise HTTP(400) + + if request.vars.username and request.vars.web2py_admin_password: + # Check if web2py is already there otherwise we get an error 500 too. + client = ServerProxy('https://%(username)s:%(web2py_admin_password)s@%(username)s.pythonanywhere.com/admin/webservices/call/jsonrpc' % request.vars) + try: + if client.login() is True: + return response.json({'status': 'ok'}) + except ProtocolError as error: + pass + import urllib, urllib2 url = 'https://www.pythonanywhere.com/api/web2py/create_account' data = urllib.urlencode(request.vars) req = urllib2.Request(url, data) + try: reply = urllib2.urlopen(req) except urllib2.HTTPError as error: if error.code == 400: reply = error + elif error.code == 500: + return response.json({'status':'error', 'errors':{'username': ['An App other than web2py is installed in the domain %(username)s.pythonanywhere.com' % request.vars]}}) else: raise response.headers['Content-Type'] = 'application/json' diff --git a/applications/admin/languages/pt.py b/applications/admin/languages/pt.py index fc2a784ef..47e5506eb 100644 --- a/applications/admin/languages/pt.py +++ b/applications/admin/languages/pt.py @@ -183,6 +183,7 @@ 'Hide/Show Translated strings': '', 'htmledit': 'htmledit', 'If the report above contains a ticket number it indicates a failure in executing the controller, before any attempt to execute the doctests. This is usually due to an indentation error or an error outside function code.\nA green title indicates that all tests (if defined) passed. In this case test results are not shown.': 'Se o relatório acima contém um número de ticket, isso indica uma falha no controlador em execução, antes de tantar executar os doctests. Isto acontece geralmente por erro de endentação ou erro fora do código da função.\r\nO titulo em verde indica que os testes (se definidos) passaram. Neste caso os testes não são mostrados.', +'if your application uses a database other than sqlite you will then have to configure its DAL in pythonanywhere.': 'if your application uses a database other than sqlite you will then have to configure its DAL in pythonanywhere.', 'Import/Export': 'Importar/Exportar', 'includes': 'inclui', 'insert new': 'inserir novo', @@ -219,11 +220,11 @@ 'Login/Register': 'Login/Register', 'Logout': 'finalizar sessão', 'Lost Password': 'Senha perdida', -'Manage': 'Manage', 'manage': 'gerenciar', +'Manage': 'Manage', 'merge': 'juntar', -'Models': 'Modelos', 'models': 'modelos', +'Models': 'Modelos', 'Modules': 'Módulos', 'modules': 'módulos', 'Name': 'Nome', @@ -271,6 +272,7 @@ 'PythonAnywhere Password': 'PythonAnywhere Password', 'Query:': 'Consulta:', 'Rapid Search': 'Rapid Search', +'Read': 'Read', 'record': 'registro', 'record does not exist': 'o registro não existe', 'record id': 'id do registro', @@ -394,6 +396,7 @@ 'view': 'visão', 'Views': 'Visões', 'views': 'visões', +'Warning!': 'Warning!', 'Web Framework': 'Web Framework', 'web2py Admin Password': 'web2py Admin Password', 'web2py is up to date': 'web2py está atualizado', @@ -401,4 +404,5 @@ 'web2py upgraded; please restart it': 'web2py atualizado; favor reiniciar', 'Welcome to web2py': 'Bem-vindo ao web2py', 'YES': 'SIM', +'You only need these if you have already registered': 'You only need these if you have already registered', } diff --git a/applications/admin/views/pythonanywhere/deploy.html b/applications/admin/views/pythonanywhere/deploy.html index aee8569b7..b6db0e270 100644 --- a/applications/admin/views/pythonanywhere/deploy.html +++ b/applications/admin/views/pythonanywhere/deploy.html @@ -9,7 +9,7 @@

{{=T('Login/Register')}}

- + *
@@ -33,7 +33,7 @@

{{=T('Login/Register')}}

- + *
@@ -41,7 +41,7 @@

{{=T('Login/Register')}}

@@ -54,6 +54,7 @@

{{=T('Login/Register')}}

+

* {{=T('You only need these if you have already registered')}}

{{=T('PythonAnywhere Apps')}}

@@ -84,12 +89,11 @@

{{=T('PythonAnywhere Apps')}}

$.web2py.disableElement($('#submit_palogin')); $.web2py.disableFormElements($('#palogin')); $.ajax({ - url: '{{=URL("pythonanywhere", "crossdomainproxy")}}', + url: '{{=URL("pythonanywhere", "create_account")}}', type: 'POST', data: data, dataType: 'json', }).done(function(data, textStatus, jqXHR) { - console.log(data); $('#palogin .error').removeClass('error'); $('#palogin .help-block').text(''); if(data.status == 'error') { @@ -124,7 +128,6 @@

{{=T('PythonAnywhere Apps')}}

data: {username: $('#username').val(), password: $('#web2py_admin_password').val(), apps: $('#local').val()}, dataType: 'json', }).done(function(data, textStatus, jqXHR) { - console.log(data); refresh_apps(); $.web2py.enableElement($('#deploy_button')); }).fail(function(){