Skip to content

Commit

Permalink
Add rails_admin config models
Browse files Browse the repository at this point in the history
  • Loading branch information
Nguyen Binh Dieu committed Jun 17, 2015
1 parent 91cad99 commit f2e74bc
Show file tree
Hide file tree
Showing 11 changed files with 89 additions and 3 deletions.
13 changes: 13 additions & 0 deletions app/models/concerns/rails_admin_repeat.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module RailsAdminRepeat
extend ActiveSupport::Concern

included do
rails_admin do
list do
field :id
field :repeat_type
field :user
end
end
end
end
14 changes: 14 additions & 0 deletions app/models/concerns/rails_admin_room.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module RailsAdminRoom
extend ActiveSupport::Concern

included do
rails_admin do
list do
field :id
field :name
field :color
field :created_at
end
end
end
end
16 changes: 16 additions & 0 deletions app/models/concerns/rails_admin_schedule.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module RailsAdminSchedule
extend ActiveSupport::Concern

included do
rails_admin do
list do
field :id
field :title
field :user
field :start_time
field :finish_time
field :created_at
end
end
end
end
9 changes: 9 additions & 0 deletions app/models/concerns/rails_admin_schedule_user.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module RailsAdminScheduleUser
extend ActiveSupport::Concern

included do
rails_admin do
visible false
end
end
end
23 changes: 23 additions & 0 deletions app/models/concerns/rails_admin_user.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
module RailsAdminUser
extend ActiveSupport::Concern

included do
rails_admin do
list do
field :id
field :name
field :email
field :avatar
field :created_at
end

edit do
field :id
field :name
field :email
field :role
field :avatar
end
end
end
end
2 changes: 2 additions & 0 deletions app/models/repeat.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
class Repeat < ActiveRecord::Base
include RailsAdminRepeat

enum repeat_type: [:week, :month]

has_many :schedules, dependent: :destroy
Expand Down
2 changes: 2 additions & 0 deletions app/models/room.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
class Room < ActiveRecord::Base
include RailsAdminRoom

has_many :schedules, dependent: :destroy

validates :name, presence: true
Expand Down
1 change: 1 addition & 0 deletions app/models/schedule.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
class Schedule < ActiveRecord::Base
include ScheduleJson
include RailsAdminSchedule

belongs_to :user
belongs_to :room
Expand Down
2 changes: 2 additions & 0 deletions app/models/schedule_user.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
class ScheduleUser < ActiveRecord::Base
include RailsAdminScheduleUser

belongs_to :member, class_name: "User", foreign_key: :user_id
belongs_to :event, class_name: "Schedule", foreign_key: :schedule_id
end
1 change: 1 addition & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
class User < ActiveRecord::Base
include RailsAdminUser
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
Expand Down
9 changes: 6 additions & 3 deletions config/initializers/rails_admin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@
config.actions do
dashboard
index
new
new do
except [Repeat]
end
export
bulk_delete
show
edit
edit do
except [Repeat]
end
delete
show_in_app
end
end

0 comments on commit f2e74bc

Please sign in to comment.