-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
39 changed files
with
956 additions
and
46 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -77,6 +77,7 @@ bundle exec rails server | |
### Lint App | ||
```bash | ||
standardrb . | ||
standardrb --fix | ||
``` | ||
|
||
### Test App | ||
|
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
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# frozen_string_literal: true | ||
|
||
# BulkActionCollectDocuments class | ||
class BulkActionCollectDocuments < ApplicationJob | ||
queue_as :priority | ||
|
||
def perform(bulk_action_id) | ||
bulk_action = BulkAction.find(bulk_action_id) | ||
bulk_action.collect_documents | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# frozen_string_literal: true | ||
|
||
module GeoblacklightAdmin | ||
class StoreImageJob < ApplicationJob | ||
queue_as :default | ||
|
||
def perform(solr_document_id) | ||
document = Document.find_by_friendlier_id(solr_document_id) | ||
GeoblacklightAdmin::ImageService.new(document).store | ||
end | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
class Asset < Kithe::Asset | ||
include AttrJson::Record::QueryScopes | ||
|
||
set_shrine_uploader(AssetUploader) | ||
|
||
# AttrJSON | ||
attr_json :thumbnail, :boolean, default: "false" | ||
attr_json :derivative_storage_type, :string, default: "public" | ||
|
||
DERIVATIVE_STORAGE_TYPE_LOCATIONS = { | ||
"public" => :kithe_derivatives | ||
}.freeze | ||
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 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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
module BulkActions | ||
# Subclass for ChangePublicationState | ||
class ChangePublicationState < BulkAction | ||
# Add specific methods and validations for ChangePublicationState here | ||
end | ||
|
||
# Subclass for PublishDocument | ||
class PublishDocument < BulkAction | ||
# Add specific methods and validations for PublishDocument here | ||
end | ||
|
||
# Subclass for UnpublishDocument | ||
class UnpublishDocument < BulkAction | ||
# Add specific methods and validations for UnpublishDocument here | ||
end | ||
|
||
# Subclass for DraftDocument | ||
class DraftDocument < BulkAction | ||
# Add specific methods and validations for DraftDocument here | ||
end | ||
end |
26 changes: 26 additions & 0 deletions
26
app/models/concerns/geoblacklight_admin/publication_state_search_behavior.rb
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# frozen_string_literal: true | ||
|
||
module GeoblacklightAdmin | ||
module PublicationStateSearchBehavior | ||
extend ActiveSupport::Concern | ||
|
||
included do | ||
self.default_processor_chain += [:publication_state_records] | ||
end | ||
|
||
## | ||
# Show/Hide records by publication state in search | ||
# Defaults to "published" items only | ||
# publication_state: ['published', 'unpublished', 'draft'] | ||
# @param [Blacklight::Solr::Request] | ||
# @return [Blacklight::Solr::Request] | ||
def publication_state_records(solr_params) | ||
solr_params[:fq] ||= [] | ||
solr_params[:fq] << if blacklight_params["publication_state"] | ||
"b1g_publication_state_s:#{blacklight_params["publication_state"]}" | ||
else | ||
"b1g_publication_state_s:published" | ||
end | ||
end | ||
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 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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# frozen_string_literal: true | ||
|
||
# Date Validation | ||
# | ||
# ex. Bad date field type value | ||
# "foo" is not a date | ||
# "2023-12-5" is a date | ||
class Document | ||
# DateValidator | ||
class DateValidator < ActiveModel::Validator | ||
def validate(record) | ||
# Assume true | ||
valid_date = true | ||
|
||
date_elements = Element.where(field_type: "date") | ||
|
||
# Sane date values? | ||
date_elements.each do |element| | ||
unless record.send(element.solr_field).nil? | ||
Rails.logger.debug("Date Validator") | ||
Rails.logger.debug("Dates: #{record.send(element.solr_field).inspect}") | ||
record.send(element.solr_field).each do |date| | ||
Rails.logger.debug("\nDate: #{date}") | ||
valid_date = proper_date(record, element, date, valid_date) | ||
|
||
break if !valid_date | ||
end | ||
end | ||
end | ||
|
||
valid_date | ||
end | ||
|
||
def proper_date(record, element, date, valid_date) | ||
if date.blank? | ||
valid_date = true | ||
elsif date.class != Date | ||
valid_date = false | ||
record.errors.add(GeoblacklightAdmin::Schema.instance.solr_fields[element.to_sym], "Bad date field type.") | ||
end | ||
|
||
Rails.logger.debug("#{date} - #{valid_date}") | ||
valid_date | ||
end | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,7 @@ class Element < ApplicationRecord | |
text | ||
integer | ||
boolean | ||
date | ||
datetime | ||
].freeze | ||
|
||
|
Oops, something went wrong.