Change role structure
Still needs to: change the views and create sub_roles in the dev.rake
This commit is contained in:
1 parent
e0cdedfa2e
commit
b7ac5478b4
45 files changed
+608
-492
No files matched your search
@@ -0,0 +1,49 @@
|
||||
class Admin::InfosController < ApplicationController
|
||||
|
||||
layout "admin"
|
||||
before_filter :authenticate_user!
|
||||
before_filter :is_admin?
|
||||
before_filter :set_attribute, :only => [:index, :show, :new, :edit]
|
||||
|
||||
def index
|
||||
@attributes = Info.all.entries
|
||||
render :template => 'admin/attributes/index'
|
||||
end
|
||||
|
||||
def show
|
||||
#@attribute = Info.find(params[:id])
|
||||
end
|
||||
|
||||
def new
|
||||
@attribute = Info.new
|
||||
end
|
||||
|
||||
def edit
|
||||
@attribute = Info.find(params[:id])
|
||||
@i18n_variable = @attribute.i18n_variable
|
||||
end
|
||||
|
||||
def create
|
||||
@attribute = Info.new(params[:info])
|
||||
@attribute.save
|
||||
redirect_to :action => :index
|
||||
end
|
||||
|
||||
def update
|
||||
@attribute = Info.find(params[:id])
|
||||
@attribute.update_attributes(params[:info])
|
||||
end
|
||||
|
||||
def destroy
|
||||
@attribute = Info.find(params[:id])
|
||||
@attribute.destroy
|
||||
redirect_to :action => :index
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def set_attribute
|
||||
@attribute_type = 'info'
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,54 @@
|
||||
class Admin::RolesController < ApplicationController
|
||||
|
||||
layout "admin"
|
||||
before_filter :authenticate_user!
|
||||
before_filter :is_admin?
|
||||
before_filter :set_attribute, :only => [:index, :show, :new, :edit]
|
||||
|
||||
def index
|
||||
@attributes = Role.all.entries
|
||||
render :template => 'admin/attributes/index'
|
||||
end
|
||||
|
||||
def show
|
||||
#@attribute = Role.find(params[:id])
|
||||
end
|
||||
|
||||
def new
|
||||
@attribute = Role.new
|
||||
end
|
||||
|
||||
def edit
|
||||
@attribute = Role.find(params[:id])
|
||||
@i18n_variable = @attribute.i18n_variable
|
||||
end
|
||||
|
||||
def create
|
||||
@attribute = Role.new(params[:role])
|
||||
@attribute.save
|
||||
redirect_to :action => :index
|
||||
end
|
||||
|
||||
def update
|
||||
@attribute = Role.find(params[:id])
|
||||
@attribute.update_attributes(params[:role])
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to :action => :index }
|
||||
format.js { render 'admin/attributes/toggle_enable' }
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
@attribute = Role.find(params[:id])
|
||||
@attribute.destroy
|
||||
redirect_to :action => :index
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def set_attribute
|
||||
@attribute_type = 'role'
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,58 +0,0 @@
|
||||
class Admin::UserInfoModelsController < ApplicationController
|
||||
|
||||
layout "admin"
|
||||
before_filter :authenticate_user!
|
||||
before_filter :is_admin?
|
||||
before_filter :set_attribute, :only => [:index, :show, :new, :edit]
|
||||
|
||||
def index
|
||||
@user_attribute_models = UserInfoModel.all.entries
|
||||
render :template => 'admin/user_attribute_models/index'
|
||||
end
|
||||
|
||||
def show
|
||||
#@user_attribute_model = UserInfoModel.find(params[:id])
|
||||
end
|
||||
|
||||
def new
|
||||
@user_attribute_model = UserInfoModel.new
|
||||
render :template => 'admin/user_attribute_models/new'
|
||||
end
|
||||
|
||||
def edit
|
||||
@user_attribute_model = UserInfoModel.find(params[:id])
|
||||
@i18n_variable = @user_attribute_model.i18n_variable
|
||||
render :template => 'admin/user_attribute_models/edit'
|
||||
end
|
||||
|
||||
def create
|
||||
@user_attribute_model = UserInfoModel.new(params[:user_info_model])
|
||||
@user_attribute_model.save
|
||||
redirect_to :action => :index
|
||||
end
|
||||
|
||||
def update
|
||||
@user_attribute_model = UserInfoModel.find(params[:id])
|
||||
@user_attribute_model.update_attributes(params[:user_info_model])
|
||||
respond_to do |format|
|
||||
format.html { redirect_to :action => :index }
|
||||
format.js { render 'admin/user_attribute_models/toggle_enable' }
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
@user_attribute_model = UserInfoModel.find(params[:id])
|
||||
@user_attribute_model.destroy
|
||||
|
||||
@user_attribute_model.destroy_i18n_variables
|
||||
|
||||
redirect_to :action => :index
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def set_attribute
|
||||
@attribute = 'info'
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,59 +0,0 @@
|
||||
class Admin::UserRoleModelsController < ApplicationController
|
||||
|
||||
layout "admin"
|
||||
before_filter :authenticate_user!
|
||||
before_filter :is_admin?
|
||||
before_filter :set_attribute, :only => [:index, :show, :new, :edit]
|
||||
|
||||
def index
|
||||
@user_attribute_models = UserRoleModel.all.entries
|
||||
render :template => 'admin/user_attribute_models/index'
|
||||
end
|
||||
|
||||
def show
|
||||
#@user_attribute_model = UserRoleModel.find(params[:id])
|
||||
end
|
||||
|
||||
def new
|
||||
@user_attribute_model = UserRoleModel.new
|
||||
render :template => 'admin/user_attribute_models/new'
|
||||
end
|
||||
|
||||
def edit
|
||||
@user_attribute_model = UserRoleModel.find(params[:id])
|
||||
@i18n_variable = @user_attribute_model.i18n_variable
|
||||
render :template => 'admin/user_attribute_models/edit'
|
||||
end
|
||||
|
||||
def create
|
||||
@user_attribute_model = UserRoleModel.new(params[:user_role_model])
|
||||
@user_attribute_model.save
|
||||
redirect_to :action => :index
|
||||
end
|
||||
|
||||
def update
|
||||
@user_attribute_model = UserRoleModel.find(params[:id])
|
||||
@user_attribute_model.update_attributes(params[:user_role_model])
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to :action => :index }
|
||||
format.js { render 'admin/user_attribute_models/toggle_enable' }
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
@user_attribute_model = UserRoleModel.find(params[:id])
|
||||
@user_attribute_model.destroy
|
||||
|
||||
@user_attribute_model.destroy_i18n_variables
|
||||
|
||||
redirect_to :action => :index
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def set_attribute
|
||||
@attribute = 'role'
|
||||
end
|
||||
|
||||
end
|
||||
@@ -20,13 +20,13 @@ class Admin::UsersController < ApplicationController
|
||||
def create
|
||||
@user = User.new(params[:user])
|
||||
if @user.save
|
||||
@user.user_infos.each do |user_info|
|
||||
user_info.save
|
||||
user_info.attribute_values.each(&:save)
|
||||
@user.user_infos.each do |info|
|
||||
info.save
|
||||
info.attribute_values.each(&:save)
|
||||
end
|
||||
@user.user_roles.each do |user_role|
|
||||
user_role.save
|
||||
user_role.attribute_values.each(&:save)
|
||||
@user.roles.each do |role|
|
||||
role.save
|
||||
role.attribute_values.each(&:save)
|
||||
end
|
||||
flash[:notice] = t('admin.create_success_user')
|
||||
redirect_to :action => :index
|
||||
@@ -77,8 +77,8 @@ class Admin::UsersController < ApplicationController
|
||||
protected
|
||||
|
||||
def get_info_role_models
|
||||
@user_info_models = UserInfoModel.excludes('disabled' => true)
|
||||
@user_role_models = UserRoleModel.excludes('disabled' => true)
|
||||
@roles = Info.excludes('disabled' => true)
|
||||
@infos = Role.excludes('disabled' => true)
|
||||
end
|
||||
|
||||
end
|
||||
@@ -7,6 +7,8 @@ class I18nVariable
|
||||
field :document_class, :type => String
|
||||
field :parent_id, :type => BSON::ObjectId, :index => true
|
||||
|
||||
belongs_to :language_value, polymorphic: true
|
||||
|
||||
def method_missing(field)
|
||||
self[field]
|
||||
end
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
class Attribute
|
||||
|
||||
include Mongoid::Document
|
||||
include Mongoid::Timestamps
|
||||
|
||||
field :key
|
||||
field :built_in, :type => Boolean, :default => false
|
||||
field :disabled, :type => Boolean, :default => false
|
||||
|
||||
embeds_many :attribute_fields
|
||||
has_one :i18n_variable, :as => :language_value, :autosave => true, :dependent => :destroy
|
||||
accepts_nested_attributes_for :i18n_variable, :allow_destroy => true
|
||||
accepts_nested_attributes_for :attribute_fields, :allow_destroy => true
|
||||
|
||||
def is_built_in?
|
||||
self.built_in
|
||||
end
|
||||
|
||||
def is_disabled?
|
||||
self.disabled
|
||||
end
|
||||
|
||||
def get_enabled_attribute_fields
|
||||
self.attribute_fields.excludes('disabled' => true)
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,37 @@
|
||||
class AttributeField
|
||||
|
||||
include Mongoid::Document
|
||||
include Mongoid::Timestamps
|
||||
|
||||
field :key
|
||||
field :markup
|
||||
field :locale, :type => Boolean
|
||||
field :list_options, :type => Array
|
||||
field :built_in, :type => Boolean, :default => false
|
||||
field :disabled, :type => Boolean, :default => false
|
||||
|
||||
embedded_in :attribute
|
||||
has_one :i18n_variable, :as => :language_value, :autosave => true, :dependent => :destroy
|
||||
has_many :attribute_values
|
||||
validates_uniqueness_of :key
|
||||
accepts_nested_attributes_for :i18n_variable, :allow_destroy => true
|
||||
|
||||
# Convert the string list_options into an array
|
||||
def select_list_options=(var)
|
||||
self.list_options = var.gsub(' ', '').split(',')
|
||||
end
|
||||
|
||||
# Convert the array list_options into a string
|
||||
def select_list_options
|
||||
self.list_options.to_a.join(', ')
|
||||
end
|
||||
|
||||
def is_built_in?
|
||||
self.built_in
|
||||
end
|
||||
|
||||
def is_disabled?
|
||||
self.disabled
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,62 +0,0 @@
|
||||
class AttributeModel
|
||||
|
||||
include Mongoid::Document
|
||||
include Mongoid::Timestamps
|
||||
|
||||
field :key
|
||||
field :i18n_variable_id, :type => BSON::ObjectId, :index => true
|
||||
field :markup
|
||||
field :locale, :type => Boolean
|
||||
field :list_options, :type => Array
|
||||
field :built_in, :type => Boolean, :default => false
|
||||
field :disabled, :type => Boolean, :default => false
|
||||
|
||||
embedded_in :user_attribute_model
|
||||
validates_uniqueness_of :key
|
||||
|
||||
# Destroy the i18n_variable
|
||||
def destroy_i18n_variable
|
||||
self.i18n_variable.destroy rescue nil
|
||||
end
|
||||
|
||||
# Get the i18n_variable
|
||||
def i18n_variable
|
||||
@i18n_variable ||= I18nVariable.find(self.i18n_variable_id) rescue nil
|
||||
end
|
||||
|
||||
# Update or create the i18n_variable record
|
||||
def i18n_variable=(attr)
|
||||
if self.i18n_variable_id
|
||||
self.i18n_variable.update_attributes(attr)
|
||||
else
|
||||
# var = I18nVariable.new(attr.merge({:key => self.key, :document_class => self.class, :parent_id => self.user_attribute_model.i18n_variable_id}))
|
||||
var = I18nVariable.new(attr.merge({:key => self.key, :document_class => self.class}))
|
||||
var.save
|
||||
self.i18n_variable_id = var.id
|
||||
end
|
||||
end
|
||||
|
||||
# Convert the string list_options into an array
|
||||
def select_list_options=(var)
|
||||
self.list_options = var.gsub(' ', '').split(',')
|
||||
end
|
||||
|
||||
# Convert the array list_options into a string
|
||||
def select_list_options
|
||||
self.list_options.to_a.join(', ')
|
||||
end
|
||||
|
||||
# Check if the attribute is set to be destroyed
|
||||
def should_destroy?
|
||||
should_destroy.to_i == 1 rescue nil
|
||||
end
|
||||
|
||||
def is_built_in?
|
||||
self.built_in
|
||||
end
|
||||
|
||||
def is_disabled?
|
||||
self.disabled
|
||||
end
|
||||
|
||||
end
|
||||
@@ -5,6 +5,7 @@ class AttributeValue
|
||||
|
||||
field :key
|
||||
|
||||
belongs_to :user_attribute
|
||||
belongs_to :attribute_field
|
||||
belongs_to :user
|
||||
|
||||
end
|
||||
@@ -0,0 +1,3 @@
|
||||
class Info < Attribute
|
||||
|
||||
end
|
||||
@@ -0,0 +1,29 @@
|
||||
class Role
|
||||
|
||||
include Mongoid::Document
|
||||
include Mongoid::Timestamps
|
||||
|
||||
field :key
|
||||
field :built_in, :type => Boolean, :default => false
|
||||
field :disabled, :type => Boolean, :default => false
|
||||
|
||||
embeds_many :sub_roles
|
||||
has_one :i18n_variable, :as => :language_value, :autosave => true, :dependent => :destroy
|
||||
has_many :users
|
||||
accepts_nested_attributes_for :i18n_variable, :allow_destroy => true
|
||||
accepts_nested_attributes_for :sub_roles, :allow_destroy => true
|
||||
|
||||
def is_built_in?
|
||||
self.built_in
|
||||
end
|
||||
|
||||
def is_disabled?
|
||||
self.disabled
|
||||
end
|
||||
|
||||
# Get an role from key
|
||||
def self.get_role_from_key(key)
|
||||
self.first(:conditions => {:key => key})
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,10 @@
|
||||
class SubRole < Attribute
|
||||
|
||||
has_many :users
|
||||
|
||||
# Get an sub_role from key
|
||||
def self.get_sub_role_from_key(key)
|
||||
self.first(:conditions => {:key => key})
|
||||
end
|
||||
|
||||
end
|
||||
+4
-37
@@ -10,43 +10,10 @@ class User
|
||||
field :admin, :type => Boolean, :default => true
|
||||
field :active_role
|
||||
|
||||
has_many :user_attributes
|
||||
has_many :user_roles
|
||||
has_many :user_infos
|
||||
|
||||
# Update or create the user_role records
|
||||
def user_roles=(*attrs)
|
||||
attrs[0].each do |roles|
|
||||
if roles[:id].blank?
|
||||
user_roles.build(roles)
|
||||
else
|
||||
user_role = user_roles.detect {|a| a.id.to_s == roles[:id].to_s }
|
||||
user_role.update_attributes(roles)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Update or create the user_info records
|
||||
def user_infos=(*attrs)
|
||||
attrs[0].each do |infos|
|
||||
if infos[:id].blank?
|
||||
user_infos.build(infos)
|
||||
else
|
||||
user_info = user_infos.detect {|a| a.id.to_s == infos[:id].to_s }
|
||||
user_info.update_attributes(infos)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Get an user_info from model key
|
||||
def get_info_from_model_key(key)
|
||||
self.user_infos.detect {|a| a.key.to_s == key.to_s }
|
||||
end
|
||||
|
||||
# Get an user_role from model key
|
||||
def get_role_from_model_key(key)
|
||||
self.user_roles.detect {|a| a.key.to_s == key.to_s }
|
||||
end
|
||||
has_many :attribute_values, :autosave => true, :dependent => :destroy
|
||||
belongs_to :role
|
||||
belongs_to :sub_role
|
||||
accepts_nested_attributes_for :attribute_values, :allow_destroy => true
|
||||
|
||||
def name
|
||||
infos = self.user_infos.detect {|info| info.key.to_s.eql?('profile') }
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
class UserAttribute
|
||||
|
||||
include Mongoid::Document
|
||||
include Mongoid::Timestamps
|
||||
|
||||
field :key
|
||||
has_many :attribute_values
|
||||
|
||||
# Update or create the attribute_value records
|
||||
def attribute_values=(*args)
|
||||
args[0].each do |value|
|
||||
if value[:id].blank?
|
||||
attribute_values.build(value)
|
||||
else
|
||||
attribute_value = attribute_values.detect {|a| a.id.to_s == value[:id].to_s }
|
||||
attribute_value.update_attributes(value)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,74 +0,0 @@
|
||||
class UserAttributeModel
|
||||
|
||||
include Mongoid::Document
|
||||
include Mongoid::Timestamps
|
||||
|
||||
field :key
|
||||
field :i18n_variable_id, :type => BSON::ObjectId, :index => true
|
||||
field :built_in, :type => Boolean, :default => false
|
||||
field :disabled, :type => Boolean, :default => false
|
||||
|
||||
embeds_many :attribute_models
|
||||
|
||||
after_update :destroy_attrs
|
||||
|
||||
# Update or create the attribute_model records
|
||||
def attribute_models=(*attrs)
|
||||
attrs[0].each do |attributes|
|
||||
if attributes[:id].blank?
|
||||
attribute_models.build(attributes)
|
||||
else
|
||||
attribute_model = attribute_models.detect {|a| a.id.to_s == attributes[:id].to_s }
|
||||
attribute_model.update_attributes(attributes)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Destroy the i18n_variables
|
||||
def destroy_i18n_variables
|
||||
self.i18n_variable.destroy rescue nil
|
||||
self.attribute_models.each do |attr|
|
||||
attr.destroy_i18n_variable
|
||||
end
|
||||
end
|
||||
|
||||
# Update or create the i18n_variable record
|
||||
def i18n_variable=(attr)
|
||||
if self.i18n_variable_id
|
||||
self.i18n_variable.update_attributes(attr) rescue nil
|
||||
else
|
||||
var = I18nVariable.new(attr.merge({:key => self.key, :document_class => self.class}))
|
||||
var.save
|
||||
self.i18n_variable_id = var.id
|
||||
end
|
||||
end
|
||||
|
||||
# Get the i18n_variable
|
||||
def i18n_variable
|
||||
@i18n_variable ||= I18nVariable.find(self.i18n_variable_id) rescue nil
|
||||
end
|
||||
|
||||
def is_built_in?
|
||||
self.built_in
|
||||
end
|
||||
|
||||
def is_disabled?
|
||||
self.disabled.blank? ? false : self.disabled
|
||||
end
|
||||
|
||||
def get_enabled_attribute_models
|
||||
self.attribute_models.excludes('disabled' => true)
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
# Destroy the i18n_variable for each attribute_models if marked to destroy
|
||||
def destroy_attrs
|
||||
attribute_models.each do |a|
|
||||
if a.should_destroy?
|
||||
a.destroy_i18n_variable
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,5 +0,0 @@
|
||||
class UserInfo < UserAttribute
|
||||
|
||||
belongs_to :user
|
||||
|
||||
end
|
||||
@@ -1,3 +0,0 @@
|
||||
class UserInfoModel < UserAttributeModel
|
||||
|
||||
end
|
||||
@@ -1,5 +0,0 @@
|
||||
class UserRole < UserAttribute
|
||||
|
||||
belongs_to :user
|
||||
|
||||
end
|
||||
@@ -1,8 +0,0 @@
|
||||
class UserRoleModel < UserAttributeModel
|
||||
|
||||
# Get an user_role_model from key
|
||||
def self.get_role_model_from_key(key)
|
||||
self.first(:conditions => {:key => key})
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,36 @@
|
||||
<%= fields_for "user_#{@attribute_type}_model[attribute_models][]", attribute_model, :index => nil do |f| %>
|
||||
<tr class="list_item">
|
||||
<td><%= attribute_model.new_record? ? (f.text_field :key) : attribute_model.key %></td>
|
||||
<td class='select_mulitlingual' style='text-align:center'>
|
||||
<%= check_box_tag "locale[]", value = '', attribute_model.locale.nil? ? true : attribute_model.locale %>
|
||||
<%= hidden_field_tag "user_#{@attribute_type}_model[attribute_models][][locale]", attribute_model.locale.nil? ? true : attribute_model.locale %>
|
||||
</td>
|
||||
<% @site_valid_locales.each do |locale| %>
|
||||
<td><%= text_field_tag "user_#{@attribute_type}_model[attribute_models][][i18n_variable][#{locale}]", (attribute_model.i18n_variable[locale] rescue nil), :style => "width:130px" %></td>
|
||||
<% end %>
|
||||
<td class='select_type'>
|
||||
<%= f.select :markup, LIST[:markups], {}, {:style => "width:90px"} %>
|
||||
<div <%= attribute_model[:markup].eql?('select') ? nil : "style='display:none'"%>>
|
||||
<%= t('admin.options') %>:
|
||||
<%= text_field_tag "user_#{@attribute_type}_model[attribute_models][][select_list_options]", attribute_model.select_list_options, :style => "width:130px" %>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<span class="action">
|
||||
<% if attribute_model.new_record? %>
|
||||
<a href="#" class="delete"><%= t(:delete) %></a>
|
||||
<% else %>
|
||||
<% if attribute_model.is_built_in? %>
|
||||
<a href="#" class="change_built_in switch" id="<%= attribute_model.id %>"></a>
|
||||
<%= hidden_field_tag "user_#{@attribute_type}_model[attribute_models][][disabled]", attribute_model.is_disabled? , :class => 'built_in_state' %>
|
||||
<% else %>
|
||||
<a href="#" class="remove_existing_record delete"><%= t(:delete) %></a>
|
||||
<%= hidden_field_tag "user_#{@attribute_type}_model[attribute_models][][should_destroy]", nil , :class => 'should_destroy' %>
|
||||
<% end %>
|
||||
<%= f.hidden_field :id %>
|
||||
<%= f.hidden_field :key %>
|
||||
<% end %>
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
@@ -0,0 +1,57 @@
|
||||
<div id="UserRole_block" class="roles_block">
|
||||
<h2><%= t("admin.user_#{@attribute_type}") %></h2>
|
||||
<div class="info_input">
|
||||
<table border="0" cellspacing="0" cellpadding="0">
|
||||
<thead class="list_head">
|
||||
<tr>
|
||||
<td><%= t('admin.key') %></td>
|
||||
<% @site_valid_locales.each do |locale| %>
|
||||
<td style="color:<%= colorize_in_use_locale(locale) %>"><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %></td>
|
||||
<% end %>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr class="list_item">
|
||||
<td><%= is_new ? (f.text_field :key, {:style => "width:150px"}) : @attribute.key %></td>
|
||||
<% @site_valid_locales.each do |locale| %>
|
||||
<td>
|
||||
<%= text_field_tag "user_#{@attribute_type}_model[i18n_variable][#{locale}]", (@i18n_variable[locale] if @i18n_variable), :style => "width:150px" %>
|
||||
</td>
|
||||
<% end %>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div id="attributes_block" class="roles_block">
|
||||
<h2>Attributes</h2>
|
||||
<div class="info_input">
|
||||
<table id='attributes' border="0" cellspacing="0" cellpadding="0">
|
||||
<thead class="list_head">
|
||||
<tr>
|
||||
<td><%= t('admin.key') %></td>
|
||||
<td><%= t('admin.multilingual') %></td>
|
||||
<% @site_valid_locales.each do |locale| %>
|
||||
<td style="color:<%= colorize_in_use_locale(locale) %>"><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %></td>
|
||||
<% end %>
|
||||
<td><%= t('admin.type')%></td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td colspan="5"><a href="#" class="add"><%= t(:add) %></a></td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
<tbody>
|
||||
<%= render :partial => 'admin/attributes/attribute_model', :collection => @attribute.attribute_models %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<% content_for :page_specific_javascript do %>
|
||||
<%= javascript_include_tag "attribute_form" %>
|
||||
<% end -%>
|
||||
@@ -0,0 +1,16 @@
|
||||
<% content_for :secondary do %>
|
||||
<%= render 'admin/users/side_bar' %>
|
||||
<% end %>
|
||||
|
||||
<div id="porfile">
|
||||
<%= form_for @attribute, :url => eval("admin_user_#{@attribute_type}_model_path(@user_role_model)") do |f| %>
|
||||
<%= f.error_messages %>
|
||||
<%= render :partial => "admin/attributes/form", :locals => { :f => f, :is_new => false } %>
|
||||
<div id="update" class='buttom clear'>
|
||||
<%= link_to t('update'), "#", :onclick=>"$('#edit_user_role_model_#{@attribute.id}').submit()" %>
|
||||
</div>
|
||||
<div id="back" class='buttom clear'>
|
||||
<%= link_back %>
|
||||
</div>
|
||||
<% end -%>
|
||||
</div>
|
||||
@@ -0,0 +1,34 @@
|
||||
<% content_for :secondary do %>
|
||||
<%= render 'admin/users/side_bar' %>
|
||||
<% end %>
|
||||
|
||||
<div class="main_list">
|
||||
<div id="add_new" class="buttom clear">
|
||||
<%= link_to t("admin.new_#{@attribute_type}"), eval("new_admin_#{@attribute_type}_path") %>
|
||||
</div>
|
||||
<ul>
|
||||
<li class="list_head clear">
|
||||
<span class="<%= @attribute_type %>s"><%= t("admin.#{@attribute_type}") %></span>
|
||||
<span class="action"><%= t('admin.action') %></span>
|
||||
</li>
|
||||
<% @attributes.each do |attribute| %>
|
||||
<li id="attribute_<%= attribute.id %>" class="list_item <%= "#{attribute.is_disabled? ? 'disable' : ''}" %> clear">
|
||||
<span class="<%= @attribute_type %>s <%= attribute.i18n_variable[:key].downcase %>"><%= attribute.i18n_variable[I18n.locale] %></span>
|
||||
<span class="action">
|
||||
|
||||
<%= link_to t(:edit), eval("edit_admin_#{@attribute_type}_path(attribute)"), :class => 'edit' %>
|
||||
<% if attribute.is_built_in? %>
|
||||
<%= link_to t(:enable), eval("admin_#{@attribute_type}_path(attribute, :authenticity_token => form_authenticity_token, :#{@attribute_type} => {:disabled => true})"), :remote => true, :method => :put, :id => "disable_#{attribute.id}", :style => "display:#{attribute.is_disabled? ? 'none' : ''}", :class => 'switch' %>
|
||||
<%= link_to t(:disable), eval("admin_#{@attribute_type}_path(attribute, :authenticity_token => form_authenticity_token, :#{@attribute_type} => {:disabled => false})"), :remote => true, :method => :put, :id => "enable_#{attribute.id}", :style => "display:#{attribute.is_disabled? ? '' : 'none'}", :class => 'switch' %>
|
||||
<% else %>
|
||||
<%= link_to t(:delete), eval("admin_#{@attribute_type}_path(attribute)"), :class => 'delete', :confirm => t('sure?'), :method => :delete %>
|
||||
<% end %>
|
||||
|
||||
</span>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
<div id="add_new" class="buttom clear">
|
||||
<%= link_to t("admin.new_#{@attribute_type}"), eval("new_admin_#{@attribute_type}_path") %>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,20 @@
|
||||
<% content_for :secondary do %>
|
||||
<%= render 'admin/users/side_bar' %>
|
||||
<% end %>
|
||||
|
||||
<div id="porfile">
|
||||
<%= form_for @attribute, :url => eval("admin_infos_path") do |f| %>
|
||||
<%= f.error_messages %>
|
||||
<%= render :partial => "admin/infos/form", :locals => { :f => f, :is_new => true } %>
|
||||
<div id="create" class='buttom clear'>
|
||||
<%= link_to t('create'), "#", :onclick=>"$('#new_attribute').submit()" %>
|
||||
</div>
|
||||
<div id="back" class='buttom clear'>
|
||||
<%= link_back %>
|
||||
</div>
|
||||
<% end -%>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
$("#enable_<%= @attribute.id %>").toggle();
|
||||
$("#disable_<%= @attribute.id %>").toggle();
|
||||
$("#attribute_<%= @attribute.id %>").toggleClass('disable');
|
||||
@@ -0,0 +1,16 @@
|
||||
<% content_for :secondary do %>
|
||||
<%= render 'admin/users/side_bar' %>
|
||||
<% end %>
|
||||
|
||||
<div id="porfile">
|
||||
<%= form_for @attribute, :url => eval("admin_user_#{@attribute_type}_model_path(@user_role_model)") do |f| %>
|
||||
<%= f.error_messages %>
|
||||
<%= render :partial => "admin/attributes/form", :locals => { :f => f, :is_new => false } %>
|
||||
<div id="update" class='buttom clear'>
|
||||
<%= link_to t('update'), "#", :onclick=>"$('#edit_user_role_model_#{@attribute.id}').submit()" %>
|
||||
</div>
|
||||
<div id="back" class='buttom clear'>
|
||||
<%= link_back %>
|
||||
</div>
|
||||
<% end -%>
|
||||
</div>
|
||||
@@ -0,0 +1,11 @@
|
||||
<div id="search">
|
||||
<input id="user_search" name="user[username]" size="30" type="text" />
|
||||
</div>
|
||||
<div class="member_setup">
|
||||
<h1><%= t('admin.setup_member') %></h1>
|
||||
<ul class="list">
|
||||
<li class="set_1"><%= link_to content_tag(:span, t('admin.list_users')), admin_users_path %></li>
|
||||
<li class="set_2"><%= link_to content_tag(:span, t('admin.list_roles')), admin_roles_path %></li>
|
||||
<li class="set_3"><%= link_to content_tag(:span, t('admin.list_infos')), admin_infos_path %></li>
|
||||
</ul>
|
||||
</div>
|
||||
Reference in new issue
Block a user