From e57a3f569d2b494d018e7d7303b6167979c132a3 Mon Sep 17 00:00:00 2001 From: Luke Barratt Date: Sun, 10 Aug 2014 23:56:18 +0100 Subject: [PATCH] Added site layout configuration for users --- app/helpers/application_helper.rb | 6 ++- app/models/user.rb | 4 ++ app/views/users/edit.html.erb | 6 +++ .../20140810224606_add_layout_to_profile.rb | 5 ++ db/schema.rb | 49 ++++++++++++++++++- 5 files changed, 68 insertions(+), 2 deletions(-) create mode 100644 db/migrate/20140810224606_add_layout_to_profile.rb diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 9f01cac..2e74fbe 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -10,7 +10,11 @@ module ApplicationHelper end def active_theme - 'default' + if cuser && cuser.profile + cuser.current_layout + else + 'default' + end end def theme_stylesheet_link_tag diff --git a/app/models/user.rb b/app/models/user.rb index bd284d8..86d0da7 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -177,6 +177,10 @@ class User < ActiveRecord::Base a end + def current_layout + profile.layout || 'default' + end + def joined created_at.strftime("%d %b %y") end diff --git a/app/views/users/edit.html.erb b/app/views/users/edit.html.erb index 45188eb..b9a17de 100644 --- a/app/views/users/edit.html.erb +++ b/app/views/users/edit.html.erb @@ -109,6 +109,12 @@

Daylight savings will be observed automatically.

+
+ <%= p.label :layout %> +
+ <%= p.select :layout, ['default', 'flat'] %> +
+
diff --git a/db/migrate/20140810224606_add_layout_to_profile.rb b/db/migrate/20140810224606_add_layout_to_profile.rb new file mode 100644 index 0000000..8279800 --- /dev/null +++ b/db/migrate/20140810224606_add_layout_to_profile.rb @@ -0,0 +1,5 @@ +class AddLayoutToProfile < ActiveRecord::Migration + def change + add_column :profiles, :layout, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index bc13abc..f58c688 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,21 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20140510080652) do +ActiveRecord::Schema.define(:version => 20140810224606) do + + create_table "admin_requests", :force => true do |t| + t.string "addr" + t.string "pwd" + t.integer "server_id" + t.string "player" + t.integer "user_id" + t.string "msg" + t.datetime "created_at" + t.datetime "updated_at" + end + + add_index "admin_requests", ["server_id"], :name => "index_admin_requests_on_server_id" + add_index "admin_requests", ["user_id"], :name => "index_admin_requests_on_user_id" create_table "article_versions", :force => true do |t| t.integer "article_id" @@ -200,6 +214,16 @@ ActiveRecord::Schema.define(:version => 20140510080652) do add_index "data_files", ["directory_id"], :name => "index_data_files_on_directory_id" add_index "data_files", ["related_id"], :name => "index_data_files_on_related_id" + create_table "deleteds", :force => true do |t| + t.integer "deletable_id" + t.string "deletable_type" + t.integer "user_id" + t.text "reason" + t.datetime "created_at" + t.datetime "updated_at" + t.integer "related_id" + end + create_table "directories", :force => true do |t| t.string "name" t.string "description" @@ -212,6 +236,21 @@ ActiveRecord::Schema.define(:version => 20140510080652) do add_index "directories", ["parent_id"], :name => "index_directories_on_parent_id" + create_table "firms", :force => true do |t| + t.string "name" + t.string "y_code" + t.string "email" + t.string "website" + t.string "phone" + t.string "address" + t.integer "zipcode" + t.string "town" + t.integer "owner" + t.string "opentime" + t.datetime "created_at" + t.datetime "updated_at" + end + create_table "forumers", :force => true do |t| t.integer "forum_id" t.integer "group_id" @@ -478,6 +517,13 @@ ActiveRecord::Schema.define(:version => 20140510080652) do add_index "movies", ["status"], :name => "index_movies_on_status" add_index "movies", ["user_id"], :name => "index_movies_on_user_id" + create_table "nodes", :force => true do |t| + t.string "name" + t.integer "foreign_key" + t.datetime "created_at" + t.datetime "updated_at" + end + create_table "options", :force => true do |t| t.string "option" t.integer "poll_id" @@ -587,6 +633,7 @@ ActiveRecord::Schema.define(:version => 20140510080652) do t.string "achievements_parsed" t.string "signature_parsed" t.string "stream" + t.string "layout" end add_index "profiles", ["user_id"], :name => "index_profiles_on_user_id"