Skip to content

Commit

Permalink
Now we are at a working base install. Tag this commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
svogtunh committed Nov 12, 2019
1 parent d4aa959 commit fb122fb
Show file tree
Hide file tree
Showing 28 changed files with 303 additions and 3 deletions.
4 changes: 3 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,6 @@ end

gem 'riiif', '~> 2.1'

gem 'mysql2'
gem 'mysql2'

gem 'hydra-role-management'
10 changes: 10 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ GEM
bootstrap-sass (3.4.1)
autoprefixer-rails (>= 5.2.1)
sassc (>= 2.0.0)
bootstrap_form (4.3.0)
actionpack (>= 5.0)
activemodel (>= 5.0)
breadcrumbs_on_rails (3.0.1)
browse-everything (1.0.2)
addressable (~> 2.5)
Expand Down Expand Up @@ -324,6 +327,12 @@ GEM
hydra-pcdm (1.1.0)
active-fedora (>= 10, < 14)
mime-types (>= 1)
hydra-role-management (1.0.2)
blacklight
bootstrap_form
bundler (>= 1.5)
cancancan
json (>= 1.8)
hydra-works (1.2.0)
activesupport (>= 4.2.10, < 6.0)
hydra-derivatives (~> 3.0)
Expand Down Expand Up @@ -801,6 +810,7 @@ DEPENDENCIES
devise
devise-guests (~> 0.6)
fcrepo_wrapper
hydra-role-management
hyrax (= 3.0.0.pre.rc1)
jbuilder (~> 2.5)
jquery-rails
Expand Down
8 changes: 8 additions & 0 deletions app/actors/hyrax/actors/generic_work_actor.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Generated via
# `rails generate hyrax:work GenericWork`
module Hyrax
module Actors
class GenericWorkActor < Hyrax::Actors::BaseActor
end
end
end
14 changes: 14 additions & 0 deletions app/controllers/hyrax/generic_works_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Generated via
# `rails generate hyrax:work GenericWork`
module Hyrax
# Generated controller for GenericWork
class GenericWorksController < ApplicationController
# Adds Hyrax behaviors to the controller.
include Hyrax::WorksControllerBehavior
include Hyrax::BreadcrumbsForWorks
self.curation_concern_type = ::GenericWork

# Use this line if you want to use a custom presenter
self.show_presenter = Hyrax::GenericWorkPresenter
end
end
9 changes: 9 additions & 0 deletions app/forms/hyrax/generic_work_form.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Generated via
# `rails generate hyrax:work GenericWork`
module Hyrax
# Generated form for GenericWork
class GenericWorkForm < Hyrax::Forms::WorkForm
self.model_class = ::GenericWork
self.terms += [:resource_type]
end
end
18 changes: 18 additions & 0 deletions app/indexers/generic_work_indexer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated via
# `rails generate hyrax:work GenericWork`
class GenericWorkIndexer < Hyrax::WorkIndexer
# This indexes the default metadata. You can remove it if you want to
# provide your own metadata and indexing.
include Hyrax::IndexesBasicMetadata

# Fetch remote labels for based_near. You can remove this if you don't want
# this behavior
include Hyrax::IndexesLinkedMetadata

# Uncomment this block if you want to add custom indexing behavior:
# def generate_solr_document
# super.tap do |solr_doc|
# solr_doc['my_custom_field_ssim'] = object.my_custom_property
# end
# end
end
6 changes: 5 additions & 1 deletion app/models/ability.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class Ability
include Hydra::Ability

include Hyrax::Ability
self.ability_logic += [:everyone_can_create_curation_concerns]

Expand All @@ -12,6 +12,10 @@ def custom_permissions
# can [:destroy], ActiveFedora::Base
# end

if current_user.admin?
can [:create, :show, :add_user, :remove_user, :index, :edit, :update, :destroy], Role
end

# Limits creating new objects to a specific group
#
# if user_groups.include? 'special_group'
Expand Down
14 changes: 14 additions & 0 deletions app/models/generic_work.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Generated via
# `rails generate hyrax:work GenericWork`
class GenericWork < ActiveFedora::Base
include ::Hyrax::WorkBehavior

self.indexer = GenericWorkIndexer
# Change this to restrict which works can be added as a child.
# self.valid_child_concerns = []
validates :title, presence: { message: 'Your work must have a title.' }

# This must be included at the end, because it finalizes the metadata
# schema (by adding accepts_nested_attributes)
include ::Hyrax::BasicMetadata
end
4 changes: 4 additions & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
class User < ApplicationRecord
# Connects this user object to Hydra behaviors.
include Hydra::User
# Connects this user object to Role-management behaviors.
include Hydra::RoleManagement::UserRoles


# Connects this user object to Hyrax behaviors.
include Hyrax::User
include Hyrax::UserUsageStats
Expand Down
6 changes: 6 additions & 0 deletions app/presenters/hyrax/generic_work_presenter.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Generated via
# `rails generate hyrax:work GenericWork`
module Hyrax
class GenericWorkPresenter < Hyrax::WorkShowPresenter
end
end
2 changes: 2 additions & 0 deletions app/views/hyrax/generic_works/_generic_work.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<%# This is a search result view %>
<%= render 'catalog/document', document: generic_work, document_counter: generic_work_counter %>
2 changes: 2 additions & 0 deletions config/initializers/hyrax.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
Hyrax.config do |config|
# Injected via `rails g hyrax:work Work`
config.register_curation_concern :work
# Injected via `rails g hyrax:work GenericWork`
config.register_curation_concern :generic_work
# Register roles that are expected by your implementation.
# @see Hyrax::RoleRegistry for additional details.
# @note there are magical roles as defined in Hyrax::RoleRegistry::MAGIC_ROLES
Expand Down
8 changes: 8 additions & 0 deletions config/locales/generic_work.de.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
de:
hyrax:
icons:
generic_work: 'fa fa-file-text-o'
select_type:
generic_work:
description: "Generic work Werke"
name: "Generic Work"
8 changes: 8 additions & 0 deletions config/locales/generic_work.en.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
en:
hyrax:
icons:
generic_work: 'fa fa-file-text-o'
select_type:
generic_work:
description: "Generic work works"
name: "Generic Work"
10 changes: 10 additions & 0 deletions config/locales/generic_work.es.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
es:
hyrax:
icons:
generic_work: 'fa fa-file-text-o'
select_type:
generic_work:
# TODO: translate `human_name` into Spanish
description: "Generic work trabajos"
name: "Generic Work"
# TODO: translate `human_name` into Spanish
8 changes: 8 additions & 0 deletions config/locales/generic_work.fr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
fr:
hyrax:
icons:
generic_work: 'fa fa-file-text-o'
select_type:
generic_work:
description: "Generic work œuvres"
name: "Generic Work"
8 changes: 8 additions & 0 deletions config/locales/generic_work.it.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
it:
hyrax:
icons:
generic_work: 'fa fa-file-text-o'
select_type:
generic_work:
description: "Generic work opere"
name: "Generic Work"
8 changes: 8 additions & 0 deletions config/locales/generic_work.pt-BR.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
pt-BR:
hyrax:
icons:
generic_work: 'fa fa-file-text-o'
select_type:
generic_work:
description: "Generic work obras"
name: "Generic Work"
10 changes: 10 additions & 0 deletions config/locales/generic_work.zh.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
zh:
hyrax:
icons:
generic_work: 'fa fa-file-text-o'
select_type:
generic_work:
# TODO: translate `human_name` into Chinese
description: "Generic work 作品"
name: "Generic Work"
# TODO: translate `human_name` into Chinese
2 changes: 2 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
end

devise_for :users
mount Hydra::RoleManagement::Engine => '/'

mount Qa::Engine => '/authorities'
mount Hyrax::Engine, at: '/'
resources :welcome, only: 'index'
Expand Down
19 changes: 19 additions & 0 deletions db/migrate/20191112184203_user_roles.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# frozen_string_literal: true
class UserRoles < ActiveRecord::Migration[5.0]
def up
create_table :roles do |t|
t.string :name
end
create_table :roles_users, id: false do |t|
t.references :role
t.references :user
end
add_index :roles_users, [:role_id, :user_id]
add_index :roles_users, [:user_id, :role_id]
end

def down
drop_table :roles_users
drop_table :roles
end
end
15 changes: 14 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20191112041953) do
ActiveRecord::Schema.define(version: 20191112184203) do

create_table "bookmarks", id: :integer, force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
t.integer "user_id", null: false
Expand Down Expand Up @@ -283,6 +283,19 @@
t.index ["uri"], name: "index_qa_local_authority_entries_on_uri", unique: true
end

create_table "roles", id: :integer, force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
t.string "name"
end

create_table "roles_users", id: false, force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
t.integer "role_id"
t.integer "user_id"
t.index ["role_id", "user_id"], name: "index_roles_users_on_role_id_and_user_id"
t.index ["role_id"], name: "index_roles_users_on_role_id"
t.index ["user_id", "role_id"], name: "index_roles_users_on_user_id_and_role_id"
t.index ["user_id"], name: "index_roles_users_on_user_id"
end

create_table "searches", id: :integer, force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
t.binary "query_params"
t.integer "user_id"
Expand Down
9 changes: 9 additions & 0 deletions spec/actors/hyrax/actors/generic_work_actor_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Generated via
# `rails generate hyrax:work GenericWork`
require 'rails_helper'

RSpec.describe Hyrax::Actors::GenericWorkActor do
it "has tests" do
skip "Add your tests here"
end
end
9 changes: 9 additions & 0 deletions spec/controllers/hyrax/generic_works_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Generated via
# `rails generate hyrax:work GenericWork`
require 'rails_helper'

RSpec.describe Hyrax::GenericWorksController do
it "has tests" do
skip "Add your tests here"
end
end
68 changes: 68 additions & 0 deletions spec/features/create_generic_work_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Generated via
# `rails generate hyrax:work GenericWork`
require 'rails_helper'
include Warden::Test::Helpers

# NOTE: If you generated more than one work, you have to set "js: true"
RSpec.feature 'Create a GenericWork', js: false do
context 'a logged in user' do
let(:user_attributes) do
{ email: '[email protected]' }
end
let(:user) do
User.new(user_attributes) { |u| u.save(validate: false) }
end
let(:admin_set_id) { AdminSet.find_or_create_default_admin_set_id }
let(:permission_template) { Hyrax::PermissionTemplate.find_or_create_by!(source_id: admin_set_id) }
let(:workflow) { Sipity::Workflow.create!(active: true, name: 'test-workflow', permission_template: permission_template) }

before do
# Create a single action that can be taken
Sipity::WorkflowAction.create!(name: 'submit', workflow: workflow)

# Grant the user access to deposit into the admin set.
Hyrax::PermissionTemplateAccess.create!(
permission_template_id: permission_template.id,
agent_type: 'user',
agent_id: user.user_key,
access: 'deposit'
)
login_as user
end

scenario do
visit '/dashboard'
click_link "Works"
click_link "Add new work"

# If you generate more than one work uncomment these lines
# choose "payload_concern", option: "GenericWork"
# click_button "Create work"

expect(page).to have_content "Add New Generic work"
click_link "Files" # switch tab
expect(page).to have_content "Add files"
expect(page).to have_content "Add folder"
within('span#addfiles') do
attach_file("files[]", "#{Hyrax::Engine.root}/spec/fixtures/image.jp2", visible: false)
attach_file("files[]", "#{Hyrax::Engine.root}/spec/fixtures/jp2_fits.xml", visible: false)
end
click_link "Descriptions" # switch tab
fill_in('Title', with: 'My Test Work')
fill_in('Creator', with: 'Doe, Jane')
select('In Copyright', from: 'Rights statement')

# With selenium and the chrome driver, focus remains on the
# select box. Click outside the box so the next line can't find
# its element
find('body').click
choose('generic_work_visibility_open')
expect(page).to have_content('Please note, making something visible to the world (i.e. marking this as Public) may be viewed as publishing which could impact your ability to')
check('agreement')

click_on('Save')
expect(page).to have_content('My Test Work')
expect(page).to have_content "Your files are being processed by Hyrax in the background."
end
end
end
9 changes: 9 additions & 0 deletions spec/forms/hyrax/generic_work_form_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Generated via
# `rails generate hyrax:work GenericWork`
require 'rails_helper'

RSpec.describe Hyrax::GenericWorkForm do
it "has tests" do
skip "Add your tests here"
end
end
9 changes: 9 additions & 0 deletions spec/models/generic_work_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Generated via
# `rails generate hyrax:work GenericWork`
require 'rails_helper'

RSpec.describe GenericWork do
it "has tests" do
skip "Add your tests here"
end
end
Loading

0 comments on commit fb122fb

Please sign in to comment.