2014-07-17 14:10:44 +08:00
|
|
|
|
|
|
|
BadgeGrouping.seed do |g|
|
2014-07-18 13:46:36 +08:00
|
|
|
g.id = BadgeGrouping::GettingStarted
|
2014-07-17 14:10:44 +08:00
|
|
|
g.name = "Getting Started"
|
2014-07-18 13:46:36 +08:00
|
|
|
g.position = 10
|
2014-07-17 14:10:44 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
BadgeGrouping.seed do |g|
|
2014-07-18 13:46:36 +08:00
|
|
|
g.id = BadgeGrouping::Community
|
2014-07-17 14:10:44 +08:00
|
|
|
g.name = "Community"
|
2014-07-18 13:46:36 +08:00
|
|
|
g.position = 11
|
2014-07-17 14:10:44 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
BadgeGrouping.seed do |g|
|
2014-07-18 13:46:36 +08:00
|
|
|
g.id = BadgeGrouping::Posting
|
2014-07-17 14:10:44 +08:00
|
|
|
g.name = "Posting"
|
2014-07-18 13:46:36 +08:00
|
|
|
g.position = 12
|
2014-07-17 14:10:44 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
BadgeGrouping.seed do |g|
|
2014-07-18 13:46:36 +08:00
|
|
|
g.id = BadgeGrouping::TrustLevel
|
2014-07-17 14:10:44 +08:00
|
|
|
g.name = "Trust Level"
|
2014-07-18 13:46:36 +08:00
|
|
|
g.position = 13
|
2014-07-17 14:10:44 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
BadgeGrouping.seed do |g|
|
2014-07-18 13:46:36 +08:00
|
|
|
g.id = BadgeGrouping::Other
|
2014-07-17 14:10:44 +08:00
|
|
|
g.name = "Other"
|
2014-07-18 13:46:36 +08:00
|
|
|
g.position = 14
|
2014-07-17 14:10:44 +08:00
|
|
|
end
|
|
|
|
|
2014-07-18 13:46:36 +08:00
|
|
|
# BUGFIX
|
|
|
|
Badge.exec_sql 'UPDATE badges
|
2014-07-18 13:55:42 +08:00
|
|
|
SET badge_grouping_id = -1
|
2014-07-18 13:46:36 +08:00
|
|
|
WHERE NOT EXISTS (
|
|
|
|
SELECT 1 FROM badge_groupings g
|
|
|
|
WHERE g.id = badge_grouping_id
|
|
|
|
)'
|
|
|
|
|
2014-06-17 14:29:49 +08:00
|
|
|
# Trust level system badges.
|
2014-05-05 02:15:38 +08:00
|
|
|
trust_level_badges = [
|
2014-07-07 15:55:25 +08:00
|
|
|
{id: 1, name: "Basic User", type: BadgeType::Bronze},
|
|
|
|
{id: 2, name: "Regular User", type: BadgeType::Bronze},
|
|
|
|
{id: 3, name: "Leader", type: BadgeType::Silver},
|
|
|
|
{id: 4, name: "Elder", type: BadgeType::Gold}
|
2014-05-05 02:15:38 +08:00
|
|
|
]
|
|
|
|
|
|
|
|
trust_level_badges.each do |spec|
|
|
|
|
Badge.seed do |b|
|
|
|
|
b.id = spec[:id]
|
2014-07-17 10:25:16 +08:00
|
|
|
b.default_name = spec[:name]
|
2014-05-05 02:15:38 +08:00
|
|
|
b.badge_type_id = spec[:type]
|
2014-07-03 15:29:44 +08:00
|
|
|
b.query = Badge::Queries.trust_level(spec[:id])
|
2014-07-18 13:46:36 +08:00
|
|
|
b.default_badge_grouping_id = BadgeGrouping::TrustLevel
|
2014-07-22 10:46:31 +08:00
|
|
|
b.trigger = Badge::Trigger::TrustLevelChange
|
2014-07-09 10:17:39 +08:00
|
|
|
|
|
|
|
# allow title for leader and elder
|
|
|
|
b.allow_title = spec[:id] > 2
|
2014-05-05 02:15:38 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-07-15 13:16:41 +08:00
|
|
|
Badge.seed do |b|
|
|
|
|
b.id = Badge::Reader
|
2014-07-17 10:25:16 +08:00
|
|
|
b.default_name = "Reader"
|
2014-07-15 13:16:41 +08:00
|
|
|
b.badge_type_id = BadgeType::Bronze
|
|
|
|
b.multiple_grant = false
|
|
|
|
b.target_posts = false
|
|
|
|
b.query = Badge::Queries::Reader
|
2014-07-18 13:46:36 +08:00
|
|
|
b.default_badge_grouping_id = BadgeGrouping::GettingStarted
|
2014-07-15 13:16:41 +08:00
|
|
|
b.auto_revoke = false
|
|
|
|
end
|
|
|
|
|
2014-07-11 15:32:29 +08:00
|
|
|
Badge.seed do |b|
|
2014-07-16 14:26:22 +08:00
|
|
|
b.id = Badge::ReadGuidelines
|
2014-07-17 10:25:16 +08:00
|
|
|
b.default_name = "Read Guidelines"
|
2014-07-11 15:32:29 +08:00
|
|
|
b.badge_type_id = BadgeType::Bronze
|
|
|
|
b.multiple_grant = false
|
|
|
|
b.target_posts = false
|
2014-07-16 14:26:22 +08:00
|
|
|
b.query = Badge::Queries::ReadGuidelines
|
2014-07-18 13:46:36 +08:00
|
|
|
b.default_badge_grouping_id = BadgeGrouping::GettingStarted
|
2014-07-22 10:46:31 +08:00
|
|
|
b.trigger = Badge::Trigger::ReadGuidelines
|
2014-07-11 15:32:29 +08:00
|
|
|
end
|
|
|
|
|
2014-07-10 09:18:02 +08:00
|
|
|
Badge.seed do |b|
|
|
|
|
b.id = Badge::FirstLink
|
2014-07-17 10:25:16 +08:00
|
|
|
b.default_name = "First Link"
|
2014-07-10 09:18:02 +08:00
|
|
|
b.badge_type_id = BadgeType::Bronze
|
|
|
|
b.multiple_grant = false
|
|
|
|
b.target_posts = true
|
|
|
|
b.query = Badge::Queries::FirstLink
|
2014-07-18 13:46:36 +08:00
|
|
|
b.default_badge_grouping_id = BadgeGrouping::GettingStarted
|
2014-07-22 10:46:31 +08:00
|
|
|
b.trigger = Badge::Trigger::PostRevision
|
2014-07-10 09:18:02 +08:00
|
|
|
end
|
|
|
|
|
2014-07-11 12:17:01 +08:00
|
|
|
Badge.seed do |b|
|
|
|
|
b.id = Badge::FirstQuote
|
2014-07-17 10:25:16 +08:00
|
|
|
b.default_name = "First Quote"
|
2014-07-11 12:17:01 +08:00
|
|
|
b.badge_type_id = BadgeType::Bronze
|
|
|
|
b.multiple_grant = false
|
|
|
|
b.target_posts = true
|
|
|
|
b.query = Badge::Queries::FirstQuote
|
2014-07-18 13:46:36 +08:00
|
|
|
b.default_badge_grouping_id = BadgeGrouping::GettingStarted
|
2014-07-22 10:46:31 +08:00
|
|
|
b.trigger = Badge::Trigger::PostRevision
|
2014-07-11 12:17:01 +08:00
|
|
|
end
|
|
|
|
|
2014-07-08 12:26:53 +08:00
|
|
|
Badge.seed do |b|
|
2014-07-09 10:17:39 +08:00
|
|
|
b.id = Badge::FirstLike
|
2014-07-17 10:25:16 +08:00
|
|
|
b.default_name = "First Like"
|
2014-07-09 10:17:39 +08:00
|
|
|
b.badge_type_id = BadgeType::Bronze
|
|
|
|
b.multiple_grant = false
|
|
|
|
b.target_posts = true
|
|
|
|
b.query = Badge::Queries::FirstLike
|
2014-07-18 13:46:36 +08:00
|
|
|
b.default_badge_grouping_id = BadgeGrouping::GettingStarted
|
2014-07-22 10:46:31 +08:00
|
|
|
b.trigger = Badge::Trigger::PostAction
|
2014-07-09 10:17:39 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
Badge.seed do |b|
|
|
|
|
b.id = Badge::FirstFlag
|
2014-07-17 10:25:16 +08:00
|
|
|
b.default_name = "First Flag"
|
2014-07-09 10:17:39 +08:00
|
|
|
b.badge_type_id = BadgeType::Bronze
|
|
|
|
b.multiple_grant = false
|
|
|
|
b.target_posts = false
|
|
|
|
b.query = Badge::Queries::FirstFlag
|
2014-07-18 13:46:36 +08:00
|
|
|
b.default_badge_grouping_id = BadgeGrouping::Community
|
2014-07-22 10:46:31 +08:00
|
|
|
b.trigger = Badge::Trigger::PostAction
|
2014-07-09 10:17:39 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
Badge.seed do |b|
|
|
|
|
b.id = Badge::FirstShare
|
2014-07-17 10:25:16 +08:00
|
|
|
b.default_name = "First Share"
|
2014-07-08 12:26:53 +08:00
|
|
|
b.badge_type_id = BadgeType::Bronze
|
|
|
|
b.multiple_grant = false
|
|
|
|
b.target_posts = true
|
2014-07-09 10:17:39 +08:00
|
|
|
b.query = Badge::Queries::FirstShare
|
2014-07-18 13:46:36 +08:00
|
|
|
b.default_badge_grouping_id = BadgeGrouping::GettingStarted
|
2014-07-22 10:46:31 +08:00
|
|
|
b.trigger = Badge::Trigger::PostRevision
|
2014-07-08 12:26:53 +08:00
|
|
|
end
|
|
|
|
|
2014-07-03 15:29:44 +08:00
|
|
|
Badge.seed do |b|
|
|
|
|
b.id = Badge::Welcome
|
2014-07-17 10:25:16 +08:00
|
|
|
b.default_name = "Welcome"
|
2014-07-07 15:55:25 +08:00
|
|
|
b.badge_type_id = BadgeType::Bronze
|
2014-07-03 15:29:44 +08:00
|
|
|
b.multiple_grant = false
|
|
|
|
b.target_posts = true
|
|
|
|
b.query = Badge::Queries::Welcome
|
2014-07-18 13:46:36 +08:00
|
|
|
b.default_badge_grouping_id = BadgeGrouping::Community
|
2014-07-22 10:46:31 +08:00
|
|
|
b.trigger = Badge::Trigger::PostAction
|
2014-07-03 15:29:44 +08:00
|
|
|
end
|
2014-05-16 08:34:06 +08:00
|
|
|
|
2014-07-03 15:29:44 +08:00
|
|
|
Badge.seed do |b|
|
|
|
|
b.id = Badge::Autobiographer
|
2014-07-17 10:25:16 +08:00
|
|
|
b.default_name = "Autobiographer"
|
2014-07-07 15:55:25 +08:00
|
|
|
b.badge_type_id = BadgeType::Bronze
|
2014-07-03 15:29:44 +08:00
|
|
|
b.multiple_grant = false
|
|
|
|
b.query = Badge::Queries::Autobiographer
|
2014-07-18 13:46:36 +08:00
|
|
|
b.default_badge_grouping_id = BadgeGrouping::GettingStarted
|
2014-07-22 10:46:31 +08:00
|
|
|
b.trigger = Badge::Trigger::UserChange
|
2014-05-05 02:15:38 +08:00
|
|
|
end
|
2014-07-03 15:29:44 +08:00
|
|
|
|
2014-07-07 15:55:25 +08:00
|
|
|
Badge.seed do |b|
|
|
|
|
b.id = Badge::Editor
|
2014-07-17 10:25:16 +08:00
|
|
|
b.default_name = "Editor"
|
2014-07-07 15:55:25 +08:00
|
|
|
b.badge_type_id = BadgeType::Bronze
|
|
|
|
b.multiple_grant = false
|
|
|
|
b.query = Badge::Queries::Editor
|
2014-07-18 13:46:36 +08:00
|
|
|
b.default_badge_grouping_id = BadgeGrouping::Community
|
2014-07-22 10:46:31 +08:00
|
|
|
b.trigger = Badge::Trigger::PostRevision
|
2014-07-07 15:55:25 +08:00
|
|
|
end
|
|
|
|
|
2014-06-17 14:29:49 +08:00
|
|
|
#
|
|
|
|
# Like system badges.
|
|
|
|
like_badges = [
|
2014-07-07 15:55:25 +08:00
|
|
|
{id: 6, name: "Nice Post", type: BadgeType::Bronze, multiple: true},
|
|
|
|
{id: 7, name: "Good Post", type: BadgeType::Silver, multiple: true},
|
|
|
|
{id: 8, name: "Great Post", type: BadgeType::Gold, multiple: true}
|
2014-06-17 14:29:49 +08:00
|
|
|
]
|
|
|
|
|
|
|
|
like_badges.each do |spec|
|
|
|
|
Badge.seed do |b|
|
|
|
|
b.id = spec[:id]
|
2014-07-17 10:25:16 +08:00
|
|
|
b.default_name = spec[:name]
|
2014-06-17 14:29:49 +08:00
|
|
|
b.badge_type_id = spec[:type]
|
|
|
|
b.multiple_grant = spec[:multiple]
|
2014-07-03 15:29:44 +08:00
|
|
|
b.target_posts = true
|
|
|
|
b.query = Badge::Queries.like_badge(Badge.like_badge_counts[spec[:id]])
|
2014-07-18 13:46:36 +08:00
|
|
|
b.default_badge_grouping_id = BadgeGrouping::Posting
|
2014-07-22 10:46:31 +08:00
|
|
|
b.trigger = Badge::Trigger::PostAction
|
2014-06-17 14:29:49 +08:00
|
|
|
end
|
|
|
|
end
|