mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-04-29 17:27:31 +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
app
|
@ -60,8 +60,13 @@ class ProtocolsController < ApplicationController
|
|||
copy_to_repository
|
||||
copy_to_repository_modal
|
||||
)
|
||||
before_action :check_import_permissions, only: [:import]
|
||||
before_action :check_export_permissions, only: [:export]
|
||||
before_action :check_import_permissions, only: :import
|
||||
before_action :check_export_permissions, only: :export
|
||||
|
||||
before_action :check_user_role,
|
||||
only: %i(
|
||||
import protocolsio_import_create protocolsio_import_save
|
||||
)
|
||||
|
||||
def index; end
|
||||
|
||||
|
@ -1169,4 +1174,8 @@ class ProtocolsController < ApplicationController
|
|||
def metadata_params
|
||||
params.require(:protocol).permit(:name, :authors, :description)
|
||||
end
|
||||
|
||||
def check_user_role
|
||||
render_403 unless can_create_protocols_in_repository?(current_team)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -49,28 +49,33 @@
|
|||
<% end %>
|
||||
</div>
|
||||
<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>
|
||||
|
||||
<ul class="dropdown-menu">
|
||||
<li>
|
||||
<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="hidden-xs"><%= t("protocols.index.import_alt") %></span>
|
||||
<input type="file" value="" accept=".eln" data-role="import-file-input"
|
||||
data-team-id="<%= @current_team.id %>"
|
||||
data-type="<%= @type %>" data-import-url="<%= import_protocols_path %>"
|
||||
<%= 'disabled="disabled"' unless can_create_protocols_in_repository?(@current_team) %>>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<%= link_to "#modal-import-json-protocol", "data-toggle" => "modal" do %>
|
||||
<span class="glyphicon glyphicon-file"></span>
|
||||
<span class="hidden-xs"><%= t("protocols.index.import_json") %></span>
|
||||
<% end %>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
<% if can_create_protocols_in_repository?(@current_team) %>
|
||||
<ul class="dropdown-menu">
|
||||
<li>
|
||||
<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="hidden-xs"><%= t("protocols.index.import_alt") %></span>
|
||||
<input type="file" value="" accept=".eln" data-role="import-file-input"
|
||||
data-team-id="<%= @current_team.id %>"
|
||||
data-type="<%= @type %>" data-import-url="<%= import_protocols_path %>"
|
||||
<%= 'disabled="disabled"' unless can_create_protocols_in_repository?(@current_team) %>>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<%= link_to "#modal-import-json-protocol", "data-toggle" => "modal" do %>
|
||||
<span class="glyphicon glyphicon-file"></span>
|
||||
<span class="hidden-xs"><%= t("protocols.index.import_json") %></span>
|
||||
<% end %>
|
||||
</li>
|
||||
</ul>
|
||||
<% end %>
|
||||
<a class="btn btn-default" data-action="export" data-export-url="<%= export_protocols_path() %>">
|
||||
<span class="glyphicon glyphicon-export"></span>
|
||||
<span class="hidden-xs"> <%= t("protocols.index.export") %></span>
|
||||
|
|
Loading…
Add table
Reference in a new issue