[deploy] Adds a new admin setting for experience levels. (#10870)

* Adds a new admin setting for experience levels.

This is used in the post management UI to determine the range of experience. These values fallback to the ones we currently see in DEV, Total Newbies and Senior Devs. There is also a removal of the word coding when talking about experience level, since the context for each forem instance should be implied when referencing experience.

* Cleans up experience defaults

* Fixes instance_of usage
This commit is contained in:
Alexis Moody 2020-10-16 14:40:25 -04:00 committed by GitHub
parent c45080c737
commit f4a10e4a44
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 73 additions and 31 deletions

View file

@ -18,6 +18,8 @@ module Admin
community_copyright_start_year
staff_user_id
tagline
experience_low
experience_high
].freeze
NEWSLETTER_PARAMS =

View file

@ -106,7 +106,7 @@ class OrganizationsController < ApplicationController
def organization_params
params.require(:organization).permit(permitted_params)
.transform_values do |value|
if value.class.name == "String"
if value.instance_of?(String)
ActionController::Base.helpers.strip_tags(value)
else
value

View file

@ -83,6 +83,14 @@ module Constants
description: "Email address",
placeholder: ""
},
experience_low: {
description: "The label for the bottom of the experience level range of a post",
placeholder: "Total Newbies"
},
experience_high: {
description: "The label for the top of the experience level range of a post",
placeholder: "Senior Devs"
},
facebook_key: {
description:
"The \"App ID\" portion of the Basic Settings section of the App page on the Facebook Developer Portal",

View file

@ -50,6 +50,8 @@ class SiteConfig < RailsSettings::Base
default: ApplicationConfig["COMMUNITY_COPYRIGHT_START_YEAR"] ||
Time.zone.today.year
field :staff_user_id, type: :integer, default: 1
field :experience_low, type: :string, default: "Total Newbies"
field :experience_high, type: :string, default: "Experienced Users"
# Emails
field :email_addresses, type: :hash, default: {

View file

@ -456,6 +456,23 @@
<div class="alert alert-info"><%= Constants::SiteConfig::DETAILS[:staff_user_id][:description] %></div>
</div>
<div class="form-group">
<%= admin_config_label :experience_low %>
<%= f.text_field :experience_low,
class: "form-control",
value: SiteConfig.experience_low,
placeholder: Constants::SiteConfig::DETAILS[:experience_low][:placeholder] %>
<div class="alert alert-info"><%= Constants::SiteConfig::DETAILS[:experience_low][:description] %></div>
</div>
<div class="form-group">
<%= admin_config_label :experience_high %>
<%= f.text_field :experience_high,
class: "form-control",
value: SiteConfig.experience_high,
placeholder: Constants::SiteConfig::DETAILS[:experience_high][:placeholder] %>
<div class="alert alert-info"><%= Constants::SiteConfig::DETAILS[:experience_high][:description] %></div>
</div>
<%= render "form_submission", f: f %>
</div>
</div>

View file

@ -51,23 +51,23 @@
<%= f.hidden_field :article_id, value: @article.id %>
<%= f.hidden_field :group, value: "experience_level" %>
<span class="button-section button-section-newbie">
<button value="1" name="rating_vote[rating]" class="level-rating-button <%= "selected" if @rating_vote&.rating == 1.0 %>">1</button>
<button value="2" name="rating_vote[rating]" class="level-rating-button <%= "selected" if @rating_vote&.rating == 2.0 %>">2</button>
<button value="3" name="rating_vote[rating]" class="level-rating-button <%= "selected" if @rating_vote&.rating == 3.0 %>">3</button>
<button value="1" name="rating_vote[rating]" class="level-rating-button <%= "selected" if @rating_vote&.rating.to_d == 1.0.to_d %>">1</button>
<button value="2" name="rating_vote[rating]" class="level-rating-button <%= "selected" if @rating_vote&.rating.to_d == 2.0.to_d %>">2</button>
<button value="3" name="rating_vote[rating]" class="level-rating-button <%= "selected" if @rating_vote&.rating.to_d == 3.0.to_d %>">3</button>
</span>
<span class="button-section button-section-intermediate">
<button value="4" name="rating_vote[rating]" class="level-rating-button <%= "selected" if @rating_vote&.rating == 4.0 %>">4</button>
<button value="5" name="rating_vote[rating]" class="level-rating-button <%= "selected" if @rating_vote&.rating == 5.0 %>">5</button>
<button value="6" name="rating_vote[rating]" class="level-rating-button <%= "selected" if @rating_vote&.rating == 6.0 %>">6</button>
<button value="7" name="rating_vote[rating]" class="level-rating-button <%= "selected" if @rating_vote&.rating == 7.0 %>">7</button>
<button value="4" name="rating_vote[rating]" class="level-rating-button <%= "selected" if @rating_vote&.rating.to_d == 4.0.to_d %>">4</button>
<button value="5" name="rating_vote[rating]" class="level-rating-button <%= "selected" if @rating_vote&.rating.to_d == 5.0.to_d %>">5</button>
<button value="6" name="rating_vote[rating]" class="level-rating-button <%= "selected" if @rating_vote&.rating.to_d == 6.0.to_d %>">6</button>
<button value="7" name="rating_vote[rating]" class="level-rating-button <%= "selected" if @rating_vote&.rating.to_d == 7.0.to_d %>">7</button>
</span>
<span class="button-section button-section-senior">
<button value="8" name="rating_vote[rating]" class="level-rating-button <%= "selected" if @rating_vote&.rating == 8.0 %>">8</button>
<button value="9" name="rating_vote[rating]" class="level-rating-button <%= "selected" if @rating_vote&.rating == 9.0 %>">9</button>
<button value="10" name="rating_vote[rating]" class="level-rating-button <%= "selected" if @rating_vote&.rating == 10.0 %>">10</button>
<button value="8" name="rating_vote[rating]" class="level-rating-button <%= "selected" if @rating_vote&.rating.to_d == 8.0.to_d %>">8</button>
<button value="9" name="rating_vote[rating]" class="level-rating-button <%= "selected" if @rating_vote&.rating.to_d == 9.0.to_d %>">9</button>
<button value="10" name="rating_vote[rating]" class="level-rating-button <%= "selected" if @rating_vote&.rating.to_d == 10.0.to_d %>">10</button>
</span>
<p>Who is this post most relevant for?</p>
<p><span class="scale-pod">👈 Total Newbies</span><span class="scale-pod">Senior Devs 👉</span></p>
<p><span class="scale-pod">👈 <%= SiteConfig.experience_low %></span><span class="scale-pod"><%= SiteConfig.experience_high %> 👉</span></p>
<% end %>
</div>
</div>

View file

@ -16,7 +16,6 @@
<script type="text/javascript" src="https://addevent.com/libs/atc/1.6.1/atc.min.js" async defer></script>
<div class="crayons-layout crayons-layout--limited-l">
<div class="crayons-card text-styles text-padding">
<h1 class="fs-3xl s:fs-4xl l:fs-5xl fw-bold s:fw-heavy lh-tight mb-4 mt-0">

View file

@ -5,7 +5,7 @@
We are happy to let you know that your <%= community_name %> account has just been upgraded to "trusted" status.
</p>
<p>
This gives you the power to privately downvote content which is low quality or spam and harassment, alongside a bit of additional functionality to help ensure the success of the community. Anywhere you now see a shield on the site indicates a place you can go to join our community's crowd-sourced moderation initiative.
This gives you the power to privately downvote content which is low quality or spam and harassment, alongside a bit of additional functionality to help ensure the success of the community. Anywhere you now see a shield on the site indicates a place you can go to join our community's crowd-sourced moderation initiative.
</p>
<p>
You may occasionally receive notifications about optional moderation actions, but you can <a href="<%= app_url(user_settings_path(:notifications)) %>">unsubscribe</a> if you do not want to receive these notices.

View file

@ -47,7 +47,7 @@
<div class="crayons-card grid gap-6 p-6">
<h2>Content Customization</h2>
<div class="crayons-field">
<%= f.label :experience_level, "What is your approximate coding experience level (1-5)?", class: "crayons-field__label" %>
<%= f.label :experience_level, "What is your approximate experience level (1-5)?", class: "crayons-field__label" %>
<div class="theme-selector-field grid grid-cols-5">
<% user_experience_levels.each_with_index do |exp, i| %>
<%= render partial: "experience_selector", locals: { f: f, exp: exp, i: i, label: user_experience_labels } %>

View file

@ -44,8 +44,8 @@ application.
![facebook-5](https://user-images.githubusercontent.com/37842/90913319-b5f20b80-e3a1-11ea-866a-0b06cf3296c7.png)
7. From the basic settings screen dashboard copy the **App ID** and **App
Secret** values to your `.env` file accordingly (name of Facebook
key -> name of our `SiteConfig` variable).
Secret** values to your `.env` file accordingly (name of Facebook key -> name
of our `SiteConfig` variable).
```text
APP ID -> FACEBOOK_APP_ID

View file

@ -18,8 +18,8 @@ keys. Then you'll need to provide these keys to the Rails application.
![github-1](https://user-images.githubusercontent.com/22895284/51085500-877a6c00-173a-11e9-913a-0dccad234cf3.png)
3. You will be redirected to the app's **Developer settings**. Here you will
find the keys. Add them to your `.env` file accordingly (name of GitHub key -> name of our
`ENV` variable):
find the keys. Add them to your `.env` file accordingly (name of GitHub key
-> name of our `ENV` variable):
```text
Client ID -> GITHUB_KEY

View file

@ -84,10 +84,10 @@ application.
![twitter-7](https://user-images.githubusercontent.com/22895284/51078803-9a9a2700-16bb-11e9-8f27-dbfe04b52031.png)
10. From the same dashboard access the **Keys and tokens** and add them to your `.env` file accordingly
(name of Twitter key -> name of our `ENV` variable). Be sure to
copy the _access token_ and _access token secret_ right away because it will
be hidden from you in the future.
10. From the same dashboard access the **Keys and tokens** and add them to your
`.env` file accordingly (name of Twitter key -> name of our `ENV` variable).
Be sure to copy the _access token_ and _access token secret_ right away
because it will be hidden from you in the future.
```text
API key -> TWITTER_KEY

View file

@ -61,8 +61,8 @@ with Podman. You can install it by following these
`git clone https://github.com/<your-username>/forem.git`
1. Set up your environment variables/secrets
- Take a look at `.env_sample`. This file lists all the `ENV` variables we use
and provides a fake default for any missing keys.
- Take a look at `.env_sample`. This file lists all the `ENV` variables we
use and provides a fake default for any missing keys.
- The [backend guide](/backend) will show you how to get free API keys for
additional services that may be required to run certain parts of the app.
- For any key that you wish to enter/replace:

View file

@ -89,8 +89,8 @@ NOTE: Make sure to download **the OSS version**, `elasticsearch-oss`.
1. Install bundler with `gem install bundler`
1. Set up your environment variables/secrets
- Take a look at `.env_sample`. This file lists all the `ENV` variables we use
and provides a fake default for any missing keys.
- Take a look at `.env_sample`. This file lists all the `ENV` variables we
use and provides a fake default for any missing keys.
- If you use a remote computer as dev env, you need to set `APP_DOMAIN`
variable to the remote computer's domain name.
- The [backend guide](/backend) will show you how to get free API keys for

View file

@ -209,8 +209,8 @@ your local Elasticsearch installation, for example:
3. Install bundler with `gem install bundler`
4. Set up your environment variables/secrets
- Take a look at `.env_sample` to see all the `ENV` variables we use and the fake
default provided for any missing keys.
- Take a look at `.env_sample` to see all the `ENV` variables we use and the
fake default provided for any missing keys.
- If you use a remote computer as dev env, you need to set `APP_DOMAIN`
variable to the remote computer's domain name.
- The [backend guide](/backend) will show you how to get free API keys for

View file

@ -256,8 +256,8 @@ To install Elasticsearch perform the following steps:
1. Install bundler with `gem install bundler`
1. Set up your environment variables/secrets
- Take a look at `.env_sample`. This file lists all the `ENV` variables we use
and provides a fake default for any missing keys.
- Take a look at `.env_sample`. This file lists all the `ENV` variables we
use and provides a fake default for any missing keys.
- If you use a remote computer as dev env, you need to set `APP_DOMAIN`
variable to the remote computer's domain name.
- The [backend guide](/backend) will show you how to get free API keys for

View file

@ -141,6 +141,20 @@ RSpec.describe "/admin/config", type: :request do
post "/admin/config", params: { site_config: { staff_user_id: 22 }, confirmation: confirmation_message }
expect(SiteConfig.staff_user_id).to eq(22)
end
it "updates the experience_low" do
experience_low = "Noobs"
post "/admin/config", params: { site_config: { experience_low: experience_low },
confirmation: confirmation_message }
expect(SiteConfig.experience_low).to eq(experience_low)
end
it "updates the experience_high" do
experience_high = "Advanced Peeps"
post "/admin/config", params: { site_config: { experience_high: experience_high },
confirmation: confirmation_message }
expect(SiteConfig.experience_high).to eq(experience_high)
end
end
describe "Emails" do