Revert "Add the Lounge category, an exclusive area for trust level 3 users"

This commit is contained in:
Neil Lalonde 2014-01-20 15:43:04 -05:00
parent 963793549c
commit 33c3e027b3
4 changed files with 0 additions and 70 deletions

View File

@ -188,9 +188,6 @@ en:
no_info_me: "<div class='missing-profile'>the About Me field of your profile is currently blank, <a href='/users/%{username_lower}/preferences/about-me'>would you like to fill it out?</a></div>" no_info_me: "<div class='missing-profile'>the About Me field of your profile is currently blank, <a href='/users/%{username_lower}/preferences/about-me'>would you like to fill it out?</a></div>"
no_info_other: "<div class='missing-profile'>%{name} hasn't entered anything in the About Me field of their profile yet</div>" no_info_other: "<div class='missing-profile'>%{name} hasn't entered anything in the About Me field of their profile yet</div>"
vip_category_name: "Lounge"
vip_category_description: "A category exclusive to members with trust level 3 and higher."
category: category:
topic_prefix: "Category definition for %{category}" topic_prefix: "Category definition for %{category}"
replace_paragraph: "[Replace this first paragraph with a short description of your new category. This guidance will appear in the category selection area, so try to keep it below 200 characters. Until you edit this text or create topics, this category won't appear on the categories page.]" replace_paragraph: "[Replace this first paragraph with a short description of your new category. This guidance will appear in the category selection area, so try to keep it below 200 characters. Until you edit this text or create topics, this category won't appear on the categories page.]"

View File

@ -423,8 +423,5 @@ uncategorized:
suppress_uncategorized_badge: suppress_uncategorized_badge:
client: true client: true
default: true default: true
lounge_category_id:
default: -1
hidden: true

View File

@ -1,35 +0,0 @@
lounge = Category.where(id: SiteSetting.lounge_category_id).first
if lounge and !lounge.group_ids.include?(Group[:trust_level_3].id)
# The category for users with trust level 3 has been created.
# Add permissions and a description to it.
lounge.group_names = ['trust_level_3']
unless lounge.save
puts lounge.errors.full_messages
raise "Failed to set permissions on trust level 3 lounge category!"
end
creator = PostCreator.new(Discourse.system_user,
raw: I18n.t('vip_category_description'),
title: I18n.t('category.topic_prefix', category: lounge.name),
category: lounge.name,
archetype: Archetype.default
)
post = creator.create
unless post && post.id
puts post.errors.full_messages if post
puts creator.errors.inspect
raise "Failed to create description for trust level 3 lounge!"
end
lounge.topic_id = post.topic.id
unless lounge.save
puts lounge.errors.full_messages
puts "Failed to set the lounge description topic!"
end
# Reset topic count because we don't count the description topic
Category.exec_sql "UPDATE categories SET topic_count = 0 WHERE id = #{lounge.id}"
end

View File

@ -1,29 +0,0 @@
class AddLoungeCategory < ActiveRecord::Migration
def up
result = Category.exec_sql "SELECT 1 FROM site_settings where name = 'lounge_category_id'"
if result.count == 0
description = I18n.t('vip_category_description')
default_name = I18n.t('vip_category_name')
name = if Category.exec_sql("SELECT 1 FROM categories where name = '#{default_name}'").count == 0
default_name
else
"CHANGE_ME"
end
result = execute "INSERT INTO categories
(name, color, text_color, created_at, updated_at, user_id, slug, description, read_restricted)
VALUES ('#{name}', 'EEEEEE', '652D90', now(), now(), -1, '#{Slug.for(name)}', '#{description}', true)
RETURNING id"
category_id = result[0]["id"].to_i
execute "INSERT INTO site_settings(name, data_type, value, created_at, updated_at)
VALUES ('lounge_category_id', 3, #{category_id}, now(), now())"
end
end
def down
# Don't reverse this change. There is so much logic around deleting a category that it's messy
# to try to do in sql. The up method will just make sure never to create the category twice.
end
end