Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update plugin.py #19

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 5 additions & 12 deletions ckanext/ngsiview/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def can_preview(self, data_dict):

format_lower = resource['format'].lower()
if format_lower in self.NGSI_FORMATS:
if self.proxy_is_enabled and not resource['on_same_domain'] and check_query(resource):
if self.proxy_is_enabled and check_query(resource):
if oauth_req == 'true' and not p.toolkit.c.user:
details = "In order to see this resource properly, you need to be logged in"
h.flash_error(details, allow_html=False)
Expand All @@ -145,14 +145,13 @@ def setup_template_variables(self, context, data_dict):
resource = data_dict['resource']
proxy_enabled = p.plugin_loaded('resource_proxy')
oauth2_enabled = p.plugin_loaded('oauth2')
same_domain = datapreview.on_same_domain(data_dict)

if 'oauth_req' not in resource:
oauth_req = 'false'
else:
oauth_req = resource['oauth_req']

if proxy_enabled and not same_domain:
if proxy_enabled:
if check_query(resource):
if oauth_req == 'true' and not p.toolkit.c.user:
details = "</br></br>In order to see this resource properly, you need to be logged in.</br></br></br>"
Expand Down Expand Up @@ -180,14 +179,8 @@ def setup_template_variables(self, context, data_dict):
view_enable = [False, details]
url = proxy.get_proxified_resource_url(data_dict)
else:
if proxy_enabled:
details = "</br></br>Enable resource_proxy</br></br></br>"
f_details = "Enable resource_proxy."

else:
details = "</br></br>This is not a ContextBroker query, please check <a href='https://forge.fiware.org/plugins/mediawiki/wiki/fiware/index.php/Publish/Subscribe_Broker_-_Orion_Context_Broker_-_User_and_Programmers_Guide'>Orion Context Broker documentation</a></br></br></br>"
f_details = "This is not a ContextBroker query, please check Orion Context Broker documentation."

details = "</br></br>Enable resource_proxy</br></br></br>"
f_details = "Enable resource_proxy."
h.flash_error(f_details, allow_html=False)
view_enable = [False, details]
url = ''
Expand All @@ -197,7 +190,7 @@ def setup_template_variables(self, context, data_dict):
'resource_url': json.dumps(url),
'view_enable': json.dumps(view_enable)}
else:
if self.proxy_is_enabled and not data_dict['resource']['on_same_domain']:
if self.proxy_is_enabled:
if check_query(data_dict['resource']):
url = self.get_proxified_ngsi_url(data_dict)
p.toolkit.c.resource['url'] = url
Expand Down