Skip to content

Commit

Permalink
Merge branch 'dev' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Pooya-Oladazimi committed Jan 19, 2022
2 parents 9736334 + 020d46c commit 3b7ac58
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 15 deletions.
12 changes: 12 additions & 0 deletions ckanext/semantic_media_wiki/controllers/media_wiki.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,4 +144,16 @@ def cancel_dataset_plugin_is_enabled():
if Helper.check_plugin_enabled('cancel_dataset_creation'):
return True
return False


def get_smw_link():
ckan_root_path = toolkit.config.get('ckan.root_path')
if ckan_root_path and 'sfb1368/ckan' in ckan_root_path:
return ['1368', "https://service.tib.eu/sfb1368/wiki/Equipment", None]

elif ckan_root_path and 'sfb1153/ckan' in ckan_root_path:
return ['1153', "https://service.tib.eu/sfb1153/wiki/Tools", "https://service.tib.eu/sfb1153/wiki/Machines"]
else:
return ['1368', "https://service.tib.eu/sfb1368/wiki/Equipment", None]


3 changes: 2 additions & 1 deletion ckanext/semantic_media_wiki/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,5 @@ def get_blueprint(self):
return blueprint

def get_helpers(self):
return {'cancel_dataset_is_enabled': MediaWikiController.cancel_dataset_plugin_is_enabled}
return {'cancel_dataset_is_enabled': MediaWikiController.cancel_dataset_plugin_is_enabled,
'get_smw_link': MediaWikiController.get_smw_link}
9 changes: 0 additions & 9 deletions ckanext/semantic_media_wiki/public/statics/machines.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,6 @@ function formatState (state) {
};

$(document).ready(function(){
let cUrl = window.location.pathname;
console.info(cUrl);
if (cUrl.includes('1368/ckan')){
$('#add_new_machine_btn').attr('href', 'https://service.tib.eu/sfb1368/wiki/Equipment');
}
else{
$('#add_new_machine_btn').attr('href', 'https://service.tib.eu/sfb1153/wiki/Equipment');
}


$("select.machine_dropdown").select2({
formatResult: formatState
Expand Down
15 changes: 13 additions & 2 deletions ckanext/semantic_media_wiki/templates/add_machines.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,20 @@ <h3>{{_('Please Select the Equipment(s) for this dataset')}}:</h3>
{{_('If you cannot find your Equipment, you can add it via the below button. Please refresh this page
if you add a new Equipment.')}}
<br><br>
<a id="add_new_machine_btn" class="btn btn-primary" href="" target='_blank'>
{% set taget_smw_url = h.get_smw_link() %}
{% if taget_smw_url[0] == '1368' %}
<a id="add_new_machine_btn" class="btn btn-primary" href="{{taget_smw_url[1]}}" target='_blank'>
{{_('Add New Equipment')}}
</a>
</a>
{% else %}
<a id="add_new_machine_btn" class="btn btn-primary" href="{{taget_smw_url[1]}}" target='_blank'>
{{_('Add New Tool')}}
</a>
<a id="add_new_machine_btn" class="btn btn-primary" href="{{taget_smw_url[2]}}" target='_blank'>
{{_('Add New Machine')}}
</a>
{% endif %}

</p>
<hr>
{% set action = h.url_for('semantic_media_wiki.save_machines', _external=True) %}
Expand Down
16 changes: 13 additions & 3 deletions ckanext/semantic_media_wiki/templates/edit_machines.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,19 @@
{{_('If you cannot find your Equipment, you can add it via the below button. Please refresh this page
if you add a new Equipment.')}}
<br><br>
<a id="add_new_machine_btn" class="btn btn-primary" href="" target='_blank'>
{{_('Add New Equipment')}}
</a>
{% set taget_smw_url = h.get_smw_link() %}
{% if taget_smw_url[0] == '1368' %}
<a id="add_new_machine_btn" class="btn btn-primary" href="{{taget_smw_url[1]}}" target='_blank'>
{{_('Add New Equipment')}}
</a>
{% else %}
<a id="add_new_machine_btn" class="btn btn-primary" href="{{taget_smw_url[1]}}" target='_blank'>
{{_('Add New Tool')}}
</a>
<a id="add_new_machine_btn" class="btn btn-primary" href="{{taget_smw_url[2]}}" target='_blank'>
{{_('Add New Machine')}}
</a>
{% endif %}
</p>
<hr>
{% set action = h.url_for('semantic_media_wiki.edit_save', _external=True) %}
Expand Down

0 comments on commit 3b7ac58

Please sign in to comment.