repo stringlengths 5 92 | file_url stringlengths 80 287 | file_path stringlengths 5 197 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 15:37:27 2026-01-04 17:58:21 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/policies/event_import_file_policy.rb | app/policies/event_import_file_policy.rb | class EventImportFilePolicy < ApplicationPolicy
def index?
user.try(:has_role?, "Librarian")
end
def show?
user.try(:has_role?, "Librarian")
end
def create?
user.try(:has_role?, "Librarian")
end
def update?
user.try(:has_role?, "Librarian")
end
def destroy?
user.try(:has_role?, "Librarian")
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/policies/frequency_policy.rb | app/policies/frequency_policy.rb | class FrequencyPolicy < ApplicationPolicy
def index?
true
end
def show?
true
end
def create?
true if user.try(:has_role?, "Administrator")
end
def update?
true if user.try(:has_role?, "Administrator")
end
def destroy?
if user.try(:has_role?, "Administrator")
true if record.manifestations.empty?
end
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/policies/resource_export_file_policy.rb | app/policies/resource_export_file_policy.rb | class ResourceExportFilePolicy < ApplicationPolicy
def index?
true if user.try(:has_role?, "Librarian")
end
def show?
true if user.try(:has_role?, "Librarian")
end
def create?
true if user.try(:has_role?, "Librarian")
end
def update?
true if user.try(:has_role?, "Librarian")
end
def destroy?
true if user.try(:has_role?, "Librarian")
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/policies/produce_type_policy.rb | app/policies/produce_type_policy.rb | class ProduceTypePolicy < ApplicationPolicy
def index?
true if user.try(:has_role?, "Librarian")
end
def show?
true if user.try(:has_role?, "Librarian")
end
def create?
true if user.try(:has_role?, "Administrator")
end
def update?
true if user.try(:has_role?, "Administrator")
end
def destroy?
true if user.try(:has_role?, "Administrator")
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/policies/own_policy.rb | app/policies/own_policy.rb | class OwnPolicy < ApplicationPolicy
def index?
true
end
def show?
true
end
def create?
true if user.try(:has_role?, "Librarian")
end
def update?
true if user.try(:has_role?, "Librarian")
end
def destroy?
true if user.try(:has_role?, "Librarian")
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/policies/reserve_policy.rb | app/policies/reserve_policy.rb | class ReservePolicy < ApplicationPolicy
def index?
user.try(:has_role?, "User")
end
def show?
if user.try(:has_role?, "Librarian")
true
elsif user && (user == record.user)
true
end
end
def create?
if user.try(:has_role?, "Librarian")
true
elsif user.try(:has_role?, "User")
true if user.profile.user_number.try(:present?)
end
end
def update?
if user.try(:has_role?, "Librarian")
true
elsif user && (user == record.user)
true
end
end
def destroy?
if user.try(:has_role?, "Librarian")
true
elsif user && (user == record.user)
true
end
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/policies/country_policy.rb | app/policies/country_policy.rb | class CountryPolicy < ApplicationPolicy
def index?
true
end
def show?
true
end
def create?
true if user.try(:has_role?, "Administrator")
end
def update?
true if user.try(:has_role?, "Administrator")
end
def destroy?
true if user.try(:has_role?, "Administrator")
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/policies/manifestation_relationship_policy.rb | app/policies/manifestation_relationship_policy.rb | class ManifestationRelationshipPolicy < ApplicationPolicy
def index?
true
end
def show?
true
end
def create?
true if user.try(:has_role?, "Librarian")
end
def update?
true if user.try(:has_role?, "Librarian")
end
def destroy?
true if user.try(:has_role?, "Librarian")
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/policies/user_reserve_stat_policy.rb | app/policies/user_reserve_stat_policy.rb | class UserReserveStatPolicy < ApplicationPolicy
def index?
user.try(:has_role?, "Librarian")
end
def show?
user.try(:has_role?, "Librarian")
end
def create?
user.try(:has_role?, "Librarian")
end
def update?
user.try(:has_role?, "Librarian")
end
def destroy?
user.try(:has_role?, "Administrator")
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/policies/manifestation_reserve_stat_policy.rb | app/policies/manifestation_reserve_stat_policy.rb | class ManifestationReserveStatPolicy < ApplicationPolicy
def index?
true
end
def show?
true
end
def create?
user.try(:has_role?, "Librarian")
end
def update?
user.try(:has_role?, "Librarian")
end
def destroy?
user.try(:has_role?, "Librarian")
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/policies/item_has_use_restriction_policy.rb | app/policies/item_has_use_restriction_policy.rb | class ItemHasUseRestrictionPolicy < ApplicationPolicy
def index?
user.try(:has_role?, "Librarian")
end
def show?
user.try(:has_role?, "Librarian")
end
def create?
user.try(:has_role?, "Administrator")
end
def update?
user.try(:has_role?, "Administrator")
end
def destroy?
user.try(:has_role?, "Administrator")
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/policies/item_custom_property_policy.rb | app/policies/item_custom_property_policy.rb | class ItemCustomPropertyPolicy < ApplicationPolicy
def index?
true if user.try(:has_role?, "Librarian")
end
def show?
true if user.try(:has_role?, "Librarian")
end
def create?
true if user.try(:has_role?, "Administrator")
end
def update?
true if user.try(:has_role?, "Administrator")
end
def destroy?
true if user.try(:has_role?, "Administrator")
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/policies/use_restriction_policy.rb | app/policies/use_restriction_policy.rb | class UseRestrictionPolicy < ApplicationPolicy
def index?
true if user.try(:has_role?, "Librarian")
end
def show?
true if user.try(:has_role?, "Librarian")
end
def create?
false
end
def update?
if user.try(:has_role?, "Administrator")
true
end
end
def destroy?
false
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/policies/identifier_type_policy.rb | app/policies/identifier_type_policy.rb | class IdentifierTypePolicy < ApplicationPolicy
def index?
true if user.try(:has_role?, "Librarian")
end
def show?
true if user.try(:has_role?, "Librarian")
end
def create?
true if user.try(:has_role?, "Administrator")
end
def update?
true if user.try(:has_role?, "Administrator")
end
def destroy?
if user.try(:has_role?, "Administrator")
true unless record.identifiers.exists?
end
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/policies/oai_policy.rb | app/policies/oai_policy.rb | class OaiPolicy < ApplicationPolicy
def provider?
true
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/policies/form_of_work_policy.rb | app/policies/form_of_work_policy.rb | class FormOfWorkPolicy < ApplicationPolicy
def index?
true
end
def show?
true
end
def create?
true if user.try(:has_role?, "Administrator")
end
def update?
true if user.try(:has_role?, "Administrator")
end
def destroy?
true if user.try(:has_role?, "Administrator")
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/policies/order_list_policy.rb | app/policies/order_list_policy.rb | class OrderListPolicy < ApplicationPolicy
def index?
true if user.try(:has_role?, "Librarian")
end
def show?
true if user.try(:has_role?, "Librarian")
end
def create?
true if user.try(:has_role?, "Librarian")
end
def update?
true if user.try(:has_role?, "Librarian")
end
def destroy?
true if user.try(:has_role?, "Librarian")
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/policies/medium_of_performance_policy.rb | app/policies/medium_of_performance_policy.rb | class MediumOfPerformancePolicy < ApplicationPolicy
def index?
true
end
def show?
true
end
def create?
true if user.try(:has_role?, "Administrator")
end
def update?
true if user.try(:has_role?, "Administrator")
end
def destroy?
true if user.try(:has_role?, "Administrator")
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/policies/carrier_type_policy.rb | app/policies/carrier_type_policy.rb | class CarrierTypePolicy < ApplicationPolicy
def index?
true if user.try(:has_role?, "Librarian")
end
def show?
true if user.try(:has_role?, "Librarian")
end
def create?
true if user.try(:has_role?, "Administrator")
end
def update?
true if user.try(:has_role?, "Administrator")
end
def destroy?
if user.try(:has_role?, "Administrator")
true unless record.manifestations.exists?
end
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/policies/checkout_type_policy.rb | app/policies/checkout_type_policy.rb | class CheckoutTypePolicy < ApplicationPolicy
def index?
true if user.try(:has_role?, "Librarian")
end
def show?
true if user.try(:has_role?, "Librarian")
end
def create?
true if user.try(:has_role?, "Administrator")
end
def update?
true if user.try(:has_role?, "Administrator")
end
def destroy?
if user.try(:has_role?, "Administrator")
true if record.items.empty?
end
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/policies/basket_policy.rb | app/policies/basket_policy.rb | class BasketPolicy < ApplicationPolicy
def index?
true if user.try(:has_role?, "Librarian")
end
def show?
true if user.try(:has_role?, "Librarian")
end
def create?
true if user.try(:has_role?, "Librarian")
end
def update?
true if user.try(:has_role?, "Librarian")
end
def destroy?
true if user.try(:has_role?, "Librarian")
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/policies/tag_policy.rb | app/policies/tag_policy.rb | class TagPolicy < ApplicationPolicy
def index?
true
end
def show?
true
end
def create?
user.try(:has_role?, "Librarian")
end
def update?
user.try(:has_role?, "Librarian")
end
def destroy?
user.try(:has_role?, "Librarian")
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/policies/agent_policy.rb | app/policies/agent_policy.rb | class AgentPolicy < ApplicationPolicy
class Scope
def initialize(user, scope)
@user = user
@scope = scope
end
def resolve
role_id = user&.role&.id || 1
scope.where("agents.required_role_id <= ?", role_id)
end
private
attr_reader :user, :scope
end
def index?
true
end
def show?
case user.try(:role).try(:name)
when "Administrator"
true
when "Librarian"
true if record.required_role_id <= 3
when "User"
true if record.required_role_id <= 2
else
true if record.required_role_id <= 1
end
end
def create?
true if user.try(:has_role?, "Librarian")
end
def update?
true if user.try(:has_role?, "Librarian")
end
def destroy?
true if user.try(:has_role?, "Librarian")
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/policies/bookmark_stat_policy.rb | app/policies/bookmark_stat_policy.rb | class BookmarkStatPolicy < ApplicationPolicy
def index?
true
end
def show?
true
end
def create?
user.try(:has_role?, "Librarian")
end
def update?
user.try(:has_role?, "Librarian")
end
def destroy?
user.try(:has_role?, "Administrator")
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/policies/ndl_book_policy.rb | app/policies/ndl_book_policy.rb | class NdlBookPolicy < ApplicationPolicy
def index?
true if user.try(:has_role?, "Librarian")
end
def create?
true if user.try(:has_role?, "Librarian")
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/policies/circulation_status_policy.rb | app/policies/circulation_status_policy.rb | class CirculationStatusPolicy < ApplicationPolicy
def index?
true
end
def show?
true if user.try(:has_role?, "Librarian")
end
def create?
false
end
def update?
if user.try(:has_role?, "Administrator")
true
end
end
def destroy?
false
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/policies/profile_policy.rb | app/policies/profile_policy.rb | class ProfilePolicy < ApplicationPolicy
def index?
true if user.try(:has_role?, "Librarian")
end
def show?
case user.try(:role).try(:name)
when "Administrator"
true
when "Librarian"
return true if record == user.profile
true if %w(Librarian User Guest).include?(record.required_role.name)
when "User"
return true if record == user.profile
true if %w(User Guest).include?(record.required_role.name)
end
end
def create?
true if user.try(:has_role?, "Librarian")
end
def update?
case user.try(:role).try(:name)
when "Administrator"
true
when "Librarian"
unless record.user.try(:has_role?, "Administrator")
true if %w(User Guest Librarian).include?(record.required_role.name)
end
when "User"
true if record == user.profile
end
end
def destroy?
return false unless user
return false unless user.try(:has_role?, "Librarian")
if record.user
if record != user.profile && record.user.id != 1
if defined?(EnjuCirculation)
if record.user.checkouts.not_returned.empty?
true if record.user.deletable_by?(user)
end
elsif record.user.deletable_by?(user)
true
end
else
false
end
else
true
end
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/policies/manifestation_relationship_type_policy.rb | app/policies/manifestation_relationship_type_policy.rb | class ManifestationRelationshipTypePolicy < ApplicationPolicy
def index?
true
end
def show?
true
end
def create?
true if user.try(:has_role?, "Administrator")
end
def update?
true if user.try(:has_role?, "Administrator")
end
def destroy?
true if user.try(:has_role?, "Administrator")
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/policies/search_engine_policy.rb | app/policies/search_engine_policy.rb | class SearchEnginePolicy < ApplicationPolicy
def index?
true if user.try(:has_role?, "Librarian")
end
def show?
true if user.try(:has_role?, "Librarian")
end
def create?
true if user.try(:has_role?, "Administrator")
end
def update?
true if user.try(:has_role?, "Administrator")
end
def destroy?
true if user.try(:has_role?, "Administrator")
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/policies/agent_import_result_policy.rb | app/policies/agent_import_result_policy.rb | class AgentImportResultPolicy < ApplicationPolicy
def index?
true if user.try(:has_role?, "Librarian")
end
def show?
true if user.try(:has_role?, "Librarian")
end
def destroy?
false
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/policies/realize_type_policy.rb | app/policies/realize_type_policy.rb | class RealizeTypePolicy < ApplicationPolicy
def index?
true if user.try(:has_role?, "Librarian")
end
def show?
true if user.try(:has_role?, "Librarian")
end
def create?
true if user.try(:has_role?, "Administrator")
end
def update?
true if user.try(:has_role?, "Administrator")
end
def destroy?
true if user.try(:has_role?, "Administrator")
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/policies/shelf_policy.rb | app/policies/shelf_policy.rb | class ShelfPolicy < ApplicationPolicy
def index?
true
end
def show?
true
end
def create?
true if user.try(:has_role?, "Administrator")
end
def update?
true if user.try(:has_role?, "Administrator")
end
def destroy?
if user.try(:has_role?, "Administrator")
true if record.items.count.zero? && !record.web_shelf?
end
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/policies/accept_policy.rb | app/policies/accept_policy.rb | class AcceptPolicy < ApplicationPolicy
def index?
true if user.try(:has_role?, "Librarian")
end
def show?
true if user.try(:has_role?, "Librarian")
end
def create?
true if user.try(:has_role?, "Librarian")
end
def update?
true if user.try(:has_role?, "Librarian")
end
def destroy?
true if user.try(:has_role?, "Librarian")
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/policies/request_status_type_policy.rb | app/policies/request_status_type_policy.rb | class RequestStatusTypePolicy < ApplicationPolicy
def index?
true if user.try(:has_role?, "Librarian")
end
def show?
true if user.try(:has_role?, "Librarian")
end
def create?
false
end
def update?
true if user.try(:has_role?, "Administrator")
end
def destroy?
false
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/policies/license_policy.rb | app/policies/license_policy.rb | class LicensePolicy < ApplicationPolicy
def index?
true
end
def show?
true
end
def create?
true if user.try(:has_role?, "Administrator")
end
def update?
true if user.try(:has_role?, "Administrator")
end
def destroy?
true if user.try(:has_role?, "Administrator")
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/policies/manifestation_checkout_stat_policy.rb | app/policies/manifestation_checkout_stat_policy.rb | class ManifestationCheckoutStatPolicy < ApplicationPolicy
def index?
true
end
def show?
true
end
def create?
user.try(:has_role?, "Librarian")
end
def update?
user.try(:has_role?, "Librarian")
end
def destroy?
user.try(:has_role?, "Librarian")
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/policies/acts_as_taggable_on/tag_policy.rb | app/policies/acts_as_taggable_on/tag_policy.rb | class ActsAsTaggableOn::TagPolicy < ApplicationPolicy
def index?
true
end
def show?
true
end
def create?
user.try(:has_role?, "Librarian")
end
def update?
user.try(:has_role?, "Librarian")
end
def destroy?
user.try(:has_role?, "Librarian")
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/controllers/agent_relationship_types_controller.rb | app/controllers/agent_relationship_types_controller.rb | class AgentRelationshipTypesController < ApplicationController
before_action :set_agent_relationship_type, only: [ :show, :edit, :update, :destroy ]
before_action :check_policy, only: [ :index, :new, :create ]
# GET /agent_relationship_types
# GET /agent_relationship_types.json
def index
@agent_relationship_types = AgentRelationshipType.order(:position)
respond_to do |format|
format.html # index.html.erb
end
end
# GET /agent_relationship_types/1
# GET /agent_relationship_types/1.json
def show
respond_to do |format|
format.html # show.html.erb
end
end
# GET /agent_relationship_types/new
def new
@agent_relationship_type = AgentRelationshipType.new
end
# GET /agent_relationship_types/1/edit
def edit
end
# POST /agent_relationship_types
# POST /agent_relationship_types.json
def create
@agent_relationship_type = AgentRelationshipType.new(agent_relationship_type_params)
respond_to do |format|
if @agent_relationship_type.save
format.html { redirect_to @agent_relationship_type, notice: t("controller.successfully_created", model: t("activerecord.models.agent_relationship_type")) }
format.json { render json: @agent_relationship_type, status: :created, location: @agent_relationship_type }
else
format.html { render action: "new" }
format.json { render json: @agent_relationship_type.errors, status: :unprocessable_entity }
end
end
end
# PUT /agent_relationship_types/1
# PUT /agent_relationship_types/1.json
def update
if params[:move]
move_position(@agent_relationship_type, params[:move])
return
end
respond_to do |format|
if @agent_relationship_type.update(agent_relationship_type_params)
format.html { redirect_to @agent_relationship_type, notice: t("controller.successfully_updated", model: t("activerecord.models.agent_relationship_type")) }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @agent_relationship_type.errors, status: :unprocessable_entity }
end
end
end
# DELETE /agent_relationship_types/1
# DELETE /agent_relationship_types/1.json
def destroy
@agent_relationship_type.destroy
respond_to do |format|
format.html { redirect_to agent_relationship_types_url, notice: t("controller.successfully_deleted", model: t("activerecord.models.agent_relationship_type")) }
format.json { head :no_content }
end
end
private
def set_agent_relationship_type
@agent_relationship_type = AgentRelationshipType.find(params[:id])
authorize @agent_relationship_type
end
def check_policy
authorize AgentRelationshipType
end
def agent_relationship_type_params
params.require(:agent_relationship_type).permit(:name, :display_name, :note)
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/controllers/participates_controller.rb | app/controllers/participates_controller.rb | class ParticipatesController < ApplicationController
before_action :set_participate, only: [ :show, :edit, :update, :destroy ]
before_action :check_policy, only: [ :index, :new, :create ]
# GET /participates
# GET /participates.json
def index
@participates = Participate.page(params[:page])
respond_to do |format|
format.html # index.html.erb
end
end
# GET /participates/1
# GET /participates/1.json
def show
respond_to do |format|
format.html # show.html.erb
end
end
# GET /participates/new
def new
@participate = Participate.new
end
# GET /participates/1/edit
def edit
end
# POST /participates
# POST /participates.json
def create
@participate = Participate.new(participate_params)
respond_to do |format|
if @participate.save
flash[:notice] = "Participate was successfully created."
format.html { redirect_to(@participate) }
format.json { render json: @participate, status: :created, location: @participate }
else
format.html { render action: "new" }
format.json { render json: @participate.errors, status: :unprocessable_entity }
end
end
end
# PUT /participates/1
# PUT /participates/1.json
def update
respond_to do |format|
if @participate.update(participate_params)
flash[:notice] = "Participate was successfully updated."
format.html { redirect_to(@participate) }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @participate.errors, status: :unprocessable_entity }
end
end
end
# DELETE /participates/1
# DELETE /participates/1.json
def destroy
@participate.destroy
respond_to do |format|
format.html { redirect_to participates_url }
format.json { head :no_content }
end
end
private
def set_participate
@participate = Participate.find(params[:id])
authorize @participate
end
def check_policy
authorize Participate
end
def participate_params
params.require(:participate).permit(:agent_id, :event_id)
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/controllers/request_status_types_controller.rb | app/controllers/request_status_types_controller.rb | class RequestStatusTypesController < ApplicationController
before_action :set_request_status_type, only: [ :show, :edit, :update ]
before_action :check_policy, only: [ :index ]
# GET /request_status_types
# GET /request_status_types.json
def index
@request_status_types = RequestStatusType.order(:position)
respond_to do |format|
format.html # index.html.erb
format.json { render json: @request_status_types }
end
end
# GET /request_status_types/1
# GET /request_status_types/1.json
def show
respond_to do |format|
format.html # show.html.erb
format.json { render json: @request_status_type }
end
end
# GET /request_status_types/1/edit
def edit
end
# PUT /request_status_types/1
# PUT /request_status_types/1.json
def update
if params[:move]
move_position(@request_status_type, params[:move])
return
end
respond_to do |format|
if @request_status_type.update(request_status_type_params)
format.html { redirect_to @request_status_type, notice: t("controller.successfully_updated", model: t("activerecord.models.request_status_type")) }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @request_status_type.errors, status: :unprocessable_entity }
end
end
end
private
def set_request_status_type
@request_status_type = RequestStatusType.find(params[:id])
authorize @request_status_type
end
def check_policy
authorize RequestStatusType
end
def request_status_type_params
params.require(:request_status_type).permit(:name, :display_name, :note)
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/controllers/subjects_controller.rb | app/controllers/subjects_controller.rb | class SubjectsController < ApplicationController
before_action :set_subject, only: [ :show, :edit, :update, :destroy ]
before_action :check_policy, only: [ :index, :new, :create ]
before_action :prepare_options, only: [ :new, :edit ]
# GET /subjects
# GET /subjects.json
def index
sort = { sort_by: "created_at", order: "desc" }
case params[:sort_by]
when "name"
sort[:sort_by] = "term"
end
sort[:order] = "asc" if params[:order] == "asc"
search = Subject.search
query = params[:query].to_s.strip
if query.present?
@query = query.dup
query = query.gsub(" ", " ")
search.build do
fulltext query
end
end
search.build do
order_by sort[:sort_by], sort[:order]
end
role = current_user.try(:role) || Role.default
search.build do
with(:required_role_id).less_than_or_equal_to role.id
end
page = params[:page] || 1
search.query.paginate(page.to_i, Subject.default_per_page)
@subjects = search.execute!.results
session[:params] = {} unless session[:params]
session[:params][:subject] = params
flash[:page_info] = { page: page, query: query }
respond_to do |format|
format.html # index.html.erb
format.rss
format.atom
end
end
# GET /subjects/1
# GET /subjects/1.json
def show
if params[:term]
subject = Subject.find_by(term: params[:term])
redirected_to subject
return
end
search = Sunspot.new_search(Manifestation)
subject = @subject
search.build do
with(:subject_ids).equal_to subject.id if subject
end
page = params[:work_page] || 1
search.query.paginate(page.to_i, Manifestation.default_per_page)
respond_to do |format|
format.html # show.html.erb
end
end
# GET /subjects/new
def new
@subject = Subject.new
end
# GET /subjects/1/edit
def edit
end
# POST /subjects
# POST /subjects.json
def create
@subject = Subject.new(subject_params)
respond_to do |format|
if @subject.save
format.html { redirect_to @subject, notice: t("controller.successfully_created", model: t("activerecord.models.subject")) }
format.json { render json: @subject, status: :created, location: @subject }
else
prepare_options
format.html { render action: "new" }
format.json { render json: @subject.errors, status: :unprocessable_entity }
end
end
end
# PUT /subjects/1
# PUT /subjects/1.json
def update
respond_to do |format|
if @subject.update(subject_params)
format.html { redirect_to @subject, notice: t("controller.successfully_updated", model: t("activerecord.models.subject")) }
format.json { head :no_content }
else
prepare_options
format.html { render action: "edit" }
format.json { render json: @subject.errors, status: :unprocessable_entity }
end
end
end
# DELETE /subjects/1
# DELETE /subjects/1.json
def destroy
@subject.destroy
respond_to do |format|
format.html { redirect_to subjects_url, notice: t("controller.successfully_deleted", model: t("activerecord.models.subject")) }
format.json { head :no_content }
end
end
private
def set_subject
@subject = Subject.find(params[:id])
authorize @subject
end
def check_policy
authorize Subject
end
def subject_params
params.require(:subject).permit(
:parent_id, :use_term_id, :term, :term_transcription,
:subject_type_id, :note, :required_role_id, :subject_heading_type_id
)
end
def prepare_options
@subject_heading_types = SubjectHeadingType.select([ :id, :display_name, :position ])
@subject_types = SubjectType.select([ :id, :display_name, :position ])
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/controllers/library_groups_controller.rb | app/controllers/library_groups_controller.rb | class LibraryGroupsController < ApplicationController
before_action :set_library_group, only: [ :show, :edit, :update ]
before_action :check_policy, only: [ :index ]
# GET /library_groups
# GET /library_groups.json
def index
@library_groups = LibraryGroup.all
respond_to do |format|
format.html # index.html.erb
end
end
# GET /library_groups/1
# GET /library_groups/1.json
def show
respond_to do |format|
format.html # show.html.erb
format.json { render json: @library_group }
end
end
# GET /library_groups/1/edit
def edit
@countries = Country.order(:position)
end
# PUT /library_groups/1
# PUT /library_groups/1.json
def update
respond_to do |format|
if @library_group.update(library_group_params)
if @library_group.delete_header_logo == "1"
@library_group.header_logo.destroy
end
format.html { redirect_to @library_group, notice: t("controller.successfully_updated", model: t("activerecord.models.library_group")) }
format.json { head :no_content }
else
@countries = Country.order(:position)
format.html { render action: "edit" }
format.json { render json: @library_group.errors, status: :unprocessable_entity }
end
end
end
private
def set_library_group
@library_group = LibraryGroup.find(params[:id])
if request.format == :download
authorize @library_group, :show_logo?
else
authorize @library_group
end
end
def check_policy
authorize LibraryGroup
end
def library_group_params
params.require(:library_group).permit(
:name, :display_name, :short_name, :my_networks,
:login_banner, :note, :country_id, :admin_networks, :url,
:max_number_of_results, :footer_banner, :email,
:book_jacket_source, :screenshot_generator,
:header_logo, :delete_header_logo,
:allow_bookmark_external_url, # EnjuBookmark
{
colors_attributes: [ :id, :property, :code ]
},
{
user_attributes: [ :email ]
},
*LibraryGroup.globalize_attribute_names
)
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/controllers/licenses_controller.rb | app/controllers/licenses_controller.rb | class LicensesController < ApplicationController
before_action :set_license, only: [ :show, :edit, :update, :destroy ]
before_action :check_policy, only: [ :index, :new, :create ]
# GET /licenses
# GET /licenses.json
def index
@licenses = License.order(:position)
respond_to do |format|
format.html # index.html.erb
end
end
# GET /licenses/1
# GET /licenses/1.json
def show
respond_to do |format|
format.html # show.html.erb
end
end
# GET /licenses/new
def new
@license = License.new
end
# GET /licenses/1/edit
def edit
end
# POST /licenses
# POST /licenses.json
def create
@license = License.new(license_params)
respond_to do |format|
if @license.save
format.html { redirect_to @license, notice: t("controller.successfully_created", model: t("activerecord.models.license")) }
format.json { render json: @license, status: :created, location: @license }
else
format.html { render action: "new" }
format.json { render json: @license.errors, status: :unprocessable_entity }
end
end
end
# PUT /licenses/1
# PUT /licenses/1.json
def update
if params[:move]
move_position(@license, params[:move])
return
end
respond_to do |format|
if @license.update(license_params)
format.html { redirect_to @license, notice: t("controller.successfully_updated", model: t("activerecord.models.license")) }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @license.errors, status: :unprocessable_entity }
end
end
end
# DELETE /licenses/1
# DELETE /licenses/1.json
def destroy
@license.destroy
respond_to do |format|
format.html { redirect_to licenses_url, notice: t("controller.successfully_deleted", model: t("activerecord.models.license")) }
format.json { head :no_content }
end
end
private
def set_license
@license = License.find(params[:id])
authorize @license
end
def check_policy
authorize License
end
def license_params
params.require(:license).permit(:name, :display_name, :note)
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/controllers/user_reserve_stats_controller.rb | app/controllers/user_reserve_stats_controller.rb | class UserReserveStatsController < ApplicationController
before_action :set_user_reserve_stat, only: [ :show, :edit, :update, :destroy ]
before_action :check_policy, only: [ :index, :new, :create ]
after_action :convert_charset, only: :show
# GET /user_reserve_stats
# GET /user_reserve_stats.json
def index
@user_reserve_stats = UserReserveStat.order("id DESC").page(params[:page])
respond_to do |format|
format.html # index.html.erb
end
end
# GET /user_reserve_stats/1
# GET /user_reserve_stats/1.json
def show
if request.format.text?
per_page = 65534
else
per_page = ReserveStatHasUser.default_per_page
end
@stats = @user_reserve_stat.reserve_stat_has_users.order("reserves_count DESC, user_id").page(params[:page]).per(per_page)
respond_to do |format|
format.html # show.html.erb
format.text
end
end
# GET /user_reserve_stats/new
def new
@user_reserve_stat = UserReserveStat.new
end
# GET /user_reserve_stats/1/edit
def edit
end
# POST /user_reserve_stats
# POST /user_reserve_stats.json
def create
@user_reserve_stat = UserReserveStat.new(user_reserve_stat_params)
@user_reserve_stat.user = current_user
respond_to do |format|
if @user_reserve_stat.save
UserReserveStatJob.perform_later(@user_reserve_stat)
format.html { redirect_to @user_reserve_stat, notice: t("statistic.successfully_created", model: t("activerecord.models.user_reserve_stat")) }
format.json { render json: @user_reserve_stat, status: :created, location: @user_reserve_stat }
else
format.html { render action: "new" }
format.json { render json: @user_reserve_stat.errors, status: :unprocessable_entity }
end
end
end
# PUT /user_reserve_stats/1
# PUT /user_reserve_stats/1.json
def update
respond_to do |format|
if @user_reserve_stat.update(user_reserve_stat_params)
if @user_reserve_stat.mode == "import"
UserReserveStatJob.perform_later(@user_reserve_stat)
end
format.html { redirect_to @user_reserve_stat, notice: t("controller.successfully_updated", model: t("activerecord.models.user_reserve_stat")) }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @user_reserve_stat.errors, status: :unprocessable_entity }
end
end
end
# DELETE /user_reserve_stats/1
# DELETE /user_reserve_stats/1.json
def destroy
@user_reserve_stat.destroy
respond_to do |format|
format.html { redirect_to user_reserve_stats_url }
format.json { head :no_content }
end
end
private
def set_user_reserve_stat
@user_reserve_stat = UserReserveStat.find(params[:id])
authorize @user_reserve_stat
end
def check_policy
authorize UserReserveStat
end
def user_reserve_stat_params
params.require(:user_reserve_stat).permit(
:start_date, :end_date, :note, :mode
)
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/controllers/user_export_files_controller.rb | app/controllers/user_export_files_controller.rb | class UserExportFilesController < ApplicationController
before_action :set_user_export_file, only: [ :show, :edit, :update, :destroy ]
before_action :check_policy, only: [ :index, :new, :create ]
# GET /user_export_files
# GET /user_export_files.json
def index
@user_export_files = UserExportFile.order("id DESC").page(params[:page])
respond_to do |format|
format.html # index.html.erb
end
end
# GET /user_export_files/1
# GET /user_export_files/1.json
def show
respond_to do |format|
format.html # show.html.erb
end
end
# GET /user_export_files/new
def new
@user_export_file = UserExportFile.new
@user_export_file.user = current_user
end
# GET /user_export_files/1/edit
def edit
end
# POST /user_export_files
# POST /user_export_files.json
def create
@user_export_file = UserExportFile.new(user_export_file_params)
@user_export_file.user = current_user
respond_to do |format|
if @user_export_file.save
if @user_export_file.mode == "export"
UserExportFileJob.perform_later(@user_export_file)
end
format.html { redirect_to @user_export_file, notice: t("export.successfully_created", model: t("activerecord.models.user_export_file")) }
format.json { render json: @user_export_file, status: :created, location: @user_export_file }
else
format.html { render action: "new" }
format.json { render json: @user_export_file.errors, status: :unprocessable_entity }
end
end
end
# PUT /user_export_files/1
# PUT /user_export_files/1.json
def update
respond_to do |format|
if @user_export_file.update(user_export_file_params)
if @user_export_file.mode == "export"
UserExportFileJob.perform_later(@user_export_file)
end
format.html { redirect_to @user_export_file, notice: t("controller.successfully_updated", model: t("activerecord.models.user_export_file")) }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @user_export_file.errors, status: :unprocessable_entity }
end
end
end
# DELETE /user_export_files/1
# DELETE /user_export_files/1.json
def destroy
@user_export_file.destroy
respond_to do |format|
format.html { redirect_to user_export_files_url }
format.json { head :no_content }
end
end
private
def set_user_export_file
@user_export_file = UserExportFile.find(params[:id])
authorize @user_export_file
end
def check_policy
authorize UserExportFile
end
def user_export_file_params
params.require(:user_export_file).permit(:mode)
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/controllers/page_controller.rb | app/controllers/page_controller.rb | class PageController < ApplicationController
before_action :skip_authorization
before_action :clear_search_sessions, only: [ :index, :advanced_search ]
before_action :authenticate_user!, except: [ :index, :advanced_search, :about, :opensearch, :statistics, :routing_error ]
before_action :check_librarian, except: [ :index, :advanced_search, :about, :opensearch, :statistics, :routing_error ]
helper_method :get_libraries
# トップページを表示します。
def index
if user_signed_in?
session[:user_return_to] = nil
# unless current_user.agent
# redirect_to new_user_agent_url(current_user); return
# end
if defined?(EnjuBookmark)
@tags = current_user.bookmarks.tag_counts.sort { |a, b|
a.count <=> b.count
}.reverse
end
if current_user.profile
@manifestation = Manifestation.pickup(
current_user.profile.keyword_list.to_s.split.sort_by { rand }.first,
current_user
)
else
@manifestation = nil
end
else
if defined?(EnjuBookmark)
# TODO: タグ下限の設定
# @tags = Tag.all(limit: 50, order: 'taggings_count DESC')
@tags = Bookmark.tag_counts.sort { |a, b|
a.count <=> b.count
}.reverse[0..49]
end
@manifestation = Manifestation.pickup rescue nil
end
get_top_page_content
@numdocs = Manifestation.search.total
respond_to do |format|
format.html
format.html.phone
end
end
# OpenSearch Descriptionファイルを表示します。
def opensearch
respond_to do |format|
format.xml { render layout: false }
end
end
# 詳細検索画面を表示します。
def advanced_search
get_libraries
@title = t("page.advanced_search")
end
# 統計画面を表示します。
def statistics
@title = t("page.statistics")
end
# システム設定画面を表示します。
def configuration
@title = t("page.configuration")
end
# システム情報画面を表示します。
def system_information
@specs = Bundler.load.specs.sort!
end
# インポート画面を表示します。
def import
@title = t("page.import")
end
# エクスポート画面を表示します。
def export
@title = t("page.export")
end
# 「このシステムについて」を表示します。
def about
@title = t("page.about_this_system")
end
# ルーティングエラー画面を表示します。
def routing_error
render_404
end
private
def check_librarian
return true if current_user.has_role?("Librarian")
access_denied
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/controllers/bookstores_controller.rb | app/controllers/bookstores_controller.rb | class BookstoresController < ApplicationController
before_action :set_bookstore, only: [ :show, :edit, :update, :destroy ]
before_action :check_policy, only: [ :index, :new, :create ]
# GET /bookstores
# GET /bookstores.json
def index
@bookstores = Bookstore.page(params[:page])
respond_to do |format|
format.html # index.html.erb
end
end
# GET /bookstores/1
# GET /bookstores/1.json
def show
respond_to do |format|
format.html # show.html.erb
end
end
# GET /bookstores/new
def new
@bookstore = Bookstore.new
end
# GET /bookstores/1/edit
def edit
end
# POST /bookstores
# POST /bookstores.json
def create
@bookstore = Bookstore.new(bookstore_params)
respond_to do |format|
if @bookstore.save
format.html { redirect_to @bookstore, notice: t("controller.successfully_created", model: t("activerecord.models.bookstore")) }
format.json { render json: @bookstore, status: :created, location: @bookstore }
else
format.html { render action: "new" }
format.json { render json: @bookstore.errors, status: :unprocessable_entity }
end
end
end
# PUT /bookstores/1
# PUT /bookstores/1.json
def update
if params[:move]
move_position(@bookstore, params[:move])
return
end
respond_to do |format|
if @bookstore.update(bookstore_params)
format.html { redirect_to @bookstore, notice: t("controller.successfully_updated", model: t("activerecord.models.bookstore")) }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @bookstore.errors, status: :unprocessable_entity }
end
end
end
# DELETE /bookstores/1
# DELETE /bookstores/1.json
def destroy
@bookstore.destroy
respond_to do |format|
format.html { redirect_to bookstores_url, notice: t("controller.successfully_deleted", model: t("activerecord.models.bookstore")) }
format.json { head :no_content }
end
end
private
def set_bookstore
@bookstore = Bookstore.find(params[:id])
authorize @bookstore
end
def check_policy
authorize Bookstore
end
def bookstore_params
params.require(:bookstore).permit(
:name, :zip_code, :address, :note, :telephone_number,
:fax_number, :url
)
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/controllers/oai_controller.rb | app/controllers/oai_controller.rb | class OaiController < ApplicationController
skip_after_action :verify_authorized
def index
provider = OaiProvider.new
response = provider.process_request(oai_params.to_h)
render body: response, content_type: "text/xml"
end
private
def oai_params
params.permit(:verb, :identifier, :metadataPrefix, :set, :from, :until, :resumptionToken)
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/controllers/checked_items_controller.rb | app/controllers/checked_items_controller.rb | class CheckedItemsController < ApplicationController
before_action :set_checked_item, only: [ :show, :edit, :update, :destroy ]
before_action :check_policy, only: [ :index, :new, :create ]
before_action :get_basket, only: [ :index, :new, :create, :update ]
# GET /checked_items
# GET /checked_items.json
def index
if @basket
@checked_items = @basket.checked_items.order("created_at DESC").page(params[:page])
else
@checked_items = CheckedItem.order("created_at DESC").page(params[:page])
end
@checked_item = CheckedItem.new
respond_to do |format|
format.html # index.html.erb
format.js
end
end
# GET /checked_items/1
# GET /checked_items/1.json
def show
respond_to do |format|
format.html # show.html.erb
end
end
# GET /checked_items/new
def new
unless @basket
redirect_to new_basket_url
return
end
@checked_item = CheckedItem.new
@checked_items = @basket.checked_items
end
# GET /checked_items/1/edit
def edit
end
# POST /checked_items
# POST /checked_items.json
def create
unless @basket
access_denied
return
end
@checked_item = CheckedItem.new(checked_item_params)
@checked_item.basket = @basket
@checked_item.librarian = current_user
flash[:message] = ""
respond_to do |format|
if @checked_item.save
if @checked_item.item.include_supplements
flash[:message] << t("item.this_item_include_supplement")
end
format.html { redirect_to(checked_items_url(basket_id: @basket.id), notice: t("controller.successfully_created", model: t("activerecord.models.checked_item"))) }
format.json { render json: @checked_item, status: :created, location: @checked_item }
format.js { redirect_to(checked_items_url(basket_id: @basket.id, format: :js)) }
else
@checked_items = @basket.checked_items.order("created_at DESC").page(1)
format.html { render action: "index" }
format.json { render json: @checked_item.errors, status: :unprocessable_entity }
format.js { render action: "index" }
end
end
end
# PUT /checked_items/1
# PUT /checked_items/1.json
def update
if @basket
@checked_item = @basket.checked_items.find(params[:id])
else
access_denied
return
end
respond_to do |format|
if @checked_item.update(checked_item_params)
format.html { redirect_to checked_item_url(@checked_item), notice: t("controller.successfully_updated", model: t("activerecord.models.checked_item")) }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @checked_item.errors, status: :unprocessable_entity }
end
end
end
# DELETE /checked_items/1
# DELETE /checked_items/1.json
def destroy
@checked_item.destroy
respond_to do |format|
format.html { redirect_to checked_items_url(basket_id: @checked_item.basket_id) }
format.json { head :no_content }
end
end
private
def set_checked_item
@checked_item = CheckedItem.find(params[:id])
authorize @checked_item
end
def check_policy
authorize CheckedItem
end
def checked_item_params
params.fetch(:checked_item, {}).permit(
:item_identifier, :ignore_restriction, :due_date_string, :lock_version
)
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/controllers/search_engines_controller.rb | app/controllers/search_engines_controller.rb | class SearchEnginesController < ApplicationController
before_action :set_search_engine, only: [ :show, :edit, :update, :destroy ]
before_action :check_policy, only: [ :index, :new, :create ]
# GET /search_engines
# GET /search_engines.json
def index
@search_engines = SearchEngine.order(:position)
respond_to do |format|
format.html # index.html.erb
end
end
# GET /search_engines/1
# GET /search_engines/1.json
def show
respond_to do |format|
format.html # show.html.erb
end
end
# GET /search_engines/new
def new
@search_engine = SearchEngine.new
end
# GET /search_engines/1/edit
def edit
end
# POST /search_engines
# POST /search_engines.json
def create
@search_engine = SearchEngine.new(search_engine_params)
respond_to do |format|
if @search_engine.save
format.html { redirect_to @search_engine, notice: t("controller.successfully_created", model: t("activerecord.models.search_engine")) }
format.json { render json: @search_engine, status: :created, location: @search_engine }
else
format.html { render action: "new" }
format.json { render json: @search_engine.errors, status: :unprocessable_entity }
end
end
end
# PUT /search_engines/1
# PUT /search_engines/1.json
def update
if params[:move]
move_position(@search_engine, params[:move])
return
end
respond_to do |format|
if @search_engine.update(search_engine_params)
format.html { redirect_to @search_engine, notice: t("controller.successfully_updated", model: t("activerecord.models.search_engine")) }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @search_engine.errors, status: :unprocessable_entity }
end
end
end
# DELETE /search_engines/1
# DELETE /search_engines/1.json
def destroy
@search_engine.destroy
respond_to do |format|
format.html { redirect_to search_engines_url, notice: t("controller.successfully_deleted", model: t("activerecord.models.search_engine")) }
format.json { head :no_content }
end
end
private
def set_search_engine
@search_engine = SearchEngine.find(params[:id])
authorize @search_engine
end
def check_policy
authorize SearchEngine
end
def search_engine_params
params.require(:search_engine).permit(
:name, :display_name, :url, :base_url, :http_method,
:query_param, :additional_param, :note
)
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/controllers/subscriptions_controller.rb | app/controllers/subscriptions_controller.rb | class SubscriptionsController < ApplicationController
before_action :set_subscription, only: [ :show, :edit, :update, :destroy ]
before_action :check_policy, only: [ :index, :new, :create ]
before_action :get_work
# GET /subscriptions
# GET /subscriptions.json
def index
if @work
@subscriptions = @work.subscriptions.page(params[:page])
else
@subscriptions = Subscription.page(params[:page])
end
respond_to do |format|
format.html # index.html.erb
end
end
# GET /subscriptions/1
# GET /subscriptions/1.json
def show
respond_to do |format|
format.html # show.html.erb
end
end
# GET /subscriptions/new
def new
@subscription = Subscription.new
end
# GET /subscriptions/1/edit
def edit
end
# POST /subscriptions
# POST /subscriptions.json
def create
@subscription = Subscription.new(subscription_params)
@subscription.user = current_user
respond_to do |format|
if @subscription.save
format.html { redirect_to @subscription, notice: t("controller.successfully_created", model: t("activerecord.models.subscription")) }
format.json { render json: @subscription, status: :created, location: @subscription }
else
format.html { render action: "new" }
format.json { render json: @subscription.errors, status: :unprocessable_entity }
end
end
end
# PUT /subscriptions/1
# PUT /subscriptions/1.json
def update
@subscription.assign_attributes(subscription_params)
respond_to do |format|
if @subscription.save
format.html { redirect_to @subscription, notice: t("controller.successfully_updated", model: t("activerecord.models.subscription")) }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @subscription.errors, status: :unprocessable_entity }
end
end
end
# DELETE /subscriptions/1
# DELETE /subscriptions/1.json
def destroy
@subscription.destroy
respond_to do |format|
format.html { redirect_to subscriptions_url }
format.json { head :no_content }
end
end
private
def set_subscription
@subscription = Subscription.find(params[:id])
authorize @subscription
end
def check_policy
authorize Subscription
end
def subscription_params
params.require(:subscription).permit(
:title, :note, :order_list_id, :user_id
)
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/controllers/classification_types_controller.rb | app/controllers/classification_types_controller.rb | class ClassificationTypesController < ApplicationController
before_action :set_classification_type, only: [ :show, :edit, :update, :destroy ]
before_action :check_policy, only: [ :index, :new, :create ]
# GET /classification_types
# GET /classification_types.json
def index
@classification_types = ClassificationType.order(:position)
respond_to do |format|
format.html # index.html.erb
end
end
# GET /classification_types/1
# GET /classification_types/1.json
def show
respond_to do |format|
format.html # show.html.erb
end
end
# GET /classification_types/new
def new
@classification_type = ClassificationType.new
end
# GET /classification_types/1/edit
def edit
end
# POST /classification_types
# POST /classification_types.json
def create
@classification_type = ClassificationType.new(classification_type_params)
respond_to do |format|
if @classification_type.save
format.html { redirect_to @classification_type, notice: t("controller.successfully_created", model: t("activerecord.models.classification_type")) }
format.json { render json: @classification_type, status: :created, location: @classification_type }
else
format.html { render action: "new" }
format.json { render json: @classification_type.errors, status: :unprocessable_entity }
end
end
end
# PUT /classification_types/1
# PUT /classification_types/1.json
def update
if params[:move]
move_position(@classification_type, params[:move])
return
end
respond_to do |format|
if @classification_type.update(classification_type_params)
format.html { redirect_to @classification_type, notice: t("controller.successfully_updated", model: t("activerecord.models.classification_type")) }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @classification_type.errors, status: :unprocessable_entity }
end
end
end
# DELETE /classification_types/1
# DELETE /classification_types/1.json
def destroy
@classification_type.destroy
respond_to do |format|
format.html { redirect_to classification_types_url, notice: t("controller.successfully_deleted", model: t("activerecord.models.classification_type")) }
format.json { head :no_content }
end
end
private
def set_classification_type
@classification_type = ClassificationType.find(params[:id])
authorize @classification_type
end
def check_policy
authorize ClassificationType
end
def classification_type_params
params.require(:classification_type).permit(:name, :display_name, :note)
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/controllers/profiles_controller.rb | app/controllers/profiles_controller.rb | class ProfilesController < ApplicationController
before_action :authenticate_user!
before_action :set_profile, only: [ :show, :edit, :update, :destroy ]
before_action :check_policy, only: [ :index, :new, :create ]
before_action :prepare_options, only: [ :new, :edit ]
# GET /profiles
# GET /profiles.json
def index
if params[:username].present?
profile = User.find_by(username: params[:username]).try(:profile)
if profile
redirect_to profile_url(profile)
return
end
end
query = flash[:query] = params[:query].to_s
@query = query.dup
@count = {}
sort = { sort_by: "created_at", order: "desc" }
case params[:sort_by]
when "username"
sort[:sort_by] = "username"
end
case params[:order]
when "asc"
sort[:order] = "asc"
when "desc"
sort[:order] = "desc"
end
query = params[:query]
page = params[:page] || 1
role = current_user.try(:role) || Role.default
search = Profile.search
search.build do
fulltext query if query
with(:required_role_id).less_than_or_equal_to role.id
order_by sort[:sort_by], sort[:order]
end
search.query.paginate(page.to_i, Profile.default_per_page)
@profiles = search.execute!.results
@count[:query_result] = @profiles.total_entries
respond_to do |format|
format.html # index.html.erb
end
end
# GET /profiles/1
# GET /profiles/1.json
def show
if @profile.user == current_user
redirect_to my_account_url
return
end
respond_to do |format|
format.html # show.html.erb
format.html.phone
end
end
# GET /profiles/new
def new
@profile = Profile.new
@profile.user = User.new
@profile.user_group = current_user.profile.user_group
@profile.library = current_user.profile.library
@profile.locale = current_user.profile.locale
end
# GET /profiles/1/edit
def edit
if defined?(EnjuCirculation)
if params[:mode] == "feed_token"
if params[:disable] == "true"
@profile.delete_checkout_icalendar_token
else
@profile.reset_checkout_icalendar_token
end
render partial: "feed_token", locals: { profile: @profile }
return
end
end
if @profile.user == current_user
redirect_to edit_my_account_url
return
end
if @profile.user.try(:locked_at?)
@profile.user.locked = true
end
end
# POST /profiles
# POST /profiles.json
def create
@profile = Profile.new(profile_params)
if current_user.has_role?("Librarian") && @profile.user
password = @profile.user.set_auto_generated_password
end
respond_to do |format|
if @profile.save
if @profile.user
@profile.user.role = Role.find_by(name: "User")
flash[:temporary_password] = password
end
format.html { redirect_to @profile, notice: t("controller.successfully_created", model: t("activerecord.models.profile")) }
format.json { render json: @profile, status: :created, location: @profile }
else
prepare_options
format.html { render action: "new" }
format.json { render json: @profile.errors, status: :unprocessable_entity }
end
end
end
# PUT /profiles/1
# PUT /profiles/1.json
def update
@profile.update(profile_update_params)
if @profile.user
if @profile.user.auto_generated_password == "1"
password = @profile.user.set_auto_generated_password
end
end
respond_to do |format|
if @profile.save
@profile.user.save! if @profile.user
flash[:temporary_password] = password
format.html { redirect_to @profile, notice: t("controller.successfully_updated", model: t("activerecord.models.profile")) }
format.json { head :no_content }
else
prepare_options
format.html { render action: "edit" }
format.json { render json: @profile.errors, status: :unprocessable_entity }
end
end
end
# DELETE /profiles/1
# DELETE /profiles/1.json
def destroy
@profile.destroy
respond_to do |format|
format.html { redirect_to profiles_url, notice: t("controller.successfully_deleted", model: t("activerecord.models.profile")) }
format.json { head :no_content }
end
end
def impersonate
skip_authorization
user = Profile.find(params[:id]).user
impersonate_user(user)
redirect_to root_path
end
def stop_impersonating
skip_authorization
stop_impersonating_user
redirect_to root_path
end
private
def set_profile
@profile = Profile.find(params[:id])
authorize @profile
end
def check_policy
authorize Profile
end
def profile_params
attrs = [
:full_name, :full_name_transcription,
:keyword_list, :locale,
:save_checkout_history, :checkout_icalendar_token, # EnjuCirculation
:save_search_history, # EnjuSearchLog
]
attrs += [
:library_id, :expired_at, :birth_date,
:user_group_id, :required_role_id, :note, :user_number, {
user_attributes: [
:id, :username, :email, :current_password, :locked,
{ user_has_role_attributes: [ :id, :role_id ] }
]
}
] if current_user.has_role?("Librarian")
params.require(:profile).permit(*attrs)
end
def profile_update_params
attrs = [
:full_name, :full_name_transcription,
:keyword_list, :locale,
:save_checkout_history, :checkout_icalendar_token, # EnjuCirculation
:save_search_history, # EnjuSearchLog
]
attrs += [
:library_id, :expired_at, :birth_date,
:user_group_id, :required_role_id, :note, :user_number,
:save_bookmarks, # EnjuBookmark
{
user_attributes: [
:id, :email, :current_password, :auto_generated_password, :locked,
{ user_has_role_attributes: [ :id, :role_id ] }
]
}
] if current_user.has_role?("Librarian")
params.require(:profile).permit(*attrs)
end
def prepare_options
@user_groups = UserGroup.all
@roles = Role.all
@libraries = Library.all
@languages = Language.all
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/controllers/mission_control_controller.rb | app/controllers/mission_control_controller.rb | class MissionControlController < ActionController::Base
before_action :authenticate_admin!
private
def authenticate_admin!
authenticate_user!
current_user.role.name == "Administrator"
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/controllers/user_checkout_stats_controller.rb | app/controllers/user_checkout_stats_controller.rb | class UserCheckoutStatsController < ApplicationController
before_action :set_user_checkout_stat, only: [ :show, :edit, :update, :destroy ]
before_action :check_policy, only: [ :index, :new, :create ]
after_action :convert_charset, only: :show
# GET /user_checkout_stats
# GET /user_checkout_stats.json
def index
@user_checkout_stats = UserCheckoutStat.order("id DESC").page(params[:page])
respond_to do |format|
format.html # index.html.erb
end
end
# GET /user_checkout_stats/1
# GET /user_checkout_stats/1.json
def show
if request.format.text?
per_page = 65534
else
per_page = CheckoutStatHasUser.default_per_page
end
@stats = @user_checkout_stat.checkout_stat_has_users.order("checkouts_count DESC, user_id").page(params[:page]).per(per_page)
respond_to do |format|
format.html # show.html.erb
format.text
end
end
# GET /user_checkout_stats/new
def new
@user_checkout_stat = UserCheckoutStat.new
end
# GET /user_checkout_stats/1/edit
def edit
end
# POST /user_checkout_stats
# POST /user_checkout_stats.json
def create
@user_checkout_stat = UserCheckoutStat.new(user_checkout_stat_params)
@user_checkout_stat.user = current_user
respond_to do |format|
if @user_checkout_stat.save
UserCheckoutStatJob.perform_later(@user_checkout_stat)
format.html { redirect_to @user_checkout_stat, notice: t("statistic.successfully_created", model: t("activerecord.models.user_checkout_stat")) }
format.json { render json: @user_checkout_stat, status: :created, location: @user_checkout_stat }
else
format.html { render action: "new" }
format.json { render json: @user_checkout_stat.errors, status: :unprocessable_entity }
end
end
end
# PUT /user_checkout_stats/1
# PUT /user_checkout_stats/1.json
def update
respond_to do |format|
if @user_checkout_stat.update(user_checkout_stat_params)
if @user_checkout_stat.mode == "import"
UserCheckoutStatJob.perform_later(@user_checkout_stat)
end
format.html { redirect_to @user_checkout_stat, notice: t("controller.successfully_updated", model: t("activerecord.models.user_checkout_stat")) }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @user_checkout_stat.errors, status: :unprocessable_entity }
end
end
end
# DELETE /user_checkout_stats/1
# DELETE /user_checkout_stats/1.json
def destroy
@user_checkout_stat.destroy
respond_to do |format|
format.html { redirect_to user_checkout_stats_url }
format.json { head :no_content }
end
end
private
def set_user_checkout_stat
@user_checkout_stat = UserCheckoutStat.find(params[:id])
authorize @user_checkout_stat
end
def check_policy
authorize UserCheckoutStat
end
def user_checkout_stat_params
params.require(:user_checkout_stat).permit(
:start_date, :end_date, :note, :mode
)
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/controllers/identifier_types_controller.rb | app/controllers/identifier_types_controller.rb | class IdentifierTypesController < ApplicationController
before_action :set_identifier_type, only: [ :show, :edit, :update, :destroy ]
before_action :check_policy, only: [ :index, :new, :create ]
# GET /identifier_types
# GET /identifier_types.json
def index
@identifier_types = IdentifierType.order(:position)
respond_to do |format|
format.html # index.html.erb
end
end
# GET /identifier_types/1
# GET /identifier_types/1.json
def show
respond_to do |format|
format.html # show.html.erb
end
end
# GET /identifier_types/new
def new
@identifier_type = IdentifierType.new
end
# GET /identifier_types/1/edit
def edit
end
# POST /identifier_types
# POST /identifier_types.json
def create
@identifier_type = IdentifierType.new(identifier_type_params)
respond_to do |format|
if @identifier_type.save
format.html { redirect_to @identifier_type, notice: t("controller.successfully_created", model: t("activerecord.models.identifier_type")) }
format.json { render json: @identifier_type, status: :created, location: @identifier_type }
else
format.html { render action: "new" }
format.json { render json: @identifier_type.errors, status: :unprocessable_entity }
end
end
end
# PUT /identifier_types/1
# PUT /identifier_types/1.json
def update
if params[:move]
move_position(@identifier_type, params[:move])
return
end
respond_to do |format|
if @identifier_type.update(identifier_type_params)
format.html { redirect_to @identifier_type, notice: t("controller.successfully_updated", model: t("activerecord.models.identifier_type")) }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @identifier_type.errors, status: :unprocessable_entity }
end
end
end
# DELETE /identifier_types/1
# DELETE /identifier_types/1.json
def destroy
@identifier_type.destroy
respond_to do |format|
format.html { redirect_to identifier_types_url, notice: t("controller.successfully_deleted", model: t("activerecord.models.identifier_type")) }
format.json { head :no_content }
end
end
private
def set_identifier_type
@identifier_type = IdentifierType.find(params[:id])
authorize @identifier_type
end
def check_policy
authorize IdentifierType
end
def identifier_type_params
params.require(:identifier_type).permit(
:display_name, :name, :note, :position
)
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/controllers/agent_import_files_controller.rb | app/controllers/agent_import_files_controller.rb | class AgentImportFilesController < ApplicationController
before_action :set_agent_import_file, only: [ :show, :edit, :update, :destroy ]
before_action :check_policy, only: [ :index, :new, :create ]
# GET /agent_import_files
# GET /agent_import_files.json
def index
@agent_import_files = AgentImportFile.page(params[:page])
respond_to do |format|
format.html # index.html.erb
end
end
# GET /agent_import_files/1
# GET /agent_import_files/1.json
def show
respond_to do |format|
format.html # show.html.erb
end
end
# GET /agent_import_files/new
def new
@agent_import_file = AgentImportFile.new
end
# GET /agent_import_files/1/edit
def edit
end
# POST /agent_import_files
# POST /agent_import_files.json
def create
@agent_import_file = AgentImportFile.new(agent_import_file_params)
@agent_import_file.user = current_user
respond_to do |format|
if @agent_import_file.save
if @agent_import_file.mode == "import"
AgentImportFileJob.perform_later(@agent_import_file)
end
format.html { redirect_to @agent_import_file, notice: t("controller.successfully_created", model: t("activerecord.models.agent_import_file")) }
format.json { render json: @agent_import_file, status: :created, location: @agent_import_file }
else
format.html { render action: "new" }
format.json { render json: @agent_import_file.errors, status: :unprocessable_entity }
end
end
end
# PUT /agent_import_files/1
# PUT /agent_import_files/1.json
def update
respond_to do |format|
if @agent_import_file.update(agent_import_file_params)
if @agent_import_file.mode == "import"
AgentImportFileJob.perform_later(@agent_import_file)
end
format.html { redirect_to @agent_import_file, notice: t("controller.successfully_updated", model: t("activerecord.models.agent_import_file")) }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @agent_import_file.errors, status: :unprocessable_entity }
end
end
end
# DELETE /agent_import_files/1
# DELETE /agent_import_files/1.json
def destroy
@agent_import_file.destroy
respond_to do |format|
format.html { redirect_to agent_import_files_url, notice: t("controller.successfully_deleted", model: t("activerecord.models.agent_import_file")) }
format.json { head :no_content }
end
end
private
def set_agent_import_file
@agent_import_file = AgentImportFile.find(params[:id])
authorize @agent_import_file
end
def check_policy
authorize AgentImportFile
end
def agent_import_file_params
params.require(:agent_import_file).permit(
:attachment, :edit_mode, :user_encoding, :mode
)
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/controllers/agent_merges_controller.rb | app/controllers/agent_merges_controller.rb | class AgentMergesController < ApplicationController
before_action :set_agent_merge, only: [ :show, :edit, :update, :destroy ]
before_action :check_policy, only: [ :index, :new, :create ]
before_action :get_agent, :get_agent_merge_list
# GET /agent_merges
# GET /agent_merges.json
def index
if @agent
@agent_merges = @agent.agent_merges.order("agent_merges.id").page(params[:page])
elsif @agent_merge_list
@agent_merges = @agent_merge_list.agent_merges.order("agent_merges.id").includes(:agent).page(params[:page])
else
@agent_merges = AgentMerge.page(params[:page])
end
respond_to do |format|
format.html # index.html.erb
end
end
# GET /agent_merges/1
# GET /agent_merges/1.json
def show
respond_to do |format|
format.html # show.html.erb
end
end
# GET /agent_merges/new
# GET /agent_merges/new.json
def new
@agent_merge = AgentMerge.new
@agent_merge.agent = @agent
end
# GET /agent_merges/1/edit
def edit
end
# POST /agent_merges
# POST /agent_merges.json
def create
@agent_merge = AgentMerge.new(agent_merge_params)
respond_to do |format|
if @agent_merge.save
format.html { redirect_to(@agent_merge, notice: t("controller.successfully_created", model: t("activerecord.models.agent_merge"))) }
format.json { render json: @agent_merge, status: :created, location: @agent_merge }
else
format.html { render action: "new" }
format.json { render json: @agent_merge.errors, status: :unprocessable_entity }
end
end
end
# PUT /agent_merges/1
# PUT /agent_merges/1.json
def update
respond_to do |format|
if @agent_merge.update(agent_merge_params)
format.html { redirect_to(@agent_merge, notice: t("controller.successfully_updated", model: t("activerecord.models.agent_merge"))) }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @agent_merge.errors, status: :unprocessable_entity }
end
end
end
# DELETE /agent_merges/1
# DELETE /agent_merges/1.json
def destroy
@agent_merge.destroy
respond_to do |format|
format.html { redirect_to(agent_merges_url) }
format.json { head :no_content }
end
end
private
def set_agent_merge
@agent_merge = AgentMerge.find(params[:id])
authorize @agent_merge
end
def check_policy
authorize AgentMerge
end
def agent_merge_params
params.require(:agent_merge).permit(:agent_id, :agent_merge_list_id)
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/controllers/bookmark_stats_controller.rb | app/controllers/bookmark_stats_controller.rb | class BookmarkStatsController < ApplicationController
before_action :set_bookmark_stat, only: [ :show, :edit, :update, :destroy ]
before_action :check_policy, only: [ :index, :new, :create ]
after_action :convert_charset, only: :show
# GET /bookmark_stats
# GET /bookmark_stats.json
def index
@bookmark_stats = BookmarkStat.page(params[:page])
respond_to do |format|
format.html # index.html.erb
end
end
# GET /bookmark_stats/1
# GET /bookmark_stats/1.json
def show
if request.format.text?
per_page = 65534
else
per_page = BookmarkStatHasManifestation.default_per_page
end
@stats = @bookmark_stat.bookmark_stat_has_manifestations.order("bookmarks_count DESC, manifestation_id").page(params[:page]).per(per_page)
respond_to do |format|
format.html # show.html.erb
format.text
end
end
# GET /bookmark_stats/new
def new
@bookmark_stat = BookmarkStat.new
end
# GET /bookmark_stats/1/edit
def edit
end
# POST /bookmark_stats
# POST /bookmark_stats.json
def create
@bookmark_stat = BookmarkStat.new(bookmark_stat_params)
respond_to do |format|
if @bookmark_stat.save
format.html { redirect_to @bookmark_stat, notice: t("controller.successfully_created", model: t("activerecord.models.bookmark_stat")) }
format.json { render json: @bookmark_stat, status: :created, location: @bookmark_stat }
else
format.html { render action: "new" }
format.json { render json: @bookmark_stat.errors, status: :unprocessable_entity }
end
end
end
# PUT /bookmark_stats/1
# PUT /bookmark_stats/1.json
def update
respond_to do |format|
if @bookmark_stat.update(bookmark_stat_params)
format.html { redirect_to @bookmark_stat, notice: t("controller.successfully_updated", model: t("activerecord.models.bookmark_stat")) }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @bookmark_stat.errors, status: :unprocessable_entity }
end
end
end
# DELETE /bookmark_stats/1
# DELETE /bookmark_stats/1.json
def destroy
@bookmark_stat.destroy
respond_to do |format|
format.html { redirect_to bookmark_stats_url }
format.json { head :no_content }
end
end
private
def set_bookmark_stat
@bookmark_stat = BookmarkStat.find(params[:id])
authorize @bookmark_stat
end
def check_policy
authorize BookmarkStat
end
def bookmark_stat_params
params.require(:bookmark_stat).permit(:start_date, :end_date, :note)
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/controllers/loc_search_controller.rb | app/controllers/loc_search_controller.rb | class LocSearchController < ApplicationController
before_action :check_policy, only: [ :index, :create ]
def index
if params[:page].to_i <= 0
page = 1
else
page = params[:page].to_i
end
@query = params[:query].to_s.strip
books = LocSearch.search(@query, { page: page })
@books = Kaminari.paginate_array(
books[:items],
total_count: books[:total_entries]
).page(page).per(10)
respond_to do |format|
format.html
end
end
def create
begin
@manifestation = LocSearch.import_from_sru_response(params[:book].try(:[], "lccn"))
rescue EnjuLoc::RecordNotFound
end
respond_to do |format|
if @manifestation.try(:save)
flash[:notice] = t("controller.successfully_created", model: t("activerecord.models.manifestation"))
format.html { redirect_to manifestation_url(@manifestation) }
else
if @manifestation and not @manifestation.valid?
flash[:notice] = @manifestation.errors.messages
else
flash[:notice] = t("enju_loc.record_not_found")
end
format.html { redirect_to loc_search_index_url }
end
end
end
private
def check_policy
authorize LocSearch
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/controllers/reserves_controller.rb | app/controllers/reserves_controller.rb | class ReservesController < ApplicationController
before_action :set_reserve, only: [ :show, :edit, :update, :destroy ]
before_action :check_policy, only: [ :index, :new, :create ]
before_action :prepare_options, only: [ :new, :edit ]
before_action :get_user, only: [ :index, :new ]
before_action :store_page
after_action :convert_charset, only: :index
helper_method :get_manifestation
helper_method :get_item
# GET /reserves
# GET /reserves.json
def index
unless current_user.has_role?("Librarian")
if @user
if current_user == @user
redirect_to reserves_url(format: params[:format])
return
else
access_denied
return
end
end
end
search = Reserve.search
query = @query = params[:query].to_s.strip
sort_by = params[:sort_by].to_s.downcase
if sort_by == "title"
@sort_by = :title
sort_column = :title_transcription
order = :asc
else
@sort_by = :created_at
sort_column = :created_at
order = :desc
end
if [ "text", "rss" ].include?(params[:format].to_s.downcase)
per_page = 500
page = 1
else
per_page = Reserve.default_per_page
page = params[:page] || 1
end
if (params[:mode] == "hold") && current_user.has_role?("Librarian")
search.build do
with(:hold).equal_to true
end
elsif @user
user = @user
if current_user.has_role?("Librarian")
search.build do
with(:username).equal_to user.username
end
else
access_denied
return
end
else
unless current_user.has_role?("Librarian")
search.build do
with(:username).equal_to current_user.username
end
end
end
begin
reserved_from = Time.zone.parse(params[:reserved_from])
@reserved_from = params[:reserved_from].to_s.strip
rescue StandardError
reserved_from = nil
end
begin
reserved_until = Time.zone.parse(params[:reserved_until])
@reserved_until = params[:reserved_until].to_s.strip
rescue StandardError
reserved_until = nil
end
if params[:state].present?
state = params[:state].downcase
end
search.build do
fulltext query
if reserved_from
with(:created_at).greater_than_or_equal_to reserved_from.beginning_of_day
end
if reserved_until
with(:created_at).less_than reserved_until.tomorrow.beginning_of_day
end
order_by sort_column, order
with(:state).equal_to state if state
facet :state
paginate page: page.to_i, per_page: per_page
end
@reserves = search.execute.results
@state_facet = search.facet(:state).rows
respond_to do |format|
format.html # index.html.erb
format.rss
format.atom
format.text
end
end
# GET /reserves/1
# GET /reserves/1.json
def show
respond_to do |format|
format.html # show.html.erb
end
end
# GET /reserves/new
def new
@reserve = Reserve.new
if current_user.has_role?("Librarian") && @user
@reserve.assign_attributes(
user: @user,
pickup_location: @user.profile.library
)
else
if @user.present?
if @user != current_user
access_denied
return
end
end
@reserve.assign_attributes(
user_number: current_user.profile.user_number,
pickup_location: current_user.profile.library
)
end
@manifestation = Manifestation.find_by(id: params[:manifestation_id])
if @manifestation
authorize @manifestation, :show?
@reserve.manifestation = @manifestation
if @reserve.user
# @reserve.expired_at = @manifestation.reservation_expired_period(@reserve.user).days.from_now.end_of_day
if @manifestation.is_reserved_by?(@reserve.user)
flash[:notice] = t("reserve.this_manifestation_is_already_reserved")
redirect_to @manifestation
nil
end
end
end
end
# GET /reserves/1/edit
def edit
@reserve.item_identifier = @reserve.item.try(:item_identifier)
end
# POST /reserves
# POST /reserves.json
def create
@reserve = Reserve.new(reserve_params)
@reserve.set_user
if current_user.has_role?("Librarian")
unless @reserve.user
@reserve.user = @user
end
elsif @reserve.user != current_user
if @user != current_user
access_denied
return
end
end
respond_to do |format|
if @reserve.save
format.html { redirect_to @reserve, notice: t("controller.successfully_created", model: t("activerecord.models.reserve")) }
format.json { render json: @reserve, status: :created, location: reserve_url(@reserve) }
else
prepare_options
format.html { render action: "new" }
format.json { render json: @reserve.errors, status: :unprocessable_entity }
end
end
end
# PUT /reserves/1
# PUT /reserves/1.json
def update
unless current_user.has_role?("Librarian")
if @reserve.user != current_user
access_denied
return
end
end
@reserve.assign_attributes(reserve_update_params)
if @reserve.valid?
if params[:mode] == "cancel"
@reserve.transition_to!(:canceled)
else
if @reserve.retained?
if @reserve.item_identifier.present? && (@reserve.force_retaining == "1")
@reserve.transition_to!(:retained)
end
else
@reserve.transition_to!(:retained) if @reserve.item_identifier.present?
end
end
end
respond_to do |format|
if @reserve.save
if @reserve.current_state == "canceled"
flash[:notice] = t("reserve.reservation_was_canceled")
else
flash[:notice] = t("controller.successfully_updated", model: t("activerecord.models.reserve"))
end
format.html { redirect_to @reserve }
format.json { head :no_content }
else
prepare_options
format.html { render action: "edit" }
format.json { render json: @reserve.errors, status: :unprocessable_entity }
end
end
end
# DELETE /reserves/1
# DELETE /reserves/1.json
def destroy
@reserve.destroy
# flash[:notice] = t('reserve.reservation_was_canceled')
if @reserve.manifestation.is_reserved?
if @reserve.item
retain = @reserve.item.retain(User.find(1)) # TODO: システムからの送信ユーザの設定
if retain.nil?
flash[:message] = t("reserve.this_item_is_not_reserved")
end
end
end
respond_to do |format|
format.html { redirect_to reserves_url, notice: t("controller.successfully_deleted", model: t("activerecord.models.reserve")) }
format.json { head :no_content }
end
end
private
def set_reserve
@reserve = Reserve.find(params[:id])
authorize @reserve
end
def check_policy
authorize Reserve
end
def reserve_params
if current_user.try(:has_role?, "Librarian")
params.fetch(:reserve, {}).permit(
:manifestation_id, :user_number,
:pickup_location_id, :expired_at,
:manifestation_id, :item_identifier, :user_number,
:request_status_type, :canceled_at, :checked_out_at,
:expiration_notice_to_patron, :expiration_notice_to_library, :item_id,
:retained_at, :postponed_at, :force_retaining
)
elsif current_user.try(:has_role?, "User")
params.fetch(:reserve, {}).permit(
:user_number, :manifestation_id, :expired_at, :pickup_location_id
)
end
end
def reserve_update_params
if current_user.try(:has_role?, "Librarian")
params.fetch(:reserve, {}).permit(
:manifestation_id, :user_number,
:pickup_location_id, :expired_at,
:manifestation_id, :item_identifier, :user_number,
:request_status_type, :canceled_at, :checked_out_at,
:expiration_notice_to_patron, :expiration_notice_to_library, :item_id,
:retained_at, :postponed_at, :force_retaining
)
elsif current_user.try(:has_role?, "User")
params.fetch(:reserve, {}).permit(
:expired_at, :pickup_location_id
)
end
end
def prepare_options
@libraries = Library.real.order(:position)
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/controllers/donates_controller.rb | app/controllers/donates_controller.rb | class DonatesController < ApplicationController
before_action :set_donate, only: [ :show, :edit, :update, :destroy ]
before_action :check_policy, only: [ :index, :new, :create ]
# GET /donates
# GET /donates.json
def index
@donates = Donate.order("id DESC").page(params[:page])
respond_to do |format|
format.html # index.html.erb
end
end
# GET /donates/1
# GET /donates/1.json
def show
respond_to do |format|
format.html # show.html.erb
end
end
# GET /donates/new
def new
@donate = Donate.new
end
# GET /donates/1/edit
def edit
end
# POST /donates
# POST /donates.json
def create
@donate = Donate.new(donate_params)
respond_to do |format|
if @donate.save
format.html { redirect_to @donate, notice: t("controller.successfully_created", model: t("activerecord.models.donate")) }
format.json { render json: @donate, status: :created, location: @donate }
else
format.html { render action: "new" }
format.json { render json: @donate.errors, status: :unprocessable_entity }
end
end
end
# PUT /donates/1
# PUT /donates/1.json
def update
respond_to do |format|
if @donate.update(donate_params)
format.html { redirect_to @donate, notice: t("controller.successfully_updated", model: t("activerecord.models.donate")) }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @donate.errors, status: :unprocessable_entity }
end
end
end
# DELETE /donates/1
# DELETE /donates/1.json
def destroy
@donate.destroy
respond_to do |format|
format.html { redirect_to(donates_url) }
format.json { head :no_content }
end
end
private
def set_donate
@donate = Donate.find(params[:id])
authorize @donate
end
def check_policy
authorize Donate
end
def donate_params
params.require(:donate).permit(:agent_id, :item_id)
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/controllers/manifestation_relationships_controller.rb | app/controllers/manifestation_relationships_controller.rb | class ManifestationRelationshipsController < ApplicationController
before_action :set_manifestation_relationship, only: [ :show, :edit, :update, :destroy ]
before_action :check_policy, only: [ :index, :new, :create ]
before_action :get_manifestation
before_action :prepare_options, only: [ :new, :edit ]
# GET /manifestation_relationships
# GET /manifestation_relationships.json
def index
case
when @manifestation
@manifestation_relationships = @manifestation.manifestation_relationships.order("manifestation_relationships.position").page(params[:page])
else
@manifestation_relationships = ManifestationRelationship.page(params[:page])
end
respond_to do |format|
format.html # index.html.erb
end
end
# GET /manifestation_relationships/1
# GET /manifestation_relationships/1.json
def show
respond_to do |format|
format.html # show.html.erb
end
end
# GET /manifestation_relationships/new
def new
if @manifestation.blank?
redirect_to manifestations_url
nil
else
@manifestation_relationship = ManifestationRelationship.new(
parent: @manifestation,
child: Manifestation.find(params[:child_id])
)
end
end
# GET /manifestation_relationships/1/edit
def edit
end
# POST /manifestation_relationships
# POST /manifestation_relationships.json
def create
@manifestation_relationship = ManifestationRelationship.new(manifestation_relationship_params)
respond_to do |format|
if @manifestation_relationship.save
format.html { redirect_to @manifestation_relationship, notice: t("controller.successfully_created", model: t("activerecord.models.manifestation_relationship")) }
format.json { render json: @manifestation_relationship, status: :created, location: @manifestation_relationship }
else
prepare_options
format.html { render action: "new" }
format.json { render json: @manifestation_relationship.errors, status: :unprocessable_entity }
end
end
end
# PUT /manifestation_relationships/1
# PUT /manifestation_relationships/1.json
def update
# 並べ替え
if @manifestation && params[:move]
move_position(@manifestation_relationship, params[:move], false)
redirect_to manifestation_relationships_url(manifestation_id: @manifestation_relationship.parent_id)
return
end
respond_to do |format|
if @manifestation_relationship.update(manifestation_relationship_params)
format.html { redirect_to @manifestation_relationship, notice: t("controller.successfully_updated", model: t("activerecord.models.manifestation_relationship")) }
format.json { head :no_content }
else
prepare_options
format.html { render action: "edit" }
format.json { render json: @manifestation_relationship.errors, status: :unprocessable_entity }
end
end
end
# DELETE /manifestation_relationships/1
# DELETE /manifestation_relationships/1.json
def destroy
@manifestation_relationship.destroy
respond_to do |format|
format.html {
flash[:notice] = t("controller.successfully_deleted", model: t("activerecord.models.manifestation_relationship"))
if @manifestation
redirect_to manifestations_url(manifestation_id: @manifestation.id)
else
redirect_to manifestation_relationships_url
end
}
format.json { head :no_content }
end
end
private
def set_manifestation_relationship
@manifestation_relationship = ManifestationRelationship.find(params[:id])
authorize @manifestation_relationship
end
def check_policy
authorize ManifestationRelationship
end
def manifestation_relationship_params
params.require(:manifestation_relationship).permit(
:parent_id, :child_id, :manifestation_relationship_type_id
)
end
def prepare_options
@manifestation_relationship_types = ManifestationRelationshipType.all
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/controllers/event_categories_controller.rb | app/controllers/event_categories_controller.rb | class EventCategoriesController < ApplicationController
before_action :set_event_category, only: [ :show, :edit, :update, :destroy ]
before_action :check_policy, only: [ :index, :new, :create ]
# GET /event_categories
# GET /event_categories.json
def index
@event_categories = EventCategory.order(:position)
respond_to do |format|
format.html # index.html.erb
end
end
# GET /event_categories/1
# GET /event_categories/1.json
def show
respond_to do |format|
format.html # show.html.erb
end
end
# GET /event_categories/new
def new
@event_category = EventCategory.new
end
# GET /event_categories/1/edit
def edit
end
# POST /event_categories
# POST /event_categories.json
def create
@event_category = EventCategory.new(event_category_params)
respond_to do |format|
if @event_category.save
format.html { redirect_to @event_category, notice: t("controller.successfully_created", model: t("activerecord.models.event_category")) }
format.json { render json: @event_category, status: :created, location: @event_category }
else
format.html { render action: "new" }
format.json { render json: @event_category.errors, status: :unprocessable_entity }
end
end
end
# PUT /event_categories/1
# PUT /event_categories/1.json
def update
if params[:move]
move_position(@event_category, params[:move])
return
end
respond_to do |format|
if @event_category.update(event_category_params)
format.html { redirect_to @event_category, notice: t("controller.successfully_updated", model: t("activerecord.models.event_category")) }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @event_category.errors, status: :unprocessable_entity }
end
end
end
# DELETE /event_categories/1
# DELETE /event_categories/1.json
def destroy
@event_category.destroy
respond_to do |format|
format.html { redirect_to event_categories_url, notice: t("controller.successfully_deleted", model: t("activerecord.models.event_category")) }
format.json { head :no_content }
end
end
private
def set_event_category
@event_category = EventCategory.find(params[:id])
authorize @event_category
end
def check_policy
authorize EventCategory
end
def event_category_params
params.require(:event_category).permit(:name, :display_name, :note)
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/controllers/nii_types_controller.rb | app/controllers/nii_types_controller.rb | class NiiTypesController < ApplicationController
before_action :set_nii_type, only: [ :show, :edit, :update, :destroy ]
before_action :check_policy, only: [ :index, :new, :create ]
# GET /nii_types
# GET /nii_types.json
def index
@nii_types = NiiType.order(:position)
respond_to do |format|
format.html # index.html.erb
end
end
# GET /nii_types/1
# GET /nii_types/1.json
def show
respond_to do |format|
format.html # show.html.erb
end
end
# GET /nii_types/new
def new
@nii_type = NiiType.new
end
# GET /nii_types/1/edit
def edit
end
# POST /nii_types
# POST /nii_types.json
def create
@nii_type = NiiType.new(nii_type_params)
respond_to do |format|
if @nii_type.save
format.html { redirect_to @nii_type, notice: t("controller.successfully_created", model: t("activerecord.models.nii_type")) }
format.json { render json: @nii_type, status: :created, location: @nii_type }
else
format.html { render action: "new" }
format.json { render json: @nii_type.errors, status: :unprocessable_entity }
end
end
end
# PUT /nii_types/1
# PUT /nii_types/1.json
def update
if params[:move]
move_position(@nii_type, params[:move])
return
end
respond_to do |format|
if @nii_type.update(nii_type_params)
format.html { redirect_to @nii_type, notice: t("controller.successfully_updated", model: t("activerecord.models.nii_type")) }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @nii_type.errors, status: :unprocessable_entity }
end
end
end
# DELETE /nii_types/1
# DELETE /nii_types/1.json
def destroy
@nii_type.destroy
respond_to do |format|
format.html { redirect_to nii_types_url, notice: t("controller.successfully_deleted", model: t("activerecord.models.nii_type")) }
format.json { head :no_content }
end
end
private
def set_nii_type
@nii_type = NiiType.find(params[:id])
authorize @nii_type
end
def check_policy
authorize NiiType
end
def nii_type_params
params.require(:nii_type).permit(:name, :display_name, :note)
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/controllers/user_import_files_controller.rb | app/controllers/user_import_files_controller.rb | class UserImportFilesController < ApplicationController
before_action :set_user_import_file, only: [ :show, :edit, :update, :destroy ]
before_action :check_policy, only: [ :index, :new, :create ]
before_action :prepare_options, only: [ :new, :edit ]
# GET /user_import_files
# GET /user_import_files.json
def index
@user_import_files = UserImportFile.order("id DESC").page(params[:page])
respond_to do |format|
format.html # index.html.erb
end
end
# GET /user_import_files/1
# GET /user_import_files/1.json
def show
@user_import_results = @user_import_file.user_import_results.page(params[:page])
respond_to do |format|
format.html # show.html.erb
end
end
# GET /user_import_files/new
def new
@user_import_file = UserImportFile.new
@user_import_file.default_user_group = current_user.profile.user_group
@user_import_file.default_library = current_user.profile.library
end
# GET /user_import_files/1/edit
def edit
end
# POST /user_import_files
# POST /user_import_files.json
def create
@user_import_file = UserImportFile.new(user_import_file_params)
@user_import_file.user = current_user
respond_to do |format|
if @user_import_file.save
if @user_import_file.mode == "import"
UserImportFileJob.perform_later(@user_import_file)
end
format.html { redirect_to @user_import_file, notice: t("import.successfully_created", model: t("activerecord.models.user_import_file")) }
format.json { render json: @user_import_file, status: :created, location: @user_import_file }
else
prepare_options
format.html { render action: "new" }
format.json { render json: @user_import_file.errors, status: :unprocessable_entity }
end
end
end
# PUT /user_import_files/1
# PUT /user_import_files/1.json
def update
respond_to do |format|
if @user_import_file.update(user_import_file_params)
if @user_import_file.mode == "import"
UserImportFileJob.perform_later(@user_import_file)
end
format.html { redirect_to @user_import_file, notice: t("controller.successfully_updated", model: t("activerecord.models.user_import_file")) }
format.json { head :no_content }
else
prepare_options
format.html { render action: "edit" }
format.json { render json: @user_import_file.errors, status: :unprocessable_entity }
end
end
end
# DELETE /user_import_files/1
# DELETE /user_import_files/1.json
def destroy
@user_import_file.destroy
respond_to do |format|
format.html { redirect_to(user_import_files_url) }
format.json { head :no_content }
end
end
private
def set_user_import_file
@user_import_file = UserImportFile.find(params[:id])
authorize @user_import_file
end
def check_policy
authorize UserImportFile
end
def user_import_file_params
params.require(:user_import_file).permit(
:attachment, :edit_mode, :user_encoding, :mode,
:default_user_group_id, :default_library_id
)
end
def prepare_options
@user_groups = UserGroup.all
@libraries = Library.all
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/controllers/frequencies_controller.rb | app/controllers/frequencies_controller.rb | class FrequenciesController < ApplicationController
before_action :set_frequency, only: [ :show, :edit, :update, :destroy ]
before_action :check_policy, only: [ :index, :new, :create ]
# GET /frequencies
# GET /frequencies.json
def index
@frequencies = Frequency.order(:position)
respond_to do |format|
format.html # index.html.erb
end
end
# GET /frequencies/1
# GET /frequencies/1.json
def show
respond_to do |format|
format.html # show.html.erb
end
end
# GET /frequencies/new
def new
@frequency = Frequency.new
end
# GET /frequencies/1/edit
def edit
end
# POST /frequencies
# POST /frequencies.json
def create
@frequency = Frequency.new(frequency_params)
respond_to do |format|
if @frequency.save
format.html { redirect_to @frequency, notice: t("controller.successfully_created", model: t("activerecord.models.frequency")) }
format.json { render json: @frequency, status: :created, location: @frequency }
else
format.html { render action: "new" }
format.json { render json: @frequency.errors, status: :unprocessable_entity }
end
end
end
# PUT /frequencies/1
# PUT /frequencies/1.json
def update
if params[:move]
move_position(@frequency, params[:move])
return
end
respond_to do |format|
if @frequency.update(frequency_params)
format.html { redirect_to @frequency, notice: t("controller.successfully_updated", model: t("activerecord.models.frequency")) }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @frequency.errors, status: :unprocessable_entity }
end
end
end
# DELETE /frequencies/1
# DELETE /frequencies/1.json
def destroy
@frequency.destroy
respond_to do |format|
format.html { redirect_to frequencies_url, notice: t("controller.successfully_deleted", model: t("activerecord.models.frequency")) }
format.json { head :no_content }
end
end
private
def set_frequency
@frequency = Frequency.find(params[:id])
authorize @frequency
end
def check_policy
authorize Frequency
end
def frequency_params
params.require(:frequency).permit(:name, :display_name, :note)
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/controllers/accepts_controller.rb | app/controllers/accepts_controller.rb | class AcceptsController < ApplicationController
before_action :set_accept, only: [ :show, :edit, :update, :destroy ]
before_action :check_policy, only: [ :index, :new, :create ]
before_action :get_basket, only: [ :index, :create ]
# GET /accepts
# GET /accepts.json
def index
if request.format.text?
@accepts = Accept.order("accepts.created_at DESC").page(params[:page]).per(65534)
else
if params[:accept]
@query = params[:accept][:item_identifier].to_s.strip
item = Item.where(item_identifier: @query).first if @query.present?
end
if item
@accepts = Accept.order("accepts.created_at DESC").where(item_id: item.id).page(params[:page])
elsif @basket
@accepts = @basket.accepts.order("accepts.created_at DESC").page(params[:page])
else
@accepts = Accept.order("accepts.created_at DESC").page(params[:page])
end
end
respond_to do |format|
format.html # index.html.erb
format.js { @accept = Accept.new }
format.text
end
end
# GET /accepts/1
# GET /accepts/1.json
def show
respond_to do |format|
format.html # show.html.erb
end
end
# GET /new
def new
@basket = Basket.new
@basket.user = current_user
@basket.save!
@accept = Accept.new
@accepts = []
end
# GET /accepts/new
# GET /accepts/1/edit
def edit
end
# POST /accepts
# POST /accepts.json
def create
unless @basket
access_denied
return
end
@accept = Accept.new(accept_params)
@accept.basket = @basket
@accept.librarian = current_user
flash[:message] = ""
if @accept.item_identifier.blank?
flash[:message] << t("accept.enter_item_identifier") if @accept.item_identifier.blank?
else
item = Item.where(item_identifier: @accept.item_identifier.to_s.strip).first
end
@accept.item = item
respond_to do |format|
if @accept.save
flash[:message] << t("accept.successfully_accepted", model: t("activerecord.models.accept"))
format.html { redirect_to accepts_url(basket_id: @basket.id) }
format.json { render json: @accept, status: :created, location: @accept }
format.js { redirect_to accepts_url(basket_id: @basket.id, format: :js) }
else
@accepts = @basket.accepts.page(params[:page])
format.html { render action: "index" }
format.json { render json: @accept.errors, status: :unprocessable_entity }
format.js { render action: "index" }
end
end
end
# PUT /accepts/1
# PUT /accepts/1.json
def update
respond_to do |format|
if @accept.update(accept_params)
format.html { redirect_to @accept, notice: t("controller.successfully_updated", model: t("activerecord.models.accept")) }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @accept.errors, status: :unprocessable_entity }
end
end
end
# DELETE /accepts/1
# DELETE /accepts/1.json
def destroy
@accept.destroy
respond_to do |format|
format.html { redirect_to accepts_url, notice: t("controller.successfully_deleted", model: t("activerecord.models.accept")) }
format.json { head :no_content }
end
end
private
def set_accept
@accept = Accept.find(params[:id])
authorize @accept
end
def check_policy
authorize Accept
end
def accept_params
params.require(:accept).permit(:item_identifier, :librarian_id, :item_id)
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/controllers/purchase_requests_controller.rb | app/controllers/purchase_requests_controller.rb | class PurchaseRequestsController < ApplicationController
before_action :store_page, only: :index
before_action :set_purchase_request, only: [ :show, :edit, :update, :destroy ]
before_action :set_order_list
before_action :check_policy, only: [ :index, :new, :create ]
after_action :convert_charset, only: :index
# GET /purchase_requests
# GET /purchase_requests.json
def index
@count = {}
if request.format.text?
per_page = 65534
else
per_page = PurchaseRequest.default_per_page
end
query = params[:query].to_s.strip
@query = query.dup
mode = params[:mode]
user = User.find_by(username: params[:user_id])
if user
if user == current_user && !current_user.has_role?("Librarian")
redirect_to purchase_requests_url(format: params[:format])
return
elsif user != current_user && !current_user.has_role?("Librarian")
access_denied
return
end
end
order_list = @order_list
search = Sunspot.new_search(PurchaseRequest)
search.build do
fulltext query if query.present?
if user
with(:user_id).equal_to user.id
else
unless current_user.has_role?("Librarian")
with(:user_id).equal_to current_user.id
end
end
with(:order_list_id).equal_to order_list.id if order_list
case mode
when "not_ordered"
with(:ordered).equal_to false
when "ordered"
with(:ordered).equal_to true
end
order_by(:created_at, :desc)
end
page = params[:page] || "1"
flash[:page] = page if page.to_i >= 1
search.query.paginate(page.to_i, per_page)
@purchase_requests = search.execute!.results
@count[:query_result] = @purchase_requests.size
respond_to do |format|
format.html # index.html.erb
format.json { render json: @purchase_requests }
format.rss { render layout: false }
format.atom
format.text
end
end
# GET /purchase_requests/1
# GET /purchase_requests/1.json
def show
respond_to do |format|
format.html # show.html.erb
format.json { render json: @purchase_request }
end
end
# GET /purchase_requests/new
# GET /purchase_requests/new.json
def new
@purchase_request = current_user.purchase_requests.new(purchase_request_params)
if defined?(EnjuBookmark)
bookmark = Bookmark.new
@purchase_request.title = bookmark.get_title_from_url(@purchase_request.url) unless @purchase_request.title?
end
end
# GET /purchase_requests/1/edit
def edit
end
# POST /purchase_requests
# POST /purchase_requests.json
def create
@purchase_request = current_user.purchase_requests.new(purchase_request_params)
respond_to do |format|
if @purchase_request.save
@order_list.purchase_requests << @purchase_request if @order_list
flash[:notice] = t("controller.successfully_created", model: t("activerecord.models.purchase_request"))
format.html { redirect_to(@purchase_request) }
format.json { render json: @purchase_request, status: :created, location: @purchase_request }
else
format.html { render action: "new" }
format.json { render json: @purchase_request.errors, status: :unprocessable_entity }
end
end
end
# PUT /purchase_requests/1
# PUT /purchase_requests/1.json
def update
respond_to do |format|
if @purchase_request.update(purchase_request_params)
@order_list.purchase_requests << @purchase_request if @order_list
flash[:notice] = t("controller.successfully_updated", model: t("activerecord.models.purchase_request"))
format.html { redirect_to(@purchase_request) }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @purchase_request.errors, status: :unprocessable_entity }
end
end
end
# DELETE /purchase_requests/1
# DELETE /purchase_requests/1.json
def destroy
@purchase_request.destroy
respond_to do |format|
format.html { redirect_to purchase_requests_url }
format.json { head :no_content }
end
end
private
def set_purchase_request
@purchase_request = PurchaseRequest.find(params[:id])
authorize @purchase_request
end
def set_order_list
@order_list = OrderList.find_by(id: params[:order_list_id])
authorize @order_list if @order_list
end
def check_policy
authorize PurchaseRequest
end
def purchase_request_params
params.fetch(:purchase_request, {}).permit(
:title, :author, :publisher, :isbn, :price, :url, :note, :pub_date
)
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/controllers/realizes_controller.rb | app/controllers/realizes_controller.rb | class RealizesController < ApplicationController
before_action :set_realize, only: [ :show, :edit, :update, :destroy ]
before_action :check_policy, only: [ :index, :new, :create ]
before_action :get_agent, :get_expression
before_action :prepare_options, only: [ :new, :edit ]
# GET /realizes
# GET /realizes.json
def index
case
when @agent
@realizes = @agent.realizes.order("realizes.position").page(params[:page])
when @expression
@realizes = @expression.realizes.order("realizes.position").page(params[:page])
else
@realizes = Realize.page(params[:page])
end
respond_to do |format|
format.html # index.html.erb
end
end
# GET /realizes/1
# GET /realizes/1.json
def show
respond_to do |format|
format.html # show.html.erb
end
end
# GET /realizes/new
def new
if @expression && @agent.blank?
redirect_to expression_agents_url(@expression)
nil
elsif @agent && @expression.blank?
redirect_to agent_expressions_url(@agent)
nil
else
@realize = Realize.new
@realize.expression = @expression
@realize.agent = @agent
end
end
# GET /realizes/1/edit
def edit
end
# POST /realizes
# POST /realizes.json
def create
@realize = Realize.new(realize_params)
respond_to do |format|
if @realize.save
format.html { redirect_to @realize, notice: t("controller.successfully_created", model: t("activerecord.models.realize")) }
format.json { render json: @realize, status: :created, location: @realize }
else
prepare_options
format.html { render action: "new" }
format.json { render json: @realize.errors, status: :unprocessable_entity }
end
end
end
# PUT /realizes/1
# PUT /realizes/1.json
def update
# 並べ替え
if @expression && params[:move]
move_position(@realize, params[:move], false)
redirect_to realizes_url(expression_id: @realize.expression_id)
return
end
respond_to do |format|
if @realize.update(realize_params)
format.html { redirect_to @realize, notice: t("controller.successfully_updated", model: t("activerecord.models.realize")) }
format.json { head :no_content }
else
prepare_options
format.html { render action: "edit" }
format.json { render json: @realize.errors, status: :unprocessable_entity }
end
end
end
# DELETE /realizes/1
# DELETE /realizes/1.json
def destroy
@realize.destroy
respond_to do |format|
format.html {
flash[:notice] = t("controller.successfully_deleted", model: t("activerecord.models.realize"))
case
when @expression
redirect_to expression_agents_url(@expression)
when @agent
redirect_to agent_expressions_url(@agent)
else
redirect_to realizes_url
end
}
format.json { head :no_content }
end
end
private
def set_realize
@realize = Realize.find(params[:id])
authorize @realize
end
def check_policy
authorize Realize
end
def realize_params
params.require(:realize).permit(
:agent_id, :expression_id, :realize_type_id, :position
)
end
def prepare_options
@realize_types = RealizeType.all
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/controllers/content_types_controller.rb | app/controllers/content_types_controller.rb | class ContentTypesController < ApplicationController
before_action :set_content_type, only: [ :show, :edit, :update, :destroy ]
before_action :check_policy, only: [ :index, :new, :create ]
# GET /content_types
# GET /content_types.json
def index
@content_types = ContentType.order(:position)
respond_to do |format|
format.html # index.html.erb
end
end
# GET /content_types/1
# GET /content_types/1.json
def show
respond_to do |format|
format.html # show.html.erb
end
end
# GET /content_types/new
def new
@content_type = ContentType.new
end
# GET /content_types/1/edit
def edit
end
# POST /content_types
# POST /content_types.json
def create
@content_type = ContentType.new(content_type_params)
respond_to do |format|
if @content_type.save
format.html { redirect_to @content_type, notice: t("controller.successfully_created", model: t("activerecord.models.content_type")) }
format.json { render json: @content_type, status: :created, location: @content_type }
else
format.html { render action: "new" }
format.json { render json: @content_type.errors, status: :unprocessable_entity }
end
end
end
# PUT /content_types/1
# PUT /content_types/1.json
def update
if params[:move]
move_position(@content_type, params[:move])
return
end
respond_to do |format|
if @content_type.update(content_type_params)
format.html { redirect_to @content_type, notice: t("controller.successfully_updated", model: t("activerecord.models.content_type")) }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @content_type.errors, status: :unprocessable_entity }
end
end
end
# DELETE /content_types/1
# DELETE /content_types/1.json
def destroy
@content_type.destroy
respond_to do |format|
format.html { redirect_to content_types_url, notice: t("controller.successfully_deleted", model: t("activerecord.models.content_type")) }
format.json { head :no_content }
end
end
private
def set_content_type
@content_type = ContentType.find(params[:id])
authorize @content_type
end
def check_policy
authorize ContentType
end
def content_type_params
params.require(:content_type).permit(:name, :display_name, :note)
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/controllers/languages_controller.rb | app/controllers/languages_controller.rb | class LanguagesController < ApplicationController
before_action :set_language, only: [ :show, :edit, :update, :destroy ]
before_action :check_policy, only: [ :index, :new, :create ]
# GET /languages
# GET /languages.json
def index
@languages = Language.page(params[:page])
respond_to do |format|
format.html # index.html.erb
end
end
# GET /languages/1
# GET /languages/1.json
def show
respond_to do |format|
format.html # show.html.erb
end
end
# GET /languages/new
def new
@language = Language.new
end
# GET /languages/1/edit
def edit
end
# POST /languages
# POST /languages.json
def create
@language = Language.new(language_params)
respond_to do |format|
if @language.save
format.html { redirect_to @language, notice: t("controller.successfully_created", model: t("activerecord.models.language")) }
format.json { render json: @language, status: :created, location: @language }
else
format.html { render action: "new" }
format.json { render json: @language.errors, status: :unprocessable_entity }
end
end
end
# PUT /languages/1
# PUT /languages/1.json
def update
if params[:move]
move_position(@language, params[:move])
return
end
respond_to do |format|
if @language.update(language_params)
format.html { redirect_to @language, notice: t("controller.successfully_updated", model: t("activerecord.models.language")) }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @language.errors, status: :unprocessable_entity }
end
end
end
# DELETE /languages/1
# DELETE /languages/1.json
def destroy
@language.destroy
respond_to do |format|
format.html { redirect_to languages_url, notice: t("controller.successfully_deleted", model: t("activerecord.models.language")) }
format.json { head :no_content }
end
end
private
def set_language
@language = Language.find(params[:id])
authorize @language
end
def check_policy
authorize Language
end
def language_params
params.require(:language).permit(
:name, :native_name, :display_name, :iso_639_1, :iso_639_2, :iso_639_3,
:note
)
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/controllers/import_requests_controller.rb | app/controllers/import_requests_controller.rb | class ImportRequestsController < ApplicationController
before_action :set_import_request, only: [ :show, :edit, :update, :destroy ]
before_action :check_policy, only: [ :index, :new, :create ]
# GET /import_requests
# GET /import_requests.json
def index
@import_requests = ImportRequest.page(params[:page])
respond_to do |format|
format.html # index.html.erb
end
end
# GET /import_requests/1
# GET /import_requests/1.json
def show
respond_to do |format|
format.html # show.html.erb
end
end
# GET /import_requests/new
def new
@import_request = ImportRequest.new
end
# GET /import_requests/1/edit
def edit
end
# POST /import_requests
# POST /import_requests.json
def create
@import_request = ImportRequest.new(import_request_params)
@import_request.user = current_user
respond_to do |format|
if @import_request.save
@error_type = @import_request.import!
format.html {
if @import_request.manifestation
redirect_to @import_request.manifestation, notice: t("controller.successfully_created", model: t("activerecord.models.import_request"))
elsif @error_type
redirect_to new_import_request_url, notice: t("import_request.#{@error_type}")
end
}
# format.html.phone {
# if @import_request.manifestation
# redirect_to @import_request.manifestation, notice: t('controller.successfully_created', model: t('activerecord.models.import_request'))
# else
# redirect_to new_import_request_url, notice: t('import_request.record_not_found')
# end
# }
format.json { render json: @import_request, status: :created, location: @import_request }
else
format.html { render action: "new" }
# format.html.phone { render action: "new" }
format.json { render json: @import_request.errors, status: :unprocessable_entity }
end
end
rescue Timeout::Error
@import_request.transition_to!(:failed)
flash[:notice] = t("page.timed_out")
redirect_to new_import_request_url
end
# PUT /import_requests/1
# PUT /import_requests/1.json
def update
respond_to do |format|
if @import_request.update(import_request_params)
@import_request.import!
format.html { redirect_to @import_request, notice: t("controller.successfully_updated", model: t("activerecord.models.import_request")) }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @import_request.errors, status: :unprocessable_entity }
end
end
end
# DELETE /import_requests/1
# DELETE /import_requests/1.json
def destroy
@import_request.destroy
respond_to do |format|
format.html { redirect_to import_requests_url, notice: t("controller.successfully_deleted", model: t("activerecord.models.import_request")) }
format.json { head :no_content }
end
end
private
def set_import_request
@import_request = ImportRequest.find(params[:id])
authorize @import_request
end
def check_policy
authorize ImportRequest
end
def import_request_params
params.require(:import_request).permit(:isbn, :manifestation_id, :user_id)
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/controllers/realize_types_controller.rb | app/controllers/realize_types_controller.rb | class RealizeTypesController < ApplicationController
before_action :set_realize_type, only: [ :show, :edit, :update, :destroy ]
before_action :check_policy, only: [ :index, :new, :create ]
# GET /realize_types
# GET /realize_types.json
def index
@realize_types = RealizeType.order(:position)
respond_to do |format|
format.html # index.html.erb
end
end
# GET /realize_types/1
# GET /realize_types/1.json
def show
respond_to do |format|
format.html # show.html.erb
end
end
# GET /realize_types/new
def new
@realize_type = RealizeType.new
end
# GET /realize_types/1/edit
def edit
end
# POST /realize_types
# POST /realize_types.json
def create
@realize_type = RealizeType.new(realize_type_params)
respond_to do |format|
if @realize_type.save
format.html { redirect_to @realize_type, notice: t("controller.successfully_created", model: t("activerecord.models.realize_type")) }
format.json { render json: @realize_type, status: :created, location: @realize_type }
else
format.html { render action: "new" }
format.json { render json: @realize_type.errors, status: :unprocessable_entity }
end
end
end
# PUT /realize_types/1
# PUT /realize_types/1.json
def update
if params[:move]
move_position(@realize_type, params[:move])
return
end
respond_to do |format|
if @realize_type.update(realize_type_params)
format.html { redirect_to @realize_type, notice: t("controller.successfully_updated", model: t("activerecord.models.realize_type")) }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @realize_type.errors, status: :unprocessable_entity }
end
end
end
# DELETE /realize_types/1
# DELETE /realize_types/1.json
def destroy
@realize_type.destroy
respond_to do |format|
format.html { redirect_to realize_types_url, notice: t("controller.successfully_deleted", model: t("activerecord.models.realize_type")) }
format.json { head :no_content }
end
end
private
def set_realize_type
@realize_type = RealizeType.find(params[:id])
authorize @realize_type
end
def check_policy
authorize RealizeType
end
def realize_type_params
params.require(:realize_type).permit(
:name, :display_name, :note, :position
)
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/controllers/tags_controller.rb | app/controllers/tags_controller.rb | class TagsController < ApplicationController
before_action :set_tag, only: [ :show, :edit, :update, :destroy ]
before_action :check_policy, only: [ :index ]
def index
session[:params] ={} unless session[:params]
session[:params][:tag] = params
sort = { sort_by: "created_at", order: "desc" }
case params[:sort_by]
when "name"
sort[:sort_by] = "name"
when "taggings_count"
sort[:sort_by] = "taggings_count"
end
sort[:order] = "asc" if params[:order] == "asc"
query = @query = params[:query].to_s.strip
page = params[:page] || 1
@tags = Tag.search do
fulltext query if query.present?
paginate page: page.to_i, per_page: Tag.default_per_page
order_by sort[:sort_by], sort[:order]
end.results
respond_to do |format|
format.html # index.html.erb
format.rss
format.atom
end
end
def show
respond_to do |format|
format.html # show.html.erb
end
end
def edit
# @tag = Tag.find(params[:id])
end
def update
# @tag = Tag.find(params[:id])
respond_to do |format|
if @tag.update(tag_params)
format.html { redirect_to @tag, notice: t("controller.successfully_updated", model: t("activerecord.models.tag")) }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @tag.errors, status: :unprocessable_entity }
end
end
end
# DELETE /tags/1
# DELETE /tags/1.json
def destroy
# @tag = Tag.find(params[:id])
@tag.destroy
respond_to do |format|
format.html { redirect_to tags_url }
format.json { head :no_content }
end
end
private
def set_tag
@tag = Tag.friendly.find(params[:id])
authorize @tag
end
def check_policy
authorize Tag
end
def tag_params
params.require(:tag).permit(:name)
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/controllers/resource_export_files_controller.rb | app/controllers/resource_export_files_controller.rb | class ResourceExportFilesController < ApplicationController
before_action :set_resource_export_file, only: [ :show, :edit, :update, :destroy ]
before_action :check_policy, only: [ :index, :new, :create ]
# GET /resource_export_files
# GET /resource_export_files.json
def index
@resource_export_files = ResourceExportFile.order("id DESC").page(params[:page])
respond_to do |format|
format.html # index.html.erb
end
end
# GET /resource_export_files/1
# GET /resource_export_files/1.json
def show
respond_to do |format|
format.html # show.html.erb
end
end
# GET /resource_export_files/new
def new
@resource_export_file = ResourceExportFile.new
@resource_export_file.user = current_user
end
# GET /resource_export_files/1/edit
def edit
end
# POST /resource_export_files
# POST /resource_export_files.json
def create
@resource_export_file = ResourceExportFile.new(resource_export_file_params)
@resource_export_file.user = current_user
respond_to do |format|
if @resource_export_file.save
if @resource_export_file.mode == "export"
ResourceExportFileJob.perform_later(@resource_export_file)
end
format.html { redirect_to @resource_export_file, notice: t("export.successfully_created", model: t("activerecord.models.resource_export_file")) }
format.json { render json: @resource_export_file, status: :created, location: @resource_export_file }
else
format.html { render action: "new" }
format.json { render json: @resource_export_file.errors, status: :unprocessable_entity }
end
end
end
# PUT /resource_export_files/1
# PUT /resource_export_files/1.json
def update
respond_to do |format|
if @resource_export_file.update(resource_export_file_params)
if @resource_export_file.mode == "export"
ResourceExportFileJob.perform_later(@resource_export_file)
end
format.html { redirect_to @resource_export_file, notice: t("controller.successfully_updated", model: t("activerecord.models.resource_export_file")) }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @resource_export_file.errors, status: :unprocessable_entity }
end
end
end
# DELETE /resource_export_files/1
# DELETE /resource_export_files/1.json
def destroy
@resource_export_file.destroy
respond_to do |format|
format.html { redirect_to resource_export_files_url }
format.json { head :no_content }
end
end
private
def set_resource_export_file
@resource_export_file = ResourceExportFile.find(params[:id])
authorize @resource_export_file
end
def check_policy
authorize ResourceExportFile
end
def resource_export_file_params
params.require(:resource_export_file).permit(:mode)
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/controllers/create_types_controller.rb | app/controllers/create_types_controller.rb | class CreateTypesController < ApplicationController
before_action :set_create_type, only: [ :show, :edit, :update, :destroy ]
before_action :check_policy, only: [ :index, :new, :create ]
# GET /create_types
# GET /create_types.json
def index
@create_types = CreateType.order(:position)
respond_to do |format|
format.html # index.html.erb
end
end
# GET /create_types/1
# GET /create_types/1.json
def show
respond_to do |format|
format.html # show.html.erb
end
end
# GET /create_types/new
def new
@create_type = CreateType.new
end
# GET /create_types/1/edit
def edit
end
# POST /create_types
# POST /create_types.json
def create
@create_type = CreateType.new(create_type_params)
respond_to do |format|
if @create_type.save
format.html { redirect_to @create_type, notice: t("controller.successfully_created", model: t("activerecord.models.create_type")) }
format.json { render json: @create_type, status: :created, location: @create_type }
else
format.html { render action: "new" }
format.json { render json: @create_type.errors, status: :unprocessable_entity }
end
end
end
# PUT /create_types/1
# PUT /create_types/1.json
def update
if params[:move]
move_position(@create_type, params[:move])
return
end
respond_to do |format|
if @create_type.update(create_type_params)
format.html { redirect_to @create_type, notice: t("controller.successfully_updated", model: t("activerecord.models.create_type")) }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @create_type.errors, status: :unprocessable_entity }
end
end
end
# DELETE /create_types/1
# DELETE /create_types/1.json
def destroy
@create_type.destroy
respond_to do |format|
format.html { redirect_to create_types_url, notice: t("controller.successfully_deleted", model: t("activerecord.models.create_type")) }
format.json { head :no_content }
end
end
private
def set_create_type
@create_type = CreateType.find(params[:id])
authorize @create_type
end
def check_policy
authorize CreateType
end
def create_type_params
params.require(:create_type).permit(:name, :display_name, :note, :position)
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/controllers/checkouts_controller.rb | app/controllers/checkouts_controller.rb | class CheckoutsController < ApplicationController
before_action :set_checkout, only: [ :show, :edit, :update, :destroy ]
before_action :check_policy, only: [ :index, :remove_all ]
before_action :get_user, only: [ :index, :remove_all ]
before_action :get_item, only: :index
after_action :convert_charset, only: :index
# GET /checkouts
# GET /checkouts.json
def index
if params[:icalendar_token].present?
icalendar_user = Profile.where(checkout_icalendar_token: params[:icalendar_token]).first.try(:user)
if icalendar_user.blank?
raise ActiveRecord::RecordNotFound
else
@checkouts = icalendar_user.checkouts.not_returned.order("checkouts.id DESC")
end
else
unless current_user
access_denied
return
end
end
if [ "text", "rss" ].include?(params[:format].to_s.downcase)
per_page = 500
page = 1
else
per_page = Checkout.default_per_page
page = params[:page] || 1
end
unless icalendar_user
search = Checkout.search
if @user
user = @user
if current_user.try(:has_role?, "Librarian")
search.build do
with(:username).equal_to user.username
end
elsif current_user == user
redirect_to checkouts_url(format: params[:format])
return
else
access_denied
return
end
else
unless current_user.try(:has_role?, "Librarian")
search.build do
with(:username).equal_to current_user.username
unless current_user.profile.save_checkout_history?
with(:checked_in_at).equal_to nil
end
end
end
end
if @item
item = @item
search.build do
with(:item_identifier).equal_to item.item_identifier
end
end
if params[:days_overdue].present?
days_overdue = params[:days_overdue].to_i
date = days_overdue.days.ago.beginning_of_day
search.build do
with(:due_date).less_than date
with(:checked_in_at).equal_to nil
end
end
if params[:reserved].present?
if params[:reserved] == "true"
@reserved = reserved = true
elsif params[:reserved] == "false"
@reserved = reserved = false
end
search.build do
with(:reserved).equal_to reserved
end
end
search.build do
order_by :created_at, :desc
facet :reserved
end
search.query.paginate(page.to_i, per_page)
@checkouts = search.execute!.results
@checkouts_facet = search.facet(:reserved).rows
end
@days_overdue = days_overdue if days_overdue
respond_to do |format|
format.html # index.html.erb
format.rss
format.ics
format.text
format.atom
end
end
# GET /checkouts/1
# GET /checkouts/1.json
def show
respond_to do |format|
format.html # show.html.erb
end
end
# GET /checkouts/1/edit
def edit
@new_due_date = @checkout.get_new_due_date
end
# PUT /checkouts/1
# PUT /checkouts/1.json
def update
@checkout.assign_attributes(checkout_params)
@checkout.checkout_renewal_count += 1
respond_to do |format|
if @checkout.save
format.html { redirect_to @checkout, notice: t("controller.successfully_updated", model: t("activerecord.models.checkout")) }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @checkout.errors, status: :unprocessable_entity }
end
end
end
# DELETE /checkouts/1
# DELETE /checkouts/1.json
def destroy
user = @checkout.user
@checkout.operator = current_user
@checkout.user_id = nil
@checkout.save!
respond_to do |format|
format.html { redirect_to checkouts_url(user_id: user.username), notice: t("controller.successfully_deleted", model: t("activerecord.models.checkout")) }
format.json { head :no_content }
end
end
def remove_all
if @user
unless current_user.has_role?("Librarian")
if @user != current_user
access_denied
return
end
end
Checkout.remove_all_history(@user)
end
respond_to do |format|
format.html { redirect_to checkouts_url, notice: t("controller.successfully_deleted", model: t("activerecord.models.checkout")) }
format.json { head :no_content }
end
end
private
def set_checkout
@checkout = Checkout.find(params[:id])
authorize @checkout
end
def check_policy
authorize Checkout
end
def checkout_params
params.fetch(:checkout, {}).permit(:due_date)
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/controllers/libraries_controller.rb | app/controllers/libraries_controller.rb | class LibrariesController < ApplicationController
before_action :set_library, only: [ :show, :edit, :update, :destroy ]
before_action :check_policy, only: [ :index, :new, :create ]
# GET /libraries
# GET /libraries.json
def index
sort = { sort_by: "position", order: "asc" }
case params[:sort_by]
when "name"
sort[:sort_by] = "name"
end
sort[:order] = "desc" if params[:order] == "desc"
query = @query = params[:query].to_s.strip
page = params[:page] || 1
@libraries = Library.search(include: [ :shelves ]) do
fulltext query if query.present?
paginate page: page.to_i, per_page: Library.default_per_page
order_by sort[:sort_by], sort[:order]
end.results
respond_to do |format|
format.html # index.html.erb
end
end
# GET /libraries/1
# GET /libraries/1.json
def show
if defined?(EnjuEvent)
search = Sunspot.new_search(Event)
library_id = @library.id
search.build do
with(:library_id).equal_to library_id
order_by(:start_at, :desc)
end
page = params[:event_page] || 1
search.query.paginate(page.to_i, Event.default_per_page)
@events = search.execute!.results
end
respond_to do |format|
format.html # show.html.erb
format.html.phone
format.js
end
end
# GET /libraries/new
def new
@library = Library.new
@library.library_group = LibraryGroup.first
@library.country = LibraryGroup.site_config.country
prepare_options
end
# GET /libraries/1/edit
def edit
prepare_options
end
# POST /libraries
# POST /libraries.json
def create
@library = Library.new(library_params)
respond_to do |format|
if @library.save
format.html { redirect_to @library, notice: t("controller.successfully_created", model: t("activerecord.models.library")) }
format.json { render json: @library, status: :created }
else
prepare_options
format.html { render action: "new" }
format.json { render json: @library.errors, status: :unprocessable_entity }
end
end
end
# PUT /libraries/1
# PUT /libraries/1.json
def update
if params[:move]
move_position(@library, params[:move])
return
end
respond_to do |format|
if @library.update(library_params)
format.html { redirect_to @library, notice: t("controller.successfully_updated", model: t("activerecord.models.library")) }
format.json { head :no_content }
else
@library.name = @library.name_was
prepare_options
format.html { render action: "edit" }
format.json { render json: @library.errors, status: :unprocessable_entity }
end
end
end
# DELETE /libraries/1
# DELETE /libraries/1.json
def destroy
@library.destroy
respond_to do |format|
format.html { redirect_to libraries_url }
format.json { head :no_content }
end
end
private
def set_library
@library = Library.friendly.find(params[:id])
authorize @library
end
def check_policy
authorize Library
end
def library_params
params.require(:library).permit(
:name, :display_name, :short_display_name, :zip_code, :street,
:locality, :region, :telephone_number_1, :telephone_number_2, :fax_number,
:note, :call_number_rows, :call_number_delimiter, :library_group_id,
:country_id, :opening_hour, :isil, :position, :latitude, :longitude
)
end
def prepare_options
@library_groups = LibraryGroup.all
@countries = Country.order(:position)
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/controllers/my_accounts_controller.rb | app/controllers/my_accounts_controller.rb | class MyAccountsController < ApplicationController
before_action :authenticate_user!
before_action :set_profile
def show
respond_to do |format|
format.html
format.html.phone
end
end
def edit
prepare_options
end
def update
respond_to do |format|
@profile.assign_attributes(profile_update_params)
if @profile.save
@profile.user.save!
bypass_sign_in(current_user)
format.html { redirect_to my_account_url, notice: t("controller.successfully_updated", model: t("activerecord.models.user")) }
format.json { head :no_content }
else
prepare_options
format.html { render action: "edit" }
format.json { render json: current_user.errors, status: :unprocessable_entity }
end
end
end
def destroy
@profile.destroy
respond_to do |format|
format.html { redirect_to my_account_url, notice: "devise.registrations.destroyed" }
format.json { head :no_content }
end
end
private
def set_profile
@profile = current_user.profile
authorize @profile
end
def profile_params
attrs = [
:full_name, :full_name_transcription,
:library_id, :keyword_list, :note,
:locale, :required_role_id,
:locked, :birth_date,
:save_checkout_history, :checkout_icalendar_token, # EnjuCirculation
:save_search_history, { # EnjuSearchLog
user_attributes: [
:id, :username, :email, :locked,
{ user_has_role_attributes: [ :id, :role_id ] }
]
}
]
attrs << :user_group_id if current_user.has_role?("Librarian")
params.require(:profile).permit(*attrs)
end
def profile_update_params
attrs = [
:full_name, :full_name_transcription,
:keyword_list, :locale,
:save_checkout_history, :checkout_icalendar_token, # EnjuCirculation
:save_search_history, # EnjuSearchLog
]
if current_user.has_role?("Librarian")
attrs += [
:library_id, :expired_at, :birth_date,
:user_group_id, :required_role_id, :note, :user_number, {
user_attributes: [
:id, :email, :locked,
{ user_has_role_attributes: [ :id, :role_id ] }
]
}
]
end
params.require(:profile).permit(*attrs)
end
def prepare_options
@user_groups = UserGroup.order(:position)
@roles = Role.order(:position)
@libraries = Library.order(:position)
@languages = Language.order(:position)
current_user.locked = if current_user.active_for_authentication?
"0"
else
"1"
end
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/controllers/medium_of_performances_controller.rb | app/controllers/medium_of_performances_controller.rb | class MediumOfPerformancesController < ApplicationController
before_action :set_medium_of_performance, only: [ :show, :edit, :update, :destroy ]
before_action :check_policy, only: [ :index, :new, :create ]
# GET /medium_of_performances
# GET /medium_of_performances.json
def index
@medium_of_performances = MediumOfPerformance.order(:position)
respond_to do |format|
format.html # index.html.erb
end
end
# GET /medium_of_performances/1
# GET /medium_of_performances/1.json
def show
respond_to do |format|
format.html # show.html.erb
end
end
# GET /medium_of_performances/new
def new
@medium_of_performance = MediumOfPerformance.new
end
# GET /medium_of_performances/1/edit
def edit
end
# POST /medium_of_performances
# POST /medium_of_performances.json
def create
@medium_of_performance = MediumOfPerformance.new(medium_of_performance_params)
respond_to do |format|
if @medium_of_performance.save
format.html { redirect_to @medium_of_performance, notice: t("controller.successfully_created", model: t("activerecord.models.medium_of_performance")) }
format.json { render json: @medium_of_performance, status: :created, location: @medium_of_performance }
else
format.html { render action: "new" }
format.json { render json: @medium_of_performance.errors, status: :unprocessable_entity }
end
end
end
# PUT /medium_of_performances/1
# PUT /medium_of_performances/1.json
def update
if params[:move]
move_position(@medium_of_performance, params[:move])
return
end
respond_to do |format|
if @medium_of_performance.update(medium_of_performance_params)
format.html { redirect_to @medium_of_performance, notice: t("controller.successfully_updated", model: t("activerecord.models.medium_of_performance")) }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @medium_of_performance.errors, status: :unprocessable_entity }
end
end
end
# DELETE /medium_of_performances/1
# DELETE /medium_of_performances/1.json
def destroy
@medium_of_performance.destroy
respond_to do |format|
format.html { redirect_to medium_of_performances_url, notice: t("controller.successfully_deleted", model: t("activerecord.models.medium_of_performance")) }
format.json { head :no_content }
end
end
private
def set_medium_of_performance
@medium_of_performance = MediumOfPerformance.find(params[:id])
authorize @medium_of_performance
end
def check_policy
authorize MediumOfPerformance
end
def medium_of_performance_params
params.require(:medium_of_performance).permit(:name, :display_name, :note)
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/controllers/classifications_controller.rb | app/controllers/classifications_controller.rb | class ClassificationsController < ApplicationController
before_action :set_classification, only: [ :show, :edit, :update, :destroy ]
before_action :check_policy, only: [ :index, :new, :create ]
before_action :get_subject, :get_classification_type
# GET /classifications
# GET /classifications.json
def index
search = Sunspot.new_search(Classification)
query = params[:query].to_s.strip
if query.present?
@query = query.dup
search.build do
fulltext query
end
end
unless params[:mode] == "add"
subject = @subject
classification_type = @classification_type
search.build do
with(:subject_ids).equal_to subject.id if subject
with(:classification_type_id).equal_to classification_type.id if classification_type
end
end
page = params[:page] || 1
search.query.paginate(page.to_i, Classification.default_per_page)
@classifications = search.execute!.results
session[:params] = {} unless session[:params]
session[:params][:classification] = params
respond_to do |format|
format.html # index.html.erb
end
end
# GET /classifications/1
# GET /classifications/1.json
def show
respond_to do |format|
format.html # show.html.erb
end
end
# GET /classifications/new
def new
@classification_types = ClassificationType.all
@classification = Classification.new
@classification.classification_type = @classification_type
end
# GET /classifications/1/edit
def edit
@classification_types = ClassificationType.all
end
# POST /classifications
# POST /classifications.json
def create
@classification = Classification.new(classification_params)
respond_to do |format|
if @classification.save
format.html { redirect_to @classification, notice: t("controller.successfully_created", model: t("activerecord.models.classification")) }
format.json { render json: @classification, status: :created, location: @classification }
else
@classification_types = ClassificationType.all
format.html { render action: "new" }
format.json { render json: @classification.errors, status: :unprocessable_entity }
end
end
end
# PUT /classifications/1
# PUT /classifications/1.json
def update
respond_to do |format|
if @classification.update(classification_params)
format.html { redirect_to @classification, notice: t("controller.successfully_updated", model: t("activerecord.models.classification")) }
format.json { head :no_content }
else
@classification_types = ClassificationType.all
format.html { render action: "edit" }
format.json { render json: @classification.errors, status: :unprocessable_entity }
end
end
end
# DELETE /classifications/1
# DELETE /classifications/1.json
def destroy
@classification = Classification.find(params[:id])
@classification.destroy
respond_to do |format|
format.html { redirect_to classifications_url, notice: t("controller.successfully_deleted", model: t("activerecord.models.classification")) }
format.json { head :no_content }
end
end
private
def set_classification
@classification = Classification.find(params[:id])
authorize @classification
end
def check_policy
authorize Classification
end
def classification_params
params.require(:classification).permit(
:parent_id, :category, :note, :classification_type_id, :url, :label
)
end
def get_classification_type
@classification_type = ClassificationType.find(params[:classification_type_id]) rescue nil
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/controllers/agent_merge_lists_controller.rb | app/controllers/agent_merge_lists_controller.rb | class AgentMergeListsController < ApplicationController
before_action :set_agent_merge_list, only: [ :show, :edit, :update, :destroy ]
before_action :check_policy, only: [ :index, :new, :create ]
# GET /agent_merge_lists
# GET /agent_merge_lists.json
def index
@agent_merge_lists = AgentMergeList.page(params[:page])
respond_to do |format|
format.html # index.html.erb
end
end
# GET /agent_merge_lists/1
# GET /agent_merge_lists/1.json
def show
respond_to do |format|
format.html # show.html.erb
end
end
# GET /agent_merge_lists/new
def new
@agent_merge_list = AgentMergeList.new
end
# GET /agent_merge_lists/1/edit
def edit
end
# POST /agent_merge_lists
# POST /agent_merge_lists.json
def create
@agent_merge_list = AgentMergeList.new(agent_merge_list_params)
respond_to do |format|
if @agent_merge_list.save
flash[:notice] = t("controller.successfully_created", model: t("activerecord.models.agent_merge_list"))
format.html { redirect_to(@agent_merge_list) }
format.json { render json: @agent_merge_list, status: :created, location: @agent_merge_list }
else
format.html { render action: "new" }
format.json { render json: @agent_merge_list.errors, status: :unprocessable_entity }
end
end
end
# PUT /agent_merge_lists/1
# PUT /agent_merge_lists/1.json
def update
respond_to do |format|
if @agent_merge_list.update(agent_merge_list_params)
if params[:mode] == "merge"
selected_agent = Agent.find_by(id: params[:selected_agent_id])
if selected_agent
@agent_merge_list.merge_agents(selected_agent)
flash[:notice] = t("merge_list.successfully_merged", model: t("activerecord.models.agent"))
else
flash[:notice] = t("merge_list.specify_id", model: t("activerecord.models.agent"))
redirect_to agent_merge_list_url(@agent_merge_list)
return
end
else
flash[:notice] = t("controller.successfully_updated", model: t("activerecord.models.agent_merge_list"))
end
format.html { redirect_to(@agent_merge_list) }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @agent_merge_list.errors, status: :unprocessable_entity }
end
end
end
# DELETE /agent_merge_lists/1
# DELETE /agent_merge_lists/1.json
def destroy
@agent_merge_list.destroy
respond_to do |format|
format.html { redirect_to(agent_merge_lists_url) }
format.json { head :no_content }
end
end
private
def set_agent_merge_list
@agent_merge_list = AgentMergeList.find(params[:id])
authorize @agent_merge_list
end
def check_policy
authorize AgentMergeList
end
def agent_merge_list_params
params.fetch(:agent_merge_list, {}).permit(:title)
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/controllers/owns_controller.rb | app/controllers/owns_controller.rb | class OwnsController < ApplicationController
before_action :set_own, only: [ :show, :edit, :update, :destroy ]
before_action :check_policy, only: [ :index, :new, :create ]
before_action :get_agent, :get_item
# GET /owns
# GET /owns.json
def index
if @agent
@owns = @agent.owns.order("owns.position").page(params[:page])
elsif @item
@owns = @item.owns.order("owns.position").page(params[:page])
else
@owns = Own.page(params[:page])
end
respond_to do |format|
format.html # index.html.erb
end
end
# GET /owns/1
# GET /owns/1.json
def show
respond_to do |format|
format.html # show.html.erb
end
end
# GET /owns/new
def new
if @item && @agent.blank?
redirect_to item_agents_url(@item)
nil
elsif @agent && @item.blank?
redirect_to agent_items_url(@agent)
nil
else
@own = Own.new
@own.item = @item
@own.agent = @agent
end
end
# GET /owns/1/edit
def edit
end
# POST /owns
# POST /owns.json
def create
@own = Own.new(own_params)
respond_to do |format|
if @own.save
format.html { redirect_to @own, notice: t("controller.successfully_created", model: t("activerecord.models.own")) }
format.json { render json: @own, status: :created, location: @own }
else
format.html { render action: "new" }
format.json { render json: @own.errors, status: :unprocessable_entity }
end
end
end
# PUT /owns/1
# PUT /owns/1.json
def update
if @item && params[:move]
move_position(@own, params[:move], false)
redirect_to owns_url(item_id: @own.item_id)
return
end
respond_to do |format|
if @own.update(own_params)
format.html { redirect_to @own, notice: t("controller.successfully_updated", model: t("activerecord.models.own")) }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @own.errors, status: :unprocessable_entity }
end
end
end
# DELETE /owns/1
# DELETE /owns/1.json
def destroy
@own.destroy
respond_to do |format|
format.html {
flash[:notice] = t("controller.successfully_deleted", model: t("activerecord.models.own"))
case
when @agent
redirect_to agent_owns_url(@agent)
when @item
redirect_to item_owns_url(@item)
else
redirect_to owns_url
end
}
format.json { head :no_content }
end
end
private
def set_own
@own = Own.find(params[:id])
authorize @own
end
def check_policy
authorize Own
end
def own_params
params.require(:own).permit(:agent_id, :item_id)
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/controllers/series_statement_merges_controller.rb | app/controllers/series_statement_merges_controller.rb | class SeriesStatementMergesController < ApplicationController
before_action :set_series_statement_merge, only: [ :show, :edit, :update, :destroy ]
before_action :check_policy, only: [ :index, :new, :create ]
before_action :get_series_statement, :get_series_statement_merge_list
# GET /series_statement_merges
# GET /series_statement_merges.json
def index
if @series_statement
@series_statement_merges = @series_statement.series_statement_merges.order("series_statement_merges.id").page(params[:page])
elsif @series_statement_merge_list
@series_statement_merges = @series_statement_merge_list.series_statement_merges.order("series_statement_merges.id").includes(:series_statement).page(params[:page])
else
@series_statement_merges = SeriesStatementMerge.page(params[:page])
end
respond_to do |format|
format.html # index.html.erb
end
end
# GET /series_statement_merges/1
# GET /series_statement_merges/1.json
def show
respond_to do |format|
format.html # show.html.erb
end
end
# GET /series_statement_merges/new
def new
@series_statement_merge = SeriesStatementMerge.new
@series_statement_merge.series_statement = @series_statement
@series_statement_merge.series_statement_merge_list = @series_statement_merge_list
end
# GET /series_statement_merges/1/edit
def edit
end
# POST /series_statement_merges
# POST /series_statement_merges.json
def create
@series_statement_merge = SeriesStatementMerge.new(series_statement_merge_params)
respond_to do |format|
if @series_statement_merge.save
flash[:notice] = t("controller.successfully_created", model: t("activerecord.models.series_statement_merge"))
format.html { redirect_to(@series_statement_merge) }
format.json { render json: @series_statement_merge, status: :created, location: @series_statement_merge }
else
format.html { render action: "new" }
format.json { render json: @series_statement_merge.errors, status: :unprocessable_entity }
end
end
end
# PUT /series_statement_merges/1
# PUT /series_statement_merges/1.json
def update
respond_to do |format|
if @series_statement_merge.update(series_statement_merge_params)
flash[:notice] = t("controller.successfully_updated", model: t("activerecord.models.series_statement_merge"))
format.html { redirect_to(@series_statement_merge) }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @series_statement_merge.errors, status: :unprocessable_entity }
end
end
end
# DELETE /series_statement_merges/1
# DELETE /series_statement_merges/1.json
def destroy
@series_statement_merge.destroy
respond_to do |format|
format.html { redirect_to(series_statement_merges_url) }
format.json { head :no_content }
end
end
private
def set_series_statement_merge
@series_statement_merge = SeriesStatementMerge.find(params[:id])
authorize @series_statement_merge
end
def check_policy
authorize SeriesStatementMerge
end
def series_statement_merge_params
params.require(:series_statement_merge).permit(
:series_statement_id, :series_statement_merge_list_id
)
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/controllers/series_statements_controller.rb | app/controllers/series_statements_controller.rb | class SeriesStatementsController < ApplicationController
before_action :set_series_statement, only: [ :show, :edit, :update, :destroy ]
before_action :check_policy, only: [ :index, :new, :create ]
before_action :get_manifestation, except: [ :create, :update, :destroy ]
before_action :get_series_statement_merge_list, except: [ :create, :update, :destroy ]
# GET /series_statements
# GET /series_statements.json
def index
search = Sunspot.new_search(SeriesStatement)
query = params[:query].to_s.strip
page = params[:page] || 1
if query.present?
@query = query.dup
query = query.gsub(" ", " ")
end
search.build do
fulltext query if query.present?
paginate page: page.to_i, per_page: SeriesStatement.default_per_page
order_by :position, :asc
end
# work = @work
manifestation = @manifestation
series_statement_merge_list = @series_statement_merge_list
search.build do
with(:manifestation_id).equal_to manifestation.id if manifestation
with(:series_statement_merge_list_ids).equal_to series_statement_merge_list.id if series_statement_merge_list
end
page = params[:page] || 1
search.query.paginate(page.to_i, SeriesStatement.default_per_page)
search_result = search.execute!
@series_statements = search_result.results
respond_to do |format|
format.html # index.html.erb
end
end
# GET /series_statements/1
# GET /series_statements/1.json
def show
respond_to do |format|
format.html # show.html.erb
end
end
# GET /series_statements/new
def new
@series_statement = SeriesStatement.new
end
# GET /series_statements/1/edit
def edit
end
# POST /series_statements
# POST /series_statements.json
def create
@series_statement = SeriesStatement.new(series_statement_params)
manifestation = Manifestation.find(@series_statement.manifestation_id) rescue nil
respond_to do |format|
if @series_statement.save
@series_statement.manifestations << manifestation if manifestation
format.html { redirect_to @series_statement, notice: t("controller.successfully_created", model: t("activerecord.models.series_statement")) }
format.json { render json: @series_statement, status: :created, location: @series_statement }
else
@frequencies = Frequency.all
format.html { render action: "new" }
format.json { render json: @series_statement.errors, status: :unprocessable_entity }
end
end
end
# PUT /series_statements/1
# PUT /series_statements/1.json
def update
if params[:move]
move_position(@series_statement, params[:move])
return
end
respond_to do |format|
if @series_statement.update(series_statement_params)
format.html { redirect_to @series_statement, notice: t("controller.successfully_updated", model: t("activerecord.models.series_statement")) }
format.json { head :no_content }
else
@frequencies = Frequency.all
format.html { render action: "edit" }
format.json { render json: @series_statement.errors, status: :unprocessable_entity }
end
end
end
# DELETE /series_statements/1
# DELETE /series_statements/1.json
def destroy
@series_statement.destroy
respond_to do |format|
format.html { redirect_to series_statements_url }
format.json { head :no_content }
end
end
private
def set_series_statement
@series_statement = SeriesStatement.find(params[:id])
authorize @series_statement
end
def check_policy
authorize SeriesStatement
end
def series_statement_params
params.require(:series_statement).permit(
:original_title, :numbering, :title_subseries, :numbering_subseries,
:title_transcription, :title_alternative, :series_statement_identifier,
:note, :root_manifestation_id, :url,
:title_subseries_transcription, :creator_string, :volume_number_string,
:series_master
)
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/controllers/resource_import_files_controller.rb | app/controllers/resource_import_files_controller.rb | class ResourceImportFilesController < ApplicationController
before_action :set_resource_import_file, only: [ :show, :edit, :update, :destroy ]
before_action :check_policy, only: [ :index, :new, :create ]
before_action :prepare_options, only: [ :new, :edit ]
# GET /resource_import_files
# GET /resource_import_files.json
def index
@resource_import_files = ResourceImportFile.page(params[:page])
respond_to do |format|
format.html # index.html.erb
end
end
# GET /resource_import_files/1
# GET /resource_import_files/1.json
def show
@resource_import_results = @resource_import_file.resource_import_results.page(params[:page])
respond_to do |format|
format.html # show.html.erb
end
end
# GET /resource_import_files/new
def new
@resource_import_file = ResourceImportFile.new
@resource_import_file.library_id = current_user.profile.library_id
end
# GET /resource_import_files/1/edit
def edit
end
# POST /resource_import_files
# POST /resource_import_files.json
def create
@resource_import_file = ResourceImportFile.new(resource_import_file_params)
@resource_import_file.user = current_user
respond_to do |format|
if @resource_import_file.save
if @resource_import_file.mode == "import"
ResourceImportFileJob.perform_later(@resource_import_file)
end
format.html { redirect_to @resource_import_file, notice: t("import.successfully_created", model: t("activerecord.models.resource_import_file")) }
format.json { render json: @resource_import_file, status: :created, location: @resource_import_file }
else
prepare_options
format.html { render action: "new" }
format.json { render json: @resource_import_file.errors, status: :unprocessable_entity }
end
end
end
# PUT /resource_import_files/1
# PUT /resource_import_files/1.json
def update
respond_to do |format|
if @resource_import_file.update(resource_import_file_params)
if @resource_import_file.mode == "import"
ResourceImportFileJob.perform_later(@resource_import_file)
end
format.html { redirect_to @resource_import_file, notice: t("controller.successfully_updated", model: t("activerecord.models.resource_import_file")) }
format.json { head :no_content }
else
prepare_options
format.html { render action: "edit" }
format.json { render json: @resource_import_file.errors, status: :unprocessable_entity }
end
end
end
# DELETE /resource_import_files/1
# DELETE /resource_import_files/1.json
def destroy
@resource_import_file.destroy
respond_to do |format|
format.html { redirect_to resource_import_files_url, notice: t("controller.successfully_deleted", model: t("activerecord.models.resource_import_file")) }
format.json { head :no_content }
end
end
private
def set_resource_import_file
@resource_import_file = ResourceImportFile.find(params[:id])
authorize @resource_import_file
end
def check_policy
authorize ResourceImportFile
end
def resource_import_file_params
params.require(:resource_import_file).permit(
:attachment, :edit_mode, :user_encoding, :mode,
:default_shelf_id, :library_id
)
end
def prepare_options
@libraries = Library.all
library = Library.where(id: @resource_import_file.try(:library_id)).first
if library
@shelves = library.shelves
else
@shelves = current_user.profile.library.try(:shelves)
end
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/controllers/produce_types_controller.rb | app/controllers/produce_types_controller.rb | class ProduceTypesController < ApplicationController
before_action :set_produce_type, only: [ :show, :edit, :update, :destroy ]
before_action :check_policy, only: [ :index, :new, :create ]
# GET /produce_types
# GET /produce_types.json
def index
@produce_types = ProduceType.order(:position)
respond_to do |format|
format.html # index.html.erb
end
end
# GET /produce_types/1
# GET /produce_types/1.json
def show
respond_to do |format|
format.html # show.html.erb
end
end
# GET /produce_types/new
def new
@produce_type = ProduceType.new
end
# GET /produce_types/1/edit
def edit
end
# POST /produce_types
# POST /produce_types.json
def create
@produce_type = ProduceType.new(produce_type_params)
respond_to do |format|
if @produce_type.save
format.html { redirect_to @produce_type, notice: t("controller.successfully_created", model: t("activerecord.models.produce_type")) }
format.json { render json: @produce_type, status: :created, location: @produce_type }
else
format.html { render action: "new" }
format.json { render json: @produce_type.errors, status: :unprocessable_entity }
end
end
end
# PUT /produce_types/1
# PUT /produce_types/1.json
def update
if params[:move]
move_position(@produce_type, params[:move])
return
end
respond_to do |format|
if @produce_type.update(produce_type_params)
format.html { redirect_to @produce_type, notice: t("controller.successfully_updated", model: t("activerecord.models.produce_type")) }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @produce_type.errors, status: :unprocessable_entity }
end
end
end
# DELETE /produce_types/1
# DELETE /produce_types/1.json
def destroy
@produce_type.destroy
respond_to do |format|
format.html { redirect_to produce_types_url, notice: t("controller.successfully_deleted", model: t("activerecord.models.produce_type")) }
format.json { head :no_content }
end
end
private
def set_produce_type
@produce_type = ProduceType.find(params[:id])
authorize @produce_type
end
def check_policy
authorize ProduceType
end
def produce_type_params
params.require(:produce_type).permit(:name, :display_name, :note, :position)
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/controllers/event_import_results_controller.rb | app/controllers/event_import_results_controller.rb | class EventImportResultsController < ApplicationController
before_action :set_event_import_result, only: [ :show, :destroy ]
before_action :check_policy, only: [ :index ]
# GET /event_import_results
# GET /event_import_results.json
def index
@event_import_file = EventImportFile.find_by(id: params[:event_import_file_id])
if @event_import_file
@event_import_results = @event_import_file.event_import_results.order(created_at: :asc).page(params[:page])
else
@event_import_results = EventImportResult.order(created_at: :desc).page(params[:page])
end
respond_to do |format|
format.html # index.html.erb
format.text
end
end
# GET /event_import_results/1
# GET /event_import_results/1.json
def show
respond_to do |format|
format.html # show.html.erb
end
end
# DELETE /event_import_results/1
# DELETE /event_import_results/1.json
def destroy
@event_import_result.destroy
respond_to do |format|
format.html { redirect_to event_import_results_url, notice: t("controller.successfully_deleted", model: t("activerecord.models.event_import_result")) }
format.json { head :no_content }
end
end
private
def set_event_import_result
@event_import_result = EventImportResult.find(params[:id])
authorize @event_import_result
end
def check_policy
authorize EventImportResult
end
def event_import_result_params
params.require(:event_import_result).permit(
:event_id, :event_import_file_id, :body # , as: :admin
)
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/controllers/cinii_books_controller.rb | app/controllers/cinii_books_controller.rb | class CiniiBooksController < ApplicationController
before_action :check_policy, only: [ :index, :create ]
def index
if params[:page].to_i.zero?
page = 1
else
page = params[:page]
end
@query = params[:query].to_s.strip
begin
books = CiniiBook.search(params[:query], page)
@books = Kaminari.paginate_array(
books[:items], total_count: books[:total_entries]
).page(page).per(10)
rescue OpenURI::HTTPError
flash[:notice] = t("enju_nii.record_not_found")
@books = Kaminari.paginate_array([], total_count: 0).page(page).per(10)
end
respond_to do |format|
format.html
end
end
def create
if params[:book]
@manifestation = CiniiBook.import_ncid(params[:book][:ncid])
respond_to do |format|
if @manifestation.try(:save)
flash[:notice] = t("controller.successfully_created", model: t("activerecord.models.manifestation"))
format.html { redirect_to manifestation_url(@manifestation) }
else
flash[:notice] = t("enju_nii.record_not_found")
format.html { redirect_to cinii_books_url }
end
end
end
# rescue ActiveRecord::RecordInvalid => e
# respond_to do |format|
# flash[:notice] = e.message
# format.html { render :action => "index" }
# end
end
private
def check_policy
authorize CiniiBook
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/controllers/checkins_controller.rb | app/controllers/checkins_controller.rb | class CheckinsController < ApplicationController
before_action :set_checkin, only: [ :show, :edit, :update, :destroy ]
before_action :check_policy, only: [ :index, :new, :create ]
before_action :get_basket, only: [ :index, :create ]
# GET /checkins
# GET /checkins.json
def index
if @basket
@checkins = @basket.checkins.page(params[:page])
else
@checkins = Checkin.page(params[:page])
end
@checkin = Checkin.new
respond_to do |format|
format.html # index.html.erb
format.js
end
end
# GET /checkins/1
# GET /checkins/1.json
def show
# @checkin = Checkin.find(params[:id])
respond_to do |format|
format.html # show.html.erb
end
end
# GET /checkins/new
def new
flash[:message] = nil
if flash[:checkin_basket_id]
@basket = Basket.find(flash[:checkin_basket_id])
else
@basket = Basket.new
@basket.user = current_user
@basket.save!
end
@checkin = Checkin.new
@checkins = Kaminari::paginate_array([]).page(1)
flash[:checkin_basket_id] = @basket.id
end
# GET /checkins/1/edit
def edit
# @checkin = Checkin.find(params[:id])
end
# POST /checkins
# POST /checkins.json
def create
unless @basket
access_denied
return
end
@checkin = Checkin.new(checkin_params)
@checkin.basket = @basket
@checkin.librarian = current_user
flash[:message] = ""
respond_to do |format|
if @checkin.save
message = @checkin.item_checkin(current_user)
if @checkin.checkout
flash[:message] << t("checkin.successfully_checked_in")
else
flash[:message] << t("checkin.not_checked_out")
end
flash[:message] << message if message
format.html { redirect_to checkins_url(basket_id: @checkin.basket_id) }
format.json { render json: { result: @checkin, messages: flash[:message] }, status: :created, location: @checkin }
format.js { redirect_to checkins_url(basket_id: @basket.id, format: :js) }
else
@checkins = @basket.checkins.page(1)
format.html { render action: "new" }
format.json { render json: { messages: @checkin.errors }, status: :unprocessable_entity }
format.js { render action: "index" }
end
end
end
# PUT /checkins/1
# PUT /checkins/1.json
def update
@checkin.assign_attributes(checkin_params)
@checkin.librarian = current_user
respond_to do |format|
if @checkin.save
format.html { redirect_to @checkin, notice: t("controller.successfully_updated", model: t("activerecord.models.checkin")) }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @checkin.errors, status: :unprocessable_entity }
end
end
end
# DELETE /checkins/1
# DELETE /checkins/1.json
def destroy
# @checkin = Checkin.find(params[:id])
@checkin.destroy
respond_to do |format|
format.html { redirect_to checkins_url }
format.json { head :no_content }
end
end
private
def set_checkin
@checkin = Checkin.find(params[:id])
authorize @checkin
end
def check_policy
authorize Checkin
end
def checkin_params
params.require(:checkin).permit(:item_identifier)
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/controllers/manifestation_custom_properties_controller.rb | app/controllers/manifestation_custom_properties_controller.rb | class ManifestationCustomPropertiesController < ApplicationController
before_action :set_manifestation_custom_property, only: [ :show, :edit, :update, :destroy ]
before_action :check_policy, only: [ :index, :new, :create ]
# GET /manifestation_custom_properties
def index
@manifestation_custom_properties = ManifestationCustomProperty.order(:position)
end
# GET /manifestation_custom_properties/1
def show
end
# GET /manifestation_custom_properties/new
def new
@manifestation_custom_property = ManifestationCustomProperty.new
end
# GET /manifestation_custom_properties/1/edit
def edit
end
# POST /manifestation_custom_properties
def create
@manifestation_custom_property = ManifestationCustomProperty.new(manifestation_custom_property_params)
if @manifestation_custom_property.save
redirect_to @manifestation_custom_property, notice: t("controller.successfully_created", model: t("activerecord.models.manifestation_custom_property"))
else
render :new
end
end
# PATCH/PUT /manifestation_custom_properties/1
def update
if params[:move]
move_position(@manifestation_custom_property, params[:move])
return
end
if @manifestation_custom_property.update(manifestation_custom_property_params)
redirect_to @manifestation_custom_property, notice: t("controller.successfully_updated", model: t("activerecord.models.manifestation_custom_property"))
else
render :edit
end
end
# DELETE /manifestation_custom_properties/1
def destroy
@manifestation_custom_property.destroy
redirect_to manifestation_custom_properties_url, notice: t("controller.successfully_deleted", model: t("activerecord.models.manifestation_custom_property"))
end
private
# Use callbacks to share common setup or constraints between actions.
def set_manifestation_custom_property
@manifestation_custom_property = ManifestationCustomProperty.find(params[:id])
authorize @manifestation_custom_property
end
def check_policy
authorize ManifestationCustomProperty
end
# Only allow a trusted parameter "white list" through.
def manifestation_custom_property_params
params.require(:manifestation_custom_property).permit(:name, :display_name, :note)
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/controllers/items_controller.rb | app/controllers/items_controller.rb | class ItemsController < ApplicationController
include EnjuInventory::Controller
before_action :set_item, only: [ :show, :edit, :update, :destroy ]
before_action :check_policy, only: [ :index, :new, :create ]
before_action :get_agent, :get_manifestation, :get_shelf, except: [ :create, :update, :destroy ]
before_action :get_inventory_file
before_action :get_library, :get_item, except: [ :create, :update, :destroy ]
before_action :prepare_options, only: [ :new, :edit ]
after_action :convert_charset, only: :index
# GET /items
# GET /items.json
def index
query = params[:query].to_s.strip
per_page = Item.default_per_page
@count = {}
if user_signed_in?
if current_user.has_role?("Librarian")
if request.format.text?
per_page = 65534
elsif params[:mode] == "barcode"
per_page = 40
end
end
end
if defined?(InventoryFile)
if @inventory_file
if user_signed_in?
if current_user.has_role?("Librarian")
case params[:inventory]
when "not_in_catalog"
mode = "not_in_catalog"
else
mode = "not_on_shelf"
end
order = "items.id"
@items = Item.inventory_items(@inventory_file, mode).order(order).page(params[:page]).per(per_page)
else
access_denied
return
end
else
redirect_to new_user_session_url
return
end
end
end
unless @inventory_file
search = Sunspot.new_search(Item)
selected_attributes = [
:id, :item_identifier, :call_number, :manifestation_id, :acquired_at,
:binding_item_identifier, :binding_call_number, :binded_at,
:include_supplements, :url, :note,
:circulation_status_id, :shelf_id,
:created_at, :updated_at
]
selected_attributes += [
:memo, :required_role_id, :budget_type_id, :bookstore_id, :price
] if current_user.try(:has_role?, "Librarian")
search.data_accessor_for(Item).select = selected_attributes
set_role_query(current_user, search)
@query = query.dup
if query.present?
search.build do
fulltext query
end
end
agent = @agent
manifestation = @manifestation
shelf = @shelf
unless params[:mode] == "add"
search.build do
with(:agent_ids).equal_to agent.id if agent
with(:manifestation_id).equal_to manifestation.id if manifestation
with(:shelf_id).equal_to shelf.id if shelf
with(:circulation_status).equal_to params[:circulation_status] if params[:circulation_status].present?
facet :circulation_status if defined?(EnjuCirculation)
end
end
search.build do
order_by(:created_at, :desc)
end
role = current_user.try(:role) || Role.default
search.build do
with(:required_role_id).less_than_or_equal_to role.id
end
if params[:acquired_from].present?
begin
acquired_from = Time.zone.parse(params[:acquired_from]).beginning_of_day
@acquired_from = acquired_from.strftime("%Y-%m-%d")
rescue ArgumentError
rescue NoMethodError
end
end
if params[:acquired_until].present?
begin
acquired_until = @acquired_until = Time.zone.parse(params[:acquired_until]).end_of_day
@acquired_until = acquired_until.strftime("%Y-%m-%d")
rescue ArgumentError
rescue NoMethodError
end
end
search.build do
with(:acquired_at).greater_than_or_equal_to acquired_from.beginning_of_day if acquired_from
with(:acquired_at).less_than acquired_until.tomorrow.beginning_of_day if acquired_until
end
page = params[:page] || 1
search.query.paginate(page.to_i, per_page)
result = search.execute
@circulation_status_facet = result.facet(:circulation_status).rows if defined?(EnjuCirculation)
@items = result.results
@count[:total] = @items.total_entries
end
flash[:page_info] = { page: page, query: query }
respond_to do |format|
format.html # index.html.erb
format.json
format.text
format.atom
end
end
# GET /items/1
# GET /items/1.json
def show
@manifestation ||= @item.manifestation
respond_to do |format|
format.html # show.html.erb
format.json
end
end
# GET /items/new
def new
if Shelf.real.blank?
flash[:notice] = t("item.create_shelf_first")
redirect_to libraries_url
return
end
unless @manifestation
flash[:notice] = t("item.specify_manifestation")
redirect_to manifestations_url
return
end
if @manifestation.series_master?
flash[:notice] = t("item.specify_manifestation")
redirect_to manifestations_url(parent_id: @manifestation.id)
return
end
@item = Item.new(library_id: @library.id)
@item.shelf = @library.shelves.first
@item.manifestation = @manifestation
if defined?(EnjuCirculation)
@circulation_statuses = CirculationStatus.where(
name: [
"In Process",
"Available For Pickup",
"Available On Shelf",
"Claimed Returned Or Never Borrowed",
"Not Available" ]
).order(:position)
@item.circulation_status = CirculationStatus.find_by(name: "In Process")
@item.checkout_type = @manifestation.carrier_type.checkout_types.first
@item.item_has_use_restriction = ItemHasUseRestriction.new
@item.item_has_use_restriction.use_restriction = UseRestriction.find_by(name: "Not For Loan")
end
end
# GET /items/1/edit
def edit
@item.library_id = @item.shelf.library_id
@manifestation = @item.manifestation
if defined?(EnjuCirculation)
unless @item.use_restriction
@item.build_item_has_use_restriction
@item.item_has_use_restriction.use_restriction = UseRestriction.find_by(name: "Not For Loan")
end
end
end
# POST /items
# POST /items.json
def create
@item = Item.new(item_params)
@item.manifestation = Manifestation.find(@item.manifestation_id)
respond_to do |format|
if @item.save
Item.transaction do
if defined?(EnjuCirculation)
if @item.reserved?
flash[:message] = t("item.this_item_is_reserved")
@item.retain(current_user)
end
end
end
format.html { redirect_to(@item, notice: t("controller.successfully_created", model: t("activerecord.models.item"))) }
format.json { render json: @item, status: :created, location: @item }
else
prepare_options
format.html { render action: "new" }
format.json { render json: @item.errors, status: :unprocessable_entity }
end
end
end
# PUT /items/1
# PUT /items/1.json
def update
respond_to do |format|
if @item.update(item_params)
format.html { redirect_to @item, notice: t("controller.successfully_updated", model: t("activerecord.models.item")) }
format.json { head :no_content }
else
prepare_options
format.html { render action: "edit" }
format.json { render json: @item.errors, status: :unprocessable_entity }
end
end
end
# DELETE /items/1
# DELETE /items/1.json
def destroy
manifestation = @item.manifestation
@item.destroy
respond_to do |format|
flash[:notice] = t("controller.successfully_deleted", model: t("activerecord.models.item"))
if @item.manifestation
format.html { redirect_to items_url(manifestation_id: manifestation.id) }
format.json { head :no_content }
else
format.html { redirect_to items_url }
format.json { head :no_content }
end
end
end
private
def set_item
@item = Item.find(params[:id])
authorize @item
end
def check_policy
authorize Item
end
def item_params
params.require(:item).permit(
:call_number, :item_identifier, :circulation_status_id,
:checkout_type_id, :shelf_id, :include_supplements, :note, :url, :price,
:acquired_at, :bookstore_id, :missing_since, :budget_type_id,
:lock_version, :manifestation_id, :library_id, :required_role_id,
:binding_item_identifier, :binding_call_number, :binded_at,
:use_restriction_id, :memo,
{ item_has_use_restriction_attributes: :use_restriction_id }, # EnjuCirculation
{ item_custom_values_attributes: [
:id, :item_custom_property_id, :item_id, :value, :_destroy
] }
)
end
def prepare_options
@libraries = Library.order(:position)
if @item
@library = @item.shelf.library
else
@library = Library.real.includes(:shelves).order(:position).first
end
@shelves = @library.try(:shelves)
@bookstores = Bookstore.order(:position)
@budget_types = BudgetType.order(:position)
@roles = Role.all
if defined?(EnjuCirculation)
@circulation_statuses = CirculationStatus.order(:position)
@use_restrictions = UseRestriction.available
if @manifestation
@checkout_types = CheckoutType.available_for_carrier_type(@manifestation.carrier_type)
else
@checkout_types = CheckoutType.order(:position)
end
end
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/controllers/roles_controller.rb | app/controllers/roles_controller.rb | class RolesController < ApplicationController
before_action :set_role, only: [ :show, :edit, :update ]
before_action :check_policy, only: [ :index ]
# GET /roles
# GET /roles.json
def index
@roles = Role.order(:position)
respond_to do |format|
format.html # index.html.erb
end
end
# GET /roles/1
# GET /roles/1.json
def show
respond_to do |format|
format.html # show.html.erb
end
end
# GET /roles/1/edit
def edit
end
# PUT /roles/1
# PUT /roles/1.json
def update
if params[:move]
move_position(@role, params[:move])
return
end
respond_to do |format|
if @role.update(role_params)
format.html { redirect_to @role, notice: t("controller.successfully_updated", model: t("activerecord.models.role")) }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @role.errors, status: :unprocessable_entity }
end
end
end
private
def set_role
@role = Role.find(params[:id])
authorize @role
end
def check_policy
authorize Role
end
def role_params
params.require(:role).permit(:name, :display_name, :note)
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/controllers/checkout_types_controller.rb | app/controllers/checkout_types_controller.rb | class CheckoutTypesController < ApplicationController
before_action :set_checkout_type, only: [ :show, :edit, :update, :destroy ]
before_action :check_policy, only: [ :index, :new, :create ]
before_action :get_user_group
# GET /checkout_types
# GET /checkout_types.json
def index
if @user_group
@checkout_types = @user_group.checkout_types.order("checkout_types.position")
else
@checkout_types = CheckoutType.order(:position)
end
respond_to do |format|
format.html # index.html.erb
end
end
# GET /checkout_types/1
# GET /checkout_types/1.json
def show
if @user_group
@checkout_type = @user_group.checkout_types.find(params[:id])
end
respond_to do |format|
format.html # show.html.erb
end
end
# GET /checkout_types/new
def new
if @user_group
@checkout_type = @user_group.checkout_types.new
else
@checkout_type = CheckoutType.new
end
end
# GET /checkout_types/1/edit
def edit
end
# POST /checkout_types
# POST /checkout_types.json
def create
if @user_group
@checkout_type = @user_group.checkout_types.new(checkout_type_params)
else
@checkout_type = CheckoutType.new(checkout_type_params)
end
respond_to do |format|
if @checkout_type.save
format.html { redirect_to @checkout_type, notice: t("controller.successfully_created", model: t("activerecord.models.checkout_type")) }
format.json { render json: @checkout_type, status: :created, location: @checkout_type }
else
format.html { render action: "new" }
format.json { render json: @checkout_type.errors, status: :unprocessable_entity }
end
end
end
# PUT /checkout_types/1
# PUT /checkout_types/1.json
def update
if params[:move]
move_position(@checkout_type, params[:move])
return
end
respond_to do |format|
if @checkout_type.update(checkout_type_params)
format.html { redirect_to @checkout_type, notice: t("controller.successfully_updated", model: t("activerecord.models.checkout_type")) }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @checkout_type.errors, status: :unprocessable_entity }
end
end
end
# DELETE /checkout_types/1
# DELETE /checkout_types/1.json
def destroy
if @user_group
@checkout_type = @user_group.checkout_types.find(params[:id])
end
@checkout_type.destroy
respond_to do |format|
format.html { redirect_to checkout_types_url }
format.json { head :no_content }
end
end
private
def set_checkout_type
@checkout_type = CheckoutType.find(params[:id])
authorize @checkout_type
end
def check_policy
authorize CheckoutType
end
def checkout_type_params
params.require(:checkout_type).permit(:name, :display_name, :note)
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/controllers/subject_heading_types_controller.rb | app/controllers/subject_heading_types_controller.rb | class SubjectHeadingTypesController < ApplicationController
before_action :set_subject_heading_type, only: [ :show, :edit, :update, :destroy ]
before_action :check_policy, only: [ :index, :new, :create ]
# GET /subject_heading_types
# GET /subject_heading_types.json
def index
@subject_heading_types = SubjectHeadingType.order(:position)
respond_to do |format|
format.html # index.html.erb
end
end
# GET /subject_heading_types/1
# GET /subject_heading_types/1.json
def show
respond_to do |format|
format.html # show.html.erb
end
end
# GET /subject_heading_types/new
def new
@subject_heading_type = SubjectHeadingType.new
end
# GET /subject_heading_types/1/edit
def edit
end
# POST /subject_heading_types
# POST /subject_heading_types.json
def create
@subject_heading_type = SubjectHeadingType.new(subject_heading_type_params)
respond_to do |format|
if @subject_heading_type.save
format.html { redirect_to @subject_heading_type, notice: t("controller.successfully_created", model: t("activerecord.models.subject_heading_type")) }
format.json { render json: @subject_heading_type, status: :created, location: @subject_heading_type }
else
format.html { render action: "new" }
format.json { render json: @subject_heading_type.errors, status: :unprocessable_entity }
end
end
end
# PUT /subject_heading_types/1
# PUT /subject_heading_types/1.json
def update
if params[:move]
move_position(@subject_heading_type, params[:move])
return
end
respond_to do |format|
if @subject_heading_type.update(subject_heading_type_params)
format.html { redirect_to @subject_heading_type, notice: t("controller.successfully_updated", model: t("activerecord.models.subject_heading_type")) }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @subject_heading_type.errors, status: :unprocessable_entity }
end
end
end
# DELETE /subject_heading_types/1
# DELETE /subject_heading_types/1.json
def destroy
@subject_heading_type.destroy
respond_to do |format|
format.html { redirect_to subject_heading_types_url, notice: t("controller.successfully_deleted", model: t("activerecord.models.subject_heading_type")) }
format.json { head :no_content }
end
end
private
def set_subject_heading_type
@subject_heading_type = SubjectHeadingType.find(params[:id])
authorize @subject_heading_type
end
def check_policy
authorize SubjectHeadingType
end
def subject_heading_type_params
params.require(:subject_heading_type).permit(:name, :display_name, :note)
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/controllers/budget_types_controller.rb | app/controllers/budget_types_controller.rb | class BudgetTypesController < ApplicationController
before_action :set_budget_type, only: [ :show, :edit, :update, :destroy ]
before_action :check_policy, only: [ :index, :new, :create ]
# GET /budget_types
# GET /budget_types.json
def index
@budget_types = BudgetType.order(:position)
respond_to do |format|
format.html # index.html.erb
end
end
# GET /budget_types/1
# GET /budget_types/1.json
def show
respond_to do |format|
format.html # show.html.erb
end
end
# GET /budget_types/new
def new
@budget_type = BudgetType.new
end
# GET /budget_types/1/edit
def edit
end
# POST /budget_types
# POST /budget_types.json
def create
@budget_type = BudgetType.new(budget_type_params)
respond_to do |format|
if @budget_type.save
format.html { redirect_to @budget_type, notice: t("controller.successfully_created", model: t("activerecord.models.budget_type")) }
format.json { render json: @budget_type, status: :created, location: @budget_type }
else
format.html { render action: "new" }
format.json { render json: @budget_type.errors, status: :unprocessable_entity }
end
end
end
# PUT /budget_types/1
# PUT /budget_types/1.json
def update
if params[:move]
move_position(@budget_type, params[:move])
return
end
respond_to do |format|
if @budget_type.update(budget_type_params)
format.html { redirect_to @budget_type, notice: t("controller.successfully_updated", model: t("activerecord.models.budget_type")) }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @budget_type.errors, status: :unprocessable_entity }
end
end
end
# DELETE /budget_types/1
# DELETE /budget_types/1.json
def destroy
@budget_type.destroy
respond_to do |format|
format.html { redirect_to budget_types_url, notice: t("controller.successfully_deleted", model: t("activerecord.models.budget_type")) }
format.json { head :no_content }
end
end
private
def set_budget_type
@budget_type = BudgetType.find(params[:id])
authorize @budget_type
end
def check_policy
authorize BudgetType
end
def budget_type_params
params.require(:budget_type).permit(
:name, :display_name, :note, :position
)
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/controllers/events_controller.rb | app/controllers/events_controller.rb | class EventsController < ApplicationController
include EnjuEvent::EnjuLibrariesController
before_action :store_page, only: :index
before_action :set_event, only: [ :show, :edit, :update, :destroy ]
before_action :check_policy, only: [ :index, :new, :create ]
before_action :get_library, :get_agent
before_action :get_libraries, except: :destroy
before_action :prepare_options
after_action :convert_charset, only: :index
# GET /events
# GET /events.json
def index
@count = {}
query = params[:query].to_s.strip
@query = query.dup
query = query.gsub(" ", " ")
tag = params[:tag].to_s if params[:tag].present?
date = params[:date].to_s if params[:date].present?
per_page = (params[:format] == "json") ? 500 : Event.default_per_page
mode = params[:mode]
search = Sunspot.new_search(Event)
library = @library
search.build do
fulltext query if query.present?
with(:library_id).equal_to library.id if library
# with(:tag).equal_to tag
if date
with(:start_at).less_than_or_equal_to Time.zone.parse(date)
with(:end_at).greater_than Time.zone.parse(date)
end
if params[:start].present? && params[:end].present?
with(:start_at).greater_than_or_equal_to Time.zone.parse(params[:start])
with(:end_at).less_than_or_equal_to Time.zone.parse(params[:end]).end_of_day
end
case mode
when "upcoming"
with(:start_at).greater_than Time.zone.now.beginning_of_day
when "past"
with(:start_at).less_than Time.zone.now.beginning_of_day
end
order_by(:start_at, :desc)
end
page = params[:page] || 1
search.query.paginate(page.to_i, per_page)
@events = search.execute!.results
@count[:query_result] = @events.total_entries
respond_to do |format|
format.html # index.html.erb
format.html.phone
format.json
format.rss
format.text
format.atom
format.ics
end
end
# GET /events/1
# GET /events/1.json
def show
respond_to do |format|
format.html # show.html.erb
format.html.phone
end
end
# GET /events/new
def new
prepare_options
if params[:date]
begin
date = Time.zone.parse(params[:date])
rescue ArgumentError
date = Time.zone.now.beginning_of_day
flash[:notice] = t("page.invalid_date")
end
else
date = Time.zone.now.beginning_of_day
end
@event = Event.new(start_at: date, end_at: date)
@event.library = @library
end
# GET /events/1/edit
def edit
prepare_options
end
# POST /events
# POST /events.json
def create
@event = Event.new(event_params)
@event.set_date
respond_to do |format|
if @event.save
flash[:notice] = t("controller.successfully_created", model: t("activerecord.models.event"))
format.html { redirect_to(@event) }
format.json { render json: @event, status: :created, location: @event }
else
prepare_options
format.html { render action: "new" }
format.json { render json: @event.errors, status: :unprocessable_entity }
end
end
end
# PUT /events/1
# PUT /events/1.json
def update
@event = Event.find(params[:id])
@event.set_date
respond_to do |format|
if @event.update(event_params)
flash[:notice] = t("controller.successfully_updated", model: t("activerecord.models.event"))
format.html { redirect_to(@event) }
format.json { head :no_content }
else
prepare_options
format.html { render action: "edit" }
format.json { render json: @event.errors, status: :unprocessable_entity }
end
end
end
# DELETE /events/1
# DELETE /events/1.json
def destroy
@event.destroy
respond_to do |format|
format.html { redirect_to events_url }
format.json { head :no_content }
end
end
private
def set_event
@event = Event.find(params[:id])
authorize @event
end
def check_policy
authorize Event
end
def event_params
params.require(:event).permit(
:library_id, :event_category_id, :name, :note, :start_at,
:end_at, :all_day, :display_name
)
end
def prepare_options
@event_categories = EventCategory.all
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/controllers/agent_types_controller.rb | app/controllers/agent_types_controller.rb | class AgentTypesController < ApplicationController
before_action :set_agent_type, only: [ :show, :edit, :update, :destroy ]
before_action :check_policy, only: [ :index, :new, :create ]
# GET /agent_types
# GET /agent_types.json
def index
@agent_types = AgentType.order(:position)
respond_to do |format|
format.html # index.html.erb
end
end
# GET /agent_types/1
# GET /agent_types/1.json
def show
respond_to do |format|
format.html # show.html.erb
end
end
# GET /agent_types/new
def new
@agent_type = AgentType.new
end
# GET /agent_types/1/edit
def edit
end
# POST /agent_types
# POST /agent_types.json
def create
@agent_type = AgentType.new(agent_type_params)
respond_to do |format|
if @agent_type.save
format.html { redirect_to @agent_type, notice: t("controller.successfully_created", model: t("activerecord.models.agent_type")) }
format.json { render json: @agent_type, status: :created, location: @agent_type }
else
format.html { render action: "new" }
format.json { render json: @agent_type.errors, status: :unprocessable_entity }
end
end
end
# PUT /agent_types/1
# PUT /agent_types/1.json
def update
if params[:move]
move_position(@agent_type, params[:move])
return
end
respond_to do |format|
if @agent_type.update(agent_type_params)
format.html { redirect_to @agent_type, notice: t("controller.successfully_updated", model: t("activerecord.models.agent_type")) }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @agent_type.errors, status: :unprocessable_entity }
end
end
end
# DELETE /agent_types/1
# DELETE /agent_types/1.json
def destroy
@agent_type.destroy
respond_to do |format|
format.html { redirect_to agent_types_url, notice: t("controller.successfully_deleted", model: t("activerecord.models.agent_type")) }
format.json { head :no_content }
end
end
private
def set_agent_type
@agent_type = AgentType.find(params[:id])
authorize @agent_type
end
def check_policy
authorize AgentType
end
def agent_type_params
params.require(:agent_type).permit(:name, :display_name, :note)
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/controllers/inventories_controller.rb | app/controllers/inventories_controller.rb | class InventoriesController < ApplicationController
before_action :set_inventory, only: [ :show ]
before_action :check_policy, only: [ :index ]
# GET /inventories
# GET /inventories.json
def index
@inventories = Inventory.page(params[:page])
respond_to do |format|
format.html # index.html.erb
end
end
# GET /inventories/1
# GET /inventories/1.json
def show
respond_to do |format|
format.html # show.html.erb
end
end
private
def set_inventory
@inventory = Inventory.find(params[:id])
authorize @inventory
end
def check_policy
authorize Inventory
end
def inventory_params
params.require(:inventory).permit(
:item_id, :inventory_id, :note
)
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.