[refs #257] User edit pages fixes
This commit is contained in:
parent
ecff8d2d41
commit
f58e24b134
|
@ -7,35 +7,35 @@
|
||||||
//= require_tree ./extra
|
//= require_tree ./extra
|
||||||
//= require_self
|
//= require_self
|
||||||
|
|
||||||
// function disableNotifierCbx(global_cbx) {
|
function disableNotifierCbx(global_cbx) {
|
||||||
// if ($(global_cbx).attr('checked')) {
|
if ($(global_cbx).attr('checked')) {
|
||||||
// $('.notify_cbx').removeAttr('disabled');
|
$('.notify_cbx').removeAttr('disabled');
|
||||||
// $('.notify_cbx').each(function(i,el) { $(el).prev().removeAttr('disabled'); })
|
$('.notify_cbx').each(function(i,el) { $(el).prev().removeAttr('disabled'); })
|
||||||
// } else {
|
} else {
|
||||||
// $('.notify_cbx').attr('disabled', 'disabled');
|
$('.notify_cbx').attr('disabled', 'disabled');
|
||||||
// $('.notify_cbx').each(function(i,el) { $(el).prev().attr('disabled', 'disabled'); })
|
$('.notify_cbx').each(function(i,el) { $(el).prev().attr('disabled', 'disabled'); })
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// $(document).ready(function() {
|
$(document).ready(function() {
|
||||||
// $('input.user_role_chbx').click(function() {
|
$('input.user_role_chbx').click(function() {
|
||||||
// var current = $(this);
|
var current = $(this);
|
||||||
// current.parent().find('input.user_role_chbx').each(function(i,el) {
|
current.parent().find('input.user_role_chbx').each(function(i,el) {
|
||||||
// if ($(el).attr('id') != current.attr('id')) {
|
if ($(el).attr('id') != current.attr('id')) {
|
||||||
// $(el).removeAttr('checked');
|
$(el).removeAttr('checked');
|
||||||
// }
|
}
|
||||||
// });
|
});
|
||||||
// });
|
});
|
||||||
//
|
|
||||||
// $('#settings_notifier_can_notify').click(function() {
|
$('#settings_notifier_can_notify').click(function() {
|
||||||
// disableNotifierCbx($(this));
|
disableNotifierCbx($(this));
|
||||||
// });
|
});
|
||||||
//
|
|
||||||
// $('div.information > div.user').live('click', function() {
|
$('div.information > div.user').live('click', function() {
|
||||||
// droplist();
|
droplist();
|
||||||
// });
|
});
|
||||||
//
|
|
||||||
// $('div.information > div.profile > a').live('click', function(e) {
|
$('div.information > div.profile > a').live('click', function(e) {
|
||||||
// e.preventDefault();
|
e.preventDefault();
|
||||||
// });
|
});
|
||||||
// });
|
});
|
||||||
|
|
|
@ -42,13 +42,25 @@ class UsersController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
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])
|
if @user.update_attributes(params[:user])
|
||||||
flash[:notice] = t('flash.user.saved')
|
flash[:notice] = t('flash.user.saved')
|
||||||
redirect_to users_path
|
redirect_to edit_user_path(@user)
|
||||||
else
|
else
|
||||||
flash[:error] = t('flash.user.save_error')
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,7 @@ class Ability
|
||||||
|
|
||||||
if user.user?
|
if user.user?
|
||||||
can [:show, :autocomplete_user_uname], User
|
can [:show, :autocomplete_user_uname], User
|
||||||
|
can [:edit, :update, :private], User, :id => user.id
|
||||||
|
|
||||||
can [:show, :update], Settings::Notifier, :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_]+$/ }
|
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? }
|
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 :role, :inclusion => {:in => ROLES}, :allow_blank => true
|
||||||
validates :language, :inclusion => {:in => LANGUAGES}, :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, :own_projects_count
|
||||||
attr_readonly :uname
|
attr_readonly :uname
|
||||||
attr_accessor :login
|
attr_accessor :login
|
||||||
|
|
|
@ -22,6 +22,11 @@
|
||||||
.rightlist
|
.rightlist
|
||||||
= f.select :language, User::LANGUAGES_FOR_SELECT
|
= f.select :language, User::LANGUAGES_FOR_SELECT
|
||||||
.both
|
.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
|
.leftlist
|
||||||
= f.label :company, t("activerecord.attributes.user.company")
|
= f.label :company, t("activerecord.attributes.user.company")
|
||||||
.rightlist
|
.rightlist
|
||||||
|
|
|
@ -23,15 +23,15 @@
|
||||||
.rightlist
|
.rightlist
|
||||||
= f.text_field :location
|
= f.text_field :location
|
||||||
.both
|
.both
|
||||||
.leftlist
|
-#.leftlist
|
||||||
Аватарка:
|
-# Аватарка:
|
||||||
.rightlist
|
-#.rightlist
|
||||||
%div
|
-# %div
|
||||||
.avatar
|
-# .avatar
|
||||||
%img{:alt => "avatar", :src => "pics/ava-admin.png"}
|
-# %img{:alt => "avatar", :src => "pics/ava-admin.png"}
|
||||||
.load
|
-# .load
|
||||||
%a.button{:href => "#"} Загрузить
|
-# %a.button{:href => "#"} Загрузить
|
||||||
.both
|
-#.both
|
||||||
.leftlist
|
.leftlist
|
||||||
= f.label :professional_experience, t("activerecord.attributes.user.professional_experience")
|
= f.label :professional_experience, t("activerecord.attributes.user.professional_experience")
|
||||||
.rightlist
|
.rightlist
|
||||||
|
|
|
@ -5,17 +5,11 @@
|
||||||
.admin-preferences
|
.admin-preferences
|
||||||
%ul
|
%ul
|
||||||
- if can? :edit, @user
|
- 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)
|
= 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' : ''}
|
%li{:class => (act == :private && contr == :users) ? 'active' : ''}
|
||||||
= link_to t("layout.users.user_private_settings"), user_private_settings_path(@user)
|
= 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' : ''}
|
%li{:class => (act == :show && contr == :notifiers) ? 'active' : ''}
|
||||||
= link_to t("layout.users.settings_notifier"), user_settings_notifier_path(@user)
|
= 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')
|
%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
|
.leftlist
|
||||||
= f.label :current_password
|
= f.label :current_password
|
||||||
.rightlist
|
.rightlist
|
||||||
|
@ -21,16 +21,6 @@
|
||||||
.rightlist
|
.rightlist
|
||||||
= submit_tag t('layout.save')
|
= submit_tag t('layout.save')
|
||||||
.both
|
.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
|
:javascript
|
||||||
$('article .right').addClass('middlepadding');
|
$('article .right').addClass('middlepadding');
|
||||||
|
|
|
@ -24,7 +24,8 @@ Rosa::Application.routes.draw do
|
||||||
resource :notifier, :only => [:show, :update]
|
resource :notifier, :only => [:show, :update]
|
||||||
end
|
end
|
||||||
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
|
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.
|
# 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|
|
create_table "activity_feeds", :force => true do |t|
|
||||||
t.integer "user_id", :null => false
|
t.integer "user_id", :null => false
|
||||||
|
@ -370,7 +370,6 @@ ActiveRecord::Schema.define(:version => 20120303062601) do
|
||||||
t.datetime "remember_created_at"
|
t.datetime "remember_created_at"
|
||||||
t.datetime "created_at"
|
t.datetime "created_at"
|
||||||
t.datetime "updated_at"
|
t.datetime "updated_at"
|
||||||
t.text "ssh_key"
|
|
||||||
t.string "uname"
|
t.string "uname"
|
||||||
t.string "role"
|
t.string "role"
|
||||||
t.string "language", :default => "en"
|
t.string "language", :default => "en"
|
||||||
|
|
Loading…
Reference in New Issue