Skip to content

Commit

Permalink
Alteracao de senha
Browse files Browse the repository at this point in the history
  • Loading branch information
Joao Paulo Barros committed Feb 12, 2010
1 parent 1ec063d commit 7498562
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 11 deletions.
1 change: 1 addition & 0 deletions app/controllers/admin/users_controller.rb
Expand Up @@ -36,6 +36,7 @@ def search_results
else
p = []
end

@results = Profile.search(p.delete(:q) || '', :page => @page, :per_page => 21)
end
end
Expand Down
19 changes: 19 additions & 0 deletions app/controllers/profiles_controller.rb
Expand Up @@ -76,6 +76,25 @@ def update
flash.now[:error] = @user.errors
render :action=> :edit
end
when 'new_password'
respond_to do |wants|
#if @comment.save
# wants.js do
# render :update do |page|
# page.insert_html :top, "#{dom_id(@parent)}_comments", :partial => 'comments/comment', :object => @comment
# page.visual_effect :highlight, "comment_#{@comment.id}".to_sym
# page << 'tb_remove();'
# page << "jq('#comment_comment').val('');"
# end
# end
#else
wants.js do
render :update do |page|
page << "message('Erro qualquer... naum interessa, soh quero ver na tela.');"
end
end
#end
end
else
RAILS_ENV == 'test' ? render( :text=>'') : raise( 'Unsupported swtich in action')
end
Expand Down
37 changes: 31 additions & 6 deletions app/views/admin/users/index.html.erb
Expand Up @@ -4,12 +4,37 @@
<h2><%=t(:search_results) %></h2>

<% @results.each do |p| %>
<div class="<%= cycle('odd','even') %> search_row left">
<div><%= icon p, :small %></div>
<div><%= link_to h(p.f), p %></div>
<div><%= mail_to h(p.email), p.email %></div>
<div><%= link_to_remote "alterar", {:url => admin_user_path(p, 'js'), :method => :put}, {:id => p.dom_id('link')} %> - <%= link_to_remote "#{ p.is_active ? t(:deactivate) : t(:activate) }", {:url => admin_user_path(p, 'js'), :method => :put}, {:id => p.dom_id('link')} %></div>
</div>

<div class="<%= cycle('odd','even') %> search_row left">
<div><%= icon p, :small %></div>
<div><%= link_to h(p.f), p %></div>
<div><%= mail_to h(p.email), p.email %></div>
<div><%= link_to_remote "#{ p.is_active ? t(:deactivate) : t(:activate) }", {:url => admin_user_path(p, 'js'), :method => :put}, {:id => p.dom_id('link')} %></div>
<div><%= inline_tb_link t(:option_edit), "new_password_#{p.id}", {:title => t(:passwd_edit_label, :nome => h(p.f))}, {:height => 150, :width => 430} if p %></div>
</div>

<div id="new_password_<%= p.id %>" class="hidden">
<% less_remote_form_for(p, :html => { :method=>:put, :id => "#{dom_id(p)}_new_password_form"} ) do |f| %>
<div id="thickbox_form">

<%= f.front :new_password, :for => :new_password %>
<input type="password" name="new_password" id="new_password" />
<%= error_messages_on(:user, :new_password) %>
<%= f.back %>
<%= f.front :confirm_password, :for => :confirm_password %>
<input type="password" name="confirm_password" id="confirm_password" />
<%= f.back %>

<div class="row button">
<%= f.submit t(:option_save), :class => 'button' %>
</div>

<input type="hidden" name="switch" value="new_password" />
</div>
<% end %>
</div>

<% end %>
<div class="clear"></div>
<%= will_paginate @results %>
Expand Down
1 change: 1 addition & 0 deletions config/locales/en.yml
Expand Up @@ -113,6 +113,7 @@ en:
search_results: "Search Results"
deactivate: "deactivate"
activate: "activate"
passwd_edit_label: "Editing password of {{nome}}"

#app/views/blogs/_blog.html.erb
blog_posted_label: "Posted"
Expand Down
1 change: 1 addition & 0 deletions config/locales/pt-BR.yml
Expand Up @@ -256,6 +256,7 @@ pt-BR:
search_results: "Resultados da pesquisa"
deactivate: "desativar"
activate: "ativar"
passwd_edit_label: "Alterar senha de {{nome}}"

#app/views/blogs/_blog.html.erb
blog_posted_label: "Postado"
Expand Down
2 changes: 1 addition & 1 deletion public/stylesheets/application.css
Expand Up @@ -175,7 +175,7 @@ img.icon_small {width: 20px; margin: 0 1px -5px 0;}
ul#post_history {padding: 0 0 0 0;}
.date_details_white {color: white;}

.search_row {width: 90px; height: 100px; overflow: hidden; padding: 5px; margin: 0 10px 15px 0;}
.search_row {width: 90px; height: 115px; overflow: hidden; padding: 5px; margin: 0 10px 15px 0;}
.search_row img {margin-bottom: 5px;}
.search_row a {font-size: 10px;}
.search_row div {text-align: center; }
Expand Down
1 change: 0 additions & 1 deletion test/fixtures/users.yml
Expand Up @@ -53,7 +53,6 @@ cant_message:
is_admin: false
can_send_messages: false


admin:
login: admin
crypted_password: 00742970dc9e6319f8019fd54864d3ea740f04b1 # test
Expand Down
5 changes: 2 additions & 3 deletions test/functional/admin/users_controller_test.rb
Expand Up @@ -4,10 +4,9 @@ class Admin::UsersControllerTest < ActionController::TestCase

context 'on GET to users list' do
should "render options update" do
Profile.stubs(:search).returns(ThinkingSphinx::Collection.new(1, 1, 1, 1))
get :index, {}, {:user => users(:admin).id}
#assert_response :success
#assert_tag :tag => "input", :attributes => {:id => "user_is_admin", :type => "checkbox"}
#assert_tag :tag => "input", :attributes => {:id => "user_can_send_news", :type => "checkbox"}
assert_response :success
end
end

Expand Down

0 comments on commit 7498562

Please sign in to comment.