fix admin interface

This commit is contained in:
Torsten Ruger 2016-05-17 16:28:34 +03:00
parent d8eecde011
commit 8cf2cb577f
8 changed files with 205 additions and 3 deletions

View File

@ -6,7 +6,7 @@ gem 'coffee-rails', '~> 4.1.0'
gem 'jquery-rails'
gem 'jbuilder', '~> 2.0'
gem "therubyracer"
gem 'administrate'
gem 'administrate' , "0.1.5"
gem 'bootstrap-sass'
gem 'devise'
gem 'devise_invitable'

View File

@ -44,7 +44,7 @@ GEM
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
addressable (2.4.0)
administrate (0.2.0)
administrate (0.1.5)
autoprefixer-rails (~> 6.0)
datetime_picker_rails (~> 0.0.7)
jquery-rails (~> 4.0)
@ -360,7 +360,7 @@ PLATFORMS
ruby
DEPENDENCIES
administrate
administrate (= 0.1.5)
animate-scss!
best_in_place
better_errors

View File

@ -0,0 +1,19 @@
module Admin
class CoursesController < Admin::ApplicationController
# To customize the behavior of this controller,
# simply overwrite any of the RESTful actions. For example:
#
# def index
# super
# @resources = Course.all.paginate(10, params[:page])
# end
# Define a custom finder by overriding the `find_resource` method:
# def find_resource(param)
# Course.find_by!(slug: param)
# end
# See https://administrate-docs.herokuapp.com/customizing_controller_actions
# for more information
end
end

View File

@ -0,0 +1,19 @@
module Admin
class ResumesController < Admin::ApplicationController
# To customize the behavior of this controller,
# simply overwrite any of the RESTful actions. For example:
#
# def index
# super
# @resources = Resume.all.paginate(10, params[:page])
# end
# Define a custom finder by overriding the `find_resource` method:
# def find_resource(param)
# Resume.find_by!(slug: param)
# end
# See https://administrate-docs.herokuapp.com/customizing_controller_actions
# for more information
end
end

View File

@ -0,0 +1,57 @@
require "administrate/base_dashboard"
class CourseDashboard < Administrate::BaseDashboard
# ATTRIBUTE_TYPES
# a hash that describes the type of each of the model's fields.
#
# Each different type represents an Administrate::Field object,
# which determines how the attribute is displayed
# on pages throughout the dashboard.
ATTRIBUTE_TYPES = {
id: Field::Number,
name: Field::String,
extra: Field::String,
start: Field::DateTime,
created_at: Field::DateTime,
updated_at: Field::DateTime,
}
# COLLECTION_ATTRIBUTES
# an array of attributes that will be displayed on the model's index page.
#
# By default, it's limited to four items to reduce clutter on index pages.
# Feel free to add, remove, or rearrange items.
COLLECTION_ATTRIBUTES = [
:id,
:name,
:extra,
:start,
]
# SHOW_PAGE_ATTRIBUTES
# an array of attributes that will be displayed on the model's show page.
SHOW_PAGE_ATTRIBUTES = [
:id,
:name,
:extra,
:start,
:created_at,
:updated_at,
]
# FORM_ATTRIBUTES
# an array of attributes that will be displayed
# on the model's form (`new` and `edit`) pages.
FORM_ATTRIBUTES = [
:name,
:extra,
:start,
]
# Overwrite this method to customize how courses are displayed
# across all pages of the admin dashboard.
#
# def display_resource(course)
# "Course ##{course.id}"
# end
end

View File

@ -0,0 +1,93 @@
require "administrate/base_dashboard"
class ResumeDashboard < Administrate::BaseDashboard
# ATTRIBUTE_TYPES
# a hash that describes the type of each of the model's fields.
#
# Each different type represents an Administrate::Field object,
# which determines how the attribute is displayed
# on pages throughout the dashboard.
ATTRIBUTE_TYPES = {
user: Field::BelongsTo,
id: Field::Number,
street: Field::String,
city: Field::String,
country: Field::String,
school: Field::Text,
uni: Field::Text,
internship: Field::Text,
work: Field::Text,
projects: Field::Text,
soft_skills: Field::Text,
tech_skills: Field::Text,
interests: Field::Text,
motivation: Field::Text,
finance: Field::Text,
other: Field::Text,
created_at: Field::DateTime,
updated_at: Field::DateTime,
}
# COLLECTION_ATTRIBUTES
# an array of attributes that will be displayed on the model's index page.
#
# By default, it's limited to four items to reduce clutter on index pages.
# Feel free to add, remove, or rearrange items.
COLLECTION_ATTRIBUTES = [
:user,
:id,
:street,
:city,
]
# SHOW_PAGE_ATTRIBUTES
# an array of attributes that will be displayed on the model's show page.
SHOW_PAGE_ATTRIBUTES = [
:user,
:id,
:street,
:city,
:country,
:school,
:uni,
:internship,
:work,
:projects,
:soft_skills,
:tech_skills,
:interests,
:motivation,
:finance,
:other,
:created_at,
:updated_at,
]
# FORM_ATTRIBUTES
# an array of attributes that will be displayed
# on the model's form (`new` and `edit`) pages.
FORM_ATTRIBUTES = [
:user,
:street,
:city,
:country,
:school,
:uni,
:internship,
:work,
:projects,
:soft_skills,
:tech_skills,
:interests,
:motivation,
:finance,
:other,
]
# Overwrite this method to customize how resumes are displayed
# across all pages of the admin dashboard.
#
# def display_resource(resume)
# "Resume ##{resume.id}"
# end
end

View File

@ -26,6 +26,8 @@ class UserDashboard < Administrate::BaseDashboard
confirmed_at: Field::DateTime,
confirmation_sent_at: Field::DateTime,
unconfirmed_email: Field::String,
role: Field::String.with_options(searchable: false),
course_id: Field::Number,
}
# COLLECTION_ATTRIBUTES
@ -61,6 +63,8 @@ class UserDashboard < Administrate::BaseDashboard
:confirmed_at,
:confirmation_sent_at,
:unconfirmed_email,
:role,
:course_id,
]
# FORM_ATTRIBUTES
@ -82,6 +86,8 @@ class UserDashboard < Administrate::BaseDashboard
:confirmed_at,
:confirmation_sent_at,
:unconfirmed_email,
:role,
:course_id,
]
# Overwrite this method to customize how users are displayed

View File

@ -1,5 +1,13 @@
Rails.application.routes.draw do
namespace :admin do
resources :users
resources :courses
resources :resumes
root to: "users#index"
end
devise_for :users, controllers: { registrations: "registrations" }
resources :users , except: [:index , :new ]