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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: da10da04976a52d4648ffdb3c778062d142dcae7
4
- data.tar.gz: 9dd2ffd57da0500042ff4c6d92c4765ab3480a34
3
+ metadata.gz: ae3828b157640356896379ff1249c5522a5a726e
4
+ data.tar.gz: 5207b80b7dff7969088deeefcf658ddb957e54c1
5
5
  SHA512:
6
- metadata.gz: b513d96125b9d8d0b679560c15e5ad6abe38676a7ca434d667707e981019aac04d22a9db76277d935fc1e7c4aad000b4a31a4c87667c71e76ebc6f7f9a386e7f
7
- data.tar.gz: faa27159f74fef4035a3355cb696ccb0dba8720a030810a58415a077b43e670b99a95e13eabd09ec0fb92ed0b245f24a5257a1ceaea7756d7c5c264bd97774a3
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
+
@@ -0,0 +1,5 @@
1
+
2
+ class My::MyController < IshApi::ApplicationController
3
+
4
+
5
+ end
@@ -0,0 +1,14 @@
1
+
2
+ module Ishapi
3
+ module My
4
+ class ReportsController < Ishapi::My::MyController
5
+
6
+ def index
7
+ authorize! :my_index, Report
8
+ @reports = @profile.reports
9
+ end
10
+
11
+ end
12
+ end
13
+ end
14
+
@@ -0,0 +1,7 @@
1
+
2
+ class Ishapi::My::ReportsController < My::MyController
3
+
4
+ def index
5
+ end
6
+
7
+ end
@@ -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 = IshModels::UserProfile.find_or_create_by :email => email
15
+ u = IshModels::UserProfile.find_or_create_by :email => email
17
16
  u.fb_access_token = access_token
18
- u.name ||= name
19
- u.user = user
20
- u.user ||= User.create( :email => email, :password => (0..8).map { "#{rand(100)}" }.join("#{rand(100)}") )
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
- @graph = Koala::Facebook::API.new( params[:accessToken] )
33
- me = @graph.get_object( 'me', :fields => 'email' )
34
- @user = User.find_by( :email => me['email'] )
35
- @user_profile = IshModels::UserProfile.find_by :email => me['email']
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
- @graph = Koala::Facebook::API.new( params[:accessToken] )
42
- me = @graph.get_object( 'me', :fields => 'email' )
43
- @user = User.find_by( :email => me['email'] )
44
- @user_profile = IshModels::UserProfile.find_by :email => me['email']
45
-
46
- flag = @user_profile.update_attributes( params[:user_profile].permit( :about, :current_city_id ) )
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 => @user_profile.errors.messages }
62
+ render :json => { :status => :not_ok, :errors => @errors }
51
63
  end
52
64
  end
53
65
 
@@ -29,7 +29,8 @@ class Ishapi::Ability
29
29
  gallery.is_public
30
30
  end
31
31
 
32
- can [ :show ], Report do |report|
32
+ can [ :index ], Report
33
+ can [ :my_index, :show ], Report do |report|
33
34
  report.is_public
34
35
  end
35
36
 
@@ -9,5 +9,8 @@ json.cache! key do
9
9
  json.id city.id.to_s
10
10
  json.name city.name
11
11
  json.cityname city.cityname
12
+ if city.profile_photo
13
+ json.photo city.profile_photo.photo.url( :thumb )
14
+ end
12
15
  end
13
16
  end
@@ -0,0 +1,7 @@
1
+
2
+ json.reports do
3
+ json.array! @reports do |report|
4
+ json.id report.id.to_s
5
+ json.name report.name
6
+ end
7
+ end
@@ -0,0 +1,2 @@
1
+
2
+ json.a 'b'
@@ -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
+
@@ -0,0 +1,2 @@
1
+
2
+ json.a 'b'
@@ -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.16
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-07-27 00:00:00.000000000 Z
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