2012-04-10 19:57:18 +00:00
|
|
|
class GettingStartedController < ApplicationController
|
|
|
|
|
2012-09-20 12:08:02 +00:00
|
|
|
=begin
|
|
|
|
|
|
|
|
Resource:
|
|
|
|
GET /api/getting_started.json
|
|
|
|
|
|
|
|
Response:
|
|
|
|
{
|
|
|
|
"master_user": 1,
|
|
|
|
"groups": [
|
|
|
|
{
|
|
|
|
"name": "group1",
|
|
|
|
"active":true
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "group2",
|
|
|
|
"active":true
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
Test:
|
|
|
|
curl http://localhost/api/getting_started.json -v -u #{login}:#{password}
|
|
|
|
|
|
|
|
=end
|
|
|
|
|
2012-04-10 19:57:18 +00:00
|
|
|
def index
|
|
|
|
|
|
|
|
# check if first user already exists
|
|
|
|
master_user = 0
|
|
|
|
count = User.all.count()
|
2012-08-02 10:06:26 +00:00
|
|
|
if count <= 2
|
2012-04-10 19:57:18 +00:00
|
|
|
master_user = 1
|
|
|
|
end
|
|
|
|
|
2012-09-20 12:08:02 +00:00
|
|
|
# if master user already exists, we need to be authenticated
|
|
|
|
if master_user == 0
|
|
|
|
return if !authentication_check
|
|
|
|
end
|
|
|
|
|
2012-04-10 19:57:18 +00:00
|
|
|
# get all groups
|
2012-09-20 12:08:02 +00:00
|
|
|
groups = Group.where( :active => true )
|
2012-04-10 19:57:18 +00:00
|
|
|
|
|
|
|
# return result
|
2012-04-11 06:34:56 +00:00
|
|
|
render :json => {
|
|
|
|
:master_user => master_user,
|
2012-09-20 12:08:02 +00:00
|
|
|
:groups => groups,
|
2012-04-11 06:34:56 +00:00
|
|
|
}
|
2012-04-10 19:57:18 +00:00
|
|
|
end
|
|
|
|
end
|