New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fixes #2969 - remove all legacy api code in UI controllers + fixes #2985 remove #as_json + fixes #2986 remove #show #855
Conversation
@@ -8,10 +8,7 @@ def index | |||
autosign = [] | |||
error e | |||
end | |||
respond_to do |format| | |||
format.html { @autosign = autosign.paginate :page => params[:page], :per_page => 20 } | |||
format.json {render :json => autosign } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i dont think we have that over the API, can you add a ticket to add that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ohadlevy, yes this was added as http://projects.theforeman.org/issues/2983
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK
two minor comments
|
@ohadlevy, yes I will also remove the as_json from the models as well. My assumption is these were only used for the API. I will check if any changes after the ajax dropdown lists. |
@ohadlevy, re-committed.
|
@isratrade it seems to be failing, can you have a look? |
@@ -1,12 +1,16 @@ | |||
object @host | |||
|
|||
attributes :name, :id, :ip, :environment, :last_report, :updated_at, :created_at, :mac, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:environment was moved below to a child node, since it caused an error "no method key?", I assume since the as_json was removed from the Environment model.
I added issue #3006 - Add to API v1 /api/hosts/disabled as /hosts/disabled with json response no longer works |
@@ -6,23 +6,6 @@ class ComputeResourcesControllerTest < ActionController::TestCase | |||
@your_compute_resource = compute_resources(:yourcompute) | |||
end | |||
|
|||
test "should not get index when not permitted" do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should keep this test, but remove the JSON bit of the request
This will wait for Greg's #858 as there's going to be a very small conflict on the reports model as_json I think, it'll be merged shortly. |
Could you rebase this please @isratrade? Thanks! |
@domcleal, rebased |
@isratrade did you see the comments about tests? Some of them could be quite useful if made non-JSON specific. |
@domcleal, @ohadlevy, re-committed with fixes in last commit that I will squash after your review. |
yes, I think they should be removed |
rebased and recommited with as_json from log.rb and report.rb removed |
@isratrade I'm getting two errors:
|
this looks good from the Reports api viewpoint now, thanks @isratrade |
I think we need to remove the api handling from the application_controller |
+1 |
@isratrade this needs a rebase now, because of the change to the hosts API rabl, thanks! |
@@ -1,6 +1,6 @@ | |||
object @host | |||
|
|||
attributes :name, :id, :ip, :environment_id, :environment, :last_report, :updated_at, :created_at, :mac, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I consider the "warning" in 62e6c84 less of a warning and more of a final error.. could we just use a normal error response? |
@domcleal, I'm not sure this is what you wanted but the response for json calls to a UI controller is
I need to create the json manually, since I'm in the UI ApplicationController controller and don't have access to the render_error method in Api::BaseController. However, render_error just calls one of several templates in api/v1/errors (or v2) that just have a simple response with node(:message). I also added to the log an error message with the real exception ActionView::MissingTemplate that I rescued from |
recommitted. Returns status 400 and includes actual exception (ActionView::MissingTemplate) in logger.error in addition to deprecation message |
Thanks @isratrade, that's much better. Unfortunately I can't get it to work, do you see this bug, or what's happening? $ git co - HEAD is now at f5ec783... fixes #2969 - add deprecation response for api calls to UI routes $ curl -s -u admin:changeme -H 'Accept: application/json' "http://0.0.0.0:3000/hosts/iridium.redhat.com" $ (a single space in the output) Started GET "/hosts/iridium.redhat.com" for 127.0.0.1 at 2013-09-10 16:45:27 +0100 Processing by HostsController#show as JSON Parameters: {"id"=>"iridium.redhat.com"} User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."login" = 'admin' LIMIT 1 AuthSource Load (0.1ms) SELECT "auth_sources".* FROM "auth_sources" WHERE "auth_sources"."id" = 1 LIMIT 1 User Load (0.2ms) SELECT "users".* FROM "users" WHERE (login='admin') LIMIT 1 Authenticated user Admin User against INTERNAL authentication source User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."login" = 'admin' ORDER BY firstname LIMIT 1 Setting current user thread-local variable to admin (0.0ms) begin transaction (0.2ms) UPDATE "users" SET "last_login_on" = '2013-09-10 15:45:29.651730', "updated_at" = '2013-09-10 15:45:29.652912' WHERE "users"."id" = 1 (33.3ms) commit transaction Role Load (0.1ms) SELECT "roles".* FROM "roles" WHERE "roles"."name" = 'Anonymous' LIMIT 1 Role Exists (0.1ms) SELECT 1 AS one FROM "roles" INNER JOIN "user_roles" ON "roles"."id" = "user_roles"."role_id" WHERE "user_roles"."user_id" = 1 AND "roles"."id" = 8 LIMIT 1 Setting current user thread-local variable to admin Setting current user thread-local variable to nil User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."login" = 'admin' LIMIT 1 Authorized user admin(Admin User) Setting current user thread-local variable to admin Host::Base Load (0.1ms) SELECT "hosts".* FROM "hosts" WHERE "hosts"."name" = 'iridium.redhat.com' LIMIT 1 Completed 406 Not Acceptable in 389ms (ActiveRecord: 35.7ms) |
@domcleal, I'm also getting 406 for /hosts or hosts/:id and not sure why. I was testing with /domains and /environments. There's another issue that came up. I can't rescue_from ActionController::RoutingError So for show actions such as domains/12, I get a routing error because :show was removed from routes.rb when it's not used. I don't have a good solution, since there are some places in the UI that uses JSON, so we can't capture all JSON requests. @ohadlevy, any ideas |
This pull request is considered as blocker for Foreman 1.3 release. |
…son output that was removed
I removed commit 2b52e77 for issue #2986 that removed the show method and show in routes.rb when not used. I will re-commit this at a later stage after we don't need the deprecation message any more on UI controllers. |
Good find, it worked properly in my test. Thanks for the patches @isratrade, merged in as 9dc1001..bc89eb3 for Foreman 1.3. |
I left the json code in the following controllers as they don't appear in the API code
Also, the json code used by the UI was of course not removed