mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-13 16:45:18 +08:00
fixes import protocol bug for guest user [fixes SCI-2197]
This commit is contained in:
parent
95425dc64b
commit
c46da5cc67
2 changed files with 37 additions and 23 deletions
|
@ -60,8 +60,13 @@ class ProtocolsController < ApplicationController
|
||||||
copy_to_repository
|
copy_to_repository
|
||||||
copy_to_repository_modal
|
copy_to_repository_modal
|
||||||
)
|
)
|
||||||
before_action :check_import_permissions, only: [:import]
|
before_action :check_import_permissions, only: :import
|
||||||
before_action :check_export_permissions, only: [:export]
|
before_action :check_export_permissions, only: :export
|
||||||
|
|
||||||
|
before_action :check_user_role,
|
||||||
|
only: %i(
|
||||||
|
import protocolsio_import_create protocolsio_import_save
|
||||||
|
)
|
||||||
|
|
||||||
def index; end
|
def index; end
|
||||||
|
|
||||||
|
@ -1169,4 +1174,8 @@ class ProtocolsController < ApplicationController
|
||||||
def metadata_params
|
def metadata_params
|
||||||
params.require(:protocol).permit(:name, :authors, :description)
|
params.require(:protocol).permit(:name, :authors, :description)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def check_user_role
|
||||||
|
render_403 unless can_create_protocols_in_repository?(current_team)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -49,28 +49,33 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
<div id="import-export-protocols" class="btn-group" role="group">
|
<div id="import-export-protocols" class="btn-group" role="group">
|
||||||
<a class="btn btn-default btn-open-file" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" href="#">
|
<a class="btn btn-default btn-open-file"
|
||||||
|
data-toggle="dropdown"
|
||||||
|
aria-haspopup="true"
|
||||||
|
aria-expanded="false"
|
||||||
|
href="#"
|
||||||
|
<%= 'disabled' unless can_create_protocols_in_repository?(@current_team) %>>
|
||||||
<span class="glyphicon glyphicon-import"></span><span class="hidden-xs"> <%= "Import protocol" %></span></a>
|
<span class="glyphicon glyphicon-import"></span><span class="hidden-xs"> <%= "Import protocol" %></span></a>
|
||||||
|
<% if can_create_protocols_in_repository?(@current_team) %>
|
||||||
<ul class="dropdown-menu">
|
<ul class="dropdown-menu">
|
||||||
<li>
|
<li>
|
||||||
<a class="btn-link-alt btn-default-link btn-open-file" <%= can_create_protocols_in_repository?(@current_team) ? 'data-action="import"' : 'disabled="disabled"' %>>
|
<a class="btn-link-alt btn-default-link btn-open-file" <%= can_create_protocols_in_repository?(@current_team) ? 'data-action="import"' : 'disabled="disabled"' %>>
|
||||||
<span class="glyphicon glyphicon-file"></span>
|
<span class="glyphicon glyphicon-file"></span>
|
||||||
<span class="hidden-xs"><%= t("protocols.index.import_alt") %></span>
|
<span class="hidden-xs"><%= t("protocols.index.import_alt") %></span>
|
||||||
<input type="file" value="" accept=".eln" data-role="import-file-input"
|
<input type="file" value="" accept=".eln" data-role="import-file-input"
|
||||||
data-team-id="<%= @current_team.id %>"
|
data-team-id="<%= @current_team.id %>"
|
||||||
data-type="<%= @type %>" data-import-url="<%= import_protocols_path %>"
|
data-type="<%= @type %>" data-import-url="<%= import_protocols_path %>"
|
||||||
<%= 'disabled="disabled"' unless can_create_protocols_in_repository?(@current_team) %>>
|
<%= 'disabled="disabled"' unless can_create_protocols_in_repository?(@current_team) %>>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<%= link_to "#modal-import-json-protocol", "data-toggle" => "modal" do %>
|
<%= link_to "#modal-import-json-protocol", "data-toggle" => "modal" do %>
|
||||||
<span class="glyphicon glyphicon-file"></span>
|
<span class="glyphicon glyphicon-file"></span>
|
||||||
<span class="hidden-xs"><%= t("protocols.index.import_json") %></span>
|
<span class="hidden-xs"><%= t("protocols.index.import_json") %></span>
|
||||||
<% end %>
|
<% end %>
|
||||||
</li>
|
</li>
|
||||||
|
</ul>
|
||||||
</ul>
|
<% end %>
|
||||||
<a class="btn btn-default" data-action="export" data-export-url="<%= export_protocols_path() %>">
|
<a class="btn btn-default" data-action="export" data-export-url="<%= export_protocols_path() %>">
|
||||||
<span class="glyphicon glyphicon-export"></span>
|
<span class="glyphicon glyphicon-export"></span>
|
||||||
<span class="hidden-xs"> <%= t("protocols.index.export") %></span>
|
<span class="hidden-xs"> <%= t("protocols.index.export") %></span>
|
||||||
|
|
Loading…
Add table
Reference in a new issue