]> git.openstreetmap.org Git - rails.git/commitdiff
Reorganised OAuth clients and tokens details page. Made clients info editable and...
authorMatt Amos <zerebubuth@gmail.com>
Mon, 3 Aug 2009 17:08:40 +0000 (17:08 +0000)
committerMatt Amos <zerebubuth@gmail.com>
Mon, 3 Aug 2009 17:08:40 +0000 (17:08 +0000)
app/views/oauth_clients/_form.html.erb
app/views/oauth_clients/edit.html.erb
app/views/oauth_clients/index.html.erb
app/views/oauth_clients/new.html.erb
app/views/oauth_clients/show.html.erb
app/views/user/account.html.erb
app/views/user/view.html.erb
config/locales/en.yml
test/integration/client_application_test.rb

index e55b016e982a2ce7e11eb28979c675160714996c..f8fd4347e7a65d12879533ae308d115dafb15b69 100644 (file)
@@ -1,40 +1,23 @@
 <div class="field">
 <div class="field">
-       <label for="client_application_name">Name*</label><br/>
+       <label for="client_application_name"><%= t'oauth.client_application.form.name' %> (<%= t'oauth.client_application.form.required' %>)</label><br/>
        <%= f.text_field :name %>
 </div>
 <div class="field">
        <%= f.text_field :name %>
 </div>
 <div class="field">
-       <label for="client_application_url">Main Application URL*</label><br/>
+       <label for="client_application_url"><%= t'oauth.client_application.form.url' %> (<%= t'oauth.client_application.form.required' %>)</label><br/>
        <%= f.text_field :url %>
 </div>
 <div class="field">
        <%= f.text_field :url %>
 </div>
 <div class="field">
-       <label for="client_application_callback_url">Callback URL*</label><br/>
+       <label for="client_application_callback_url"><%= t'oauth.client_application.form.callback_url' %></label><br/>
        <%= f.text_field :callback_url %>
 </div>
 <div class="field">
        <%= f.text_field :callback_url %>
 </div>
 <div class="field">
-       <label for="client_application_support_url">Support URL</label><br/>
+       <label for="client_application_support_url"><%= t'oauth.client_application.form.support_url' %></label><br/>
        <%= f.text_field :support_url %>
 </div>
        <%= f.text_field :support_url %>
 </div>
+<p><%= t'oauth.client_application.form.requests' %></p>
+<% ClientApplication.all_permissions.each do |perm| %>
 <div class="field">
 <div class="field">
-  <%= f.check_box :allow_read_prefs %>
-  <label for="client_application_allow_read_prefs">Request permission to read the user preferences.</label><br/>
-</div>
-<div class="field">
-  <%= f.check_box :allow_write_prefs %>
-  <label for="client_application_allow_write_prefs">Request permission to write the user preferences.</label><br/>
-</div>
-<div class="field">
-  <%= f.check_box :allow_write_diary %>
-  <label for="client_application_allow_write_diary">Request permission to create diary entries, comments and friends.</label><br/>
-</div>
-<div class="field">
-  <%= f.check_box :allow_write_api %>
-  <label for="client_application_allow_write_api">Request permission to write the API on the user's behalf.</label><br/>
-</div>
-<div class="field">
-  <%= f.check_box :allow_read_gpx %>
-  <label for="client_application_allow_read_gpx">Request permission to read the user's private GPS traces.</label><br/>
-</div>
-<div class="field">
-  <%= f.check_box :allow_write_gpx %>
-  <label for="client_application_allow_write_gpx">Request permission to upload GPS traces as the user.</label><br/>
+  <%= f.check_box perm %>
+  <label for="client_application_<%= perm.to_s %>"><%= t('oauth.client_application.form.' + perm.to_s) %></label><br/>
 </div>
 </div>
+<% end %>
index 3ff72fee3951158c7f12fc920b2f80bf68402b78..d3b2c8c8ad915aa55bdd5fecabbb15c8bf97c73a 100644 (file)
@@ -1,5 +1,6 @@
-<h1>Edit your application</h1>
-<% form_for :client_application do |f| %>
+<h1><%= t'oauth.client_application.edit.title' %></h1>
+<% form_for :client_application, @client_application, :url => oauth_client_path(@client_application), :html => { :method => :put } do |f| %>
        <%= render :partial => "form", :locals => { :f => f } %>
        <%= render :partial => "form", :locals => { :f => f } %>
-       <%= submit_tag "Edit" %>
-<% end %>
\ No newline at end of file
+       <br/>
+       <%= submit_tag t'oauth.client_application.edit.submit' %>
+<% end %>
index 8f9e0a0b1da03b89a8bbe4ad2bbe4dad39712312..9f11cddef16c6ece66bc9072dd0ec9755dddce75 100644 (file)
@@ -1,9 +1,10 @@
-<div class="flash"><%= flash[:notice] %></div>
-<h1>OAuth Client Applications</h1>
+<h1><%= t'oauth.client_application.index.title' %></h1>
 <% unless @tokens.empty? %>
 <% unless @tokens.empty? %>
-<p>The following tokens have been issued to applications in your name</p>
+<h3><%= t'oauth.client_application.index.my_tokens' %></h3>
+<p><%= t'oauth.client_application.index.list_tokens' %></p>
 <table>
 <table>
-  <tr><th>Application</th><th>Issued</th><th>&nbsp;</th></tr>
+  <tr><th><%= t'oauth.client_application.index.application' %></th>
+    <th><%= t'oauth.client_application.index.issued_at' %></th><th>&nbsp;</th></tr>
   <% @tokens.each do |token|%>
     <% content_tag_for :tr, token do %>
       <td><%= link_to token.client_application.name, token.client_application.url %></td>
   <% @tokens.each do |token|%>
     <% content_tag_for :tr, token do %>
       <td><%= link_to token.client_application.name, token.client_application.url %></td>
       <td>
        <% form_tag :controller => 'oauth', :action => 'revoke' do %>
        <%= hidden_field_tag 'token', token.token %>
       <td>
        <% form_tag :controller => 'oauth', :action => 'revoke' do %>
        <%= hidden_field_tag 'token', token.token %>
-       <%= submit_tag "Revoke!" %>
+       <%= submit_tag t('oauth.client_application.index.revoke') %>
        <% end %>
       </td>
     <% end %>
   <% end %>    
 </table>
 <% end %>
        <% end %>
       </td>
     <% end %>
   <% end %>    
 </table>
 <% end %>
-<h3>Application Developers</h3>
+<h3><%= t'oauth.client_application.index.my_apps' %></h3>
 <% if @client_applications.empty? %>
 <% if @client_applications.empty? %>
-       <p>
-               Do you have an application you would like to register for use with us using the <a href="http://oauth.net">OAuth</a> standard?
-       </p>
-       <p>
-               You must register your web application before it can make OAuth requests to this service
-       </p>
+<p><%= t('oauth.client_application.index.no_apps', :oauth => "<a href=\"http://oauth.net\">OAuth</a>") %></p>
 <% else %>
 <% else %>
-       <p>
-               You have the following client applications registered:
-       </p>
-       <% @client_applications.each do |client|%>
-               <% div_for client do %>
-                       <%= link_to client.name, :action => :show, :id => client.id %>
-               <% end %>
-       <% end %>
+<p><%= t'oauth.client_application.index.registered_apps' %></p>
+<% @client_applications.each do |client|%>
+  <% div_for client do %>
+    <%= link_to client.name, :action => :show, :id => client.id %>
+  <% end %>
+<% end %>
 <% end %>
 <% end %>
-<h3><%= link_to "Register your application", :action => :new %></h3>
+<h3><%= link_to t('oauth.client_application.index.register_new'), :action => :new %></h3>
index 34b2d2b296ee7529d33223629492f3bfd71929db..75102f80c91c76da92101c17bb2e9d7bfb42c986 100644 (file)
@@ -1,6 +1,6 @@
-<h1>Register a new application</h1>
+<h1><%= t'oauth.client_application.new.title' %></h1>
 <% form_for :client_application, :url => { :action => :create } do |f| %>
    <%= render :partial => "form", :locals => { :f => f } %>
    <br />
 <% form_for :client_application, :url => { :action => :create } do |f| %>
    <%= render :partial => "form", :locals => { :f => f } %>
    <br />
-   <%= submit_tag "Register" %>
+   <%= submit_tag t'oauth.client_application.new.submit' %>
 <% end %>
 <% end %>
index 5ec45aef5b6115c3b361ed8f676fba6f6a003408..281af522278b79bef6eda189c58c22ded0968672 100644 (file)
@@ -1,20 +1,28 @@
-<h1>OAuth details for <%=@client_application.name %></h1>
+<h1><%= t('oauth.client_application.show.title', :app_name => @client_application.name) %></h1>
 <p>
 <p>
-       <b>Consumer Key:</b> <%=@client_application.key %>
+       <b><%= t'oauth.client_application.show.key' %></b> <%=@client_application.key %>
 </p>
 <p>
 </p>
 <p>
-       <b>Consumer Secret:</b> <%=@client_application.secret %>
+       <b><%= t'oauth.client_application.show.secret' %></b> <%=@client_application.secret %>
 </p>
 <p>
 </p>
 <p>
-       <b>Request Token URL</b> http<%='s' if request.ssl? %>://<%= request.host_with_port %><%=@client_application.oauth_server.request_token_path %>
+       <b><%= t'oauth.client_application.show.url' %></b> http<%='s' if request.ssl? %>://<%= request.host_with_port %><%=@client_application.oauth_server.request_token_path %>
 </p>
 <p>
 </p>
 <p>
-       <b>Access Token URL</b> http<%='s' if request.ssl? %>://<%= request.host_with_port %><%=@client_application.oauth_server.access_token_path %>
+       <b><%= t'oauth.client_application.show.access_url' %></b> http<%='s' if request.ssl? %>://<%= request.host_with_port %><%=@client_application.oauth_server.access_token_path %>
 </p>
 <p>
 </p>
 <p>
-       <b>Authorize URL</b> http<%='s' if request.ssl? %>://<%= request.host_with_port %><%=@client_application.oauth_server.authorize_path %>
+       <b><%= t'oauth.client_application.show.authorize_url' %></b> http<%='s' if request.ssl? %>://<%= request.host_with_port %><%=@client_application.oauth_server.authorize_path %>
 </p>
 
 </p>
 
-<p>
-       We support hmac-sha1 (recommended) as well as plain text in ssl mode.
-</p>
\ No newline at end of file
+<p><%= t'oauth.client_application.show.requests' %></p>
+<ul><% @client_application.permissions.each do |perm| %>
+<div class="field">
+  <li><%= t('oauth.client_application.form.' + perm.to_s) %></li>
+</div>
+<% end %></ul>
+
+<p><%= t'oauth.client_application.show.support_notice' %></p>
+
+<p><%= link_to t('oauth.client_application.show.edit'), edit_oauth_client_url(@client_application) %></p>
+
index 1cc6b4a29817fb348e96f93fd4b51080481cc7b5..45a129077563145ca47ed20e7c2542be4f54b0a9 100644 (file)
   <br /><br />
   <%= button_to t('user.account.make all my edits public button'), :action => :go_public %>
 <% end %>
   <br /><br />
   <%= button_to t('user.account.make all my edits public button'), :action => :go_public %>
 <% end %>
-<h2><%= t 'user.account.my apps' %></h2>
-<% if @tokens.empty? %>
-<p><%= t 'oauth.token.none' %></p>
-<% else %>
-<table>
-  <tr><th><%= t 'oauth.token.application' %></th><th><%= t 'oauth.token.issued' %></th><th>&nbsp;</th></tr>
-  <% @tokens.each do |token|%>
-    <% content_tag_for :tr, token do %>
-      <td><%= link_to token.client_application.name, token.client_application.url %></td>
-      <td><%= token.authorized_at %></td>
-      <td>
-       <% form_tag :controller => 'oauth', :action => 'revoke' do %>
-       <%= hidden_field_tag 'token', token.token %>
-       <%= submit_tag t('oauth.token.revoke') %>
-       <% end %>
-      </td>
-    <% end %>
-  <% end %>    
-</table>
-<% end %>
-<h2><%= t 'user.account.developers' %></h2>
-<% if @user.client_applications.empty? %>
-<p><%= t 'user.account.dev_intro', :link => "<a href=\"http://oauth.net\">OAuth</a>" %></p>
-<p><%= link_to t('user.account.register_app'), :controller => 'oauth_clients', :action => :new %></p>
-<% else %>
-<p><%= t 'user.account.apps_registered' %></p>
-<ul><% @user.client_applications.each do |client| %>
-  <li><% div_for client do %>
-    <%= link_to client.name, :controller => 'oauth_clients', :action => :show, :id => client.id %>
-  <% end %></li>
-<% end %></ul>
-<p><%= link_to t('user.account.register_another_app'), :controller => 'oauth_clients', :action => :new %></p>
-<% end %>
 <br/>
 <br/>
 <%= link_to t('user.account.return to profile'), :controller => 'user', :action => @user.display_name %>
 <br/>
 <br/>
 <%= link_to t('user.account.return to profile'), :controller => 'user', :action => @user.display_name %>
index ff349858c9229fd42916982fd0786c5fed3207f1..931037319a2d909d21815efa7cb6820778a64621 100644 (file)
 <br/>
 <% if @user and @this_user.id == @user.id %>
 <%= link_to t('user.view.change your settings'), :controller => 'user', :action => 'account', :display_name => @user.display_name %>
 <br/>
 <% if @user and @this_user.id == @user.id %>
 <%= link_to t('user.view.change your settings'), :controller => 'user', :action => 'account', :display_name => @user.display_name %>
+<br/><br/>
+<%= link_to t('user.view.my_oauth_details'), :controller => 'oauth_clients', :action => 'index' %>
 <% end %>
 <% end %>
index d98ac61d64f87a25b352bfab14175dde7c3885bf..8c685df651e4db4ea38005012c213ac48a4f6916 100644 (file)
@@ -793,11 +793,52 @@ en:
       allow_write_api:   "modify the map."
       allow_read_gpx:    "read your private GPS traces."
       allow_write_gpx:   "upload GPS traces."
       allow_write_api:   "modify the map."
       allow_read_gpx:    "read your private GPS traces."
       allow_write_gpx:   "upload GPS traces."
-    token:
-      none: "You have not authorised any clients to act on your behalf. You do not have to do anything now to authorise them, as they will ask for authorisation when they need it. After that time you can return here to revoke those permissions if you do not want the clients to have your authorisation any more."
-      application: "Application"
-      issued: "Issued"
-      revoke: "Revoke!"
+      new:
+        title: "Register a new application"
+        submit: "Register"
+      edit:
+        title: "Edit your application"
+        submit: "Edit"
+      show:
+        title: "OAuth details for {{app_name}}"
+        key: "Consumer Key:"
+        secret: "Consumer Secret:"
+        url: "Request Token URL:"
+        access_url: "Access Token URL:"
+        authorize_url: "Authorise URL:"
+        support_notice: "We support hmac-sha1 (recommended) as well as plain text in ssl mode."
+        edit: "Edit Details"
+        requests: "Requesting the following permissions from the user:"
+        allow_read_prefs:  "read their user preferences."
+        allow_write_prefs: "modify their user preferences."
+        allow_write_diary: "create diary entries, comments and make friends."
+        allow_write_api:   "modify the map."
+        allow_read_gpx:    "read their private GPS traces."
+        allow_write_gpx:   "upload GPS traces."
+      index:
+        title: "My OAuth Details"
+        my_tokens: "My Authorised Applications"
+        list_tokens: "The following tokens have been issued to applications in your name:"
+        application: "Application Name"
+        issued_at: "Issued At"
+        revoke: "Revoke!"
+        my_apps: "My Client Applications"
+        no_apps: "Do you have an application you would like to register for use with us using the {{oauth}} standard? You must register your web application before it can make OAuth requests to this service."
+        registered_apps: "You have the following client applications registered:"
+        register_new: "Register your application"
+      form:
+        name: "Name"
+        required: "Required"
+        url: "Main Application URL"
+        callback_url: "Callback URL"
+        support_url: "Support URL"
+        requests: "Request the following permissions from the user:"
+        allow_read_prefs:  "read their user preferences."
+        allow_write_prefs: "modify their user preferences."
+        allow_write_diary: "create diary entries, comments and make friends."
+        allow_write_api:   "modify the map."
+        allow_read_gpx:    "read their private GPS traces."
+        allow_write_gpx:   "upload GPS traces."
   user:
     login:
       title: "Login"
   user:
     login:
       title: "Login"
@@ -870,6 +911,7 @@ en:
       nearby users: "Nearby users: "
       no nearby users: "There are no users who admit to mapping nearby yet."
       change your settings: change your settings
       nearby users: "Nearby users: "
       no nearby users: "There are no users who admit to mapping nearby yet."
       change your settings: change your settings
+      my_oauth_details: "View my OAuth details"
     friend_map:
       your location: Your location
       nearby mapper: "Nearby mapper: "
     friend_map:
       your location: Your location
       nearby mapper: "Nearby mapper: "
@@ -896,12 +938,6 @@ en:
       return to profile: Return to profile
       flash update success confirm needed: "User information updated successfully. Check your email for a note to confirm your new email address."
       flash update success: "User information updated successfully."
       return to profile: Return to profile
       flash update success confirm needed: "User information updated successfully. Check your email for a note to confirm your new email address."
       flash update success: "User information updated successfully."
-      my apps: "My client applications"
-      developers: "Application Developers"
-      dev_intro: "Have you written an application which you would like to register to make {{link}} requests to the OpenStreetMap server?"
-      register_app: "Register your application"
-      apps_registered: "You have the following client applications registered:"
-      register_another_app: "Register another application"
     confirm:
       heading: Confirm a user account
       press confirm button: "Press the confirm button below to activate your account."
     confirm:
       heading: Confirm a user account
       press confirm button: "Press the confirm button below to activate your account."
index 0af2260858ae90cddd658542d3bb8c68ffbdf5da..cc2cbc21790328bfa7c634bb4466e2356b110b58 100644 (file)
@@ -7,15 +7,21 @@ class ClientApplicationTest < ActionController::IntegrationTest
   # run through the procedure of creating a client application and checking
   # that it shows up on the user's account page.
   def test_create_application
   # run through the procedure of creating a client application and checking
   # that it shows up on the user's account page.
   def test_create_application
-    post '/login', {'user[email]' => "test@example.com", 'user[password]' => "test", :referer => '/user/test/account'}
+    post '/login', {'user[email]' => "test@example.com", 'user[password]' => "test", :referer => '/user/test2'}
     assert_response :redirect
     follow_redirect!
     assert_response :success
     assert_response :redirect
     follow_redirect!
     assert_response :success
-    assert_template 'user/account'
+    assert_template 'user/view'
 
     # check that the form to allow new client application creations exists
     assert_in_body do
 
     # check that the form to allow new client application creations exists
     assert_in_body do
-      assert_select "h2", "Application Developers" 
+      assert_select "a[href='/oauth_clients']"
+    end
+
+    # now we follow the link to the oauth client list
+    get '/oauth_clients'
+    assert_response :success
+    assert_in_body do
       assert_select "a[href='/oauth_clients/new']"
     end
 
       assert_select "a[href='/oauth_clients/new']"
     end
 
@@ -46,10 +52,10 @@ class ClientApplicationTest < ActionController::IntegrationTest
     assert_equal 'Registered the information successfully', flash[:notice]
 
     # now go back to the account page and check its listed under this user
     assert_equal 'Registered the information successfully', flash[:notice]
 
     # now go back to the account page and check its listed under this user
-    get '/user/test/account'
+    get '/oauth_clients'
     assert_response :success
     assert_response :success
-    assert_template 'user/account'
-    assert_in_body { assert_select "li>div>a", "My New App" }
+    assert_template 'oauth_clients/index'
+    assert_in_body { assert_select "div>a", "My New App" }
   end
 
   ##
   end
 
   ##