docbrown/app/controllers/pages_controller.rb
Andy Zhao ecbb9d4ab1 [Done] New Reporting System MVP (#408)
* Move validations from controller to model

* Add new columns to feedback message model

* Use polymorphic notes relationship

* MVP of ticketing system

* Use new URL for reported_url param

* Add missing files

* Add validations and tests for feedback_messages

* Clean up some html

* Update create spec and add update spec

* Add mail tests and lint

* Add link to user profile
2018-06-19 16:41:31 -04:00

72 lines
1.8 KiB
Ruby

class PagesController < ApplicationController
before_action :set_cache_control_headers, only: [:rlyweb, :now, :events, :membership]
def phishing
@user = current_user
end
def now
set_surrogate_key_header "now_page"
end
def about
set_surrogate_key_header "about_page"
end
def membership
flash[:notice] = ""
flash[:error] = ""
@members = members_for_display
set_surrogate_key_header "membership_page"
end
def membership_form
render "membership_form", layout: false
end
def report_abuse
@feedback_message = FeedbackMessage.new(
reported_url: params[:reported_url] || params[:url] || request.referrer,
)
render "pages/report-abuse"
end
def rlyweb
set_surrogate_key_header "rlyweb"
end
def welcome
daily_thread = latest_published_welcome_thread
if daily_thread
redirect_to daily_thread.path
else
# fail safe if we haven't made the first welcome thread
redirect_to "/notifications"
end
end
def live
@active_channel = ChatChannel.find_by_channel_name("Workshop")
@chat_channels = [@active_channel].to_json
end
private # helpers
def latest_published_welcome_thread
Article.where(user_id: ENV["DEVTO_USER_ID"], published: true).
tagged_with("welcome").last
end
def members_for_display
Rails.cache.fetch("members-for-display-on-membership-page", expires_in: 6.hours) do
members = User.with_any_role(:level_1_member,
:level_2_member,
:level_3_member,
:level_4_member,
:triple_unicorn_member,
:workshop_pass)
team_ids = [1, 264, 6, 3, 31047, 510, 560, 1075, 48943, 13962]
members.reject { |user| team_ids.include?(user.id) }.shuffle
end
end
end