ishapi 0.1.8.174 → 0.1.8.177

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
  SHA256:
3
- metadata.gz: 5ca21156e5ba448350ec31e26cd9b5535e592f1466fcd93d2fdc20a95c54a6e6
4
- data.tar.gz: 81296feba05c6e80d915ba72471a14bb478dbb56b4426a89fc8a74dc1ee9c879
3
+ metadata.gz: 3d2316758e2797aeecb65f3e8cacdb034902a7271f8518da15707050bf64e097
4
+ data.tar.gz: ba8bc72419963ea42441cee3dfd3b537aa79d3bf8dd21ff5fa4f44f7e77b37c7
5
5
  SHA512:
6
- metadata.gz: caf3f76f15dfa7ce327ad1397e2c5c5675a049319078d889e1d86975277052f3f7b93a0125965e3e0b1b6e391a3884b5f95f6590b1b298d5661edd21698a074f
7
- data.tar.gz: a8d1894747b69ead5559264ed71c78f4ff3c4beb7add7890e9f87b1a928fba61c6afac94daa0e4cd1391ee8b2b6a8f8dfaee6143e771536ac5359e382f3a3b15
6
+ metadata.gz: 33e25407dddeeafa0fe7e80e3483c0e674ebb36028644f69c4b37c2ac03787d93568cddad0ce6981d4c63c0f527c754a4bb572e6d4a8d622e215d212c9e9b22b
7
+ data.tar.gz: cfed72d717b27f1c7f303eace2491441f0e5108f2536a51fdedaf7c1ed00735012a16b2db13422e4dc6f93aff33a008e4a5b843685fd26fc4c443f3f22fcea60
@@ -2,12 +2,26 @@ require_dependency "ishapi/application_controller"
2
2
  module Ishapi
3
3
  class UserProfilesController < ApplicationController
4
4
 
5
- before_action :check_profile
5
+ before_action :check_profile, only: %i| show | ## @TODO: hmmm I may not need this check at all
6
+
7
+ before_action :check_profile_hard, only: %i| update |
6
8
 
7
9
  def show
8
- @profile = IshModels::UserProfile.find_by :username => params[:username]
10
+ @profile = Ish::UserProfile.find_by :username => params[:username]
9
11
  authorize! :show, @profile
10
12
  end
11
13
 
14
+ def update
15
+ @profile = Ish::UserProfile.find @current_user.profile
16
+ authorize! :update, @profile
17
+
18
+ flag = @profile.update params[:profile].permit!
19
+ if flag
20
+ render json: { message: 'ok' }, status: :ok
21
+ else
22
+ render json: { message: "No luck: #{@profile.errors.full_messages.join(", ")}." }, code: 400
23
+ end
24
+ end
25
+
12
26
  end
13
27
  end
@@ -33,6 +33,9 @@ class Ishapi::Ability
33
33
  user ||= User.new
34
34
 
35
35
  can [ :show ], Ish::UserProfile
36
+ can [ :update ], Ish::UserProfile do |p|
37
+ p.user.id.to_s == user.id.to_s
38
+ end
36
39
 
37
40
  can [ :index, :show ], City
38
41
 
@@ -20,10 +20,9 @@ json.markers do
20
20
  ## @TODO: this is copy-pasted and should be abstracted.
21
21
  destination = marker.destination
22
22
  json.premium_tier destination.premium_tier
23
+ json.is_premium destination.is_premium
23
24
  json.id destination.id.to_s
24
25
  if destination.is_premium
25
- json.premium_tier destination.premium_tier
26
- json.is_premium destination.premium_tier > 0
27
26
  if current_user && current_user.profile
28
27
  json.is_purchased current_user.profile.has_premium_purchase( destination )
29
28
  end
@@ -5,6 +5,7 @@
5
5
  json.n_newsitems newsitems.count
6
6
  json.newsitems do
7
7
  json.array! newsitems do |item|
8
+ json.id item.id.to_s
8
9
  json.name item.name
9
10
  json.created_at item.created_at
10
11
  json.updated_at item.updated_at
@@ -59,7 +60,7 @@ json.newsitems do
59
60
  end
60
61
  end
61
62
 
62
- if item.video_id
63
+ if item.video
63
64
  json.id item.video_id.to_s
64
65
  # @TODO: why this relation is so weird here?!
65
66
  video = Video.unscoped.find( item.video_id )
data/config/routes.rb CHANGED
@@ -58,8 +58,8 @@ Ishapi::Engine.routes.draw do
58
58
 
59
59
  post 'users/fb_sign_in', to: 'users#fb_sign_in'
60
60
  get 'users/me', to: 'users#account'
61
- post 'users/profile', to: 'users#show'
62
- post 'users/profile/update', to: 'users#update'
61
+ post 'users/profile', to: 'users#show' ## @TODO: change, this makes no sense
62
+ post 'users/profile/update', to: 'user_profiles#update'
63
63
  get 'users/profile', to: 'users#show' # @TODO: only for testing! accessToken must be hidden
64
64
  match 'users/long_term_token', to: 'application#long_term_token', via: [ :get, :post ]
65
65
  post 'users/login', to: 'users#login'
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.174
4
+ version: 0.1.8.177
5
5
  platform: ruby
6
6
  authors:
7
7
  - piousbox
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-03-19 00:00:00.000000000 Z
11
+ date: 2022-04-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails