|
1 | 1 | # frozen_string_literal: true |
2 | 2 |
|
3 | | -json.extract! member, :id, :username, :email, :group_id |
4 | | -json.role member.roles.first.name |
| 3 | +json.extract! member, :username, :email, :slug |
| 4 | +unless @restricted_member_show |
| 5 | + json.id member.id |
| 6 | + json.group_id member.group_id |
| 7 | + json.role member.roles.first.name |
| 8 | +end |
5 | 9 | json.name member.profile.full_name |
6 | | -json.need_completion member.need_completion? |
7 | | -json.ip_address member.current_sign_in_ip.to_s |
8 | | -json.mapped_from_sso member.mapped_from_sso&.split(',') |
| 10 | +json.need_completion member.need_completion? unless @restricted_member_show |
| 11 | +json.ip_address member.current_sign_in_ip.to_s unless @restricted_member_show |
| 12 | +json.mapped_from_sso member.mapped_from_sso&.split(',') unless @restricted_member_show |
9 | 13 |
|
10 | 14 | json.profile_attributes do |
11 | | - json.extract! member.profile, :id, :first_name, :last_name, :interest, :software_mastered, :phone, :website, :job |
12 | | - if member.profile.user_avatar |
13 | | - json.user_avatar_attributes do |
14 | | - json.id member.profile.user_avatar.id |
15 | | - json.attachment_url "#{member.profile.user_avatar.attachment_url}?#{member.profile.user_avatar.updated_at.to_i}" |
| 15 | + json.first_name member.profile.first_name |
| 16 | + json.last_name member.profile.last_name |
| 17 | + json.interest member.profile.interest |
| 18 | + json.software_mastered member.profile.software_mastered |
| 19 | + |
| 20 | + if @restricted_member_show |
| 21 | + json.facebook member.profile.facebook |
| 22 | + json.twitter member.profile.twitter |
| 23 | + json.viadeo member.profile.viadeo |
| 24 | + json.linkedin member.profile.linkedin |
| 25 | + json.instagram member.profile.instagram |
| 26 | + json.youtube member.profile.youtube |
| 27 | + json.vimeo member.profile.vimeo |
| 28 | + json.dailymotion member.profile.dailymotion |
| 29 | + json.github member.profile.github |
| 30 | + json.echosciences member.profile.echosciences |
| 31 | + json.pinterest member.profile.pinterest |
| 32 | + json.lastfm member.profile.lastfm |
| 33 | + json.flickr member.profile.flickr |
| 34 | + else |
| 35 | + json.id member.profile.id |
| 36 | + json.phone member.profile.phone |
| 37 | + json.website member.profile.website |
| 38 | + json.job member.profile.job |
| 39 | + if member.profile.user_avatar |
| 40 | + json.user_avatar do |
| 41 | + json.id member.profile.user_avatar.id |
| 42 | + json.attachment_url "#{member.profile.user_avatar.attachment_url}?#{member.profile.user_avatar.updated_at.to_i}" |
| 43 | + end |
16 | 44 | end |
| 45 | + json.extract! member.profile, :facebook, :twitter, :viadeo, :linkedin, :instagram, :youtube, :vimeo, :dailymotion, :github, :echosciences, :pinterest, :lastfm, :flickr |
| 46 | + json.tours member.profile.tours&.split || [] |
17 | 47 | end |
18 | | - json.extract! member.profile, :facebook, :twitter, :viadeo, :linkedin, :instagram, :youtube, :vimeo, :dailymotion, :github, :echosciences, :pinterest, :lastfm, :flickr |
19 | | - json.tours member.profile.tours&.split || [] |
20 | 48 | end |
21 | 49 |
|
22 | | -json.invoicing_profile_attributes do |
23 | | - json.extract! member.invoicing_profile, :id, :external_id |
24 | | - if member.invoicing_profile.address |
25 | | - json.address_attributes do |
26 | | - json.id member.invoicing_profile.address.id |
27 | | - json.address member.invoicing_profile.address.address |
| 50 | +unless @restricted_member_show |
| 51 | + json.invoicing_profile_attributes do |
| 52 | + json.extract! member.invoicing_profile, :id, :external_id |
| 53 | + if member.invoicing_profile.address |
| 54 | + json.address_attributes do |
| 55 | + json.id member.invoicing_profile.address.id |
| 56 | + json.address member.invoicing_profile.address.address |
| 57 | + end |
28 | 58 | end |
29 | | - end |
30 | 59 |
|
31 | | - if member.invoicing_profile.organization |
32 | | - json.organization_attributes do |
33 | | - json.extract! member.invoicing_profile.organization, :id, :name |
34 | | - if member.invoicing_profile.organization.address |
35 | | - json.address_attributes do |
36 | | - json.id member.invoicing_profile.organization.address.id |
37 | | - json.address member.invoicing_profile.organization.address.address |
| 60 | + if member.invoicing_profile.organization |
| 61 | + json.organization_attributes do |
| 62 | + json.extract! member.invoicing_profile.organization, :id, :name |
| 63 | + if member.invoicing_profile.organization.address |
| 64 | + json.address_attributes do |
| 65 | + json.id member.invoicing_profile.organization.address.id |
| 66 | + json.address member.invoicing_profile.organization.address.address |
| 67 | + end |
38 | 68 | end |
39 | 69 | end |
40 | 70 | end |
41 | | - end |
42 | 71 |
|
43 | | - json.user_profile_custom_fields_attributes member.invoicing_profile.user_profile_custom_fields |
44 | | - .joins(:profile_custom_field).where('profile_custom_fields.actived' => true).order('profile_custom_fields.id ASC') do |f| |
45 | | - json.id f.id |
46 | | - json.invoicing_profile_id f.invoicing_profile_id |
47 | | - json.profile_custom_field_id f.profile_custom_field_id |
48 | | - json.value f.value |
| 72 | + json.user_profile_custom_fields_attributes member.invoicing_profile.user_profile_custom_fields |
| 73 | + .joins(:profile_custom_field).where('profile_custom_fields.actived' => true).order('profile_custom_fields.id ASC') do |f| |
| 74 | + json.id f.id |
| 75 | + json.invoicing_profile_id f.invoicing_profile_id |
| 76 | + json.profile_custom_field_id f.profile_custom_field_id |
| 77 | + json.value f.value |
| 78 | + end |
49 | 79 | end |
50 | | -end |
51 | 80 |
|
52 | | -json.statistic_profile_attributes do |
53 | | - json.id member.statistic_profile.id |
54 | | - json.gender member.statistic_profile.gender.to_s |
55 | | - json.birthday member.statistic_profile&.birthday&.to_date&.iso8601 |
56 | | - json.training_ids member.statistic_profile&.training_ids |
57 | | -end |
| 81 | + json.statistic_profile_attributes do |
| 82 | + json.id member.statistic_profile.id |
| 83 | + json.gender member.statistic_profile.gender.to_s |
| 84 | + json.birthday member.statistic_profile&.birthday&.to_date&.iso8601 |
| 85 | + json.training_ids member.statistic_profile&.training_ids |
| 86 | + end |
58 | 87 |
|
59 | | -if member.subscribed_plan |
60 | | - json.subscribed_plan do |
61 | | - json.partial! 'api/shared/plan', plan: member.subscribed_plan |
| 88 | + if member.subscribed_plan |
| 89 | + json.subscribed_plan do |
| 90 | + json.partial! 'api/shared/plan', plan: member.subscribed_plan |
| 91 | + end |
62 | 92 | end |
63 | | -end |
64 | 93 |
|
65 | | -if member.subscription |
66 | | - json.subscription do |
67 | | - json.id member.subscription.id |
68 | | - json.expired_at member.subscription.expired_at.iso8601 |
69 | | - json.canceled_at member.subscription.canceled_at.iso8601 if member.subscription.canceled_at |
70 | | - json.plan do # TODO, refactor: duplicates subscribed_plan |
71 | | - json.id member.subscription.plan.id |
72 | | - json.base_name member.subscription.plan.base_name |
73 | | - json.name member.subscription.plan.name |
74 | | - json.interval member.subscription.plan.interval |
75 | | - json.interval_count member.subscription.plan.interval_count |
76 | | - json.amount member.subscription.plan.amount ? (member.subscription.plan.amount / 100.0) : 0 |
77 | | - json.monthly_payment member.subscription.plan.monthly_payment |
| 94 | + if member.subscription |
| 95 | + json.subscription do |
| 96 | + json.id member.subscription.id |
| 97 | + json.expired_at member.subscription.expired_at.iso8601 |
| 98 | + json.canceled_at member.subscription.canceled_at.iso8601 if member.subscription.canceled_at |
| 99 | + json.plan do |
| 100 | + json.id member.subscription.plan.id |
| 101 | + json.base_name member.subscription.plan.base_name |
| 102 | + json.name member.subscription.plan.name |
| 103 | + json.interval member.subscription.plan.interval |
| 104 | + json.interval_count member.subscription.plan.interval_count |
| 105 | + json.amount member.subscription.plan.amount ? (member.subscription.plan.amount / 100.0) : 0 |
| 106 | + json.monthly_payment member.subscription.plan.monthly_payment |
| 107 | + end |
78 | 108 | end |
79 | 109 | end |
| 110 | + json.training_credits member.training_credits do |tc| |
| 111 | + json.training_id tc.creditable_id |
| 112 | + end |
| 113 | + json.machine_credits member.machine_credits do |mc| |
| 114 | + json.machine_id mc.creditable_id |
| 115 | + json.hours_used mc.users_credits.find_by(user_id: member.id).hours_used |
| 116 | + end |
| 117 | + json.last_sign_in_at member.last_sign_in_at.iso8601 if member.last_sign_in_at |
| 118 | + json.validated_at member.validated_at |
80 | 119 | end |
81 | | -json.training_credits member.training_credits do |tc| |
82 | | - json.training_id tc.creditable_id |
83 | | -end |
84 | | -json.machine_credits member.machine_credits do |mc| |
85 | | - json.machine_id mc.creditable_id |
86 | | - json.hours_used mc.users_credits.find_by(user_id: member.id).hours_used |
87 | | -end |
88 | | -# TODO, missing space_credits? |
89 | | -json.last_sign_in_at member.last_sign_in_at.iso8601 if member.last_sign_in_at |
90 | | - |
91 | | -json.validated_at member.validated_at |
|
0 commit comments