Skip to content

Commit

Permalink
🤖
Browse files Browse the repository at this point in the history
  • Loading branch information
bonflintstone committed Oct 31, 2024
1 parent 71e6879 commit 8e64e2e
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions app/models/event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Event < ApplicationRecord
ORGANIZATIONS = ORGANIZATIONS_BY_TYPE.values.flatten.uniq

validates :name, :location, :datetime, :link, presence: true
validates :name, uniqueness: { scope: [:datetime, :organization] }
validates :name, uniqueness: { scope: [ :datetime, :organization ] }
validates :organization, inclusion: { in: ORGANIZATIONS }

scope :published, -> { where.not(approved_at: nil).or(where(source: :scraper)) }
Expand All @@ -17,5 +17,5 @@ class Event < ApplicationRecord

def date = datetime.to_date

def source_enum = [:scraper, :webform] # for rails_admin
def source_enum = [ :scraper, :webform ] # for rails_admin
end
6 changes: 3 additions & 3 deletions config/initializers/rails_admin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
config.asset_source = :sprockets

config.authenticate_with do
authenticate_or_request_with_http_basic('Login required') do |username, password|
username == 'admin' && ActiveSupport::SecurityUtils.secure_compare(password, ENV['ADMIN_PASSWORD'])
authenticate_or_request_with_http_basic("Login required") do |username, password|
username == "admin" && ActiveSupport::SecurityUtils.secure_compare(password, ENV["ADMIN_PASSWORD"])
end
end

Expand All @@ -21,7 +21,7 @@

config.model Event do
list do
scopes [nil, :published, :to_approve, :approved]
scopes [ nil, :published, :to_approve, :approved ]
end
end
end
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Rails.application.routes.draw do
mount RailsAdmin::Engine => '/admin', as: 'rails_admin'
mount RailsAdmin::Engine => "/admin", as: "rails_admin"
# Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html

# Reveal health status on /up that returns 200 if the app boots with no exceptions, otherwise 500.
Expand Down
2 changes: 1 addition & 1 deletion db/migrate/20241031101411_adds_approved_at_to_events.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class AddsApprovedAtToEvents < ActiveRecord::Migration[7.2]
def change
create_enum :event_source, %w(scraper webform)
create_enum :event_source, %w[scraper webform]

add_column :events, :approved_at, :datetime
add_column :events, :source, :event_source
Expand Down

0 comments on commit 8e64e2e

Please sign in to comment.