diff --git a/app/controllers/admin/links_controller.rb b/app/controllers/admin/links_controller.rb index 63744182..ad146fc5 100644 --- a/app/controllers/admin/links_controller.rb +++ b/app/controllers/admin/links_controller.rb @@ -37,7 +37,7 @@ class Admin::LinksController < Admin::ItemsController link = Link.find(params[:id]) m = {} m["public"] = link.is_published ? 1 : 0 - m["link"] = @site_valid_locales.inject([]) do |result, locale| + m["link"] = @site_in_use_locales.inject([]) do |result, locale| result << [locale, (link.enabled_for && link.enabled_for.include?(locale)) ? 1 : 0, (link.menu_enabled_for && link.menu_enabled_for[locale].eql?("true")) ? 1 :0] end render json: JSON.pretty_generate(m) diff --git a/app/controllers/admin/pages_controller.rb b/app/controllers/admin/pages_controller.rb index ef16c878..7f3ecde4 100644 --- a/app/controllers/admin/pages_controller.rb +++ b/app/controllers/admin/pages_controller.rb @@ -73,7 +73,7 @@ class Admin::PagesController < Admin::ItemsController m["category"] = page.category.present? ? page.category.map{|c| c.to_s} : [] m["tags"] = page.tag.present? ? page.tag.map{|c| c.to_s} : [] m["public"] = page.is_published ? 1 : 0 - m["link"] = @site_valid_locales.inject([]) do |link, locale| + m["link"] = @site_in_use_locales.inject([]) do |link, locale| link << [locale, (page.enabled_for && page.enabled_for.include?(locale)) ? 1 : 0, (page.menu_enabled_for && page.menu_enabled_for[locale].eql?('true')) ? 1 :0] end m["count"] = page.frontend_data_count diff --git a/app/controllers/admin/sites_controller.rb b/app/controllers/admin/sites_controller.rb index 96088f42..50d399a9 100644 --- a/app/controllers/admin/sites_controller.rb +++ b/app/controllers/admin/sites_controller.rb @@ -21,6 +21,7 @@ class Admin::SitesController < OrbitBackendController end def update + params[:site][:defalut_locale] = "zh_tw" if params[:site][:default_locale].blank? @site.update_attributes(params[:site]) redirect_to :back end @@ -71,6 +72,13 @@ class Admin::SitesController < OrbitBackendController end + def reset_default_locale + @site.defalut_locale = params[:default_locale] + if @site.save + render :nothing => true + end + end + def change_design design = Design.find(params[:site_id]) rescue nil update_design(design) if design diff --git a/app/helpers/admin/assets_helper.rb b/app/helpers/admin/assets_helper.rb index 9a2fd0a3..acc65c11 100644 --- a/app/helpers/admin/assets_helper.rb +++ b/app/helpers/admin/assets_helper.rb @@ -2,7 +2,7 @@ module Admin::AssetsHelper def show_all_fields(asset, field) a = [] - @site_valid_locales.each do |locale| + @site_in_use_locales.each do |locale| a << asset.send("#{field}_translations")[locale] rescue nil end a.join(' - ') diff --git a/app/helpers/admin/tags_helper.rb b/app/helpers/admin/tags_helper.rb index a9c48c3a..4d195e63 100644 --- a/app/helpers/admin/tags_helper.rb +++ b/app/helpers/admin/tags_helper.rb @@ -6,7 +6,7 @@ module Admin::TagsHelper end def show_names_slash(tag) - span_names = @site_valid_locales.inject([]) do |names, locale| + span_names = @site_in_use_locales.inject([]) do |names, locale| names << content_tag(:span, tag.name_translations[locale], class: "tag") end span_names.join(" / ").html_safe diff --git a/app/models/user/user.rb b/app/models/user/user.rb index 2bfc4eeb..88760a32 100644 --- a/app/models/user/user.rb +++ b/app/models/user/user.rb @@ -59,7 +59,8 @@ class User validates :user_id, :presence => { :message => I18n.t("users.user_id_not_null") } , - :length => {:minimum => 3, :maximum => 50, :message => I18n.t("users.user_id_length") } + :length => {:minimum => 3, :maximum => 50, :message => I18n.t("users.user_id_length") }, + :uniqueness => true def email_required? false diff --git a/app/views/admin/ad_images/_form.html.erb b/app/views/admin/ad_images/_form.html.erb index 71d6dbf4..1ddecf8b 100644 --- a/app/views/admin/ad_images/_form.html.erb +++ b/app/views/admin/ad_images/_form.html.erb @@ -166,7 +166,7 @@