Merge with sub_roles

This commit is contained in:
chris2tof committed 2011-12-23 18:34:21 +08:00
1 parent fc591ee308
commit 62aaf79491
308 files changed
+2844 -17841

No files matched your search

+10 -17
View File
@@ -16,28 +16,21 @@
</label>
<label>
<span><%= t('admin.role') %>:</span>
<%= f.select :active_role, @user_role_models.sort_by{|role| role.key }.collect {|role| [ role.i18n_variable[I18n.locale], role.key ]}, :selected => (@user.active_role || 'student') %>
<%= f.select :role_id, @roles.sort_by{|role| role.key }.collect {|role| [ role.i18n_variable[I18n.locale], role.id ]}, :selected => (@user.role_id || Role.get_role_from_key('student')) %>
</label>
</div>
<% @user_info_models.each do |ua| %>
<div id="basic_block" class="roles_block <%= @class %>">
<h2><%= ua.i18n_variable[I18n.locale] %></h2>
<hr>
<%= render :partial => 'user_attribute',
:object => (@user.user_infos.detect {|u| u.key == ua.key } || @user.user_infos.build),
:locals => {:ua => ua, :type => 'info'} %>
</div>
<% end -%>
<div id='role_models'>
<% @user_role_models.each do |ua| %>
<div id="<%= ua.key %>_block" class="roles_block <%= @class %>" <%= raw(' style="display: none;"') unless ((@user.active_role.eql?(ua.key) rescue nil) || (ua.key.eql?('student') && @user.new_record?)) %>>
<h2><%= ua.i18n_variable[I18n.locale] %></h2>
<%= render :partial => 'info', :collection => @infos, :locals => {:f => f} %>
<div id='roles'>
<% @roles.each do |role| %>
<div id="<%= role.id %>_block" class="attributes_block <%= @class %>" <%= raw(' style="display: none;"') unless ((@user.role.id.eql?(role.id) rescue nil) || (role.key.eql?('student') && @user.new_record?)) %>>
<h2><%= role.i18n_variable[I18n.locale] %></h2>
<hr>
<%= render :partial => 'user_attribute',
:object => (@user.user_roles.detect {|u| u.key == ua.key } || @user.user_roles.build),
:locals => {:ua => ua, :type => 'role'} %>
<%= render :partial => 'sub_role_selector', :locals => {:f => f, :role => role} %>
<%= render :partial => 'sub_role', :collection => role.sub_roles, :locals => {:f => f, :role => role} %>
</div>
<% end -%>
</div>
+40
View File
@@ -0,0 +1,40 @@
<div id="basic_block" class="attributes_block <%= @class %>">
<h2><%= info.i18n_variable[I18n.locale] %></h2>
<hr>
<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><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %></td>
<% end %>
</tr>
</thead>
<tbody>
<% info.get_enabled_attribute_fields.each do |attr| %>
<%= f.fields_for :attribute_values, @user.get_value_from_field_id(attr.id) do |f| %>
<tr class="list_item">
<td><%= attr.i18n_variable[I18n.locale] %></td>
<% if attr["locale"] && attr["markup"] == 'text_field' %>
<% @site_valid_locales.each do |locale| %>
<td><%= f.text_field locale %></td>
<% end %>
<% else %>
<td colspan=<%= @site_valid_locales.size %>>
<% if attr["markup"] == "text_field" %>
<%= f.text_field :non_locale %>
<% elsif attr["markup"] == "select" %>
<%= f.select :non_locale, options_for_select(attr["options"], value['non_locale']) %>
<% end -%>
</td>
<% end -%>
<%= f.hidden_field :attribute_field_id, :value => attr.id %>
<%= f.hidden_field :key, :value => attr.key %>
</tr>
<% end %>
<% end %>
</tbody>
</table>
</div>
</div>
@@ -0,0 +1,26 @@
<div class="info_input">
<table border="0" cellspacing="0" cellpadding="0">
<thead class="list_head">
<td><%= t("admin.key") %></td>
<% @site_valid_locales.each do |locale| %>
<td><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %></td>
<% end %>
</thead>
<tbody>
<% show_attribute.get_enabled_attribute_fields.each do |attr| %>
<tr class="list_item">
<td><%= attr.i18n_variable[I18n.locale] %></td>
<% @site_valid_locales.each do |locale| %>
<td>
<% if attr["locale"] && attr["markup"] == 'text_field' %>
<%= show_attribute(@user, attr.id, locale) %>
<% else %>
<%= show_attribute(@user, attr.id) %>
<% end %>
</td>
<% end %>
</tr>
<% end %>
</tbody>
</table>
</div>
@@ -0,0 +1,4 @@
<div id="sub_role_<%= show_sub_role.id %>" class="info_input">
<h2><%= show_sub_role.i18n_variable[I18n.locale] %></h2>
<%= render :partial => 'show_attribute', :object => show_sub_role %>
</div>
@@ -1,27 +0,0 @@
<div class="info_input">
<table border="0" cellspacing="0" cellpadding="0">
<thead class="list_head">
<td><%= t("admin.key") %></td>
<% @site_valid_locales.each do |locale| %>
<td><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %></td>
<% end %>
</thead>
<tbody>
<% am.get_enabled_attribute_models.each do |attr| %>
<tr class="list_item">
<td><%= attr.i18n_variable[I18n.locale] %></td>
<% @site_valid_locales.each do |locale| %>
<td>
<% if attr["locale"] && attr["markup"] == 'text_field' %>
<%= show_user_attribute(object, attr.key, locale) %>
<% else %>
<%= show_user_attribute(object, attr.key) %>
<% end %>
</td>
<% end %>
</tr>
<% end %>
</tbody>
</table>
</div>
+6 -6
View File
@@ -2,10 +2,10 @@
<input id="user_search" name="user[username]" size="30" type="text" />
</div>
<div class="member_setup <%= @class %>">
<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_user_roles')), admin_user_role_models_path %></li>
<li class="set_3"><%= link_to content_tag(:span, t('admin.list_user_infos')), admin_user_info_models_path %></li>
</ul>
<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>
+37
View File
@@ -0,0 +1,37 @@
<div id="sub_role_<%= sub_role.id %>" class="info_input" <%= raw(' style="display: none;"') unless @user.sub_role_ids.include?(sub_role.id) %>>
<h2><%= sub_role.i18n_variable[I18n.locale] %></h2>
<table border="0" cellspacing="0" cellpadding="0">
<thead class="list_head">
<tr>
<td><%= t("admin.key") %></td>
<% @site_valid_locales.each do |locale| %>
<td><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %></td>
<% end %>
</tr>
</thead>
<tbody>
<% sub_role.get_enabled_attribute_fields.each do |attr| %>
<%= f.fields_for :attribute_values, @user.get_value_from_field_id(attr.id) do |f| %>
<tr class="list_item">
<td><%= attr.i18n_variable[I18n.locale] %></td>
<% if attr["locale"] && attr["markup"] == 'text_field' %>
<% @site_valid_locales.each do |locale| %>
<td><%= f.text_field locale %></td>
<% end %>
<% else %>
<td colspan=<%= @site_valid_locales.size %>>
<% if attr["markup"] == "text_field" %>
<%= f.text_field :non_locale %>
<% elsif attr["markup"] == "select" %>
<%= f.select :non_locale, options_for_select(attr["options"], value['non_locale']) %>
<% end -%>
</td>
<% end -%>
<%= f.hidden_field :attribute_field_id, :value => attr.id %>
<%= f.hidden_field :key, :value => attr.key %>
</tr>
<% end %>
<% end %>
</tbody>
</table>
</div>
@@ -0,0 +1,4 @@
<% role.sub_roles.each do |sub_role| %>
<%= sub_role.i18n_variable[I18n.locale] %>
<%= check_box_tag "user[sub_role_ids][]", sub_role.id, @user.sub_role_ids.include?(sub_role.id), :class => 'sub_role_select' %>
<% end %>
@@ -1,44 +0,0 @@
<%= fields_for "user[user_#{type}s]", user_attribute, :index => nil do |f| %>
<%= f.hidden_field :key, :value => ua.key %>
<%= f.hidden_field :id unless user_attribute.new_record? %>
<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><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %></td>
<% end %>
</tr>
</thead>
<tbody>
<% ua.get_enabled_attribute_models.each do |attr| %>
<% value = user_attribute.attribute_values.detect{|v| v.key == attr.key } %>
<%= hidden_field_tag "user[user_#{type}s][][attribute_values][][id]", value.id rescue nil %>
<%= hidden_field_tag "user[user_#{type}s][][attribute_values][][key]", attr.key %>
<tr class="list_item">
<td><%= attr.i18n_variable[I18n.locale] %></td>
<% if attr["locale"] && attr["markup"] == 'text_field' %>
<%= hidden_field_tag "user[user_#{type}s][][attribute_values][][non_locale]", nil %>
<% @site_valid_locales.each do |locale| %>
<td>
<%= text_field_tag "user[user_#{type}s][][attribute_values][][#{locale}]", (value[locale] rescue nil) %>
</td>
<% end -%>
<% else %>
<td colspan=<%= @site_valid_locales.size %>>
<% if attr["markup"] == "text_field" %>
<%= text_field_tag "user[user_#{type}s][][attribute_values][][non_locale]", (value['non_locale'] rescue nil) %>
<% elsif attr["markup"] == "select" %>
<%= select_tag "user[user_#{type}s][][attribute_values][][non_locale]", options_for_select(attr["options"], value['non_locale']) %>
<% end -%>
</td>
<% end -%>
</tr>
<% end %>
</tbody>
</table>
</div>
<% end %>
+1 -1
View File
@@ -2,7 +2,7 @@
<%= render 'side_bar' %>
<% end %>
<div id="porfile" class="clear">
<div id="profile" class="clear">>
<%= form_for @user, :url => admin_user_path(@user), :html => { :multipart => true } do |f| %>
<%= f.error_messages %>
<%= render :partial => 'form', :locals => { :f => f } %>
+1 -2
View File
@@ -19,9 +19,8 @@
</thead>
<tbody>
<% @users.each do |user| %>
<% active_role = UserRoleModel.get_role_model_from_key(user.active_role) %>
<tr class="have">
<td class="roles <%= active_role.key.downcase rescue nil %>"><%= active_role.i18n_variable[I18n.locale] rescue nil %></td>
<td class="roles <%= user.role.key.downcase rescue nil %>"><%= user.role.i18n_variable[I18n.locale] rescue nil %></td>
<td class="name"><%= user.name ? user.name : 'bob' %></td>
<td class="email"><%= user.email %></td>
<td class="admin"><%= user.admin ? t(:yes_) : t(:no_) %></td>
+1 -1
View File
@@ -2,7 +2,7 @@
<%= render 'side_bar' %>
<% end %>
<div id="porfile" class="clear">
<div id="profile" class="clear">
<%= form_for @user, :url => admin_users_path, :html => { :multipart => true } do |f| %>
<%= f.error_messages %>
<%= render :partial => 'form', :locals => { :f => f } %>
+11 -12
View File
@@ -2,29 +2,28 @@
<%= render 'side_bar' %>
<% end %>
<div id="porfile" class="clear">
<div id="profile" class="clear">
<div id="person">
<% if @user.avatar? %>
<%= image_tag(@user.avatar.thumb.url) %>
<% if @user.avatar? %>
<%= image_tag(@user.avatar.thumb.url) %>
<% else %>
<%= image_tag "person.png" %>
<%= image_tag "person.png" %>
<% end %>
<label><span><%= @user.email %></span></label>
</div>
<% @user_info_models.each do |am| %>
<% @infos.each do |a| %>
<div id="basic_block" class="roles_block <%= @class %>">
<h2><%= am.i18n_variable[I18n.locale] %></h2>
<h2><%= a.i18n_variable[I18n.locale] %></h2>
<hr>
<%= render :partial => 'show_user_attribute', :locals => {:am => am, :object => @user.get_info_from_model_key(am.key)} %>
<%= render :partial => 'show_attribute', :object => a %>
</div>
<% end -%>
<div id="<%= @user.active_role %>_block" class="roles_block <%= @class %>">
<% active_role = UserRoleModel.get_role_model_from_key(@user.active_role) %>
<h2><%= active_role.i18n_variable[I18n.locale] %></h2>
<div id="<%= @user.role.key %>_block" class="roles_block <%= @class %>">
<h2><%= @user.role.i18n_variable[I18n.locale] %></h2>
<hr>
<%= render :partial => 'show_user_attribute', :locals => {:am => active_role, :object => @user.get_role_from_model_key(active_role.key)} %>
<%= render :partial => 'show_sub_role', :collection => @user.sub_roles %>
</div>
<div class="button_bar">
<%= link_to t(:edit), edit_admin_user_path(@user) %>