ishapi 0.1.8.16 → 0.1.8.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/controllers/ishapi/my/my_controller.rb +24 -0
- data/app/controllers/ishapi/my/my_controller.rb~ +5 -0
- data/app/controllers/ishapi/my/reports_controller.rb +14 -0
- data/app/controllers/ishapi/my/reports_controller.rb~ +7 -0
- data/app/controllers/ishapi/reports_controller.rb +9 -0
- data/app/controllers/ishapi/users_controller.rb +30 -18
- data/app/models/ishapi/ability.rb +2 -1
- data/app/views/ishapi/cities/index.jbuilder +3 -0
- data/app/views/ishapi/my/reports/index.jbuilder +7 -0
- data/app/views/ishapi/my/reports/index.jbuilder~ +2 -0
- data/app/views/ishapi/reports/index.jbuilder +15 -0
- data/app/views/ishapi/reports/index.jbuilder~ +2 -0
- data/config/routes.rb +10 -0
- metadata +10 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ae3828b157640356896379ff1249c5522a5a726e
|
4
|
+
data.tar.gz: 5207b80b7dff7969088deeefcf658ddb957e54c1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b1f2fd2c999ce138c68f89eb47edaf4390ddd99585ef8e84e0baecd7e34a3ae15c0916ccfedb653365f01aafc46bfee62c6ca79d63d9fe4b570ac8875260a4e8
|
7
|
+
data.tar.gz: c102ffde5d23f1c224a4620a303a4283a9044fcf0c0345980db429578bf729263c89580e9f71cf26e5b9f91548e1783ba8769251bab8c3400f8844765b21ab74
|
@@ -0,0 +1,24 @@
|
|
1
|
+
|
2
|
+
module Ishapi
|
3
|
+
module My
|
4
|
+
class MyController < Ishapi::ApplicationController
|
5
|
+
|
6
|
+
before_action :set_profile
|
7
|
+
|
8
|
+
private
|
9
|
+
|
10
|
+
def set_profile
|
11
|
+
begin
|
12
|
+
@graph = Koala::Facebook::API.new( params[:accessToken] )
|
13
|
+
me = @graph.get_object( 'me', :fields => 'email' )
|
14
|
+
@profile = IshModels::UserProfile.find_by :email => me['email']
|
15
|
+
rescue Koala::Facebook::AuthenticationError => e
|
16
|
+
render :json => { :status => :not_ok, :errors => "Probably expired token." }
|
17
|
+
return
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
@@ -7,5 +7,14 @@ module Ishapi
|
|
7
7
|
authorize! :show, @report
|
8
8
|
end
|
9
9
|
|
10
|
+
def index
|
11
|
+
authorize! :index, Report
|
12
|
+
@reports = Report.all
|
13
|
+
if params[:cityname]
|
14
|
+
city = City.find_by :cityname => params[:cityname]
|
15
|
+
@reports = @reports.where( :city_id => city.id )
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
10
19
|
end
|
11
20
|
end
|
@@ -5,7 +5,6 @@ module Ishapi
|
|
5
5
|
|
6
6
|
def fb_sign_in
|
7
7
|
authorize! :fb_sign_in, Ishapi
|
8
|
-
|
9
8
|
params.permit!
|
10
9
|
|
11
10
|
access_token = params[:accessToken]
|
@@ -13,14 +12,17 @@ module Ishapi
|
|
13
12
|
name = params[:name]
|
14
13
|
user = User.where( :email => email ).first
|
15
14
|
|
16
|
-
u
|
15
|
+
u = IshModels::UserProfile.find_or_create_by :email => email
|
17
16
|
u.fb_access_token = access_token
|
18
|
-
u.name
|
19
|
-
u.user
|
20
|
-
u.user
|
17
|
+
u.name ||= name
|
18
|
+
u.user = user
|
19
|
+
u.user ||= User.create( :email => email, :password => (0..8).map { "#{rand(100)}" }.join("#{rand(100)}") )
|
20
|
+
|
21
|
+
auth = Koala::Facebook::OAuth.new
|
22
|
+
u.fb_long_access_token = auth.exchange_access_token access_token
|
21
23
|
|
22
24
|
if u.save
|
23
|
-
render :json => { :status => :ok }
|
25
|
+
render :json => { :status => :ok, :profile => u }
|
24
26
|
else
|
25
27
|
render :json => { :status => :not_ok, :errors => u.errors.messages }
|
26
28
|
end
|
@@ -28,26 +30,36 @@ module Ishapi
|
|
28
30
|
|
29
31
|
def show
|
30
32
|
authorize! :fb_sign_in, Ishapi
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
33
|
+
begin
|
34
|
+
@graph = Koala::Facebook::API.new( params[:accessToken] )
|
35
|
+
me = @graph.get_object( 'me', :fields => 'email' )
|
36
|
+
@user = User.find_by :email => me['email']
|
37
|
+
@user_profile = IshModels::UserProfile.find_by :email => me['email']
|
38
|
+
rescue Koala::Facebook::AuthenticationError => e
|
39
|
+
render :json => { :status => :not_ok, :errors => "Probably expired token." }
|
40
|
+
return
|
41
|
+
end
|
36
42
|
end
|
37
43
|
|
38
44
|
def update
|
39
45
|
authorize! :fb_sign_in, Ishapi
|
40
46
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
+
begin
|
48
|
+
@graph = Koala::Facebook::API.new( params[:accessToken] )
|
49
|
+
me = @graph.get_object( 'me', :fields => 'email' )
|
50
|
+
@user = User.find_by( :email => me['email'] )
|
51
|
+
@user_profile = IshModels::UserProfile.find_by :email => me['email']
|
52
|
+
flag = @user_profile.update_attributes( params[:user_profile].permit( :about, :current_city_id ) )
|
53
|
+
@errors = @user_profile.errors.messages
|
54
|
+
rescue Koala::Facebook::AuthenticationError => e
|
55
|
+
flag = false
|
56
|
+
@errors = "Probably expired token."
|
57
|
+
end
|
58
|
+
|
47
59
|
if flag
|
48
60
|
render :json => { :status => :ok }
|
49
61
|
else
|
50
|
-
render :json => { :status => :not_ok, :errors => @
|
62
|
+
render :json => { :status => :not_ok, :errors => @errors }
|
51
63
|
end
|
52
64
|
end
|
53
65
|
|
@@ -0,0 +1,15 @@
|
|
1
|
+
|
2
|
+
#
|
3
|
+
# ishapi / reports / index.jbuilder
|
4
|
+
#
|
5
|
+
|
6
|
+
json.array! @reports do |report|
|
7
|
+
json.id report.id.to_s
|
8
|
+
json.name report.name
|
9
|
+
json.reportname report.name_seo
|
10
|
+
json.subhead report.subhead
|
11
|
+
if report.photo
|
12
|
+
json.photo report.photo.photo.url( :thumb )
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
data/config/routes.rb
CHANGED
@@ -8,6 +8,16 @@ Ishapi::Engine.routes.draw do
|
|
8
8
|
|
9
9
|
get 'galleries/view/:galleryname', :to => 'galleries#show'
|
10
10
|
|
11
|
+
namespace :my do
|
12
|
+
post 'reports', :to => 'reports#index'
|
13
|
+
get 'reports', :to => 'reports#index'
|
14
|
+
|
15
|
+
# resources :reports
|
16
|
+
# resources :galleries
|
17
|
+
# resources :videos
|
18
|
+
end
|
19
|
+
|
20
|
+
get 'reports', :to => 'reports#index'
|
11
21
|
get 'reports/view/:name_seo', :to => 'reports#show'
|
12
22
|
|
13
23
|
get 'sites/view/:domain', :to => 'sites#show', :constraints => { :domain => /[^\/]+/ }
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ishapi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.8.
|
4
|
+
version: 0.1.8.17
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- piousbox
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-08-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -132,6 +132,10 @@ files:
|
|
132
132
|
- app/controllers/ishapi/cities_controller.rb~
|
133
133
|
- app/controllers/ishapi/galleries_controller.rb
|
134
134
|
- app/controllers/ishapi/galleries_controller.rb~
|
135
|
+
- app/controllers/ishapi/my/my_controller.rb
|
136
|
+
- app/controllers/ishapi/my/my_controller.rb~
|
137
|
+
- app/controllers/ishapi/my/reports_controller.rb
|
138
|
+
- app/controllers/ishapi/my/reports_controller.rb~
|
135
139
|
- app/controllers/ishapi/reports_controller.rb
|
136
140
|
- app/controllers/ishapi/reports_controller.rb~
|
137
141
|
- app/controllers/ishapi/sites_controller.rb
|
@@ -165,6 +169,8 @@ files:
|
|
165
169
|
- app/views/ishapi/galleries/_show.jbuilder~
|
166
170
|
- app/views/ishapi/galleries/show.jbuilder
|
167
171
|
- app/views/ishapi/galleries/show.jbuilder~
|
172
|
+
- app/views/ishapi/my/reports/index.jbuilder
|
173
|
+
- app/views/ishapi/my/reports/index.jbuilder~
|
168
174
|
- app/views/ishapi/newsitems/_index.jbuilder
|
169
175
|
- app/views/ishapi/newsitems/_index.jbuilder~
|
170
176
|
- app/views/ishapi/photos/_index.jbuilder
|
@@ -173,6 +179,8 @@ files:
|
|
173
179
|
- app/views/ishapi/photos/_show.jbuilder~
|
174
180
|
- app/views/ishapi/reports/_index.jbuilder
|
175
181
|
- app/views/ishapi/reports/_index.jbuilder~
|
182
|
+
- app/views/ishapi/reports/index.jbuilder
|
183
|
+
- app/views/ishapi/reports/index.jbuilder~
|
176
184
|
- app/views/ishapi/reports/show.jbuilder
|
177
185
|
- app/views/ishapi/reports/show.jbuilder~
|
178
186
|
- app/views/ishapi/sites/show.jbuilder
|