card 1.16.8 → 1.16.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/db/migrate_core_cards/{20150611203506_rails_inflection_updates.rb → 20120611203506_rails_inflection_updates.rb} +0 -0
- data/db/migrate_core_cards/20150326205655_bootswatch_themes.rb +0 -1
- data/db/migrate_core_cards/20150429090551_search_card_context.rb +1 -1
- data/db/migrate_core_cards/20150708224756_add_list_cards.rb +22 -0
- data/db/seed/new/card_actions.yml +789 -509
- data/db/seed/new/card_acts.yml +1 -1
- data/db/seed/new/card_changes.yml +2618 -1920
- data/db/seed/new/card_references.yml +1034 -901
- data/db/seed/new/cards.yml +2303 -1675
- data/db/seed/test/fixtures/card_actions.yml +1926 -1606
- data/db/seed/test/fixtures/card_acts.yml +354 -324
- data/db/seed/test/fixtures/card_changes.yml +5950 -5175
- data/db/seed/test/fixtures/card_references.yml +1861 -1630
- data/db/seed/test/fixtures/cards.yml +3768 -3048
- data/db/seed/test/seed.rb +121 -107
- data/lib/card.rb +2 -3
- data/lib/card/active_record_helper.rb +44 -0
- data/lib/card/auth.rb +51 -47
- data/lib/card/cache.rb +7 -3
- data/lib/card/codename.rb +7 -7
- data/lib/card/format.rb +2 -1
- data/lib/card/migration.rb +17 -16
- data/lib/card/name.rb +71 -20
- data/lib/card/set.rb +202 -166
- data/lib/card/simplecov_helper.rb +11 -7
- data/lib/card/subcards.rb +249 -0
- data/mod/01_core/set/all/collection.rb +1 -2
- data/mod/01_core/set/all/fetch.rb +167 -92
- data/mod/01_core/set/all/initialize.rb +8 -22
- data/mod/01_core/set/all/name.rb +128 -79
- data/mod/01_core/set/all/phases.rb +93 -95
- data/mod/01_core/set/all/subcards.rb +70 -0
- data/mod/01_core/set/all/tracked_attributes.rb +83 -59
- data/mod/01_core/set/all/trash.rb +14 -12
- data/mod/01_core/set/all/type.rb +3 -24
- data/mod/01_core/spec/set/all/initialize_spec.rb +44 -14
- data/mod/01_core/spec/set/all/permissions_spec.rb +206 -185
- data/mod/01_core/spec/set/all/tracked_attributes_spec.rb +0 -10
- data/mod/01_core/spec/set/all/trash_spec.rb +38 -13
- data/mod/01_core/spec/set/all/type_spec.rb +0 -19
- data/mod/01_history/set/all/content_history.rb +5 -3
- data/mod/01_history/set/all/history.rb +117 -82
- data/mod/02_basic_types/set/all/base.rb +50 -49
- data/mod/03_machines/lib/card/machine.rb +2 -1
- data/mod/03_machines/lib/javascript/wagn_mod.js.coffee +55 -17
- data/mod/03_machines/spec/set/type/javascript_spec.rb +18 -12
- data/mod/05_email/set/right/followers.rb +5 -5
- data/mod/05_email/set/right/following.rb +1 -1
- data/mod/05_email/set/type_plus_right/user/follow.rb +1 -1
- data/mod/05_standard/lib/carrier_wave/cardmount.rb +19 -11
- data/mod/05_standard/lib/file_uploader.rb +1 -1
- data/mod/05_standard/set/abstract/attachment.rb +20 -8
- data/mod/05_standard/set/all/list_changes.rb +43 -0
- data/mod/05_standard/set/all/rich_html/form.rb +21 -11
- data/mod/05_standard/set/all/rich_html/menu.rb +1 -1
- data/mod/05_standard/set/right/account.rb +5 -5
- data/mod/05_standard/set/self/head.rb +0 -1
- data/mod/05_standard/set/self/signin.rb +43 -35
- data/mod/05_standard/set/type/file.rb +9 -2
- data/mod/05_standard/set/type/list.rb +134 -0
- data/mod/05_standard/set/type/listed_by.rb +94 -0
- data/mod/05_standard/set/type/search_type.rb +62 -61
- data/mod/05_standard/set/type/signup.rb +94 -63
- data/mod/05_standard/set/type/user.rb +48 -39
- data/mod/05_standard/spec/set/all/account_spec.rb +1 -1
- data/mod/05_standard/spec/set/all/rich_html/form_spec.rb +2 -2
- data/mod/05_standard/spec/set/self/signin_spec.rb +23 -27
- data/mod/05_standard/spec/set/type/email_template_spec.rb +0 -2
- data/mod/05_standard/spec/set/type/list_spec.rb +140 -0
- data/mod/05_standard/spec/set/type/listed_by_spec.rb +157 -0
- data/mod/05_standard/spec/set/type/signup_spec.rb +38 -32
- data/spec/lib/card/subcards_spec.rb +126 -0
- metadata +14 -3
@@ -0,0 +1,94 @@
|
|
1
|
+
event :validate_listed_by_name, before: :validate, on: :save, changed: :name do
|
2
|
+
if !junction? || !right || right.type_id != CardtypeID
|
3
|
+
errors.add :name, 'must have a cardtype name as right part'
|
4
|
+
end
|
5
|
+
end
|
6
|
+
|
7
|
+
event :validate_listed_by_content,
|
8
|
+
before: :validate, on: :save,
|
9
|
+
changed: :content do
|
10
|
+
item_cards(content: content).each do |item_card|
|
11
|
+
if item_card.type_id != right.id
|
12
|
+
errors.add(
|
13
|
+
:content,
|
14
|
+
"#{item_card.name} has wrong cardtype; " \
|
15
|
+
"only cards of type #{cardname.right} are allowed"
|
16
|
+
)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
event :update_content_in_list_cards,
|
22
|
+
before: :approve_subcards, on: :save, changed: :content do
|
23
|
+
if content.present?
|
24
|
+
new_items = item_keys(content: content)
|
25
|
+
old_items = item_keys
|
26
|
+
removed_items = old_items - new_items
|
27
|
+
added_items = new_items - old_items
|
28
|
+
removed_items.each do |item|
|
29
|
+
if (lc = list_card(item))
|
30
|
+
lc.drop_item cardname.left
|
31
|
+
subcards.add lc
|
32
|
+
end
|
33
|
+
end
|
34
|
+
added_items.each do |item|
|
35
|
+
if (lc = list_card(item))
|
36
|
+
lc.add_item cardname.left
|
37
|
+
subcards.add lc
|
38
|
+
else
|
39
|
+
subcards.add(
|
40
|
+
name: "#{Card[item].name}+#{left.type_name}", type: 'list',
|
41
|
+
content: "[[#{cardname.left}]]"
|
42
|
+
)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def raw_content
|
49
|
+
Card::Cache[Card::Set::Type::ListedBy].fetch(key) do
|
50
|
+
generate_content
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def generate_content
|
55
|
+
listed_by.map do |item|
|
56
|
+
'[[%s]]' % item.to_name.left
|
57
|
+
end.join "\n"
|
58
|
+
end
|
59
|
+
|
60
|
+
def listed_by
|
61
|
+
Card.search(
|
62
|
+
type: 'list', right: trunk.type_name,
|
63
|
+
left: { type: cardname.tag }, refer_to: cardname.trunk, return: :name
|
64
|
+
)
|
65
|
+
end
|
66
|
+
|
67
|
+
def update_cached_list
|
68
|
+
Card::Cache[Card::Set::Type::ListedBy].write key, generate_content
|
69
|
+
end
|
70
|
+
|
71
|
+
def list_card item
|
72
|
+
Card.fetch "#{item}+#{left.type_name}"
|
73
|
+
end
|
74
|
+
|
75
|
+
def unfilled?
|
76
|
+
false
|
77
|
+
end
|
78
|
+
|
79
|
+
include Pointer
|
80
|
+
format do
|
81
|
+
include Pointer::Format
|
82
|
+
end
|
83
|
+
format :html do
|
84
|
+
include Pointer::HtmlFormat
|
85
|
+
end
|
86
|
+
format :css do
|
87
|
+
include Pointer::CssFormat
|
88
|
+
end
|
89
|
+
format :js do
|
90
|
+
include Pointer::JsFormat
|
91
|
+
end
|
92
|
+
format :data do
|
93
|
+
include Pointer::DataFormat
|
94
|
+
end
|
@@ -1,11 +1,10 @@
|
|
1
1
|
|
2
|
-
|
3
2
|
def item_cards params={}
|
4
3
|
s = query(params)
|
5
|
-
raise(
|
4
|
+
raise('OH NO.. no limit') unless s[:limit]
|
6
5
|
# forces explicit limiting
|
7
6
|
# can be 0 or less to force no limit
|
8
|
-
Card.search(
|
7
|
+
Card.search(s)
|
9
8
|
end
|
10
9
|
|
11
10
|
def item_names params={}
|
@@ -13,11 +12,12 @@ def item_names params={}
|
|
13
12
|
end
|
14
13
|
|
15
14
|
def item_type
|
15
|
+
return if query[:type].is_a?(Array) || query[:type].is_a?(Hash)
|
16
16
|
query[:type]
|
17
17
|
end
|
18
18
|
|
19
19
|
def count params={}
|
20
|
-
Card.count_by_wql query(
|
20
|
+
Card.count_by_wql query(params)
|
21
21
|
end
|
22
22
|
|
23
23
|
def query params={}
|
@@ -26,47 +26,50 @@ def query params={}
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def get_query params={}
|
29
|
-
|
29
|
+
# why is this a wagn_bot thing? can't deny search content??
|
30
|
+
query = Auth.as_bot do
|
30
31
|
query_content = params.delete(:query) || raw_content
|
31
|
-
|
32
|
+
case
|
33
|
+
when query_content.empty?
|
32
34
|
raise JSON::ParserError,
|
33
|
-
|
35
|
+
"Error in card '#{name}':can't run search with empty content"
|
36
|
+
when query_content.is_a?(String)
|
37
|
+
JSON.parse(query_content)
|
38
|
+
else query_content
|
34
39
|
end
|
35
|
-
String === query_content ? JSON.parse( query_content ) : query_content
|
36
40
|
end
|
37
41
|
query.symbolize_keys!.merge! params.symbolize_keys
|
38
|
-
if default_limit = query.delete(:default_limit)
|
39
|
-
query[:limit]
|
42
|
+
if (default_limit = query.delete(:default_limit))
|
43
|
+
query[:limit] ||= default_limit
|
40
44
|
end
|
41
45
|
query[:context] ||= cardname
|
42
46
|
query
|
43
47
|
end
|
44
48
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
49
|
format do
|
49
|
-
|
50
|
+
# rubocop:disable Style/ExtraSpacing
|
50
51
|
view :core do |args|
|
51
|
-
view =
|
52
|
-
|
53
|
-
when
|
54
|
-
when
|
55
|
-
|
52
|
+
view =
|
53
|
+
case search_results args
|
54
|
+
when Exception then :search_error
|
55
|
+
when Integer then :search_count
|
56
|
+
when @mode == :template then :raw
|
57
|
+
else :card_list
|
56
58
|
end
|
57
59
|
_render view, args
|
58
60
|
end
|
61
|
+
# rubocop:enable Style/ExtraSpacing
|
59
62
|
|
60
|
-
|
61
|
-
view :search_count do |args|
|
63
|
+
view :search_count do |_args|
|
62
64
|
search_results.to_s
|
63
65
|
end
|
64
66
|
|
65
|
-
view :search_error do |
|
66
|
-
|
67
|
+
view :search_error do |_args|
|
68
|
+
sr_class = search_results.class.to_s
|
69
|
+
%{#{sr_class} :: #{search_results.message} :: #{card.raw_content}}
|
67
70
|
end
|
68
71
|
|
69
|
-
view :card_list do |
|
72
|
+
view :card_list do |_args|
|
70
73
|
if search_results.empty?
|
71
74
|
'no results'
|
72
75
|
else
|
@@ -80,8 +83,8 @@ format do
|
|
80
83
|
@search_vars ||=
|
81
84
|
begin
|
82
85
|
v = {}
|
83
|
-
v[:query] = card.query(
|
84
|
-
v[:item]
|
86
|
+
v[:query] = card.query(search_params)
|
87
|
+
v[:item] = set_inclusion_opts args.merge(query_view: v[:query][:view])
|
85
88
|
v
|
86
89
|
rescue JSON::ParserError => e
|
87
90
|
{ error: e }
|
@@ -99,7 +102,7 @@ format do
|
|
99
102
|
is_count = search_vars[:query][:return] == 'count'
|
100
103
|
is_count ? raw_results.to_i : raw_results
|
101
104
|
rescue BadQuery => e
|
102
|
-
e
|
105
|
+
e
|
103
106
|
end
|
104
107
|
end
|
105
108
|
end
|
@@ -110,7 +113,7 @@ format do
|
|
110
113
|
begin
|
111
114
|
card.item_names search_params
|
112
115
|
rescue => e
|
113
|
-
{ error: e}
|
116
|
+
{ error: e }
|
114
117
|
end
|
115
118
|
end
|
116
119
|
|
@@ -123,13 +126,12 @@ format do
|
|
123
126
|
def set_inclusion_opts args
|
124
127
|
@inclusion_defaults = nil
|
125
128
|
@inclusion_opts ||= {}
|
126
|
-
@inclusion_opts[:view] = args[:item] || inclusion_opts[:view] ||
|
129
|
+
@inclusion_opts[:view] = args[:item] || inclusion_opts[:view] ||
|
130
|
+
args[:query_view] || default_item_view
|
127
131
|
# explicit > inclusion syntax > WQL > inclusion defaults
|
128
132
|
end
|
129
133
|
|
130
|
-
|
131
|
-
|
132
|
-
def page_link text, page, current=false, options={}
|
134
|
+
def page_link text, page, _current=false, options={}
|
133
135
|
@paging_path_args[:offset] = page * @paging_limit
|
134
136
|
options.merge!(class: 'card-paging-link slotter', remote: true)
|
135
137
|
link_to raw(text), path(@paging_path_args), options
|
@@ -148,11 +150,13 @@ format do
|
|
148
150
|
end
|
149
151
|
|
150
152
|
def previous_page_link page
|
151
|
-
page_li '<span aria-hidden="true">«</span>', page, false,
|
153
|
+
page_li '<span aria-hidden="true">«</span>', page, false,
|
154
|
+
'aria-label' => 'Previous'
|
152
155
|
end
|
153
156
|
|
154
157
|
def next_page_link page
|
155
|
-
page_li '<span aria-hidden="true">»</span>', page, false,
|
158
|
+
page_li '<span aria-hidden="true">»</span>', page, false,
|
159
|
+
'aria-label' => 'Next'
|
156
160
|
end
|
157
161
|
|
158
162
|
def ellipse_page
|
@@ -164,10 +168,8 @@ format do
|
|
164
168
|
end
|
165
169
|
end
|
166
170
|
|
167
|
-
|
168
171
|
format :data do
|
169
|
-
|
170
|
-
view :card_list do |args|
|
172
|
+
view :card_list do |_args|
|
171
173
|
search_results.map do |c|
|
172
174
|
nest c
|
173
175
|
end
|
@@ -194,13 +196,13 @@ end
|
|
194
196
|
format :rss do
|
195
197
|
view :feed_body do |args|
|
196
198
|
case raw_feed_items args
|
197
|
-
when Exception
|
198
|
-
when Integer
|
199
|
+
when Exception then @xml.item(render :search_error)
|
200
|
+
when Integer then @xml.item(render :search_count)
|
199
201
|
else super args
|
200
202
|
end
|
201
203
|
end
|
202
204
|
|
203
|
-
def raw_feed_items
|
205
|
+
def raw_feed_items _args
|
204
206
|
@raw_feed_items ||= begin
|
205
207
|
search_params.merge!(default_limit: 25)
|
206
208
|
search_results
|
@@ -209,7 +211,6 @@ format :rss do
|
|
209
211
|
end
|
210
212
|
|
211
213
|
format :html do
|
212
|
-
|
213
214
|
view :card_list do |args|
|
214
215
|
paging = _optional_render :paging, args
|
215
216
|
|
@@ -236,42 +237,44 @@ format :html do
|
|
236
237
|
end
|
237
238
|
end
|
238
239
|
|
239
|
-
|
240
240
|
view :closed_content do |args|
|
241
241
|
if @depth > self.class.max_depth
|
242
|
-
|
242
|
+
'...'
|
243
243
|
else
|
244
244
|
search_limit = args[:closed_search_limit]
|
245
|
-
search_params[:limit] =
|
246
|
-
|
247
|
-
_render_core args.merge(
|
248
|
-
# TODO: if item is queryified to be "name", then that should work.
|
245
|
+
search_params[:limit] =
|
246
|
+
search_limit && [search_limit, Card.config.closed_search_limit].min
|
247
|
+
_render_core args.merge(hide: 'paging', item: :link)
|
248
|
+
# TODO: if item is queryified to be "name", then that should work.
|
249
|
+
# otherwise use link
|
249
250
|
end
|
250
251
|
end
|
251
252
|
|
252
253
|
view :editor, mod: Html::HtmlFormat
|
253
254
|
|
254
|
-
view :no_search_results do |
|
255
|
+
view :no_search_results do |_args|
|
255
256
|
%{<div class="search-no-results"></div>}
|
256
257
|
end
|
257
258
|
|
258
|
-
view :paging do |
|
259
|
+
view :paging do |_args|
|
259
260
|
s = card.query search_params
|
260
261
|
offset, limit = s[:offset].to_i, s[:limit].to_i
|
261
262
|
return '' if limit < 1
|
262
|
-
|
263
|
+
# avoid query if we know there aren't enough results to warrant paging
|
264
|
+
return '' if offset == 0 && limit > offset + search_results.length
|
263
265
|
total = card.count search_params
|
264
|
-
|
266
|
+
# should only happen if limit exactly equals the total
|
267
|
+
return '' if limit >= total
|
265
268
|
|
266
269
|
@paging_path_args = { limit: limit, item: inclusion_defaults(card)[:view] }
|
267
270
|
@paging_limit = limit
|
268
271
|
|
269
272
|
s[:vars].each { |key, value| @paging_path_args["_#{key}"] = value }
|
270
273
|
|
271
|
-
out = ['<nav><ul class="pagination paging">'
|
274
|
+
out = ['<nav><ul class="pagination paging">']
|
272
275
|
|
273
|
-
total_pages
|
274
|
-
current_page = (
|
276
|
+
total_pages = ((total - 1) / limit).to_i
|
277
|
+
current_page = (offset / limit).to_i # should already be integer
|
275
278
|
window = 2 # should be configurable
|
276
279
|
window_min = current_page - window
|
277
280
|
window_max = current_page + window
|
@@ -279,19 +282,19 @@ format :html do
|
|
279
282
|
previous_page = current_page > 0 ? current_page - 1 : false
|
280
283
|
out << previous_page_link(previous_page)
|
281
284
|
if window_min > 0
|
282
|
-
out << page_li(
|
285
|
+
out << page_li(1, 0)
|
283
286
|
out << ellipse_page if window_min > 1
|
284
287
|
end
|
285
288
|
|
286
|
-
(window_min
|
287
|
-
next if page < 0
|
289
|
+
(window_min..window_max).each do |page|
|
290
|
+
next if page < 0 || page > total_pages
|
288
291
|
text = page + 1
|
289
|
-
out << page_li(
|
292
|
+
out << page_li(text, page, page == current_page)
|
290
293
|
end
|
291
294
|
|
292
295
|
if total_pages > window_max
|
293
296
|
out << ellipse_page if total_pages > window_max + 1
|
294
|
-
out << page_li(
|
297
|
+
out << page_li(total_pages + 1, total_pages)
|
295
298
|
end
|
296
299
|
|
297
300
|
next_page = current_page < total_pages ? current_page + 1 : false
|
@@ -304,6 +307,4 @@ format :html do
|
|
304
307
|
def default_search_params
|
305
308
|
set_default_search_params default_limit: 20
|
306
309
|
end
|
307
|
-
|
308
310
|
end
|
309
|
-
|
@@ -1,80 +1,112 @@
|
|
1
1
|
|
2
2
|
format :html do
|
3
|
-
|
4
3
|
def default_new_args args
|
5
4
|
super args
|
6
5
|
args.merge!(
|
7
|
-
optional_help: :show,
|
8
|
-
buttons: button_tag(
|
9
|
-
|
10
|
-
|
11
|
-
|
6
|
+
optional_help: :show, # , optional_menu: :never
|
7
|
+
buttons: button_tag(' Submit',
|
8
|
+
disable_with: 'Submitting', situation: 'primary'),
|
9
|
+
account: card.fetch(trait: :account, new: {}),
|
10
|
+
title: 'Sign up',
|
11
|
+
hidden: {
|
12
12
|
success: (card.rule(:thanks) || '_self'),
|
13
13
|
'card[type_id]' => card.type_id
|
14
14
|
}
|
15
15
|
)
|
16
|
+
return unless Auth.signed_in? && args[:account].confirm_ok?
|
17
|
+
invite_args args
|
18
|
+
end
|
16
19
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
20
|
+
def invite_args args
|
21
|
+
args.merge!(
|
22
|
+
title: 'Invite',
|
23
|
+
buttons: button_tag('Send Invitation', situation: 'primary'),
|
24
|
+
hidden: { success: '_self' }
|
25
|
+
)
|
22
26
|
end
|
23
27
|
|
24
28
|
view :new do |args|
|
25
|
-
#FIXME
|
29
|
+
# FIXME: make more use of standard new view?
|
26
30
|
|
27
|
-
frame_and_form :create, args, 'main-success'=>
|
31
|
+
frame_and_form :create, args, 'main-success' => 'REDIRECT' do
|
28
32
|
[
|
29
|
-
_render_name_formgroup(
|
30
|
-
_optional_render(
|
31
|
-
(
|
32
|
-
_optional_render(
|
33
|
+
_render_name_formgroup(help: 'usually first and last name'),
|
34
|
+
_optional_render(:account_formgroups, args),
|
35
|
+
(card.structure ? edit_slot : ''),
|
36
|
+
_optional_render(:button_formgroup, args)
|
33
37
|
]
|
34
38
|
end
|
35
39
|
end
|
36
40
|
|
37
|
-
|
38
41
|
view :account_formgroups do |args|
|
39
42
|
sub_args = { structure: true }
|
40
43
|
sub_args[:no_password] = true if Auth.signed_in?
|
41
|
-
Auth.as_bot
|
44
|
+
Auth.as_bot do
|
45
|
+
subformat(args[:account])._render :content_formgroup, sub_args
|
46
|
+
end # YUCK!!!!
|
42
47
|
end
|
43
48
|
|
44
|
-
|
45
|
-
|
46
|
-
headings
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
if account.confirm_ok?
|
57
|
-
links << link_to( "#{token_action} verification email", card_path("update/~#{card.id}?approve_with_token=true" ) )
|
58
|
-
links << link_to( "Approve without verification", card_path("update/~#{card.id}?approve_without_token=true") )
|
59
|
-
end
|
60
|
-
if card.ok? :delete
|
61
|
-
links << link_to( "Deny and delete", card_path("delete/~#{card.id}") )
|
62
|
-
end
|
63
|
-
headings << links * '' if links.any?
|
64
|
-
else
|
65
|
-
headings << "ERROR: signup card missing account"
|
66
|
-
end
|
49
|
+
view :core do |_args|
|
50
|
+
return if card.new_card? # necessary?
|
51
|
+
headings = []
|
52
|
+
by_anon = card.creator_id == AnonymousID
|
53
|
+
headings << %(
|
54
|
+
<strong>#{ card.name }</strong> #{ 'was' if !by_anon } signed up on
|
55
|
+
#{ format_date card.created_at }
|
56
|
+
)
|
57
|
+
if (account = card.account)
|
58
|
+
headings += verification_info account
|
59
|
+
else
|
60
|
+
headings << 'ERROR: signup card missing account'
|
67
61
|
end
|
68
|
-
|
69
|
-
|
62
|
+
<<-HTML
|
63
|
+
<div class="invite-links">
|
64
|
+
#{ headings.map { |h| "<div>#{h}</div>" }.join "\n" }
|
70
65
|
</div>
|
71
66
|
#{ process_content render_raw }
|
72
|
-
|
67
|
+
HTML
|
68
|
+
end
|
69
|
+
|
70
|
+
def verification_info account
|
71
|
+
headings = []
|
72
|
+
token_action = 'Send'
|
73
|
+
if account.token.present?
|
74
|
+
headings << 'A verification email has been sent ' \
|
75
|
+
"#{ "to #{account.email}" if account.email_card.ok? :read }"
|
76
|
+
token_action = 'Resend'
|
77
|
+
end
|
78
|
+
links = verification_links account, token_action
|
79
|
+
headings << links * '' if links.any?
|
80
|
+
headings
|
81
|
+
end
|
82
|
+
|
83
|
+
def verification_links account, token_action
|
84
|
+
links = []
|
85
|
+
if account.confirm_ok?
|
86
|
+
links << link_to(
|
87
|
+
"#{token_action} verification email",
|
88
|
+
card_path("update/~#{card.id}?approve_with_token=true")
|
89
|
+
)
|
90
|
+
links << link_to(
|
91
|
+
'Approve without verification',
|
92
|
+
card_path("update/~#{card.id}?approve_without_token=true")
|
93
|
+
)
|
94
|
+
end
|
95
|
+
if card.ok? :delete
|
96
|
+
links << link_to('Deny and delete', card_path("delete/~#{card.id}"))
|
97
|
+
end
|
98
|
+
links
|
73
99
|
end
|
74
100
|
end
|
75
101
|
|
76
|
-
event :activate_by_token, before: :approve, on: :update,
|
77
|
-
|
102
|
+
event :activate_by_token, before: :approve, on: :update,
|
103
|
+
when: proc { |c| c.has_token? } do
|
104
|
+
result = if account
|
105
|
+
account.authenticate_by_token(@env_token)
|
106
|
+
else
|
107
|
+
"no account associated with #{name}"
|
108
|
+
end
|
109
|
+
|
78
110
|
case result
|
79
111
|
when Integer
|
80
112
|
abort :failure, 'no field manipulation mid-activation' if subcards.present?
|
@@ -96,18 +128,23 @@ def has_token?
|
|
96
128
|
end
|
97
129
|
|
98
130
|
event :activate_account do
|
99
|
-
|
131
|
+
add_subfield :account
|
132
|
+
subfield(:account).add_subfield :status, content: 'active'
|
100
133
|
self.type_id = Card.default_accounted_type_id
|
101
134
|
account.send_welcome_email
|
102
135
|
end
|
103
136
|
|
104
|
-
event :approve_with_token,
|
137
|
+
event :approve_with_token,
|
138
|
+
on: :update, before: :approve,
|
139
|
+
when: proc { Env.params[:approve_with_token] } do
|
105
140
|
abort :failure, 'illegal approval' unless account.confirm_ok?
|
106
141
|
account.reset_token
|
107
142
|
account.send_account_verification_email
|
108
143
|
end
|
109
144
|
|
110
|
-
event :approve_without_token,
|
145
|
+
event :approve_without_token,
|
146
|
+
on: :update, before: :approve,
|
147
|
+
when: proc { Env.params[:approve_without_token] } do
|
111
148
|
abort :failure, 'illegal approval' unless account.confirm_ok?
|
112
149
|
activate_account
|
113
150
|
end
|
@@ -118,27 +155,21 @@ event :resend_activation_token do
|
|
118
155
|
Env.params[:success] = {
|
119
156
|
id: '_self',
|
120
157
|
view: 'message',
|
121
|
-
message:
|
158
|
+
message: 'Sorry, this token has expired. ' \
|
159
|
+
' Please check your email for a new password reset link.'
|
122
160
|
}
|
123
161
|
end
|
124
162
|
|
125
163
|
def signed_in_as_me_without_password?
|
126
|
-
Auth.signed_in? && Auth.current_id==id && account.password.blank?
|
164
|
+
Auth.signed_in? && Auth.current_id == id && account.password.blank?
|
127
165
|
end
|
128
166
|
|
129
|
-
event :redirect_to_edit_password,
|
167
|
+
event :redirect_to_edit_password,
|
168
|
+
on: :update, after: :store,
|
169
|
+
when: proc { |c| c.signed_in_as_me_without_password? } do
|
130
170
|
Env.params[:success] = account.edit_password_success_args
|
131
171
|
end
|
132
172
|
|
133
|
-
event :preprocess_account_subcards, before: :process_subcards, on: :create do
|
134
|
-
#FIXME: use codenames!
|
135
|
-
email, password = subcards.delete('+*account+*email'), subcards.delete('+*account+*password')
|
136
|
-
subcards['+*account'] ||={}
|
137
|
-
subcards['+*account']['+*email'] = email if email
|
138
|
-
subcards['+*account']['+*password' ]=password if password
|
139
|
-
end
|
140
|
-
|
141
173
|
event :act_as_current_for_extend_phase, before: :extend, on: :create do
|
142
|
-
Auth.current_id =
|
174
|
+
Auth.current_id = id
|
143
175
|
end
|
144
|
-
|