-
Notifications
You must be signed in to change notification settings - Fork 51
Merge show/new page of DataProvider #1553
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
Open
natacha-beck
wants to merge
13
commits into
aces:dev
Choose a base branch
from
natacha-beck:new_show
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 11 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
d8cf724
[WIP] new/show DP
natacha-beck cfd7e0e
[WIP] Need fix for user
natacha-beck bb57f44
[WIP]
natacha-beck 837f0a5
[FIX] for S3 dp show
natacha-beck 659e712
[FIX] DataProvider Spec
natacha-beck 4d3bbdc
[FIX] DP documentation
natacha-beck 751ae5c
[WIP]
natacha-beck fb14f49
[RM] datalad reference for now
natacha-beck 5a805cc
[WIP] remove othe datalad ref
natacha-beck 96dcad4
[WIP]
natacha-beck a5791f8
[FIX] spacing and return value
natacha-beck 7fb117b
[WIP] fix after PR review
natacha-beck b69458f
[FIX] afer PR
natacha-beck File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,6 +64,8 @@ def show #:nodoc: | |
@provider = DataProvider.find(data_provider_id) | ||
cb_notice "Provider not accessible by current user." unless @provider.can_be_accessed_by?(current_user) | ||
|
||
@typelist = get_type_list | ||
|
||
respond_to do |format| | ||
format.html # show.html.erb | ||
format.xml { | ||
|
@@ -77,19 +79,30 @@ def show #:nodoc: | |
|
||
def new #:nodoc: | ||
provider_group_id = current_assignable_group.id | ||
@provider = DataProvider.new( :user_id => current_user.id, | ||
@provider = DataProvider.new( | ||
:user_id => current_user.id, | ||
:group_id => provider_group_id, | ||
:online => true, | ||
:read_only => false | ||
) | ||
|
||
@typelist = get_type_list | ||
@unsaved_meta = {} | ||
@is_personal = false | ||
@typelist = get_type_list | ||
|
||
# Edit/create/show are the same view | ||
render :action => :show | ||
end | ||
|
||
def create #:nodoc: | ||
@provider = DataProvider.sti_new(data_provider_params) | ||
@provider.user_id ||= current_user.id # disabled field in form DOES NOT send value! | ||
@provider.group_id ||= current_assignable_group.id | ||
@unsaved_meta = params[:meta] || {} | ||
|
||
# Fix some attributes | ||
@provider.update_attributes(userkey_provider_params) if @provider.is_a?(UserkeyFlatDirSshDataProvider) | ||
@provider.update_attributes(s3_provider_params) if @provider.is_a?(S3FlatDataProvider) | ||
|
||
if @provider.save | ||
add_meta_data_from_form(@provider, [:must_move, :no_uploads, :no_viewers, :browse_gid]) | ||
|
@@ -103,7 +116,7 @@ def create #:nodoc: | |
else | ||
@typelist = get_type_list | ||
respond_to do |format| | ||
format.html { render :action => :new } | ||
format.html { render :action => :show } | ||
format.xml { render :xml => @provider.errors, :status => :unprocessable_entity } | ||
format.json { render :json => @provider.errors, :status => :unprocessable_entity } | ||
end | ||
|
@@ -117,32 +130,40 @@ def new_personal #:nodoc: | |
:online => true, | ||
:read_only => false, | ||
) | ||
@groups = current_user.assignable_groups | ||
@unsaved_meta = {} | ||
@is_personal = true | ||
@typelist = get_personal_type_list | ||
|
||
# Edit/create/show are the same view | ||
render :action => :show | ||
end | ||
|
||
# Can be create by normal user, | ||
# only UserkeyFlatDirSshDataProvider, S3FlatDataProvider, S3MultiLevelDataProvider | ||
def create_personal | ||
@provider = DataProvider.new(base_provider_params).class_update | ||
@provider.update_attributes(userkey_provider_params) if @provider.is_a?(UserkeyFlatDirSshDataProvider) | ||
@provider.update_attributes(s3_provider_params) if @provider.is_a?(S3FlatDataProvider) | ||
|
||
authorized_type = [UserkeyFlatDirSshDataProvider, S3FlatDataProvider, S3MultiLevelDataProvider] | ||
@provider.errors.add(:type, "is not allowed") unless authorized_type.include?(@provider.type) | ||
@unsaved_meta = params[:meta] || {} | ||
|
||
@provider = DataProvider.new(base_provider_params).class_update | ||
# Fix some attributes | ||
@provider.user_id = current_user.id | ||
@provider.group_id = current_user.own_group.id unless | ||
current_user.assignable_group_ids.include?(@provider.group_id) | ||
@provider.online = true | ||
|
||
if ! @provider.save | ||
@provider.update_attributes(userkey_provider_params) if @provider.is_a?(UserkeyFlatDirSshDataProvider) | ||
@provider.update_attributes(s3_provider_params) if @provider.is_a?(S3FlatDataProvider) | ||
|
||
authorized_type = ["UserkeyFlatDirSshDataProvider", "S3FlatDataProvider", "S3MultiLevelDataProvider"] | ||
@provider.errors.add(:type, "is not allowed") unless authorized_type.include?(@provider.type) | ||
|
||
if ! @provider.errors.empty? || ! @provider.save | ||
@typelist = get_personal_type_list | ||
@groups = current_user.assignable_groups | ||
respond_to do |format| | ||
format.html { render :action => :new_personal} | ||
format.html { render :action => :show } | ||
format.json { render :json => @provider.errors, :status => :unprocessable_entity } | ||
end | ||
return | ||
return | ||
end | ||
|
||
@provider.addlog_context(self, "Created by #{current_user.login}") | ||
|
@@ -808,8 +829,30 @@ def get_type_list #:nodoc: | |
grouped_options = data_provider_list.to_a.hashed_partitions { |name| name.constantize.pretty_category_name } | ||
grouped_options.delete(nil) # data providers that can not be on this list return a category name of nil, so we remove them | ||
grouped_options.keys.sort.map { |type| [ type, grouped_options[type].sort ] } | ||
|
||
return grouped_options || [] | ||
end | ||
|
||
def get_personal_type_list #:nodoc: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What does this method do? Explain please. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add a comment block before the method name |
||
data_provider_list = [ "FlatDirSshDataProvider" ] | ||
data_provider_list = DataProvider.descendants.map(&:name) | ||
|
||
grouped_options = data_provider_list.to_a.hashed_partitions { |name| name.constantize.pretty_category_name } | ||
# Keep only Cloud | ||
grouped_options = grouped_options.select { |type, values| ["Cloud"].include?(type) } | ||
# Remove S3DataProvider | ||
grouped_options["Cloud"].reject! { |v| v == S3DataProvider.name } if grouped_options["Cloud"] | ||
|
||
# Add UserkeyFlatDirSshDataProvider group | ||
category_of_userkey_dp = UserkeyFlatDirSshDataProvider.pretty_category_name | ||
userkey_group = grouped_options.find { |type, _ | type == category_of_userkey_dp } || [] | ||
userkey_group << UserkeyFlatDirSshDataProvider.name | ||
grouped_options[category_of_userkey_dp] = userkey_group | ||
|
||
return grouped_options || [] | ||
end | ||
|
||
|
||
# A name to store the scope for the browsing page; | ||
# a distinct scope is used for each distinct DP | ||
def browse_scope_name(provider) #:nodoc: | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why was this
return
added? Didn't the previous code return an empty array already?