diff --git a/app/controllers/collections_controller.rb b/app/controllers/collections_controller.rb deleted file mode 100644 index 73743ee..0000000 --- a/app/controllers/collections_controller.rb +++ /dev/null @@ -1,91 +0,0 @@ -class CollectionsController < ApplicationController - before_action :authenticate_user! - before_action :restrict_to_admin, only: [:new, :create, :edit, :update, :destroy] - before_action :set_collection, only: [:show, :edit, :update, :destroy] - - # GET /collections - # GET /collections.json - def index - @collections = Collection.all - end - - # GET /collections/1 - # GET /collections/1.json - def show - end - - # GET /collections/new - def new - @collection = Collection.new - @parsers = SWORD_CONFIG[:parsers] - @list_of_parsers - end - - # GET /collections/1/edit - def edit - end - - # POST /collections - # POST /collections.json - def create - @collection = Collection.new(collection_params) - - respond_to do |format| - if @collection.save - format.html { redirect_to @collection, notice: 'Collection was successfully created.' } - format.json { render :show, status: :created, location: @collection } - else - format.html { render :new } - format.json { render json: @collection.errors, status: :unprocessable_entity } - end - end - end - - # PATCH/PUT /collections/1 - # PATCH/PUT /collections/1.json - def update - respond_to do |format| - if @collection.update(collection_params) - format.html { redirect_to @collection, notice: 'Collection was successfully updated.' } - format.json { render :show, status: :ok, location: @collection } - else - format.html { render :edit } - format.json { render json: @collection.errors, status: :unprocessable_entity } - end - end - end - - # DELETE /collections/1 - # DELETE /collections/1.json - def destroy - @collection.destroy - respond_to do |format| - format.html { redirect_to collections_url, notice: 'Collection was successfully destroyed.' } - format.json { head :no_content } - end - end - - private - # Use callbacks to share common setup or constraints between actions. - def set_collection - @collection = Collection.find(params[:id]) - end - - def restrict_to_admin - redirect_to(collections_path, notice: "Only admin can perform this action") unless current_user.admin? - end - - # Never trust parameters from the scary internet, only allow the white list through. - def collection_params - # params.fetch(:collection, {}) - params.require(:collection).permit(:name, - :atom_title, - :slug, - :abstract, - :hyacinth_project_string_key, - :parser, - :mime_types, - :sword_package_types, - :mediation_enabled ) - end -end diff --git a/app/controllers/depositors_controller.rb b/app/controllers/depositors_controller.rb deleted file mode 100644 index 6e687aa..0000000 --- a/app/controllers/depositors_controller.rb +++ /dev/null @@ -1,110 +0,0 @@ -class DepositorsController < ApplicationController - before_action :authenticate_user! - before_action :restrict_to_admin, only: [:new, :create, :edit, :update, :destroy, - :edit_permissions, :remove_permission, :add_permission] - before_action :set_depositor, only: [:show, :edit, :update, :destroy, - :edit_permissions, :remove_permission, :add_permission] - - # GET /depositors - # GET /depositors.json - def index - @depositors = Depositor.all - end - - # GET /depositors/1 - # GET /depositors/1.json - def show - end - - # GET /depositors/new - def new - @depositor = Depositor.new - end - - # GET /depositors/1/edit - def edit - end - - # POST /depositors - # POST /depositors.json - def create - @depositor = Depositor.new(depositor_params) - - respond_to do |format| - if @depositor.save - format.html { redirect_to @depositor, notice: 'Depositor was successfully created.' } - format.json { render :show, status: :created, location: @depositor } - else - format.html { render :new } - format.json { render json: @depositor.errors, status: :unprocessable_entity } - end - end - end - - # PATCH/PUT /depositors/1 - # PATCH/PUT /depositors/1.json - def update - respond_to do |format| - if @depositor.update(depositor_params) - format.html { redirect_to @depositor, notice: 'Depositor was successfully updated.' } - format.json { render :show, status: :ok, location: @depositor } - else - format.html { render :edit } - format.json { render json: @depositor.errors, status: :unprocessable_entity } - end - end - end - - # DELETE /depositors/1 - # DELETE /depositors/1.json - def destroy - @depositor.destroy - respond_to do |format| - format.html { redirect_to depositors_url, notice: 'Depositor was successfully destroyed.' } - format.json { head :no_content } - end - end - - def edit_permissions - @has_access_to_collection = {} - Collection.all.each do |collection| - if @depositor.collections.include? collection - @has_access_to_collection[collection] = true - else - @has_access_to_collection[collection] = false - end - end - end - - def add_permission - collection = Collection.find_by(id: params[:collection_id]) - @depositor.collections << collection - @depositor.save - redirect_to action: :edit_permissions - end - - def remove_permission - collection = Collection.find_by(id: params[:collection_id]) - @depositor.collections.delete(collection) - @depositor.save - redirect_to action: :edit_permissions - end - - private - # Use callbacks to share common setup or constraints between actions. - def set_depositor - @depositor = Depositor.find(params[:id]) - end - - def restrict_to_admin - redirect_to(depositors_path, notice: "Only admin can perform this action") unless current_user.admin? - end - - # Never trust parameters from the scary internet, only allow the white list through. - def depositor_params - params.fetch(:depositor, {}).permit(:name, - :basic_authentication_user_id, - :password, - :password_confirmation) - end -end diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 02ad41b..4598742 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -14,8 +14,6 @@ <% if user_signed_in? %>