[refs #257] User edit pages fixes
This commit is contained in:
parent
ecff8d2d41
commit
f58e24b134
|
@ -7,35 +7,35 @@
|
|||
//= require_tree ./extra
|
||||
//= require_self
|
||||
|
||||
// function disableNotifierCbx(global_cbx) {
|
||||
// if ($(global_cbx).attr('checked')) {
|
||||
// $('.notify_cbx').removeAttr('disabled');
|
||||
// $('.notify_cbx').each(function(i,el) { $(el).prev().removeAttr('disabled'); })
|
||||
// } else {
|
||||
// $('.notify_cbx').attr('disabled', 'disabled');
|
||||
// $('.notify_cbx').each(function(i,el) { $(el).prev().attr('disabled', 'disabled'); })
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// $(document).ready(function() {
|
||||
// $('input.user_role_chbx').click(function() {
|
||||
// var current = $(this);
|
||||
// current.parent().find('input.user_role_chbx').each(function(i,el) {
|
||||
// if ($(el).attr('id') != current.attr('id')) {
|
||||
// $(el).removeAttr('checked');
|
||||
// }
|
||||
// });
|
||||
// });
|
||||
//
|
||||
// $('#settings_notifier_can_notify').click(function() {
|
||||
// disableNotifierCbx($(this));
|
||||
// });
|
||||
//
|
||||
// $('div.information > div.user').live('click', function() {
|
||||
// droplist();
|
||||
// });
|
||||
//
|
||||
// $('div.information > div.profile > a').live('click', function(e) {
|
||||
// e.preventDefault();
|
||||
// });
|
||||
// });
|
||||
function disableNotifierCbx(global_cbx) {
|
||||
if ($(global_cbx).attr('checked')) {
|
||||
$('.notify_cbx').removeAttr('disabled');
|
||||
$('.notify_cbx').each(function(i,el) { $(el).prev().removeAttr('disabled'); })
|
||||
} else {
|
||||
$('.notify_cbx').attr('disabled', 'disabled');
|
||||
$('.notify_cbx').each(function(i,el) { $(el).prev().attr('disabled', 'disabled'); })
|
||||
}
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
$('input.user_role_chbx').click(function() {
|
||||
var current = $(this);
|
||||
current.parent().find('input.user_role_chbx').each(function(i,el) {
|
||||
if ($(el).attr('id') != current.attr('id')) {
|
||||
$(el).removeAttr('checked');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('#settings_notifier_can_notify').click(function() {
|
||||
disableNotifierCbx($(this));
|
||||
});
|
||||
|
||||
$('div.information > div.user').live('click', function() {
|
||||
droplist();
|
||||
});
|
||||
|
||||
$('div.information > div.profile > a').live('click', function(e) {
|
||||
e.preventDefault();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -42,13 +42,25 @@ class UsersController < ApplicationController
|
|||
end
|
||||
|
||||
def update
|
||||
@user.role = params[:user][:role]
|
||||
@user.role = params[:user][:role] if params[:user][:role] && current_user.admin?
|
||||
if @user.update_attributes(params[:user])
|
||||
flash[:notice] = t('flash.user.saved')
|
||||
redirect_to users_path
|
||||
redirect_to edit_user_path(@user)
|
||||
else
|
||||
flash[:error] = t('flash.user.save_error')
|
||||
render :action => :edit
|
||||
render(:action => :edit)
|
||||
end
|
||||
end
|
||||
|
||||
def private
|
||||
if request.put?
|
||||
if @user.update_attributes(params[:user])
|
||||
flash[:notice] = t('flash.user.saved')
|
||||
redirect_to user_private_settings_path(@user)
|
||||
else
|
||||
flash[:error] = t('flash.user.save_error')
|
||||
render(:action => :private)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@ class Ability
|
|||
|
||||
if user.user?
|
||||
can [:show, :autocomplete_user_uname], User
|
||||
can [:edit, :update, :private], User, :id => user.id
|
||||
|
||||
can [:show, :update], Settings::Notifier, :user_id => user.id
|
||||
|
||||
|
|
|
@ -29,11 +29,13 @@ class User < ActiveRecord::Base
|
|||
|
||||
validates :uname, :presence => true, :uniqueness => {:case_sensitive => false}, :format => { :with => /^[a-z0-9_]+$/ }
|
||||
validate { errors.add(:uname, :taken) if Group.where('uname LIKE ?', uname).present? }
|
||||
validates :ssh_key, :uniqueness => true, :allow_blank => true
|
||||
validates :role, :inclusion => {:in => ROLES}, :allow_blank => true
|
||||
validates :language, :inclusion => {:in => LANGUAGES}, :allow_blank => true
|
||||
validates_confirmation_of :password
|
||||
|
||||
attr_accessible :email, :password, :password_confirmation, :remember_me, :login, :name, :ssh_key, :uname, :language
|
||||
attr_accessor :password, :password_confirmation, :current_password
|
||||
attr_accessible :email, :password, :password_confirmation, :current_password, :remember_me, :login, :name, :ssh_key, :uname, :language,
|
||||
:site, :company, :professional_experience, :location
|
||||
attr_readonly :uname, :own_projects_count
|
||||
attr_readonly :uname
|
||||
attr_accessor :login
|
||||
|
|
|
@ -22,6 +22,11 @@
|
|||
.rightlist
|
||||
= f.select :language, User::LANGUAGES_FOR_SELECT
|
||||
.both
|
||||
- if current_user.admin?
|
||||
.leftlist
|
||||
= f.label :role, t("activerecord.attributes.user.role"), :class => :label
|
||||
.rightlist
|
||||
= f.select :role, User::ROLES.push(""), :selected => resource.role
|
||||
.leftlist
|
||||
= f.label :company, t("activerecord.attributes.user.company")
|
||||
.rightlist
|
||||
|
|
|
@ -23,15 +23,15 @@
|
|||
.rightlist
|
||||
= f.text_field :location
|
||||
.both
|
||||
.leftlist
|
||||
Аватарка:
|
||||
.rightlist
|
||||
%div
|
||||
.avatar
|
||||
%img{:alt => "avatar", :src => "pics/ava-admin.png"}
|
||||
.load
|
||||
%a.button{:href => "#"} Загрузить
|
||||
.both
|
||||
-#.leftlist
|
||||
-# Аватарка:
|
||||
-#.rightlist
|
||||
-# %div
|
||||
-# .avatar
|
||||
-# %img{:alt => "avatar", :src => "pics/ava-admin.png"}
|
||||
-# .load
|
||||
-# %a.button{:href => "#"} Загрузить
|
||||
-#.both
|
||||
.leftlist
|
||||
= f.label :professional_experience, t("activerecord.attributes.user.professional_experience")
|
||||
.rightlist
|
||||
|
|
|
@ -5,17 +5,11 @@
|
|||
.admin-preferences
|
||||
%ul
|
||||
- if can? :edit, @user
|
||||
%li{:class => (act == :edit && contr == :registrations) ? 'active' : ''}
|
||||
%li{:class => (act == :edit && :users == contr) ? 'active' : ''}
|
||||
= link_to t("layout.users.edit"), edit_user_path(@user)
|
||||
- if can? :edit_platform_private_user, @user
|
||||
- if can? :private, @user
|
||||
%li{:class => (act == :private && contr == :users) ? 'active' : ''}
|
||||
= link_to t("layout.users.user_private_settings"), user_private_settings_path(@user)
|
||||
- if can? :user_settings_notifier, @user
|
||||
- if can? :show, @user.notifier
|
||||
%li{:class => (act == :show && contr == :notifiers) ? 'active' : ''}
|
||||
= link_to t("layout.users.settings_notifier"), user_settings_notifier_path(@user)
|
||||
|
||||
-#.block.notice
|
||||
-# %h3= t("layout.users.groups")
|
||||
-# .content
|
||||
-# - @user.groups.each do |group|
|
||||
-# %p= link_to group.name, group
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
%h3.fix.bpadding10= t('layout.users.private_settings_header')
|
||||
|
||||
= form_for(@user, :url => registration_path(@user), :html => { :method => :put, :class => "form" }) do |f|
|
||||
= form_for(@user, :url => user_private_settings_path(@user), :html => { :method => :put, :class => "form" }) do |f|
|
||||
.leftlist
|
||||
= f.label :current_password
|
||||
.rightlist
|
||||
|
@ -21,16 +21,6 @@
|
|||
.rightlist
|
||||
= submit_tag t('layout.save')
|
||||
.both
|
||||
.hr
|
||||
%h3= t("layout.users.delete_header")
|
||||
.leftside
|
||||
= t("layout.users.delete_warning")
|
||||
.rightside
|
||||
= link_to t("layout.delete"), user_path(@project), :method => :delete, :confirm => t("layout.users.confirm_delete"), :class => 'button' if can? :destroy, @user
|
||||
.both
|
||||
|
||||
.notify
|
||||
%p= t('layout.users.public_data_edit_warning')
|
||||
|
||||
:javascript
|
||||
$('article .right').addClass('middlepadding');
|
||||
|
|
|
@ -24,7 +24,8 @@ Rosa::Application.routes.draw do
|
|||
resource :notifier, :only => [:show, :update]
|
||||
end
|
||||
end
|
||||
match 'users/:id/settings/private' => 'users#private', :as => :user_private_settings
|
||||
match 'users/:id/settings/private' => 'users#private', :as => :user_private_settings, :via => :get
|
||||
match 'users/:id/settings/private' => 'users#private', :as => :user_private_settings, :via => :put
|
||||
|
||||
resources :event_logs, :only => :index
|
||||
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
class RemoveSshKeyFieldFromUsers < ActiveRecord::Migration
|
||||
def up
|
||||
remove_column :users, :ssh_key
|
||||
end
|
||||
|
||||
def down
|
||||
add_column :users, :ssh_key, :text
|
||||
end
|
||||
end
|
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20120303062601) do
|
||||
ActiveRecord::Schema.define(:version => 20120303151303) do
|
||||
|
||||
create_table "activity_feeds", :force => true do |t|
|
||||
t.integer "user_id", :null => false
|
||||
|
@ -370,7 +370,6 @@ ActiveRecord::Schema.define(:version => 20120303062601) do
|
|||
t.datetime "remember_created_at"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.text "ssh_key"
|
||||
t.string "uname"
|
||||
t.string "role"
|
||||
t.string "language", :default => "en"
|
||||
|
|
Loading…
Reference in New Issue