From bff95a6a972b263bcd56b53dec2e52ef254d9e7f Mon Sep 17 00:00:00 2001 From: riking Date: Wed, 24 Sep 2014 17:19:26 -0700 Subject: [PATCH] Rename 'leader' -> 'tl3' --- app/assets/javascripts/admin/models/admin_user.js | 8 ++++---- .../javascripts/admin/models/leader_requirements.js | 2 +- app/assets/javascripts/admin/routes/admin_routes.js | 2 +- ...ents_route.js => admin_user_tl3_requirements_route.js} | 2 +- app/assets/javascripts/admin/templates/user_index.hbs | 4 ++-- app/assets/stylesheets/common/admin/admin_base.scss | 2 +- app/controllers/admin/users_controller.rb | 2 +- .../scheduled/{leader_promotions.rb => tl3_promotions.rb} | 4 ++-- app/models/trust_level3_requirements.rb | 2 +- app/models/user.rb | 4 ++-- app/serializers/admin_detailed_user_serializer.rb | 8 ++++---- config/routes.rb | 3 ++- 12 files changed, 22 insertions(+), 21 deletions(-) rename app/assets/javascripts/admin/routes/{admin_user_leader_requirements_route.js => admin_user_tl3_requirements_route.js} (87%) rename app/jobs/scheduled/{leader_promotions.rb => tl3_promotions.rb} (88%) diff --git a/app/assets/javascripts/admin/models/admin_user.js b/app/assets/javascripts/admin/models/admin_user.js index 2f35fcae975..a37a7cf7d74 100644 --- a/app/assets/javascripts/admin/models/admin_user.js +++ b/app/assets/javascripts/admin/models/admin_user.js @@ -399,11 +399,11 @@ Discourse.AdminUser = Discourse.User.extend({ }); }, - leaderRequirements: function() { - if (this.get('leader_requirements')) { - return Discourse.LeaderRequirements.create(this.get('leader_requirements')); + tl3Requirements: function() { + if (this.get('tl3_requirements')) { + return Discourse.TL3Requirements.create(this.get('tl3_requirements')); } - }.property('leader_requirements'), + }.property('tl3_requirements'), suspendedBy: function() { if (this.get('suspended_by')) { diff --git a/app/assets/javascripts/admin/models/leader_requirements.js b/app/assets/javascripts/admin/models/leader_requirements.js index b1a300108da..52386830e64 100644 --- a/app/assets/javascripts/admin/models/leader_requirements.js +++ b/app/assets/javascripts/admin/models/leader_requirements.js @@ -1,4 +1,4 @@ -Discourse.LeaderRequirements = Discourse.Model.extend({ +Discourse.TL3Requirements = Discourse.Model.extend({ days_visited_percent: function() { return ((this.get('days_visited') * 100) / this.get('time_period')); }.property('days_visited', 'time_period'), diff --git a/app/assets/javascripts/admin/routes/admin_routes.js b/app/assets/javascripts/admin/routes/admin_routes.js index cee2200f8dc..c5b63815f51 100644 --- a/app/assets/javascripts/admin/routes/admin_routes.js +++ b/app/assets/javascripts/admin/routes/admin_routes.js @@ -48,7 +48,7 @@ Discourse.Route.buildRoutes(function() { this.resource('adminUsers', { path: '/users' }, function() { this.resource('adminUser', { path: '/:username' }, function() { this.route('badges'); - this.route('leaderRequirements', { path: '/leader_requirements' }); + this.route('tl3Requirements', { path: '/tl3_requirements' }); }); this.resource('adminUsersList', { path: '/list' }, function() { _.each(['active', 'new', 'pending', 'admins', 'moderators', 'blocked', 'suspended', diff --git a/app/assets/javascripts/admin/routes/admin_user_leader_requirements_route.js b/app/assets/javascripts/admin/routes/admin_user_tl3_requirements_route.js similarity index 87% rename from app/assets/javascripts/admin/routes/admin_user_leader_requirements_route.js rename to app/assets/javascripts/admin/routes/admin_user_tl3_requirements_route.js index 8afe74ab16c..cc71692e9bd 100644 --- a/app/assets/javascripts/admin/routes/admin_user_leader_requirements_route.js +++ b/app/assets/javascripts/admin/routes/admin_user_tl3_requirements_route.js @@ -7,7 +7,7 @@ @namespace Discourse @module Discourse **/ -Discourse.AdminUserLeaderRequirementsRoute = Discourse.Route.extend({ +Discourse.AdminUserTl3RequirementsRoute = Discourse.Route.extend({ model: function() { return this.modelFor('adminUser'); }, diff --git a/app/assets/javascripts/admin/templates/user_index.hbs b/app/assets/javascripts/admin/templates/user_index.hbs index 0959956ffb1..f4f11d36743 100644 --- a/app/assets/javascripts/admin/templates/user_index.hbs +++ b/app/assets/javascripts/admin/templates/user_index.hbs @@ -269,8 +269,8 @@ {{combo-box content=trustLevels value=trust_level nameProperty="detailedName"}}
- {{#if leaderRequirements}} - {{#link-to 'adminUser.leaderRequirements' this class="btn"}}{{i18n admin.user.trust_level_3_requirements}}{{/link-to}} + {{#if tl3Requirements}} + {{#link-to 'adminUser.tl3Requirements' this class="btn"}}{{i18n admin.user.trust_level_3_requirements}}{{/link-to}} {{/if}} {{#if dirty}} diff --git a/app/assets/stylesheets/common/admin/admin_base.scss b/app/assets/stylesheets/common/admin/admin_base.scss index 390e1454c9a..c068dd08654 100644 --- a/app/assets/stylesheets/common/admin/admin_base.scss +++ b/app/assets/stylesheets/common/admin/admin_base.scss @@ -1147,7 +1147,7 @@ table.api-keys { } } -.leader-requirements { +.tl3-requirements { .fa-check { color: $success; } diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb index d5a4daeaab5..728b7d513a4 100644 --- a/app/controllers/admin/users_controller.rb +++ b/app/controllers/admin/users_controller.rb @@ -212,7 +212,7 @@ class Admin::UsersController < Admin::AdminController def badges end - def leader_requirements + def tl3_requirements end def ip_info diff --git a/app/jobs/scheduled/leader_promotions.rb b/app/jobs/scheduled/tl3_promotions.rb similarity index 88% rename from app/jobs/scheduled/leader_promotions.rb rename to app/jobs/scheduled/tl3_promotions.rb index 3f0c1d016d3..37acfcec154 100644 --- a/app/jobs/scheduled/leader_promotions.rb +++ b/app/jobs/scheduled/tl3_promotions.rb @@ -1,6 +1,6 @@ module Jobs - class LeaderPromotions < Jobs::Scheduled + class Tl3Promotions < Jobs::Scheduled daily at: 4.hours def execute(args) @@ -8,7 +8,7 @@ module Jobs demoted_user_ids = [] User.real.where(trust_level: TrustLevel[3], trust_level_locked: false).find_each do |u| # Don't demote too soon after being promoted - next if u.on_leader_grace_period? + next if u.on_tl3_grace_period? if Promotion.tl3_lost?(u) demoted_user_ids << u.id diff --git a/app/models/trust_level3_requirements.rb b/app/models/trust_level3_requirements.rb index 552cc5c1b60..5aad577047d 100644 --- a/app/models/trust_level3_requirements.rb +++ b/app/models/trust_level3_requirements.rb @@ -58,7 +58,7 @@ class TrustLevel3Requirements end def on_grace_period - @user.on_leader_grace_period? + @user.on_tl3_grace_period? end def days_visited diff --git a/app/models/user.rb b/app/models/user.rb index eadcd59c024..fd2bef99cc4 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -570,11 +570,11 @@ class User < ActiveRecord::Base last_sent_email_address || email end - def leader_requirements + def tl3_requirements @lq ||= TrustLevel3Requirements.new(self) end - def on_leader_grace_period? + def on_tl3_grace_period? UserHistory.for(self, :auto_trust_level_change) .where('created_at >= ?', SiteSetting.tl3_promotion_min_duration.to_i.days.ago) .where(previous_value: TrustLevel[2].to_s) diff --git a/app/serializers/admin_detailed_user_serializer.rb b/app/serializers/admin_detailed_user_serializer.rb index 1df1089ef28..c762e1da187 100644 --- a/app/serializers/admin_detailed_user_serializer.rb +++ b/app/serializers/admin_detailed_user_serializer.rb @@ -23,7 +23,7 @@ class AdminDetailedUserSerializer < AdminUserSerializer has_one :approved_by, serializer: BasicUserSerializer, embed: :objects has_one :api_key, serializer: ApiKeySerializer, embed: :objects has_one :suspended_by, serializer: BasicUserSerializer, embed: :objects - has_one :leader_requirements, serializer: TrustLevel3RequirementsSerializer, embed: :objects + has_one :tl3_requirements, serializer: TrustLevel3RequirementsSerializer, embed: :objects has_many :groups, embed: :object, serializer: BasicGroupSerializer def can_revoke_admin @@ -66,11 +66,11 @@ class AdminDetailedUserSerializer < AdminUserSerializer object.suspend_record.try(:acting_user) end - def leader_requirements - object.leader_requirements + def tl3_requirements + object.tl3_requirements end - def include_leader_requirements? + def include_tl3_requirements? object.has_trust_level?(TrustLevel[2]) end diff --git a/config/routes.rb b/config/routes.rb index 0a98a95dfd5..8d9c0a6abf0 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -77,7 +77,8 @@ Discourse::Application.routes.draw do post "groups" => "users#add_group", constraints: AdminConstraint.new delete "groups/:group_id" => "users#remove_group", constraints: AdminConstraint.new get "badges" - get "leader_requirements" + get "leader_requirements" => "users#tl3_requirements" + get "tl3_requirements" end resources :impersonate, constraints: AdminConstraint.new