From 5798e6dda4a1c31188550595bcfb6c005f0a430f Mon Sep 17 00:00:00 2001 From: alexandru-m-g Date: Fri, 24 Jun 2016 03:10:17 +0300 Subject: [PATCH] #4238 fixing redirect after successful request - adapting label to specify protocol is needed - small fixes --- .../controllers/request_controller.py | 15 ++++++++++----- .../organization/request_organization_form.html | 4 ++-- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/ckanext-hdx_org_group/ckanext/hdx_org_group/controllers/request_controller.py b/ckanext-hdx_org_group/ckanext/hdx_org_group/controllers/request_controller.py index 63afe9a1d3..007db0d125 100644 --- a/ckanext-hdx_org_group/ckanext/hdx_org_group/controllers/request_controller.py +++ b/ckanext-hdx_org_group/ckanext/hdx_org_group/controllers/request_controller.py @@ -3,6 +3,10 @@ @author: Dan, alexandru-m-g ''' + +import logging as logging +import exceptions as exceptions + import ckan.lib.helpers as h import ckan.logic as logic import ckan.lib.base as base @@ -11,8 +15,7 @@ import ckan.lib.base as base import ckanext.hdx_theme.helpers.helpers as hdx_h import ckan.model as model -import logging as logging -import exceptions as exceptions + import ckanext.hdx_theme.util.mail as hdx_mail @@ -90,7 +93,8 @@ def request_new_organization(self): errors = {} error_summary = {} data = {'from': request.params.get('from','')} - from_url = '' + + sent_successfully = False if 'save' in request.params: try: data = self._process_new_org_request() @@ -98,10 +102,9 @@ def request_new_organization(self): tk.get_action('hdx_send_new_org_request')(context, data) - #from_url = data.get('from','') data.clear() h.flash_success(_('Request sent successfully')) - h.redirect_to('user_dashboard_organizations') + sent_successfully = True except hdx_mail.NoRecipientException, e: h.flash_error(_(str(e))) except logic.ValidationError, e: @@ -110,6 +113,8 @@ def request_new_organization(self): except exceptions.Exception, e: log.error(str(e)) h.flash_error(_('Request can not be sent. Contact an administrator')) + if sent_successfully: + h.redirect_to('user_dashboard_organizations') vars = {'data': data, 'errors': errors, 'error_summary': error_summary, 'action': 'new'} diff --git a/ckanext-hdx_theme/ckanext/hdx_theme/templates/organization/request_organization_form.html b/ckanext-hdx_theme/ckanext/hdx_theme/templates/organization/request_organization_form.html index 61c9aaf515..ac04f40e8e 100644 --- a/ckanext-hdx_theme/ckanext/hdx_theme/templates/organization/request_organization_form.html +++ b/ckanext-hdx_theme/ckanext/hdx_theme/templates/organization/request_organization_form.html @@ -41,8 +41,8 @@

{{ form.prepend('name', label=_('URL'), prepend=prefix, id='field-url', placeholder=_('my-organisation'), value=data.name, error=errors.name, attrs=attrs) }}
- {% set org_url_value = h.hdx_get_extras_element(data.extras) %} - {{ form.input('org_url', label=_('URL of Organisation'), id='field-org-url', type='url', placeholder=_('http://example.com/about'), value=org_url_value, error=errors.image_url, classes=['control-full','org-control','field-with-info']) }} + {{ form.input('org_url', label=_('URL of Organisation (please include protocol, e.g. "http://")'), id='field-org-url', + type='url', placeholder=_('http://example.com/about'), value=data.org_url, error=errors.org_url, classes=['control-full','org-control','field-with-info']) }}
{{_('Where can people go to find more about this organisation?')}}