card 1.16.15 → 1.17.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (153) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/config/initializers/recaptcha.rb +21 -4
  4. data/db/migrate_core_cards/20130823192433_add_style_cards.rb +1 -1
  5. data/db/migrate_core_cards/20140512155840_add_script_cards.rb +1 -1
  6. data/db/migrate_core_cards/20140629222005_add_email_cards.rb +2 -2
  7. data/db/migrate_core_cards/20150202143810_import_bootstrap_layout.rb +1 -1
  8. data/db/migrate_core_cards/20150528084659_add_session_cardtype.rb +1 -1
  9. data/db/migrate_core_cards/20150610180019_add_recaptcha_key_and_admin_info_cards.rb +63 -0
  10. data/db/migrate_core_cards/20150724123438_update_file_and_image_cards.rb +1 -1
  11. data/db/migrate_core_cards/20150903130006_attachment_upload_cards.rb +1 -1
  12. data/db/schema.rb +1 -1
  13. data/db/seed/new/card_actions.yml +602 -394
  14. data/db/seed/new/card_acts.yml +595 -1
  15. data/db/seed/new/card_changes.yml +26282 -10262
  16. data/db/seed/new/card_references.yml +1252 -1084
  17. data/db/seed/new/cards.yml +1899 -1423
  18. data/db/seed/test/fixtures/card_actions.yml +1653 -1413
  19. data/db/seed/test/fixtures/card_acts.yml +1063 -445
  20. data/db/seed/test/fixtures/card_changes.yml +29674 -13637
  21. data/db/seed/test/fixtures/card_references.yml +1976 -1815
  22. data/db/seed/test/fixtures/cards.yml +3194 -2719
  23. data/lib/card.rb +14 -13
  24. data/lib/card/auth.rb +10 -6
  25. data/lib/card/cache.rb +58 -120
  26. data/lib/card/cache/persistent.rb +50 -0
  27. data/lib/card/cache/temporary.rb +38 -0
  28. data/lib/card/chunk.rb +34 -25
  29. data/lib/card/content.rb +3 -3
  30. data/lib/card/env.rb +3 -0
  31. data/lib/card/format.rb +56 -53
  32. data/lib/card/migration.rb +6 -2
  33. data/lib/card/name.rb +9 -1
  34. data/lib/card/query.rb +1 -1
  35. data/lib/card/reference.rb +17 -11
  36. data/lib/card/set.rb +1 -1
  37. data/lib/card/subcards.rb +6 -6
  38. data/lib/card/view_cache.rb +45 -28
  39. data/lib/generators/card/migration/templates/card_migration.erb +1 -2
  40. data/mod/01_core/chunk/include.rb +71 -48
  41. data/mod/01_core/chunk/link.rb +6 -3
  42. data/mod/01_core/chunk/query_reference.rb +38 -29
  43. data/mod/01_core/chunk/reference.rb +23 -24
  44. data/mod/01_core/set/all/collection.rb +1 -1
  45. data/mod/01_core/set/all/fetch.rb +39 -12
  46. data/mod/01_core/set/all/permissions.rb +2 -4
  47. data/mod/01_core/set/all/references.rb +50 -75
  48. data/mod/01_core/set/all/rules.rb +19 -18
  49. data/mod/01_core/set/all/subcards.rb +1 -1
  50. data/mod/01_core/set/all/templating.rb +31 -88
  51. data/mod/01_core/set/all/tracked_attributes.rb +7 -14
  52. data/mod/01_core/set/all/utils.rb +77 -66
  53. data/mod/01_core/set_pattern/07_type_plus_right.rb +6 -3
  54. data/mod/01_core/spec/set/all/fetch_spec.rb +148 -96
  55. data/mod/01_core/spec/set/all/templating_spec.rb +49 -40
  56. data/mod/01_core/spec/set/all/trash_spec.rb +1 -1
  57. data/mod/01_history/set/all/actions.rb +1 -1
  58. data/mod/02_basic_types/set/all/base.rb +13 -7
  59. data/mod/02_basic_types/set/all/rss.rb +17 -22
  60. data/mod/02_basic_types/set/type/plain_text.rb +5 -2
  61. data/mod/02_basic_types/spec/set/all/base_spec.rb +1 -0
  62. data/mod/02_basic_types/spec/set/all/rss_spec.rb +7 -6
  63. data/mod/03_machines/lib/javascript/wagn.js.coffee +22 -9
  64. data/mod/03_machines/set/right/machine_output.rb +1 -1
  65. data/mod/04_settings/lib/card/setting.rb +45 -31
  66. data/mod/04_settings/set/right/structure.rb +47 -1
  67. data/mod/04_settings/set/self/default_html_view.rb +2 -0
  68. data/mod/04_settings/set/self/follow_fields.rb +2 -0
  69. data/mod/04_settings/set/self/recent_settings.rb +1 -1
  70. data/mod/05_standard/file/favicon/image-icon.png +0 -0
  71. data/mod/05_standard/file/favicon/image-large.png +0 -0
  72. data/mod/05_standard/file/favicon/image-medium.png +0 -0
  73. data/mod/05_standard/file/favicon/image-original.png +0 -0
  74. data/mod/05_standard/file/favicon/image-small.png +0 -0
  75. data/mod/05_standard/set/all/links.rb +27 -26
  76. data/mod/05_standard/set/all/rich_html/editing.rb +1 -1
  77. data/mod/05_standard/set/all/rich_html/toolbar.rb +1 -1
  78. data/mod/05_standard/set/rstar/rules.rb +20 -325
  79. data/mod/05_standard/set/rstar/rules_editor.rb +362 -0
  80. data/mod/05_standard/set/self/admin_info.rb +82 -0
  81. data/mod/05_standard/set/self/all.rb +16 -10
  82. data/mod/05_standard/set/self/head.rb +20 -19
  83. data/mod/05_standard/set/type/signup.rb +0 -1
  84. data/mod/05_standard/spec/set/all/account_spec.rb +44 -43
  85. data/mod/05_standard/spec/set/right/account_spec.rb +4 -2
  86. data/mod/05_standard/spec/set/type/search_type_spec.rb +8 -0
  87. data/mod/05_standard/spec/set/type/signup_spec.rb +24 -17
  88. data/mod/06_bootstrap/set/all/bootstrap/helper.rb +1 -1
  89. data/spec/lib/card/cache_spec.rb +64 -70
  90. data/spec/lib/card/content_spec.rb +236 -150
  91. data/spec/lib/card/reference_spec.rb +22 -38
  92. data/spec/lib/card/subcards_spec.rb +38 -0
  93. data/spec/lib/card/view_cache_spec.rb +8 -0
  94. data/spec/spec_helper.rb +1 -1
  95. data/tmpsets/set/mod001-01_core/all/collection.rb +77 -74
  96. data/tmpsets/set/mod001-01_core/all/content.rb +14 -16
  97. data/tmpsets/set/mod001-01_core/all/fetch.rb +137 -110
  98. data/tmpsets/set/mod001-01_core/all/name.rb +58 -40
  99. data/tmpsets/set/mod001-01_core/all/pattern.rb +12 -11
  100. data/tmpsets/set/mod001-01_core/all/permissions.rb +125 -117
  101. data/tmpsets/set/mod001-01_core/all/phases.rb +2 -1
  102. data/tmpsets/set/mod001-01_core/all/references.rb +52 -77
  103. data/tmpsets/set/mod001-01_core/all/rules.rb +47 -53
  104. data/tmpsets/set/mod001-01_core/all/templating.rb +31 -87
  105. data/tmpsets/set/mod001-01_core/all/tracked_attributes.rb +12 -21
  106. data/tmpsets/set/mod001-01_core/all/trash.rb +4 -1
  107. data/tmpsets/set/mod001-01_core/all/type.rb +23 -21
  108. data/tmpsets/set/mod001-01_core/all/utils.rb +80 -64
  109. data/tmpsets/set/mod002-01_history/all/actions.rb +20 -16
  110. data/tmpsets/set/mod002-01_history/all/history.rb +18 -13
  111. data/tmpsets/set/mod003-02_basic_types/all/base.rb +37 -10
  112. data/tmpsets/set/mod003-02_basic_types/all/rss.rb +17 -22
  113. data/tmpsets/set/mod003-02_basic_types/type/plain_text.rb +5 -2
  114. data/tmpsets/set/mod003-02_basic_types/type/pointer.rb +51 -39
  115. data/tmpsets/set/mod004-03_machines/right/machine_output.rb +10 -6
  116. data/tmpsets/set/mod005-04_settings/abstract/permission.rb +10 -5
  117. data/tmpsets/set/mod005-04_settings/right/structure.rb +47 -1
  118. data/tmpsets/set/mod005-04_settings/self/recent_settings.rb +1 -0
  119. data/tmpsets/set/mod005-04_settings/type/setting.rb +4 -1
  120. data/tmpsets/set/mod006-05_email/all/follow.rb +45 -54
  121. data/tmpsets/set/mod006-05_email/all/notify.rb +88 -73
  122. data/tmpsets/set/mod006-05_email/right/followers.rb +17 -14
  123. data/tmpsets/set/mod006-05_email/self/follow_defaults.rb +22 -18
  124. data/tmpsets/set/mod006-05_email/type/email_template.rb +1 -1
  125. data/tmpsets/set/mod007-05_standard/abstract/attachment.rb +94 -67
  126. data/tmpsets/set/mod007-05_standard/all/account.rb +18 -20
  127. data/tmpsets/set/mod007-05_standard/all/comment.rb +51 -29
  128. data/tmpsets/set/mod007-05_standard/all/error.rb +129 -99
  129. data/tmpsets/set/mod007-05_standard/all/links.rb +27 -26
  130. data/tmpsets/set/mod007-05_standard/all/rich_html/content.rb +115 -103
  131. data/tmpsets/set/mod007-05_standard/all/rich_html/editing.rb +112 -78
  132. data/tmpsets/set/mod007-05_standard/all/rich_html/form.rb +123 -81
  133. data/tmpsets/set/mod007-05_standard/all/rich_html/modal.rb +15 -58
  134. data/tmpsets/set/mod007-05_standard/all/rich_html/toolbar.rb +2 -2
  135. data/tmpsets/set/mod007-05_standard/right/account.rb +71 -75
  136. data/tmpsets/set/mod007-05_standard/right/email.rb +16 -13
  137. data/tmpsets/set/mod007-05_standard/right/password.rb +20 -12
  138. data/tmpsets/set/mod007-05_standard/right/status.rb +2 -2
  139. data/tmpsets/set/mod007-05_standard/right/token.rb +49 -2
  140. data/tmpsets/set/mod007-05_standard/rstar/rules.rb +20 -325
  141. data/tmpsets/set/mod007-05_standard/self/all.rb +16 -10
  142. data/tmpsets/set/mod007-05_standard/self/head.rb +76 -62
  143. data/tmpsets/set/mod007-05_standard/self/search.rb +45 -22
  144. data/tmpsets/set/mod007-05_standard/self/signin.rb +14 -12
  145. data/tmpsets/set/mod007-05_standard/type/cardtype.rb +13 -11
  146. data/tmpsets/set/mod007-05_standard/type/file.rb +1 -1
  147. data/tmpsets/set/mod007-05_standard/type/search_type.rb +3 -2
  148. data/tmpsets/set/mod007-05_standard/type/set.rb +20 -16
  149. data/tmpsets/set/mod007-05_standard/type/signup.rb +19 -25
  150. data/tmpsets/set/mod007-05_standard/type/user.rb +1 -1
  151. data/tmpsets/set/mod008-06_bootstrap/all/bootstrap/helper.rb +1 -1
  152. data/tmpsets/set_pattern/106-type_plus_right.rb +6 -3
  153. metadata +11 -2
@@ -2,24 +2,17 @@
2
2
  class Card; module Set; module All; module RichHtml; module Modal; extend Card::Set
3
3
  # ~~~~~~~~~~~ above autogenerated; below pulled from /Users/ethan/dev/wagn/gem/card/mod/05_standard/set/all/rich_html/modal.rb ~~~~~~~~~~~
4
4
  format :html do
5
-
6
-
7
-
8
-
9
5
  view :modal_link do |args|
10
6
  path_opts = args[:path_opts] || {}
11
7
  path_opts.merge!(layout: :modal)
12
8
  html_args = args[:html_args] || {}
13
- #html_args.merge!('data-target'=>"#modal-#{card.cardname.safe_key}#{args[:modal_slot_id_postfix]}",
14
- html_args.merge!('data-target'=>"#modal-main-slot",
15
- 'data-toggle'=>'modal')
9
+ html_args.merge!('data-target' => '#modal-main-slot',
10
+ 'data-toggle' => 'modal')
16
11
  link_to(args[:text] || _render_title(args), path(path_opts), html_args)
17
12
  end
18
13
 
19
14
  view :modal_slot do |args|
20
- #wrap_with(:div, class: 'modal fade', role: 'dialog', id: "modal-#{card.cardname.safe_key}#{args[:modal_slot_id_postfix]}") do
21
- id = "modal-"
22
- id += (args[:modal_id] || 'main-slot')
15
+ id = "modal-#{args[:modal_id] || 'main-slot'}"
23
16
  wrap_with(:div, class: 'modal fade', role: 'dialog', id: id) do
24
17
  wrap_with(:div, class: 'modal-dialog') do
25
18
  content_tag :div, class: 'modal-content' do
@@ -29,16 +22,19 @@ format :html do
29
22
  end
30
23
  end
31
24
 
32
-
33
- view :modal_menu, tags: :unknown_ok do |args|
25
+ view :modal_menu, tags: :unknown_ok do
34
26
  popout_params = {}
35
27
  popout_params[:view] = params[:view] if params[:view]
36
- # we probably want to pass on a lot more params than just view, but not all of them
28
+ # we probably want to pass on a lot more params than just view,
29
+ # but not all of them
37
30
  # (eg we don't want layout, id, controller...)
38
31
  wrap_with :div, class: 'modal-menu' do
39
32
  [
40
- link_to( glyphicon('remove'), '', class: 'close-modal pull-right close', 'data-dismiss'=>'modal'),
41
- link_to( glyphicon('new-window'), popout_params, class: 'pop-out-modal pull-right close ' )
33
+ link_to(glyphicon('remove'), '',
34
+ class: 'close-modal pull-right close',
35
+ 'data-dismiss' => 'modal'),
36
+ link_to(glyphicon('new-window'), popout_params,
37
+ class: 'pop-out-modal pull-right close ')
42
38
  ]
43
39
  end
44
40
  end
@@ -48,50 +44,11 @@ format :html do
48
44
  end
49
45
 
50
46
  def default_modal_footer_args args
51
- args[:buttons] ||= button_tag 'Close', class: 'btn-xs close-modal pull-right', 'data-dismiss'=>'modal'
52
- end
53
-
54
- =begin
55
- def default_modal_content_args args
56
- args[:buttons] ||= button_tag 'Close', 'data-dismiss'=>'modal'
57
- end
58
-
59
- view :modal_link_and_dialog do |args|
60
- _render_modal_link(args) + _render_modal(args)
61
- end
62
-
63
-
64
-
65
- # use modal_content for ajax calls to fill a modal_slot with content
66
- view :modal_content do |args|
67
- output [
68
- wrap_with( :div, _render_modal_header(args), class: 'modal-header' ),
69
- wrap_with( :div, _render_modal_body(args), class: 'modal-body' ),
70
- wrap_with( :div, _render_modal_footer(args), class: 'modal-footer' ),
71
- ]
47
+ args[:buttons] ||=
48
+ button_tag 'Close',
49
+ class: 'btn-xs close-modal pull-right',
50
+ 'data-dismiss' => 'modal'
72
51
  end
73
-
74
- view :modal_header do |args|
75
- _render_modal_title(args)
76
- end
77
-
78
- view :modal_body do |args|
79
- _render_core(args)
80
- end
81
-
82
- view :modal_footer do |args|
83
- args[:buttons] || ''
84
- end
85
-
86
- view :modal_title do |args|
87
- "<h4>#{_render_title args.merge(title_class: 'modal-title')}</h4>"
88
- end
89
-
90
- view :modal do |args|
91
- _render_modal_slot args.merge(optional_modal_content: :show)
92
- end
93
- =end
94
-
95
52
  end
96
53
 
97
54
 
@@ -4,7 +4,7 @@ class Card; module Set; module All; module RichHtml; module Toolbar; extend Card
4
4
 
5
5
  format :html do
6
6
  def toolbar_pinned?
7
- Card[:toolbar_pinned].content == 'true'
7
+ (tp = Card[:toolbar_pinned]) && tp.content == 'true'
8
8
  end
9
9
 
10
10
  view :toolbar do |args|
@@ -216,9 +216,9 @@ format :html do
216
216
  path_opts = tag_args.delete(:path_opts) || {}
217
217
  path_opts.merge! action: tag_args.delete(:action) if tag_args[:action]
218
218
  link_to link_text, path_opts, tag_args
219
+
219
220
  end
220
221
  end
221
-
222
222
  def autosaved_draft_link
223
223
  view_link('autosaved draft', :edit, path_opts: {edit_draft: true, slot: {show: :toolbar}}, class: 'navbar-link slotter pull-right')
224
224
  end
@@ -10,47 +10,50 @@ card_accessor :salt
10
10
  card_accessor :status
11
11
  card_accessor :token
12
12
 
13
- def active? ; status=='active' end
14
- def blocked? ; status=='blocked' end
15
- def built_in? ; status=='system' end
16
- def pending? ; status=='pending' end
13
+ def active?; status == 'active' end
14
+ def blocked?; status == 'blocked' end
15
+ def built_in?; status == 'system' end
16
+ def pending?; status == 'pending' end
17
17
 
18
-
19
- def authenticate_by_token val
20
- tcard = token_card or return :token_not_found
21
- token == val or return :incorrect_token
22
- tcard.updated_at > Card.config.token_expiry.ago or return :token_expired # > means "after"
23
- left and left.accountable? or return :illegal_account #(overkill?)
24
- Auth.as_bot { tcard.delete! }
25
- left.id
18
+ def validate_token! test_token
19
+ tcard = token_card
20
+ tcard.validate! test_token
21
+ copy_errors tcard
22
+ errors.empty?
26
23
  end
27
24
 
28
-
29
25
  format do
30
- view :verify_url do |args|
31
- card_url "update/#{card.cardname.left_name.url_key}?token=#{card.token}"
26
+ view :verify_url do
27
+ signup_name = card.cardname.left_name
28
+ card_url "update/#{signup_name.url_key}" \
29
+ "?token=#{card.token}" \
30
+ '&live_token=true'
32
31
  end
33
32
 
34
- view :verify_days do |args|
35
- ( Card.config.token_expiry / 1.day ).to_s
33
+ view :verify_days do
34
+ (Card.config.token_expiry / 1.day).to_s
36
35
  end
37
36
 
38
- view :reset_password_url do |args|
39
- card_url "update/#{card.cardname.url_key}?reset_token=#{card.token_card.refresh(true).content}"
37
+ view :reset_password_url do
38
+ card_url "update/#{card.cardname.url_key}" \
39
+ "?token=#{card.token_card.refresh(true).content}" \
40
+ '&live_token=true&event=reset_password'
40
41
  end
41
42
 
42
- view :reset_password_days do |args|
43
- ( Card.config.token_expiry / 1.day ).to_s
43
+ view :reset_password_days do
44
+ (Card.config.token_expiry / 1.day).to_s
44
45
  end
45
46
  end
46
47
 
47
-
48
48
  format :html do
49
-
50
49
  view :raw do |args|
51
50
  content = []
52
- content << "{{+#{Card[:email ].name}|titled;title:email}}" unless args[:no_email]
53
- content << "{{+#{Card[:password].name}|titled;title:password}}" unless args[:no_password]
51
+ unless args[:no_email]
52
+ content << "{{+#{Card[:email].name}|titled;title:email}}"
53
+ end
54
+ unless args[:no_password]
55
+ content << "{{+#{Card[:password].name}|titled;title:password}}"
56
+ end
54
57
  content * ' '
55
58
  end
56
59
 
@@ -60,56 +63,51 @@ format :html do
60
63
  end
61
64
  end
62
65
 
63
-
64
66
  event :validate_accountability, on: :create, before: :approve do
65
- unless left and left.accountable?
66
- errors.add :content, "not allowed on this card"
67
+ unless left && left.accountable?
68
+ errors.add :content, 'not allowed on this card'
67
69
  end
68
70
  end
69
71
 
70
72
  event :require_email, on: :create, after: :approve do
71
- unless subfield(:email)
72
- errors.add :email, 'required'
73
- end
73
+ errors.add :email, 'required' unless subfield(:email)
74
74
  end
75
75
 
76
-
77
- event :set_default_salt, on: :create, before: :process_subcards do
78
- salt = Digest::SHA1.hexdigest "--#{Time.now.to_s}--"
76
+ event :set_default_salt, on: :create, before: :approve_subcards do
77
+ salt = Digest::SHA1.hexdigest "--#{Time.zone.now}--"
79
78
  Env[:salt] = salt # HACK!!! need viable mechanism to get this to password
80
79
  add_subfield :salt, content: salt
81
80
  end
82
81
 
83
- event :set_default_status, on: :create, before: :process_subcards do
84
- default_status = ( Auth.needs_setup? ? 'active' : 'pending' )
82
+ event :set_default_status, on: :create, before: :approve_subcards do
83
+ default_status = Auth.needs_setup? ? 'active' : 'pending'
85
84
  add_subfield :status, content: default_status
86
85
  end
87
86
 
88
87
  def confirm_ok?
89
- Card.new( type_id: Card.default_accounted_type_id ).ok? :create
88
+ Card.new(type_id: Card.default_accounted_type_id).ok? :create
90
89
  end
91
90
 
92
- event :generate_confirmation_token, :on=>:create, :before=>:process_subcards, :when=>proc{ |c| c.confirm_ok? } do
91
+ event :generate_confirmation_token,
92
+ on: :create, before: :process_subcards,
93
+ when: proc { |c| c.confirm_ok? } do
93
94
  add_subfield :token, content: generate_token
94
95
  end
95
96
 
96
- event :reset_password, on: :update, before: :approve, when: proc{ |c| c.has_reset_token? } do
97
- case ( result = authenticate_by_token @env_token )
98
- when Integer
99
- Auth.signin result
97
+ event :reset_password, on: :update, before: :approve, when:
98
+ proc { |c| c.reset_password? } do
99
+ if validate_token! @env_token
100
+ token_card.used!
101
+ Auth.signin left_id
100
102
  success << edit_password_success_args
101
- abort :success
102
- when :token_expired
103
- send_reset_password_token
104
- success << {
105
- id: '_self',
106
- view: 'message',
107
- message: "Sorry, this token has expired. Please check your email for a new password reset link."
108
- }
109
- abort :success
110
103
  else
111
- abort :failure, "error resetting password: #{result}" # bad token or account
104
+ error_msg = errors.first.last
105
+ send_reset_password_token
106
+ msg = "Sorry, #{error_msg}. " \
107
+ 'Please check your email for a new password reset link.'
108
+ success << { id: '_self', view: 'message', message: msg }
112
109
  end
110
+ abort :success
113
111
  end
114
112
 
115
113
  def edit_password_success_args
@@ -120,8 +118,9 @@ def edit_password_success_args
120
118
  }
121
119
  end
122
120
 
123
- def has_reset_token?
124
- @env_token = Env.params[:reset_token]
121
+ def reset_password?
122
+ @env_token = Env.params[:token]
123
+ @env_token && Env.params[:event] == 'reset_password'
125
124
  end
126
125
 
127
126
  event :reset_token do
@@ -130,51 +129,49 @@ event :reset_token do
130
129
  end
131
130
  end
132
131
 
133
-
134
132
  event :send_welcome_email do
135
- if ((welcome = Card['welcome email']) && welcome.type_code == :email_template)
136
- welcome.deliver(context: left, to: self.email)
133
+ welcome = Card['welcome email']
134
+ if welcome && welcome.type_code == :email_template
135
+ welcome.deliver context: left, to: email
137
136
  end
138
137
  end
139
138
 
140
- event :send_account_verification_email, on: :create, after: :extend, when: proc{ |c| c.token.present? } do
141
- Card[:verification_email].deliver( context: self, to: self.email )
139
+ event :send_account_verification_email, on: :create, after: :extend, when:
140
+ proc { |c| c.token.present? } do
141
+ Card[:verification_email].deliver context: self, to: email
142
142
  end
143
143
 
144
144
  event :send_reset_password_token do
145
145
  Auth.as_bot do
146
146
  token_card.update_attributes! content: generate_token
147
147
  end
148
- Card[:password_reset_email].deliver( context: self, to: self.email )
148
+ Card[:password_reset_email].deliver context: self, to: email
149
149
  end
150
150
 
151
151
  def ok_to_read
152
- is_own_account? ? true : super
152
+ own_account? ? true : super
153
153
  end
154
154
 
155
-
156
155
  def changes_visible? act
157
156
  act.relevant_actions_for(act.card).each do |action|
158
157
  return true if action.card.ok? :read
159
158
  end
160
- return false
159
+ false
161
160
  end
162
161
 
163
162
  def send_change_notice act, followed_set, follow_option
164
- if changes_visible?(act)
165
- Auth.as(left.id) do
166
- Card[:follower_notification_email].deliver(
167
- context: act.card,
168
- to: email,
169
- follower: left.name,
170
- followed_set: followed_set,
171
- follow_option: follow_option
172
- )
173
- end
163
+ return unless changes_visible?(act)
164
+ Auth.as(left.id) do
165
+ Card[:follower_notification_email].deliver(
166
+ context: act.card,
167
+ to: email,
168
+ follower: left.name,
169
+ followed_set: followed_set,
170
+ follow_option: follow_option
171
+ )
174
172
  end
175
173
  end
176
174
 
177
-
178
175
  format :email do
179
176
  view :mail do |args|
180
177
  args[:to] ||= card.email
@@ -183,6 +180,5 @@ format :email do
183
180
  end
184
181
 
185
182
 
186
-
187
183
  # ~~~~~~~~~~~ below autogenerated; above pulled from /Users/ethan/dev/wagn/gem/card/mod/05_standard/set/right/account.rb ~~~~~~~~~~~
188
184
  end;end;end;end;
@@ -1,13 +1,14 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  class Card; module Set; module Right; module Email; extend Card::Set
3
3
  # ~~~~~~~~~~~ above autogenerated; below pulled from /Users/ethan/dev/wagn/gem/card/mod/05_standard/set/right/email.rb ~~~~~~~~~~~
4
- #event :
5
4
  include All::Permissions::Accounts
6
5
 
7
- view :raw do |args|
6
+ view :raw do
8
7
  case
9
- when card.real? ; card.content
10
- when card.left.account ; card.left.account.email #this supports legacy behavior (should be moved to User+*email+*type plus right)
8
+ when card.real? then card.content
9
+ # following supports legacy behavior
10
+ # (should be moved to User+*email+*type plus right)
11
+ when card.left.account then card.left.account.email
11
12
  else ''
12
13
  end
13
14
  end
@@ -23,9 +24,10 @@ end
23
24
  event :validate_unique_email, after: :validate_email, on: :save do
24
25
  if content.present?
25
26
  Auth.as_bot do
26
- wql = { right_id: Card::EmailID, eq: content }
27
+ wql = { right_id: Card::EmailID, eq: content, return: :id }
27
28
  wql[:not] = { id: id } if id
28
- if Card.search( wql ).first
29
+ wql_comment = "email duplicate? (#{content})"
30
+ if Card.search(wql, wql_comment).first
29
31
  errors.add :content, 'must be unique'
30
32
  end
31
33
  end
@@ -33,9 +35,8 @@ event :validate_unique_email, after: :validate_email, on: :save do
33
35
  end
34
36
 
35
37
  event :downcase_email, before: :approve, on: :save do
36
- if content and content != content.downcase
37
- self.content = content.downcase
38
- end
38
+ return if !content || content == content.downcase
39
+ self.content = content.downcase
39
40
  end
40
41
 
41
42
  def email_required?
@@ -43,16 +44,18 @@ def email_required?
43
44
  end
44
45
 
45
46
  def ok_to_read
46
- if is_own_account? or Auth.always_ok?
47
+ if own_email? || Auth.always_ok?
47
48
  true
48
49
  else
49
- deny_because "viewing email is restricted to administrators and account holders"
50
+ deny_because 'viewing email is restricted to administrators and ' \
51
+ 'account holders'
50
52
  end
51
53
  end
52
54
 
53
- def is_own_account?
54
- cardname.parts[0].to_name.key == Auth.as_card.cardname.key
55
+ def own_email?
56
+ cardname.part_names[0].key == Auth.as_card.key
55
57
  end
56
58
 
59
+
57
60
  # ~~~~~~~~~~~ below autogenerated; above pulled from /Users/ethan/dev/wagn/gem/card/mod/05_standard/set/right/email.rb ~~~~~~~~~~~
58
61
  end;end;end;end;
@@ -4,26 +4,34 @@ class Card; module Set; module Right; module Password; extend Card::Set
4
4
 
5
5
  include All::Permissions::Accounts
6
6
 
7
- view :editor do |args|
7
+ view :editor do
8
8
  card.content = ''
9
- autocomplete = (@parent && @parent.card.name=='*signin+*account') ? 'on' : 'off' #hack
9
+
10
+ # HACK
11
+ autocomplete = if @parent && @parent.card.name == '*signin+*account'
12
+ 'on'
13
+ else
14
+ 'off'
15
+ end
10
16
  password_field :content, class: 'card-content', autocomplete: autocomplete
11
17
  end
12
18
 
13
- view :raw do |args|
19
+ view :raw do
14
20
  '<em>encrypted</em>'
15
21
  end
16
22
 
17
- event :encrypt_password, on: :save, after: :process_subcards, changed: :content,
18
- when: proc{ |c| !Card::Env[:no_password_encryptions] } do
19
- # no_password_encryptions = hack for import - fix with api for ignoring events
20
-
21
- salt = (left && left.salt)
22
- salt = Card::Env[:salt] unless salt.present? # hack - fix with better ORM handling
23
+ event :encrypt_password, on: :save, after: :process_subcards,
24
+ changed: :content,
25
+ when: proc { !Card::Env[:no_password_encryptions] } do
26
+ # no_password_encryptions = hack for import - fix with api for ignoring events
27
+ salt = left && left.salt
28
+ # HACK: fix with better ORM handling
29
+ salt = Card::Env[:salt] unless salt.present?
23
30
  self.content = Auth.encrypt content, salt
24
31
 
25
- # errors.add :password, 'need a valid salt'
26
- # turns out we have a lot of existing account without a salt. not sure when that broke??
32
+ # errors.add :password, 'need a valid salt'
33
+ # turns out we have a lot of existing account without a salt.
34
+ # not sure when that broke??
27
35
  end
28
36
 
29
37
  event :validate_password, on: :save, before: :approve do
@@ -37,7 +45,7 @@ event :validate_password_present, on: :update, before: :approve do
37
45
  end
38
46
 
39
47
  def ok_to_read
40
- is_own_account? ? true : super
48
+ own_account? ? true : super
41
49
  end
42
50
 
43
51