card 1.105.6 → 1.107.0
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/config/environments/development.rb +0 -3
- data/config/environments/production.rb +0 -3
- data/config/environments/test.rb +0 -2
- data/config/initializers/02_patches/active_record.rb +2 -2
- data/db/schema.rb +5 -13
- data/lib/card/auth/current.rb +1 -1
- data/lib/card/auth/permissions.rb +1 -9
- data/lib/card/codename.rb +8 -0
- data/lib/card/director/store.rb +1 -1
- data/lib/card/fetch/all.rb +1 -1
- data/lib/card/model/save_helper/save_helper_helper.rb +6 -2
- data/lib/card/query/abstract_query/tie.rb +16 -2
- data/lib/card/query/card_query/interpretation.rb +26 -3
- data/lib/card/query/reference_query.rb +4 -4
- data/lib/card/set.rb +27 -0
- data/lib/card/view/permission.rb +1 -1
- data/lib/cardio/command/rspec_command/parser.rb +1 -9
- data/lib/cardio/command.rb +1 -0
- data/lib/cardio/generators/base.rb +1 -1
- data/lib/cardio/migration/assumption.rb +29 -0
- data/lib/cardio/migration/schema.rb +12 -0
- data/lib/cardio/migration/stamp.rb +31 -0
- data/lib/cardio/migration/transform.rb +44 -0
- data/lib/cardio/migration.rb +64 -73
- data/lib/cardio/mod/dirs.rb +6 -5
- data/lib/cardio/mod/eat/edibles.rb +9 -3
- data/lib/cardio/mod/eat.rb +2 -1
- data/lib/cardio/mod/sow/card_source.rb +48 -0
- data/lib/cardio/mod/sow/yaml_dump.rb +25 -0
- data/lib/cardio/mod/sow.rb +22 -62
- data/lib/cardio/mod.rb +8 -4
- data/lib/cardio/railtie.rb +6 -6
- data/lib/cardio/seed.rb +3 -6
- data/lib/generators/deck/templates/cypress.json.erb +1 -1
- data/lib/generators/migration/USAGE +10 -11
- data/lib/generators/migration/migration_generator.rb +26 -24
- data/lib/generators/migration/templates/card_migration.erb +1 -3
- data/mod/core/config/admin.yml +10 -0
- data/mod/core/data/fixtures/real/transform_migrations.yml +351 -0
- data/mod/core/data/real.yml +0 -1
- data/mod/core/data/recode.yml +7 -0
- data/{db/migrate → mod/core/data/schema}/20110511221913_require_earlier_migrations.rb +3 -3
- data/{db/migrate → mod/core/data/schema}/20120105203350_require_1_8_migrations.rb +1 -1
- data/{db/migrate → mod/core/data/schema}/20121111025347_require_1_10_migrations.rb +1 -1
- data/{db/migrate → mod/core/data/schema}/20121118114000_split_link_type.rb +1 -1
- data/{db/migrate → mod/core/data/schema}/20121118115000_update_link_type.rb +1 -1
- data/{db/migrate → mod/core/data/schema}/20130106052640_table_cleanup.rb +1 -1
- data/{db/migrate → mod/core/data/schema}/20130109015336_trunk_left.rb +1 -1
- data/{db/migrate → mod/core/data/schema}/20140822073704_create_new_revision_tables.rb +1 -1
- data/mod/core/data/schema/20141001105348_move_revisions_to_actions.rb +87 -0
- data/{db/migrate → mod/core/data/schema}/20141216053032_better_index_names.rb +10 -4
- data/{db/migrate → mod/core/data/schema}/20150724210803_add_comment_to_actions.rb +1 -1
- data/{db/migrate → mod/core/data/schema}/20151105225559_more_space_for_db_content.rb +1 -1
- data/{db/migrate → mod/core/data/schema}/20160122153608_new_indices.rb +1 -1
- data/{db/migrate → mod/core/data/schema}/20170908114442_create_delayed_jobs.rb +1 -1
- data/{db/migrate → mod/core/data/schema}/20170908114452_increase_text_size_for_delayed_jobs.rb +1 -1
- data/{db/migrate → mod/core/data/schema}/20180514152037_add_card_virtuals_table.rb +1 -1
- data/{db/migrate → mod/core/data/schema}/20190116170824_add_left_key_to_card_virtuals.rb +1 -1
- data/{db/migrate → mod/core/data/schema}/20190131223248_add_codename_index.rb +1 -1
- data/{db/migrate → mod/core/data/schema}/20190929202325_rename_present_in_reference_table.rb +1 -1
- data/{db/migrate → mod/core/data/schema}/20200718051236_compound_names_do_not_store_name_and_key.rb +1 -1
- data/{db/migrate → mod/core/data/schema}/20200805200729_add_unique_pair_indices.rb +1 -3
- data/{db/migrate → mod/core/data/schema}/20211128040849_virtuals_updated_at.rb +1 -1
- data/{db/migrate → mod/core/data/schema}/20221031182227_remove_referee_key_requirement.rb +1 -1
- data/mod/core/data/test.yml +4 -4
- data/{db/migrate_core_cards → mod/core/data/transform}/20120611203506_rails_inflection_updates.rb +10 -6
- data/mod/core/data/transform/20130411191151_renaming_for_menu.rb +17 -0
- data/mod/core/data/transform/20130920214038_jsonize_tinymce.rb +28 -0
- data/{db/migrate_core_cards → mod/core/data/transform}/20130920291703_update_stylesheets.rb +1 -1
- data/mod/core/data/transform/20140307231621_user_data_to_cards.rb +40 -0
- data/{db/migrate_core_cards → mod/core/data/transform}/20140317035504_account_requests_to_signups.rb +1 -1
- data/{db/migrate_core_cards → mod/core/data/transform}/20141204061304_watchers_to_following.rb +2 -2
- data/{db/migrate_core_cards → mod/core/data/transform}/20141208132416_partial_reference_type.rb +1 -1
- data/{db/migrate_core_cards → mod/core/data/transform}/20150220134731_following_to_follow_rule.rb +1 -1
- data/{db/migrate_core_cards → mod/core/data/transform}/20150429090551_search_card_context.rb +1 -1
- data/{db/migrate_core_cards → mod/core/data/transform}/20150510031118_fix_skin_codenames.rb +2 -2
- data/{db/migrate_core_cards → mod/core/data/transform}/20150724123438_update_file_and_image_cards.rb +2 -2
- data/{db/migrate_core_cards → mod/core/data/transform}/20150807205221_create_references_for_search_cards.rb +1 -1
- data/mod/core/data/transform/20150824135418_update_file_history.rb +33 -0
- data/{db/migrate_core_cards → mod/core/data/transform}/20160811115836_rename_stats_to_admin.rb +1 -1
- data/{db/migrate_core_cards → mod/core/data/transform}/20160914132636_fix_mod_files.rb +1 -1
- data/{db/migrate_core_cards → mod/core/data/transform}/20161103154836_update_keys.rb +3 -3
- data/{db/migrate_core_cards → mod/core/data/transform}/20170830210517_correct_signup_success_message.rb +1 -1
- data/{db/migrate_core_cards → mod/core/data/transform}/20180905061537_migrate_layouts.rb +1 -1
- data/{db/migrate_core_cards → mod/core/data/transform}/20190125125150_add_script_rules_card.rb +1 -1
- data/{db/migrate_core_cards → mod/core/data/transform}/20190320091257_upgrade_recaptcha_to_v3.rb +1 -1
- data/{db/migrate_core_cards → mod/core/data/transform}/20190322095534_remove_toolbar_cards.rb +1 -1
- data/{db/migrate_core_cards → mod/core/data/transform}/20190502130029_add_shark_and_help_desk_role.rb +2 -1
- data/{db/migrate_core_cards → mod/core/data/transform}/20190528131330_enabled_roles.rb +1 -1
- data/{db/migrate_core_cards → mod/core/data/transform}/20190625153616_pointer_overhaul.rb +1 -1
- data/{db/migrate_core_cards → mod/core/data/transform}/20190718140126_add_guides.rb +1 -1
- data/{db/migrate_core_cards → mod/core/data/transform}/20190822093633_move_help_text_to_code.rb +3 -1
- data/{db/migrate_core_cards → mod/core/data/transform}/20190829205148_remove_add_help.rb +1 -1
- data/mod/core/data/transform/20190902193208_input_type.rb +10 -0
- data/{db/migrate_core_cards → mod/core/data/transform}/20190904174403_token_upgrade.rb +2 -2
- data/{db/migrate_core_cards → mod/core/data/transform}/20190909104250_add_cardtype_input_types.rb +2 -2
- data/{db/migrate_core_cards → mod/core/data/transform}/20191115160748_history_cleanup.rb +1 -1
- data/mod/core/data/transform/20230502094848_repair_all_references.rb +7 -0
- data/mod/core/lib/admin_item.rb +21 -0
- data/mod/core/lib/tasks/card/migrate.rake +79 -114
- data/mod/core/lib/tasks/card/seed.rake +1 -1
- data/mod/core/lib/tasks/card.rake +57 -28
- data/mod/core/set/abstract/task_table.rb +16 -0
- data/mod/core/set/all/admin.rb +108 -0
- data/mod/core/set/self/admin.rb +3 -12
- data/mod/core/set/self/mod.rb +39 -0
- data/mod/core/set/self/version.rb +1 -1
- data/mod/core/set/type/mod.rb +227 -0
- data/mod/core/spec/set/all/admin_spec.rb +34 -0
- data/mod/core/spec/set/type/mod_spec.rb +30 -0
- data/mod/core/spec/shared_examples/mod_admin_config.rb +10 -0
- metadata +78 -72
- data/db/migrate/20130411210957_update_codenames.rb +0 -15
- data/db/migrate/20141001105348_move_revisions_to_actions.rb +0 -70
- data/db/migrate/20141121172918_rename_card_migration_table.rb +0 -15
- data/db/migrate/20141208132159_remove_present_from_reference_table.rb +0 -9
- data/db/migrate_core_cards/20130411191151_renaming_for_menu.rb +0 -47
- data/db/migrate_core_cards/20130920214038_jsonize_tinymce.rb +0 -15
- data/db/migrate_core_cards/20140307231621_user_data_to_cards.rb +0 -28
- data/db/migrate_core_cards/20150824135418_update_file_history.rb +0 -24
- data/db/migrate_core_cards/20190902193208_input_type.rb +0 -15
- data/db/migrate_core_cards/20230502094848_repair_all_references.rb +0 -7
- data/lib/cardio/migration/core.rb +0 -11
- data/lib/cardio/migration/deck.rb +0 -0
- data/lib/cardio/migration/deck_structure.rb +0 -19
- data/lib/cardio/schema.rb +0 -96
- data/mod/core/data/fixtures/real/schema_migrations_core_cards.yml +0 -347
- data/mod/core/data/fixtures/real/schema_migrations_deck.yml +0 -1
- data/mod/core/data/fixtures/real/schema_migrations_deck_cards.yml +0 -5
@@ -1,148 +1,61 @@
|
|
1
|
-
def run_card_migration core_or_deck
|
2
|
-
prepare_migration
|
3
|
-
verbose = ENV["VERBOSE"] ? ENV["VERBOSE"] == "true" : true
|
4
|
-
Cardio::Schema.migrate core_or_deck, version, verbose
|
5
|
-
end
|
6
|
-
|
7
|
-
def prepare_migration
|
8
|
-
Card::Cache.reset_all
|
9
|
-
ENV["SCHEMA"] ||= "#{Cardio.gem_root}/db/schema.rb"
|
10
|
-
Card::Cache.reset_all
|
11
|
-
Card.config.action_mailer.perform_deliveries = false
|
12
|
-
Card.reset_column_information
|
13
|
-
# this is needed in production mode to insure core db
|
14
|
-
Card::Reference.reset_column_information
|
15
|
-
# structures are loaded before schema_mode is set
|
16
|
-
end
|
17
|
-
|
18
|
-
# @param mod [Boolean] if true reset column information for models defined in
|
19
|
-
# in mods in the deck
|
20
|
-
def reset_column_information mod=false
|
21
|
-
Rails.application.eager_load!
|
22
|
-
load_mod_lib if mod && !ENV["NO_CARD_LOAD"]
|
23
|
-
Cardio::Record.descendants.each(&:reset_column_information)
|
24
|
-
end
|
25
|
-
|
26
|
-
# FIXME: too general
|
27
|
-
# intent is to find Record classes; this gets a lot more.
|
28
|
-
def load_mod_lib
|
29
|
-
Dir.glob(Cardio.root.join("mod/*/lib/*.rb")).sort.each { |x| require x }
|
30
|
-
end
|
31
|
-
|
32
|
-
def without_dumping
|
33
|
-
ActiveRecord::Base.dump_schema_after_migration = false
|
34
|
-
yield
|
35
|
-
end
|
36
1
|
|
37
2
|
namespace :card do
|
38
3
|
desc "migrate structure and cards"
|
39
4
|
task migrate: :environment do
|
40
5
|
ENV["NO_RAILS_CACHE"] = "true"
|
41
|
-
ENV["SCHEMA"] ||= "#{Cardio.gem_root}/db/schema.rb"
|
42
|
-
|
43
|
-
stamp = ENV["STAMP_MIGRATIONS"]
|
44
|
-
|
45
|
-
puts "migrating structure"
|
46
|
-
Rake::Task["card:migrate:structure"].invoke
|
47
|
-
Rake::Task["card:migrate:stamp"].invoke :structure if stamp
|
48
|
-
|
49
|
-
puts "migrating deck structure"
|
50
|
-
Rake::Task["card:migrate:deck_structure"].execute
|
51
|
-
if stamp
|
52
|
-
Rake::Task["card:migrate:stamp"].reenable
|
53
|
-
Rake::Task["card:migrate:stamp"].invoke :core_cards
|
54
|
-
end
|
55
|
-
|
56
|
-
puts "migrating core cards"
|
57
|
-
Card::Cache.reset_all
|
58
|
-
# not invoke because we don't want to reload environment
|
59
|
-
Rake::Task["card:migrate:core_cards"].execute
|
60
|
-
if stamp
|
61
|
-
Rake::Task["card:migrate:stamp"].reenable
|
62
|
-
Rake::Task["card:migrate:stamp"].invoke :core_cards
|
63
|
-
end
|
64
|
-
|
65
|
-
puts "migrating deck cards"
|
66
|
-
# not invoke because we don't want to reload environment
|
67
|
-
Rake::Task["card:migrate:deck_cards"].execute
|
68
|
-
if stamp
|
69
|
-
Rake::Task["card:migrate:stamp"].reenable
|
70
|
-
Rake::Task["card:migrate:stamp"].invoke :deck_cards
|
71
|
-
end
|
72
6
|
|
7
|
+
Rake::Task["card:migrate:schema"].invoke
|
8
|
+
Rake::Task["card:migrate:transform"].execute
|
73
9
|
Card::Cache.reset_all
|
74
10
|
end
|
75
11
|
|
76
12
|
namespace :migrate do
|
77
|
-
desc "
|
78
|
-
task
|
13
|
+
desc "run structure migrations"
|
14
|
+
task schema: :environment do
|
15
|
+
puts "running schema migrations"
|
79
16
|
|
80
|
-
|
81
|
-
task structure: :environment do
|
82
|
-
ENV["SCHEMA"] ||= "#{Cardio.gem_root}/db/schema.rb"
|
17
|
+
interpret_env_schema
|
83
18
|
without_dumping do
|
84
|
-
|
19
|
+
run_migration :schema
|
85
20
|
end
|
86
|
-
end
|
87
|
-
|
88
|
-
desc "migrate core cards"
|
89
|
-
task core_cards: :environment do
|
90
|
-
without_dumping do
|
91
|
-
require "cardio/migration/core"
|
92
|
-
run_card_migration :core_cards
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
desc "migrate deck structure"
|
97
|
-
task deck_structure: :environment do
|
98
|
-
migrate_deck_structure
|
99
|
-
reset_column_information
|
100
|
-
end
|
101
|
-
|
102
|
-
def migrate_deck_structure
|
103
|
-
require "cardio/migration/deck_structure"
|
104
|
-
set_schema_path
|
105
|
-
Cardio::Schema.migrate :deck, version
|
106
21
|
Rake::Task["db:_dump"].invoke # write schema.rb
|
107
22
|
reset_column_information true
|
108
23
|
end
|
109
24
|
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
ENV["SCHEMA"] = "#{schema_dir}/schema.rb"
|
114
|
-
end
|
25
|
+
desc "run transform migrations"
|
26
|
+
task transform: :environment do
|
27
|
+
puts "running transform migrations"
|
115
28
|
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
29
|
+
without_dumping do
|
30
|
+
prepare_migration
|
31
|
+
run_migration :transform
|
32
|
+
end
|
120
33
|
end
|
121
34
|
|
122
|
-
desc "Redo the
|
35
|
+
desc "Redo the transform migration given by VERSION."
|
123
36
|
task redo: :environment do
|
124
|
-
|
125
|
-
verbose = ENV["VERBOSE"] ? ENV["VERBOSE"] == "true" : true
|
126
|
-
raise "VERSION is required" unless version
|
37
|
+
raise "VERSION is required" unless version.present?
|
127
38
|
|
128
39
|
ActiveRecord::Migration.verbose = verbose
|
129
40
|
ActiveRecord::SchemaMigration.where(version: version.to_s).delete_all
|
130
|
-
|
41
|
+
run_migration :transform
|
131
42
|
end
|
132
43
|
|
133
|
-
# maybe we should move this to a method?
|
134
44
|
desc "write the version to a file (not usually called directly)"
|
135
45
|
task :stamp, [:type] => [:environment] do |_t, args|
|
136
|
-
|
46
|
+
interpret_env_schema
|
137
47
|
Cardio.config.action_mailer.perform_deliveries = false
|
48
|
+
Cardio::Migration.new_for(args[:type]).stamp
|
49
|
+
end
|
138
50
|
|
139
|
-
|
51
|
+
task port: :environment do
|
52
|
+
Cardio::Migration.port_all
|
53
|
+
end
|
140
54
|
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
file.puts version
|
55
|
+
task recode: :environment do
|
56
|
+
Cardio::Mod.dirs.subpaths("data", "recode.yml").each_value do |path|
|
57
|
+
YAML.load_file(path).each do |oldcode, newcode|
|
58
|
+
Card::Codename.recode oldcode, newcode
|
146
59
|
end
|
147
60
|
end
|
148
61
|
end
|
@@ -152,3 +65,55 @@ namespace :card do
|
|
152
65
|
end
|
153
66
|
end
|
154
67
|
end
|
68
|
+
|
69
|
+
private
|
70
|
+
|
71
|
+
def interpret_env_schema schema_dir=nil
|
72
|
+
schema_dir ||= "#{Cardio.root}/db"
|
73
|
+
# schema_dir = "#{Cardio.root}/db"
|
74
|
+
# Dir.mkdir schema_dir unless Dir.exist? schema_dir
|
75
|
+
ENV["SCHEMA"] ||= "#{schema_dir}/schema.rb"
|
76
|
+
end
|
77
|
+
|
78
|
+
def run_migration type
|
79
|
+
verbose = ENV["VERBOSE"] ? ENV["VERBOSE"] == "true" : true
|
80
|
+
Cardio::Migration.new_for(type).run version, verbose
|
81
|
+
stamp_migration type
|
82
|
+
end
|
83
|
+
|
84
|
+
def stamp_migration type
|
85
|
+
return unless ENV["STAMP_MIGRATIONS"]
|
86
|
+
|
87
|
+
task = Rake::Task["card:migrate:stamp"]
|
88
|
+
task.reenable
|
89
|
+
task.invoke type
|
90
|
+
end
|
91
|
+
|
92
|
+
def prepare_migration
|
93
|
+
interpret_env_schema
|
94
|
+
Card::Cache.reset_all
|
95
|
+
Card.config.action_mailer.perform_deliveries = false
|
96
|
+
Card.reset_column_information
|
97
|
+
# this is needed in production mode to insure core db
|
98
|
+
Card::Reference.reset_column_information
|
99
|
+
# structures are loaded before schema_mode is set
|
100
|
+
end
|
101
|
+
|
102
|
+
# @param mod [Boolean] if true reset column information for models defined in
|
103
|
+
# in mods in the deck
|
104
|
+
def reset_column_information mod=false
|
105
|
+
Rails.application.eager_load!
|
106
|
+
load_mod_lib if mod && !ENV["NO_CARD_LOAD"]
|
107
|
+
Cardio::Record.descendants.each(&:reset_column_information)
|
108
|
+
end
|
109
|
+
|
110
|
+
# FIXME: too general
|
111
|
+
# intent is to find Record classes; this gets a lot more.
|
112
|
+
def load_mod_lib
|
113
|
+
Dir.glob(Cardio.root.join("mod/*/lib/*.rb")).sort.each { |x| require x }
|
114
|
+
end
|
115
|
+
|
116
|
+
def without_dumping
|
117
|
+
ActiveRecord::Base.dump_schema_after_migration = false
|
118
|
+
yield
|
119
|
+
end
|
@@ -45,7 +45,7 @@ namespace :card do
|
|
45
45
|
ENV["CARD_UPDATE_SEED"] = "true"
|
46
46
|
# tells Cardio::Seed to use fixtures upon which the seeds being updated depend
|
47
47
|
|
48
|
-
invoke_card_tasks %w[
|
48
|
+
invoke_card_tasks %w[reset seed:replant]
|
49
49
|
end
|
50
50
|
|
51
51
|
def invoke_card_tasks tasks
|
@@ -4,19 +4,19 @@ namespace :card do
|
|
4
4
|
desc "Creates the database, loads the schema, initializes seed data, " \
|
5
5
|
"and adds symlinks to public directories"
|
6
6
|
task setup: %w[db:setup card:mod:symlink]
|
7
|
+
# task setup: %w[db:setup card:update] # can't do update yet, because it overrides
|
8
|
+
# coded assets, which breaks testing
|
7
9
|
|
8
10
|
desc "Runs migrations, installs mods, and updates symlinks"
|
9
11
|
task :update do
|
10
12
|
failing_loudly "decko update" do
|
11
13
|
ENV["NO_RAILS_CACHE"] = "true"
|
12
14
|
# Benchmark.bm do |x|
|
13
|
-
[:migrate, :
|
15
|
+
["migrate:port", "migrate:schema", "migrate:recode", :eat, "migrate:transform",
|
16
|
+
:reset,
|
14
17
|
"mod:uninstall", "mod:install", "mod:symlink"].each do |task|
|
15
|
-
# x.report(task) do
|
16
18
|
Rake::Task["card:#{task}"].invoke
|
17
|
-
# end
|
18
19
|
end
|
19
|
-
# end
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
@@ -24,15 +24,26 @@ namespace :card do
|
|
24
24
|
task eat: :environment do
|
25
25
|
parse_options :eat do
|
26
26
|
add_opt :m, :mod, "only eat cards in given mod"
|
27
|
-
add_opt :n, :name, "only eat card with name"
|
28
|
-
|
29
|
-
|
30
|
-
add_opt :u, :user, "user to credit unless specified (otherwise uses Decko Bot)"
|
27
|
+
add_opt :n, :name, "only eat card with name (handles : for codenames)"
|
28
|
+
add_opt :u, :user, "user to credit unless specified (default is Decko Bot)"
|
31
29
|
add_opt :p, :podtype, "pod type: real, test, or all " \
|
32
30
|
"(defaults to all in test env, otherwise real)"
|
31
|
+
add_opt :e, :env, "environment (test, production, etc)"
|
33
32
|
flag_opt :v, :verbose, "output progress info and error backtraces"
|
34
33
|
end
|
35
|
-
|
34
|
+
|
35
|
+
adjust_environment options, :eat do
|
36
|
+
rake_result(:eat) { Cardio::Mod::Eat.new(**options).up }
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def adjust_environment options, task
|
41
|
+
if (env = options.delete(:env))
|
42
|
+
task_options = options.map { |k, v| "--#{k}=#{v}" }.join(" ")
|
43
|
+
system "env RAILS_ENV=#{env} bundle exec rake card:#{task} #{task_options}"
|
44
|
+
else
|
45
|
+
yield
|
46
|
+
end
|
36
47
|
end
|
37
48
|
|
38
49
|
desc "Exports card data to mod yaml"
|
@@ -42,30 +53,25 @@ namespace :card do
|
|
42
53
|
flag_opt :i, :items, "also export card items (with -n)"
|
43
54
|
flag_opt :o, :only_items, "only export card items (with -n)", items: :only
|
44
55
|
add_opt :c, :cql, "export cards found by CQL (in JSON format)"
|
56
|
+
add_opt_without_shortcut :url, "source card details from url"
|
45
57
|
add_opt :m, :mod, "output yaml file in mod"
|
46
58
|
add_opt :p, :podtype, "podtype to dump (real or test. default based on current env)"
|
47
59
|
add_opt :t, :field_tags, "comma-separated list of field tag marks"
|
60
|
+
add_opt :e, :env, "environment (test, production, etc)"
|
61
|
+
end
|
62
|
+
adjust_environment options, :sow do
|
63
|
+
rake_result(:sow) { Cardio::Mod::Sow.new(**options).out }
|
48
64
|
end
|
49
|
-
rake_result(:sow) { Cardio::Mod::Sow.new(**options).out }
|
50
|
-
end
|
51
|
-
|
52
|
-
desc "Resets cache"
|
53
|
-
task reset_cache: :environment do
|
54
|
-
Card::Cache.reset_all
|
55
65
|
end
|
56
66
|
|
57
|
-
desc "
|
58
|
-
task :
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
next if filename.match?(/^\./)
|
63
|
-
|
64
|
-
FileUtils.rm_rf File.join(tmp_dir, filename), secure: true
|
65
|
-
end
|
66
|
-
else
|
67
|
-
Dir.mkdir tmp_dir
|
67
|
+
desc "Clears both cache and tmpfiles"
|
68
|
+
task reset: :environment do
|
69
|
+
parse_options :reset do
|
70
|
+
flag_opt :c, :cache, "cache only"
|
71
|
+
flag_opt :t, :tmpfiles, "tmpfiles only"
|
68
72
|
end
|
73
|
+
reset_tmpfiles unless options[:cache]
|
74
|
+
Card::Cache.reset_all unless options[:tmpfiles]
|
69
75
|
end
|
70
76
|
|
71
77
|
desc "Loads seed data"
|
@@ -91,17 +97,27 @@ namespace :card do
|
|
91
97
|
end
|
92
98
|
|
93
99
|
def add_opt letter, key, desc
|
94
|
-
op.on "-#{letter}",
|
100
|
+
op.on "-#{letter}", key_to_option_description(key), desc do |val|
|
95
101
|
options[key] = val
|
96
102
|
end
|
97
103
|
end
|
98
104
|
|
105
|
+
def add_opt_without_shortcut key, desc
|
106
|
+
op.on key_to_option_description(key), desc do |val|
|
107
|
+
options[key] = val
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
def key_to_option_description key
|
112
|
+
"--#{key.to_s.tr '_', '-'} #{key.to_s.upcase}"
|
113
|
+
end
|
114
|
+
|
99
115
|
def op
|
100
116
|
@op ||= OptionParser.new
|
101
117
|
end
|
102
118
|
|
103
119
|
def parse_options task
|
104
|
-
op.banner = "Usage:
|
120
|
+
op.banner = "Usage: card #{task} [options]"
|
105
121
|
yield if block_given?
|
106
122
|
args = op.order!(ARGV) {}
|
107
123
|
# args << "-h" if args.empty?
|
@@ -116,4 +132,17 @@ namespace :card do
|
|
116
132
|
raise "\n>>>>>> FAILURE! #{task} did not complete successfully." \
|
117
133
|
"\n>>>>>> Please address errors and re-run:\n\n\n"
|
118
134
|
end
|
135
|
+
|
136
|
+
def reset_tmpfiles
|
137
|
+
tmp_dir = Cardio.paths["tmp"].first
|
138
|
+
if Cardio.paths["tmp"].existent
|
139
|
+
Dir.foreach(tmp_dir) do |filename|
|
140
|
+
next if filename.match?(/^\./)
|
141
|
+
|
142
|
+
FileUtils.rm_rf File.join(tmp_dir, filename), secure: true
|
143
|
+
end
|
144
|
+
else
|
145
|
+
Dir.mkdir tmp_dir
|
146
|
+
end
|
147
|
+
end
|
119
148
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
format :html do
|
2
|
+
def task_row task, mod
|
3
|
+
base = "#{mod}_task_#{task}"
|
4
|
+
[
|
5
|
+
link_to_card(:admin, t("#{base}_link_text"), path: { action: :update, task: task }),
|
6
|
+
t("#{base}_description")
|
7
|
+
]
|
8
|
+
end
|
9
|
+
|
10
|
+
def task_table tasks
|
11
|
+
table_content = tasks.map do |task, task_config|
|
12
|
+
task_row task, task_config[:mod]
|
13
|
+
end
|
14
|
+
table table_content, header: %w[Task Description]
|
15
|
+
end
|
16
|
+
end
|
data/mod/core/set/all/admin.rb
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
|
2
2
|
basket[:tasks] = {}
|
3
|
+
basket[:config_title] = {
|
4
|
+
basic: "Basic configuration",
|
5
|
+
editor: "Editor configuration"
|
6
|
+
}
|
3
7
|
# to add an admin task:
|
4
8
|
#
|
5
9
|
# basket[:tasks][TASK_NAME] = {
|
@@ -12,3 +16,107 @@ basket[:tasks] = {}
|
|
12
16
|
|
13
17
|
# MOD_task_TASK_NAME_link_text: LINK_TEXT
|
14
18
|
# MOD_task_TASK_NAME_description: DESCRIPTION
|
19
|
+
|
20
|
+
def mod_cards_with_config
|
21
|
+
Card.search(type: :mod).select { |mod| mod.admin_config.present? }
|
22
|
+
end
|
23
|
+
|
24
|
+
def create_admin_items mod, category, subcategory, values
|
25
|
+
Array.wrap(values).map do |value|
|
26
|
+
::AdminItem.new(mod, category, subcategory, value).tap do |config|
|
27
|
+
codenamed = Card::Codename.exist? config.codename.to_sym
|
28
|
+
config.roles = codenamed ? Card[config.codename.to_sym].responsible_role : []
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def scoping_rule_card
|
34
|
+
Card.fetch([self, :self, :update], new: {})
|
35
|
+
end
|
36
|
+
|
37
|
+
def responsible_role
|
38
|
+
scoping_rule_card.find_existing_rule_card.item_cards.map(&:codename)
|
39
|
+
end
|
40
|
+
|
41
|
+
def all_configs
|
42
|
+
mod_cards_with_config.map(&:admin_config_objects).flatten
|
43
|
+
end
|
44
|
+
|
45
|
+
def all_admin_configs_grouped_by property1, property2=nil
|
46
|
+
return admin_config_group_by_properties property1, property2 if property2
|
47
|
+
|
48
|
+
result = Hash.new { |hash, k| hash[k] = [] }
|
49
|
+
all_configs.each_with_object(result) do |config, h|
|
50
|
+
property_values = Array.wrap(config.send(property1))
|
51
|
+
property_values.each do |value|
|
52
|
+
h[value] << config
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def all_admin_configs_of_category category
|
58
|
+
all_admin_configs_grouped_by(:category)[category]
|
59
|
+
end
|
60
|
+
|
61
|
+
def config_codenames_grouped_by_title configs
|
62
|
+
configs&.group_by { |c| c.title }&.map do |title, grouped_configs|
|
63
|
+
[title, grouped_configs.map { |config| config.codename.to_sym }]
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
format :html do
|
68
|
+
def section title, content
|
69
|
+
"<p>#{section_title(title)}#{content}</p>"
|
70
|
+
end
|
71
|
+
|
72
|
+
def section_title title
|
73
|
+
"<h3>#{title}</h3>"
|
74
|
+
end
|
75
|
+
|
76
|
+
def list_section title, items, item_view=:bar
|
77
|
+
return unless items.present?
|
78
|
+
|
79
|
+
section title, list_section_content(items, item_view)
|
80
|
+
end
|
81
|
+
|
82
|
+
def nested_list_section title, grouped_items
|
83
|
+
output [
|
84
|
+
section_title(title),
|
85
|
+
wrap_with(:div, accordion_sections(grouped_items), class: "accordion")
|
86
|
+
]
|
87
|
+
end
|
88
|
+
|
89
|
+
def accordion_sections grouped_items
|
90
|
+
return unless grouped_items.present?
|
91
|
+
|
92
|
+
grouped_items.map do |title, codenames|
|
93
|
+
accordion_item(title,
|
94
|
+
subheader: nil,
|
95
|
+
body: list_section_content(codenames),
|
96
|
+
open: false,
|
97
|
+
context: title.hash)
|
98
|
+
end.join " "
|
99
|
+
end
|
100
|
+
|
101
|
+
def list_section_content items, item_view=:bar
|
102
|
+
items&.map do |card|
|
103
|
+
nest card, view: item_view
|
104
|
+
end&.join(" ")
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
private
|
109
|
+
|
110
|
+
def admin_config_group_by_properties property1, property2
|
111
|
+
result = Hash.new { |hash, k| hash[k] = Hash.new { |hash2, k2| hash2[k2] = [] } }
|
112
|
+
all_configs.each_with_object(result) do |config, h|
|
113
|
+
property1_values = Array.wrap(config.send(property1))
|
114
|
+
property2_values = Array.wrap(config.send(property2))
|
115
|
+
|
116
|
+
property1_values.each do |p1v|
|
117
|
+
property2_values.each do |p2v|
|
118
|
+
h[p1v][p2v] << config
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
data/mod/core/set/self/admin.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
include_set Abstract::TaskTable
|
2
|
+
|
1
3
|
basket[:tasks].merge!(
|
2
4
|
clear_cache: {
|
3
5
|
mod: :core,
|
@@ -54,18 +56,7 @@ end
|
|
54
56
|
|
55
57
|
format :html do
|
56
58
|
view :core, cache: :never do
|
57
|
-
|
58
|
-
task_row task, task_config[:mod]
|
59
|
-
end
|
60
|
-
table table_content, header: %w[Task Description]
|
61
|
-
end
|
62
|
-
|
63
|
-
def task_row task, mod
|
64
|
-
base = "#{mod}_task_#{task}"
|
65
|
-
[
|
66
|
-
link_to_card(:admin, t("#{base}_link_text"), path: { action: :update, task: task }),
|
67
|
-
t("#{base}_description")
|
68
|
-
]
|
59
|
+
task_table basket[:tasks]
|
69
60
|
end
|
70
61
|
|
71
62
|
view :warning do
|
@@ -0,0 +1,39 @@
|
|
1
|
+
include_set Abstract::List
|
2
|
+
|
3
|
+
def item_codenames
|
4
|
+
Cardio.mods.map do |mod|
|
5
|
+
"#{mod}_mod"
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
def content
|
10
|
+
item_codenames.map(&:cardname).compact.to_pointer_content
|
11
|
+
end
|
12
|
+
|
13
|
+
format :html do
|
14
|
+
%i[cardtypes settings tasks configurations].each do |view_name|
|
15
|
+
view view_name do
|
16
|
+
[
|
17
|
+
content_tag(:h1, view_name),
|
18
|
+
card.all_admin_configs_grouped_by(:category, :mod)[view_name.to_s]
|
19
|
+
.map do |(mod, configs)|
|
20
|
+
list_section(mod.name, configs.map { |c| c.codename.to_sym })
|
21
|
+
end.join("<br\>")
|
22
|
+
]
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
view :roles do
|
27
|
+
[
|
28
|
+
content_tag(:h1, "Roles"),
|
29
|
+
card.all_admin_configs_grouped_by(:roles, :category).map do |(role, configs_by_cat)|
|
30
|
+
output [
|
31
|
+
content_tag(:h2, Card[role.to_sym].name),
|
32
|
+
(configs_by_cat.map do |(cat, configs)|
|
33
|
+
list_section cat, configs.map(&:codename)
|
34
|
+
end)
|
35
|
+
]
|
36
|
+
end.join("<br\>")
|
37
|
+
]
|
38
|
+
end
|
39
|
+
end
|