Changes for sub_roles
Issues: update doesn't create new i18n_variables, role form has bugs
This commit is contained in:
1 parent
d23cf152da
commit
d27d7a623c
62 files changed
+508
-1142
No files matched your search
@@ -16,27 +16,27 @@
|
||||
</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 :active_role, @roles.sort_by{|role| role.key }.collect {|role| [ role.i18n_variable[I18n.locale], role.key ]}, :selected => (@user.active_role || 'student') %>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<% @user_info_models.each do |ua| %>
|
||||
<div id="basic_block" class="roles_block <%= @class %>">
|
||||
<% @infos.each do |ua| %>
|
||||
<div id="basic_block" class="attributes_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),
|
||||
<%= render :partial => 'attribute',
|
||||
:object => (@user.infos.detect {|u| u.key == ua.key } || @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?)) %>>
|
||||
<div id='roles'>
|
||||
<% @roles.each do |ua| %>
|
||||
<div id="<%= ua.key %>_block" class="attributes_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>
|
||||
<hr>
|
||||
<%= render :partial => 'user_attribute',
|
||||
:object => (@user.user_roles.detect {|u| u.key == ua.key } || @user.user_roles.build),
|
||||
<%= render :partial => 'attribute',
|
||||
:object => (@user.roles.detect {|u| u.key == ua.key } || @user.roles.build),
|
||||
:locals => {:ua => ua, :type => 'role'} %>
|
||||
</div>
|
||||
<% end -%>
|
||||
|
||||
@@ -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>
|
||||
<% a.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>
|
||||
@@ -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>
|
||||
@@ -1,6 +1,6 @@
|
||||
<%= fields_for "user[user_#{type}s]", user_attribute, :index => nil do |f| %>
|
||||
<%= fields_for "user[#{type}s]", attribute, :index => nil do |f| %>
|
||||
<%= f.hidden_field :key, :value => ua.key %>
|
||||
<%= f.hidden_field :id unless user_attribute.new_record? %>
|
||||
<%= f.hidden_field :id unless attribute.new_record? %>
|
||||
|
||||
<div class="info_input">
|
||||
<table border="0" cellspacing="0" cellpadding="0">
|
||||
@@ -13,25 +13,25 @@
|
||||
</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 %>
|
||||
<% ua.get_enabled_attribute_fields.each do |attr| %>
|
||||
<% value = attribute.attribute_values.detect{|v| v.key == attr.key } %>
|
||||
<%= hidden_field_tag "user[#{type}s][][attribute_values][][id]", value.id rescue nil %>
|
||||
<%= hidden_field_tag "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 %>
|
||||
<%= hidden_field_tag "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) %>
|
||||
<%= text_field_tag "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) %>
|
||||
<%= text_field_tag "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']) %>
|
||||
<%= select_tag "user[#{type}s][][attribute_values][][non_locale]", options_for_select(attr["options"], value['non_locale']) %>
|
||||
<% end -%>
|
||||
</td>
|
||||
<% end -%>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<%= render 'side_bar' %>
|
||||
<% end %>
|
||||
|
||||
<div id="porfile">
|
||||
<div id="profile">
|
||||
<%= form_for @user, :url => admin_user_path(@user), :html => { :multipart => true } do |f| %>
|
||||
<%= f.error_messages %>
|
||||
<%= render :partial => 'form', :locals => { :f => f } %>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<%= render 'side_bar' %>
|
||||
<% end %>
|
||||
|
||||
<div id="porfile">
|
||||
<div id="profile">
|
||||
<%= form_for @user, :url => admin_users_path, :html => { :multipart => true } do |f| %>
|
||||
<%= f.error_messages %>
|
||||
<%= render :partial => 'form', :locals => { :f => f } %>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<%= render 'side_bar' %>
|
||||
<% end %>
|
||||
|
||||
<div id="porfile">
|
||||
<div id="profile" class="clear">
|
||||
|
||||
<div id="person">
|
||||
<% if @user.avatar? %>
|
||||
@@ -11,20 +11,18 @@
|
||||
<%= image_tag "person.png" %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<% @user_info_models.each do |am| %>
|
||||
<div id="basic_block" class="roles_block <%= @class %>">
|
||||
<h2><%= am.i18n_variable[I18n.locale] %></h2>
|
||||
<% @infos.each do |a| %>
|
||||
<div id="basic_block" class="attributes_block <%= @class %>">
|
||||
<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', :locals => {:a => 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="attributes_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_attribute', :locals => {:a => active_role, :object => @user.get_role_from_key(active_role.key)} %>
|
||||
</div>
|
||||
<div class="button_bar">
|
||||
<%= link_to t(:edit), edit_admin_user_path(@user) %>
|
||||
|
||||
Reference in new issue
Block a user