-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #421 from mbarnett/multi_comm_coll
Working multi-community/collection selection
- Loading branch information
Showing
20 changed files
with
180 additions
and
314 deletions.
There are no files selected for viewing
This file contains 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.
This file contains 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 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 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 |
---|---|---|
@@ -1,85 +1,11 @@ | ||
class ItemsController < ApplicationController | ||
|
||
before_action :load_item, only: [:show, :edit, :update] | ||
before_action :initialize_communities_and_collections, only: [:new, :edit] | ||
|
||
def show; end | ||
|
||
def new | ||
# TODO: Remove for Draft Item Controller | ||
@item = Item.new_locked_ldp_object | ||
authorize @item | ||
end | ||
|
||
def create | ||
# TODO: Remove for Draft Item Controller | ||
communities = params[:item].delete :community | ||
collections = params[:item].delete :collection | ||
|
||
@item = Item.new_locked_ldp_object(permitted_attributes(Item)) | ||
authorize @item | ||
|
||
# TODO: add validations? | ||
@item.unlock_and_fetch_ldp_object do |unlocked_item| | ||
unlocked_item.owner = current_user.id | ||
unlocked_item.add_communities_and_collections(communities, collections) | ||
unlocked_item.add_files(params[:item][:file]) | ||
unlocked_item.save! | ||
|
||
if unlocked_item.save | ||
redirect_to @item, notice: t('.created') | ||
else | ||
initialize_communities_and_collections | ||
render :new, status: :bad_request | ||
end | ||
end | ||
end | ||
|
||
def edit | ||
# TODO: Remove for Draft Item Controller | ||
end | ||
|
||
def update | ||
# TODO: Remove for Draft Item Controller | ||
authorize @item | ||
|
||
communities = params[:item].delete :community | ||
collections = params[:item].delete :collection | ||
|
||
@item.unlock_and_fetch_ldp_object do |unlocked_item| | ||
unlocked_item.update_attributes(permitted_attributes(@item)) | ||
unlocked_item.add_communities_and_collections(communities, collections) | ||
unlocked_item.add_files(params[:item][:file]) | ||
|
||
if unlocked_item.save | ||
redirect_to @item, notice: t('.updated') | ||
else | ||
initialize_communities_and_collections | ||
render :edit, status: :bad_request | ||
end | ||
end | ||
end | ||
|
||
private | ||
|
||
def load_item | ||
def show | ||
@item = JupiterCore::LockedLdpObject.find(params[:id], types: [Item, Thesis]) | ||
authorize @item | ||
end | ||
|
||
def initialize_communities_and_collections | ||
@communities = Community.all | ||
|
||
@item_communities = [] | ||
@item_collections = [] | ||
@collection_choices = [] | ||
|
||
return if @item.nil? | ||
@item.each_community_collection do |community, collection| | ||
@item_communities << community | ||
@item_collections << collection | ||
@collection_choices << community.member_collections | ||
end | ||
end | ||
# TODO: this is just a temp hack to give edit_item_path calls in templates somewhere to point until draft editing lands | ||
def edit; end | ||
|
||
end |
This file contains 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.