@@ -1,60 +1,60 @@
# frozen_string_literal: true

class Features
# This is for toggling Wiki Ed-specific features that should not be active
# on any other dashboard instances.
def self.wiki_ed?
return true if ENV['dashboard_url'] == 'dashboard.wikiedu.org'
return true if ENV['dashboard_url'] == 'dashboard-testing.wikiedu.org'
false
ENV['wiki_education'] == 'true'
end

def self.default_course_type
ENV['default_course_type'] || 'ClassroomProgramCourse'
def self.enable_get_help_button?
ENV['wiki_education'] == 'true'
end

def self.default_course_string_prefix
default_course_type.constantize.new.string_prefix
def self.wiki_trainings?
ENV['wiki_education'] != 'true'
end

def self.disable_help?
ENV['wiki_education'] != 'true'
end

def self.disable_onboarding?
ENV['disable_onboarding'] == 'true'
ENV['wiki_education'] != 'true'
end

def self.disable_help?
ENV['disable_help'] == 'true'
def self.enable_language_switcher?
ENV['wiki_education'] != 'true'
end

def self.disable_wiki_output?
ENV['disable_wiki_output'] == 'true'
def self.enable_account_requests?
ENV['wiki_education'] != 'true'
end

def self.open_course_creation?
ENV['open_course_creation'] == 'true'
def self.disable_wiki_output?
ENV['disable_wiki_output'] == 'true'
end

def self.enable_article_finder?
ENV['enable_article_finder'] == 'true'
end

def self.hot_loading?
ENV['hot_loading'] == 'true'
def self.open_course_creation?
ENV['wiki_education'] != 'true'
end

def self.email?
!ENV['mailgun_key'].nil?
def self.default_course_type
ENV['default_course_type'] || 'ClassroomProgramCourse'
end

def self.enable_get_help_button?
ENV['enable_get_help_button'] == 'true'
def self.default_course_string_prefix
default_course_type.constantize.new.string_prefix
end

def self.enable_language_switcher?
ENV['enable_language_switcher'] == 'true'
def self.hot_loading?
ENV['hot_loading'] == 'true'
end

def self.wiki_trainings?
ENV['enable_wiki_trainings'] == 'true'
def self.email?
!ENV['mailgun_key'].nil?
end

# Determines whether chat is available at all within the dashboard
@@ -68,10 +68,6 @@ def self.enable_course_chat?(course)
course.flags[:enable_chat] == true
end

def self.enable_account_requests?
ENV['enable_account_requests'] == 'true'
end

def self.celebrate?(current_user)
return false unless current_user&.admin?
ENV['celebrate'] == 'true'
@@ -1,9 +1,13 @@
# This example configuration is suitable for a development environment.
# Depending on which features you are working on, you may need to make
# adjustments to enable, disable, or configure certain features.

# Add configuration values here.
#
# Fulfill value requirements and save as application.yml
#
# Values required for WikiEduDashboard include:
# This is the main switch between the Wiki Education configuration
# and the Programs & Events Dashboard configuration.
# Set this to 'true' to enable Wiki Education-only features,
# or set it to 'false' to enable the features used for the global community
# instance of the Dashboard.
wiki_education: 'false'

# The name of the dashboard
dashboard_title: Programs and Events Dashboard
@@ -18,24 +22,12 @@
# a message to display to all users at the top of each page
# sitenotice: "NOTICE: The system will go down for maintenance soon."

# Set to 'true' to disable help links to ask.wikiedu.org.
disable_help: 'true'

# Set to true to disable mandatory training.
enable_wiki_trainings: 'false'
# Pages on meta.wikimedia.org that define training content.
# Only
training_slides_wiki_page: 'Training modules/dashboard/slides'
training_modules_wiki_page: 'Training modules/dashboard/modules'
training_libraries_wiki_page: 'Training modules/dashboard/libraries'

# Setting disable_wiki_output to 'true' means course pages will not be mirrored
# to the wiki.
disable_wiki_output: 'true'

# Setting 'open_course_creation' to 'true' means that any use can create a
# course, and it will be automatically added to the default campaign and be ready
# for use.
open_course_creation: 'true'

# Wikimedia OAuth consumer details. Register a consumer at:
# https://meta.wikimedia.org/wiki/Special:OAuthConsumerRegistration/propose
# No one but the user who registers the consumer will be able to log in until
@@ -44,20 +36,33 @@
wikipedia_token: 6e171fe7c5fc549ecce52471d22a6b0a
wikipedia_secret: 7f345a52566194a19d2adba5fcbb802e8c79f7ef

# The language version of Wikipedia: <wiki_language>.wikipedia.org
# Setting disable_wiki_output to 'true' means course pages will not be mirrored
# to the wiki, and other on-wiki edits will not be attempted.
# The default OAuth token does allow edits anyway, but if you replace it with
# OAuth credentials that do allow editing, use this to control whether live
# edits should be attempted.
# If enabled in generally, edits must also be enabled explicitly on a per-wiki
# basis. See below.
disable_wiki_output: 'true'

# Projects with automatic edits enabled, add as edit_<language>.<project_url>
# edit_en.wikipedia.org: "true"

# The default language version of Wikipedia: <wiki_language>.wikipedia.org
wiki_language: en

# The prefix for all course pages that get posted on behalf of users.
# This should probably be in the Project (Wikipedia) namespace, and should be
# a prefix that will only be used for this purpose.
# In production, this should probably be in the Project (Wikipedia) namespace,
# and should be a prefix that will only be used for this purpose.
# In development, userspace is a safe option.
course_prefix: 'User:Ragesock'
course_talk_prefix: 'User_talk:Ragesock'

# This is the community discussion page where new courses should be announced.
course_announcement_page: 'User:Ragesock'

# Set the default course type for newly created courses.
# default_course_type: ClassroomProgramCourse
default_course_type: BasicCourse

# Setting enable_article_finder to 'true' enables the prototype article_finder
# tool. Large queries can make the app unresponsive, so it's not ready for
@@ -75,23 +80,8 @@
sentry_dsn: 'http://somelongkey:anotherlongkey@sentry.myserver.com/1'
sentry_public_dsn: 'http://anotherlongkey@sentry.myserver.com/1'

# One or more campaigns of classes, with each campaign defined by a wiki page of
# course ids, one per line. For development, list at least 2 campaigns,
# which are needed for integration tests.
#
# Campaign names become uppercase, and underscores become spaces.
campaigns: "fall_2014,spring_2015"

## You can create wiki-based campaigns that pull data from the EP extension.
## You should not do so.
# campaign_fall_2014: "Wikipedia:Education_program/Dashboard/Fall_2014_course_ids"
# campaign_spring_2015: "Wikipedia:Education_program/Dashboard/course_ids"

# The slug for the default campaign
default_campaign: "fall_2014"

# Projects with automatic edits enabled, add as edit_<language>.<project_url>
# edit_en.wikipedia.org: "true"
default_campaign: "miscellanea"

# How many days after a course ends should the dashboard continue updating
# data for it?
@@ -108,10 +98,10 @@
# no_views: "true"

# Logo filename, under the /images directory.
logo_file: "wiki-logo.png"
logo_file: "outreach-logo.png"

# Favicon filename, under /images
favicon_file: "favicon.ico"
favicon_file: "outreach-logo.png"

# Development-mode favicon filename, under /images
favicon_dev_file: "favicon_dev.png"
@@ -139,6 +129,3 @@
chat_server: 'https://your.rocket.chat'
chat_admin_username: 'admin'
chat_admin_password: 'passwiord'

# Account requests
enable_account_requests: 'false'
@@ -1,10 +1,8 @@
ENV['dashboard_url'] = 'dashboard.wikiedu.org'
ENV['default_course_type'] = 'ClassroomProgramCourse'
ENV['open_course_creation'] = 'false'
ENV['disable_wiki_output'] = 'false'
ENV['open_course_creation'] = 'false'
ENV['course_prefix'] = 'Wikipedia:Wiki_Ed'
ENV['wiki_language'] = 'en'
ENV['wiki_education'] = 'true'
ENV['disable_wiki_output'] = 'false'
ENV['enable_article_finder'] = 'true'
ENV['oauth_ids'] = '252,212,542'
ENV['training_page_id'] = '36892501'
@@ -19,16 +17,11 @@
ENV['sentry_dsn'] = 'dummy://12345:67890@sentry.localdomain/sentry/42'
ENV['sentry_public_dsn'] = 'http://anotherlongkey@sentry.example.com/1'
ENV['no_views'] = 'false'
ENV['disable_onboarding'] = 'false'
#ENV['hot_loading'] = 'false'
ENV['mailgun_key'] = 'mailgun_api_key'
ENV['enable_legacy_courses'] = 'true'
ENV['enable_get_help_button'] = 'true'
ENV['enable_language_switcher'] = 'true'
ENV['training_path'] = 'training_content/wiki_ed'
ENV['enable_wiki_trainings'] = 'false'
ENV['enable_chat'] = 'true'
ENV['enable_account_requests'] = 'true'
ENV['chat_admin_username'] = 'username'
ENV['chat_admin_password'] = 'password'
ENV['chat_server'] = 'https://dashboardchat.wmflabs.org'
@@ -4,6 +4,7 @@
require "#{Rails.root}/lib/importers/user_importer"

describe RequestedAccountsCampaignsController do
before { allow(Features).to receive(:enable_account_requests?).and_return(true) }
describe '#request_account' do
let(:course) { create(:course, end: Time.zone.today + 1.week) }
let(:campaign) { create(:campaign, register_accounts: true) }
@@ -4,6 +4,8 @@
require "#{Rails.root}/lib/importers/user_importer"

describe RequestedAccountsController do
before { allow(Features).to receive(:enable_account_requests?).and_return(true) }

describe '#request_account' do
let(:course) { create(:course, end: Time.zone.today + 1.week) }
let(:user) { create(:user) }
@@ -2,6 +2,8 @@
require 'rails_helper'

describe 'language_switcher', type: :feature, js: true do
before { allow(Features).to receive(:enable_language_switcher?).and_return(true) }

context 'user logged out' do
it 'should default to English' do
visit root_path
@@ -123,38 +123,40 @@
end

context 'makes correct edits on P&E Outreach Dashboard' do
before :each do
@dashboard_url = ENV['dashboard_url']
ENV['dashboard_url'] = 'outreachdashboard.wmflabs.org'
end

after do
ENV['dashboard_url'] = @dashboard_url
end
unless Features.wiki_ed?
before :each do
@dashboard_url = ENV['dashboard_url']
ENV['dashboard_url'] = 'outreachdashboard.wmflabs.org'
end

context 'for enabled projects' do
it 'posts to P&E Dashboard' do
# Only twice for outreachdashboard, for user page and talk page.
# Sandbox templates are skipped for non-Wiki Ed edits.
expect_any_instance_of(WikiEdits).to receive(:add_to_page_top).twice
WikiCourseEdits.new(action: :enroll_in_course,
course: course,
current_user: user,
enrolling_user: enrolling_user)
after do
ENV['dashboard_url'] = @dashboard_url
end
end

context 'for disabled projects' do
before { stub_wiki_validation }
let(:wiki) { create(:wiki, language: 'pt', project: 'wikipedia') }
let(:course) { create(:course, id: 1, submitted: true, home_wiki_id: wiki.id) }
context 'for enabled projects' do
it 'posts to P&E Dashboard' do
# Only twice for outreachdashboard, for user page and talk page.
# Sandbox templates are skipped for non-Wiki Ed edits.
expect_any_instance_of(WikiEdits).to receive(:add_to_page_top).twice
WikiCourseEdits.new(action: :enroll_in_course,
course: course,
current_user: user,
enrolling_user: enrolling_user)
end
end

it 'does not post to P&E Dashboard' do
expect_any_instance_of(WikiEdits).to_not receive(:add_to_page_top)
WikiCourseEdits.new(action: :enroll_in_course,
course: course,
current_user: user,
enrolling_user: enrolling_user)
context 'for disabled projects' do
before { stub_wiki_validation }
let(:wiki) { create(:wiki, language: 'pt', project: 'wikipedia') }
let(:course) { create(:course, id: 1, submitted: true, home_wiki_id: wiki.id) }

it 'does not post to P&E Dashboard' do
expect_any_instance_of(WikiEdits).to_not receive(:add_to_page_top)
WikiCourseEdits.new(action: :enroll_in_course,
course: course,
current_user: user,
enrolling_user: enrolling_user)
end
end
end
end
@@ -5,22 +5,13 @@

describe Features do
describe '.wiki_ed?' do
context 'when the url is dashboard-testing.wikiedu.org' do
context 'when wiki_education is true' do
before do
allow(ENV).to receive(:[]).with('dashboard_url').and_return('dashboard-testing.wikiedu.org')
allow(ENV).to receive(:[]).with('wiki_education').and_return('true')
end
it 'returns true' do
expect(Features.wiki_ed?).to eq(true)
end
end

context 'when the url is outreachdashboard.wmflabs.org' do
before do
allow(ENV).to receive(:[]).with('dashboard_url').and_return('outreachdashboard.wmflabs.org')
end
it 'returns false' do
expect(Features.wiki_ed?).to eq(false)
end
end
end
end