Skip to content

Commit

Permalink
Merge branch 'main' into chore/clear-github-data-on-account-deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
su-su-su-su authored Aug 21, 2024
2 parents 0de0a02 + 507edb8 commit eb2db3f
Show file tree
Hide file tree
Showing 205 changed files with 1,715 additions and 984 deletions.
8 changes: 4 additions & 4 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ GEM
cocoon (1.2.15)
coderay (1.1.3)
commonmarker (0.23.10)
concurrent-ruby (1.2.2)
concurrent-ruby (1.3.4)
connection_pool (2.4.1)
countries (5.7.0)
unaccent (~> 0.3)
Expand Down Expand Up @@ -162,7 +162,7 @@ GEM
domain_name (0.5.20190701)
unf (>= 0.0.5, < 1.0.0)
erubi (1.12.0)
et-orbi (1.2.7)
et-orbi (1.2.11)
tzinfo
event_emitter (0.2.6)
event_stream_parser (0.3.0)
Expand All @@ -176,8 +176,8 @@ GEM
faraday-net_http (3.0.2)
ffi (1.16.3)
foreman (0.87.2)
fugit (1.9.0)
et-orbi (~> 1, >= 1.2.7)
fugit (1.11.1)
et-orbi (~> 1, >= 1.2.11)
raabro (~> 1.4)
globalid (1.2.1)
activesupport (>= 6.1)
Expand Down
Binary file removed app/assets/images/welcome/companies.jpg
Binary file not shown.
Binary file added app/assets/images/welcome/companies.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
55 changes: 55 additions & 0 deletions app/components/calendar/nico_nico_calendar_component.html.slim
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
.a-card
header.card-header.is-sm
h2.card-header__title
| ニコニコカレンダー
hr.a-border-tint
.card-body
.card__description
.niconico-calendar-nav
- if prev_month?(current_date)
= link_to prev_month_path do
.niconico-calendar-nav__previous
i.fa-solid.fa-angle-left
- else
.niconico-calendar-nav__next.is-blank
.niconico-calendar-nav__year--month
= "#{current_date.year}年#{current_date.month}月"
- if next_month?(current_date)
= link_to next_month_path do
.niconico-calendar-nav__next
i.fa-solid.fa-angle-right
- else
.niconico-calendar-nav__next.is-blank
table.niconico-calendar
thead.niconico-calendar__header
tr
th.niconico-calendar__header-day.is-sunday
th.niconico-calendar__header-day
th.niconico-calendar__header-day
th.niconico-calendar__header-day
th.niconico-calendar__header-day
th.niconico-calendar__header-day
th.niconico-calendar__header-day.is-saturday
tbody.niconico-calendar__body
- user.niconico_calendar(current_calendar).each do |week|
tr.niconico-calendar__week
- week.each do |set|
- day_css_class = frame_and_background(set[:date], set[:emotion])
- day_label_html = capture do
.niconico-calendar__day-label
= set[:date]&.day
.niconico-calendar__day-value
- if set[:emotion]
img.niconico-calendar__emotion-image src="/images/emotion/#{set[:emotion]}.svg" alt="#{set[:emotion]}"
- elsif set[:date]
i.fa-solid.fa-minus
td.niconico-calendar__day class=day_css_class
- if set[:report]
= link_to report_path(set[:report]), class: 'niconico-calendar__day-inner' do
= day_label_html
- elsif set[:date] && !set[:date].future?
= link_to new_report_path(reported_on: set[:date]), class: 'niconico-calendar__day-inner' do
= day_label_html
- else
.niconico-calendar__day-inner
= day_label_html
36 changes: 36 additions & 0 deletions app/components/calendar/nico_nico_calendar_component.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# frozen_string_literal: true

class Calendar::NicoNicoCalendarComponent < ViewComponent::Base
def initialize(user:, path:, current_date:, current_calendar:)
@user = user
@path = path
@current_date = current_date
@current_calendar = current_calendar
end

def prev_month?(month)
month.beginning_of_month > user.created_at.to_date.beginning_of_month
end

def prev_month_path
send(path, niconico_calendar: current_date.prev_month.strftime('%Y-%m'))
end

def frame_and_background(date, emotion)
day_class = emotion ? "is-#{emotion}" : 'is-blank'
day_class += ' is-today' if date&.today?
day_class
end

def next_month?(month)
month.beginning_of_month < Time.zone.today.to_date.beginning_of_month
end

def next_month_path
send(path, niconico_calendar: current_date.next_month.strftime('%Y-%m'))
end

private

attr_reader :user, :path, :current_date, :current_calendar
end
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
- practice_content = product.practice_content_for_toggle(content_type)

.a-card.is-toggle
input.a-toggle-checkbox(id=practice_content[:id_name] type='checkbox')
label.card-header.is-sm(for=practice_content[:id_name])
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# frozen_string_literal: true

module PracticeContentToggle
class PracticeContentToggleComponent < ViewComponent::Base
def initialize(content_type:, practice:)
@content_type = content_type
@practice = practice
end

def practice_content
case @content_type
when :practice
{
id_name: 'toggle_description_body',
title: 'プラクティスを確認',
description: @practice.description
}
when :goal
{
id_name: 'toggle_goal_body',
title: '終了条件を確認',
description: @practice.goal
}
end
end
end
end
2 changes: 1 addition & 1 deletion app/controllers/admin/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def user_params
:twitter_account, :facebook_url, :blog_url,
:password, :password_confirmation, :job,
:organization, :os, :study_place,
:experience, :company_id,
{ experiences: [] }, :company_id,
:trainee, :job_seeking, :nda,
:graduated_on, :retired_on, :free,
:job_seeker, :github_collaborator,
Expand Down
10 changes: 0 additions & 10 deletions app/controllers/api/niconico_calendars_controller.rb

This file was deleted.

9 changes: 0 additions & 9 deletions app/controllers/api/users/worried_controller.rb

This file was deleted.

2 changes: 1 addition & 1 deletion app/controllers/api/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def search_for_users(target, target_users, search_word)
end

def target_allowlist
target_allowlist = %w[student_and_trainee student trainee followings mentor graduate adviser year_end_party]
target_allowlist = %w[student_and_trainee student trainee followings mentor graduate adviser year_end_party admin]
target_allowlist.push('job_seeking') if current_user.adviser?
target_allowlist.push('all') if @company
target_allowlist.concat(%w[job_seeking hibernated retired inactive all]) if current_user.mentor? || current_user.admin?
Expand Down
16 changes: 11 additions & 5 deletions app/controllers/articles_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,17 @@ class ArticlesController < ApplicationController
def index
@articles = list_articles
@articles = @articles.tagged_with(params[:tag]) if params[:tag]
render layout: 'welcome'
number_per_page = @articles.page(1).limit_value
@atom_articles = list_recent_articles(number_per_page)
respond_to do |format|
format.html { render layout: 'welcome' }
format.atom
end
end

def show
@mentor = @article.user
@recent_articles = list_recent_articles
@recent_articles = list_recent_articles(10)
if @article.published? || admin_or_mentor_login?
render layout: 'welcome'
else
Expand Down Expand Up @@ -62,13 +67,14 @@ def set_article
end

def list_articles
articles = Article.with_attached_thumbnail.includes(user: { avatar_attachment: :blob }).order(created_at: :desc).page(params[:page])
articles = Article.with_attached_thumbnail.includes(user: { avatar_attachment: :blob })
.order(published_at: :desc, created_at: :desc).page(params[:page])
admin_or_mentor_login? ? articles : articles.where(wip: false)
end

def list_recent_articles
def list_recent_articles(number)
Article.with_attached_thumbnail.includes(user: { avatar_attachment: :blob })
.where(wip: false).order(published_at: :desc).limit(10)
.where(wip: false).order(published_at: :desc).limit(number)
end

def article_params
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/companies/users_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

class Companies::UsersController < ApplicationController
ALLOWED_TARGETS = %w[all student_and_trainee graduate adviser mentor].freeze
ALLOWED_TARGETS = %w[all student_and_trainee graduate adviser mentor admin].freeze

def index
@target = params[:target]
Expand Down
10 changes: 8 additions & 2 deletions app/controllers/courses_controller.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
# frozen_string_literal: true

class CoursesController < ApplicationController
before_action :require_mentor_login, except: %i[index]
skip_before_action :require_active_user_login, raise: false

def index
@courses = Course.order(created_at: :desc)
if logged_in?
@courses = Course.order(created_at: :desc)
else
@rails_course = Course.preload(categories: :practices).find_by(title: 'Railsエンジニア')
@frontend_course = Course.preload(categories: :practices).find_by(title: 'フロントエンドエンジニア')
render 'welcome/courses', layout: 'welcome'
end
end

private
Expand Down
6 changes: 4 additions & 2 deletions app/controllers/current_user_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,17 @@ def user_params
:github_account, :twitter_account, :facebook_url,
:blog_url, :password, :password_confirmation,
:job, :organization, :os,
:experience, :editor, :other_editor, :company_id,
{ experiences: [] }, :editor, :other_editor, :company_id,
:nda, :avatar, :trainee,
:mail_notification, :job_seeker, :tag_list,
:after_graduation_hope, :training_ends_on, :profile_image,
:hide_mentor_profile,
:profile_name, :profile_job, :profile_text, { authored_books_attributes: %i[id title url cover _destroy] },
:feed_url, :country_code, :subdivision_code, { discord_profile_attributes: %i[id account_name times_url] }
]
user_attribute.push(:retired_on, :graduated_on, :free, :github_collaborator) if current_user.admin?
if current_user.admin?
user_attribute.push(:retired_on, :graduated_on, :free, :github_collaborator, :auto_retire, :invoice_payment, :mentor, :subscription_id)
end
params.require(:user).permit(user_attribute)
end

Expand Down
1 change: 1 addition & 0 deletions app/controllers/home_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def display_dashboard
@collegue_trainees_recent_reports = collegue_trainees_reports.order(reported_on: :desc).limit(10)
@recent_reports = Report.with_avatar.where(wip: false).order(reported_on: :desc, created_at: :desc).limit(10)
@collegues = current_user.collegues_other_than_self
@calendar = NicoNicoCalendar.new(current_user, params[:niconico_calendar])
end

def display_events_on_dashboard
Expand Down
3 changes: 2 additions & 1 deletion app/controllers/inquiries_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ def new

def create
@inquiry = Inquiry.new(inquiry_params)

result = valid_recaptcha?('inquiry')

if result && @inquiry.save
Newspaper.publish(:came_inquiry, { inquiry: @inquiry })
InquiryMailer.incoming(@inquiry).deliver_later
redirect_to new_inquiry_url, notice: 'お問い合わせを送信しました。'
else
Expand Down
4 changes: 3 additions & 1 deletion app/controllers/mentor/home_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# frozen_string_literal: true

class Mentor::HomeController < MentorController
def index; end
def index
@worried_users = User.delayed.order(completed_at: :asc)
end
end
44 changes: 44 additions & 0 deletions app/controllers/mentor/practices/submission_answer_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# frozen_string_literal: true

class Mentor::Practices::SubmissionAnswerController < ApplicationController
before_action :require_admin_or_mentor_login
before_action :set_submission_answer, only: %i[edit update]

def new
@practice = Practice.find(params[:practice_id])
@submission_answer = @practice.build_submission_answer
end

def edit
@practice = @submission_answer.practice
end

def create
@practice = Practice.find(params[:practice_id])
@submission_answer = @practice.build_submission_answer(submission_answer_params)
if @submission_answer.save
redirect_to practice_submission_answer_url, notice: '模範解答を作成しました。'
else
render :new, status: :unprocessable_entity
end
end

def update
@practice = @submission_answer.practice
if @submission_answer.update(submission_answer_params)
redirect_to practice_submission_answer_url, notice: '模範解答を更新しました。'
else
render :edit, status: :unprocessable_entity
end
end

private

def set_submission_answer
@submission_answer = SubmissionAnswer.find_by(practice_id: params[:practice_id])
end

def submission_answer_params
params.require(:submission_answer).permit(:description)
end
end
4 changes: 2 additions & 2 deletions app/controllers/mentor/practices_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def edit; end
def create
@practice = Practice.new(practice_params)
if @practice.save
ChatNotifier.message("プラクティス:「#{@practice.title}」を#{current_user.login_name}さんが作成しました。\r#{url_for(@practice)}")
ChatNotifier.message("プラクティス:「#{@practice.title}」を#{current_user.login_name}さんが作成しました。\r<#{url_for(@practice)}>")
redirect_to @practice, notice: 'プラクティスを作成しました。'
else
render :new
Expand All @@ -28,7 +28,7 @@ def create
def update
@practice.last_updated_user = current_user
if @practice.update(practice_params)
ChatNotifier.message("プラクティス:「#{@practice.title}」を#{current_user.login_name}さんが編集しました。\r#{url_for(@practice)}")
ChatNotifier.message("プラクティス:「#{@practice.title}」を#{current_user.login_name}さんが編集しました。\r<#{url_for(@practice)}>")
redirect_to @practice, notice: 'プラクティスを更新しました。'
else
render :edit
Expand Down
20 changes: 20 additions & 0 deletions app/controllers/practices/submission_answer_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# frozen_string_literal: true

class Practices::SubmissionAnswerController < ApplicationController
before_action :check_permission!, only: %i[show]

def show
@practice = Practice.find(params[:practice_id])
@submission_answer = @practice.submission_answer
end

private

def check_permission!
practice = Practice.find(params[:practice_id])
submission_answer = practice.submission_answer || SubmissionAnswer.new(practice:)
return if policy(submission_answer).show?

redirect_to practice_path(practice), alert: 'プラクティスを修了するまで模範解答は見れません。'
end
end
Loading

0 comments on commit eb2db3f

Please sign in to comment.