Skip to content
This repository has been archived by the owner on Sep 21, 2022. It is now read-only.

Commit

Permalink
displays already set UTBCredentials in form
Browse files Browse the repository at this point in the history
this closes #18
  • Loading branch information
Marv Cool committed Jan 15, 2013
1 parent d71517d commit 0c9ea28
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
10 changes: 6 additions & 4 deletions app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,15 @@ def update
existing_credentials.each { |co|
# updating existing credentials
if co.testbed == for_testbed
co.username = h[:username]
co.password = h[:password]
co.save
if h[:password].gsub("*","").length > 0
co.username = h[:username]
co.password = h[:password]
co.save
end
updated = true
end
}
if (not updated) and h[:username].length > 0
if (not updated) and h[:password].gsub("*","").length > 0
# the supplied credentials where not updated => create new object
new_utc = UserTestbedCredential.new(:testbed_id => for_testbed.id,
:username => h[:username],
Expand Down
20 changes: 12 additions & 8 deletions app/views/users/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<% if @user.github_uid %>
<%# if user comes from github, just make a button to update his account
via a github api request or whatever... %>
changes to users with github account are not (yet) possible! <br/>
<strong>Sorry</strong>, changes to users with github account are not (yet) possible! <br/>
<% else %>
<div class="field">
<%= f.label :name %>
Expand All @@ -40,16 +40,20 @@

<hr>
Change your testbed credentials here: username, password <br/>
<% @testbeds = Testbed.all.inject(Hash.new) { |h, tb| h[tb.shortname] = tb.name; h } %>
<% @testbeds.each do |shortname, name| %>
<% Testbed.all.each do |tb| %>
<%
users_credentials_for_current_testbed = UserTestbedCredential.where(:user_id => @user.id, :testbed_id => tb.id).first
user_username = users_credentials_for_current_testbed.nil? ? "" : users_credentials_for_current_testbed.username
user_password = users_credentials_for_current_testbed.nil? ? "" : "*"*12
%>
<%= fields_for UserTestbedCredential.new do |testbed_fields| %>
<div class="testbedform" id="<%= shortname %>">
<div class="testbedform" id="<%= tb.shortname %>">
<div class="field">
<%= testbed_fields.label name %>
<%= testbed_fields.hidden_field :shortname, :name => "[credentials][#{shortname}][shortname]", :value => shortname %>
<%= testbed_fields.text_field :username, :name => "[credentials][#{shortname}][username]" %>
<%= testbed_fields.password_field :password, :name => "[credentials][#{shortname}][password]" %>
<%= testbed_fields.label tb.name %>
<%= testbed_fields.hidden_field :shortname, :name => "[credentials][#{tb.shortname}][shortname]", :value => tb.shortname %>
<%= testbed_fields.text_field :username, :name => "[credentials][#{tb.shortname}][username]", :value => user_username %>
<%= testbed_fields.password_field :password, :name => "[credentials][#{tb.shortname}][password]", :value => user_password %>
</div>
</div>
<% end %>
Expand Down

0 comments on commit 0c9ea28

Please sign in to comment.