Skip to content

Commit

Permalink
Merge pull request #7920 from fjordllc/main
Browse files Browse the repository at this point in the history
Release 2024-07-03 06:36:16 +0000
  • Loading branch information
komagata authored Jul 4, 2024
2 parents 76cf12f + 8effdcf commit 01bad3b
Show file tree
Hide file tree
Showing 54 changed files with 626 additions and 402 deletions.
2 changes: 1 addition & 1 deletion app/controllers/admin/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def user_params
:graduated_on, :retired_on, :free,
:job_seeker, :github_collaborator,
:officekey_permission, :tag_list, :training_ends_on,
:auto_retire, :invoice_payment,
:auto_retire, :invoice_payment, :hide_mentor_profile,
:profile_image, :profile_name, :profile_job, :mentor,
:profile_text, { authored_books_attributes: %i[id title url cover _destroy] },
:country_code, :subdivision_code, discord_profile_attributes: %i[account_name times_url times_id]
Expand Down
9 changes: 7 additions & 2 deletions app/controllers/connection/git_hub_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ class Connection::GitHubController < ApplicationController
skip_before_action :require_active_user_login, raise: false

def destroy
current_user.update(github_id: nil)
redirect_to root_path, notice: 'GitHubとの連携を解除しました。'
user = User.find(params[:user_id])
if !admin_login? && user != current_user
redirect_to root_path, alert: '管理者としてログインしてください'
else
user.update(github_id: nil)
redirect_to user_path(user), notice: 'GitHubとの連携を解除しました。'
end
end
end
10 changes: 3 additions & 7 deletions app/controllers/events_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
class EventsController < ApplicationController
before_action :set_event, only: %i[edit update destroy]

def index; end
def index
@upcoming_events_groups = UpcomingEvent.upcoming_events_groups
end

def show
@event = Event.with_avatar.find(params[:id])
Expand Down Expand Up @@ -75,12 +77,6 @@ def set_wip
@event.wip = (params[:commit] == 'WIP')
end

def redirect_url(event)
return new_announcement_path(event_id: event.id) if publish_with_announcement?

event.wip? ? edit_event_url(event) : event_url(event)
end

def notice_message(event)
case params[:action]
when 'create'
Expand Down
7 changes: 1 addition & 6 deletions app/controllers/home_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,7 @@ def display_dashboard
end

def display_events_on_dashboard
@today_events = (Event.today_events + RegularEvent.today_events)
.sort_by { |e| e.start_at.strftime('%H:%M') }
@tomorrow_events = (Event.tomorrow_events + RegularEvent.tomorrow_events)
.sort_by { |e| e.start_at.strftime('%H:%M') }
@day_after_tomorrow_events = (Event.day_after_tomorrow_events + RegularEvent.day_after_tomorrow_events)
.sort_by { |e| e.start_at.strftime('%H:%M') }
@upcoming_events_groups = UpcomingEvent.upcoming_events_groups
end

def display_welcome_message_for_adviser
Expand Down
4 changes: 3 additions & 1 deletion app/controllers/regular_events_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
class RegularEventsController < ApplicationController
before_action :set_regular_event, only: %i[edit update destroy]

def index; end
def index
@upcoming_events_groups = UpcomingEvent.upcoming_events_groups
end

def show
@regular_event = RegularEvent.find(params[:id])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ def show
private

def notify_coming_soon_regular_events
today_events = RegularEvent.today_events
tomorrow_events = RegularEvent.tomorrow_events
today_events = RegularEvent.scheduled_on(Time.zone.today)
tomorrow_events = RegularEvent.scheduled_on(Time.zone.today + 1.day)
return if today_events.blank? && tomorrow_events.blank?

NotificationFacade.coming_soon_regular_events(today_events, tomorrow_events)
Expand Down
4 changes: 2 additions & 2 deletions app/decorators/regular_event_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ def holding_cycles
def next_holding_date
if finished
'開催終了'
elsif holding_today?
!hold_national_holiday && HolidayJp.holiday?(Time.zone.today) ? "次回の開催日は #{l next_event_date} です" : '本日開催'
elsif next_event_date == Time.zone.today
'本日開催'
else
"次回の開催日は #{l next_event_date} です"
end
Expand Down
30 changes: 30 additions & 0 deletions app/decorators/upcoming_event_decorator.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# frozen_string_literal: true

module UpcomingEventDecorator
def label_style
case original_event
when Event
'is-special'
when RegularEvent
"is-#{original_event.category}"
end
end

def inner_title_style
case original_event
when Event
'card-list-item__label-inner.is-sm'
when RegularEvent
nil
end
end

def inner_title
case original_event
when Event
'特別<br>イベント'
when RegularEvent
I18n.translate("activerecord.enums.regular_event.category.#{original_event.category}")
end
end
end
56 changes: 24 additions & 32 deletions app/javascript/components/Events.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,41 +14,33 @@ export default function Events() {

if (error) return <>エラーが発生しました。</>
if (!data) {
return (
<div className="page-body">
<div className="container is-md">
<LoadingListPlaceholder />
</div>
</div>
)
return <LoadingListPlaceholder />
}

return (
<div className="page-body">
<div className="container is-md">
{data.total_pages > 1 && (
<Pagination
sum={data.total_pages * per}
per={per}
page={page}
setPage={setPage}
/>
)}
<ul className="card-list a-card">
{data.events.map((event) => {
return <Event event={event} key={event.id} />
})}
</ul>
{data.total_pages > 1 && (
<Pagination
sum={data.total_pages * per}
per={per}
page={page}
setPage={setPage}
/>
)}
</div>
</div>
<>
{data.total_pages > 1 && (
<Pagination
sum={data.total_pages * per}
per={per}
page={page}
setPage={setPage}
/>
)}
<ul className="card-list a-card">
{data.events.map((event) => {
return <Event event={event} key={event.id} />
})}
</ul>
{data.total_pages > 1 && (
<Pagination
sum={data.total_pages * per}
per={per}
page={page}
setPage={setPage}
/>
)}
</>
)
}

Expand Down
16 changes: 12 additions & 4 deletions app/javascript/components/Reports.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,19 @@ const NoReports = ({ unchecked }) => {
</p>
</>
) : (
<div className="o-empty-message">
<div className="o-empty-message__icon">
<i className="fa-regular fa-sad-tear" />
<div className="card-list">
<div className="card-body">
<div className="card__description">
<div className="o-empty-message">
<div className="o-empty-message__icon">
<i className="fa-regular fa-sad-tear" />
</div>
<p className="o-empty-message__text">
日報はまだありません。
</p>
</div>
</div>
</div>
<p className="o-empty-message__text">日報はまだありません。</p>
</div>
)}
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/components/questions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ div
loadingListPlaceholder
.o-empty-message(v-else-if='questions.length === 0')
.o-empty-message__icon
i.fa-regular.fa-smile
i.fa-regular.fa-sad-tear
p.o-empty-message__text
| {{ emptyMessage }}
.card-list.a-card(v-else)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
position: relative
max-width: 45em
margin-inline: auto
&.is-ais-flex-start
align-items: flex-start
+media-breakpoint-down(sm)
flex-direction: column

Expand Down
2 changes: 1 addition & 1 deletion app/javascript/stylesheets/atoms/_a-side-nav.sass
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
padding-right: var(--side-nav-width)

.a-side-nav
background-color: var(--background)
background-color: var(--base)
+media-breakpoint-up(lg)
+position(absolute, right 0, top -1.5rem, bottom -1.5rem)
width: var(--side-nav-width)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,14 @@
height: auto

.welcome-member__inner
padding: 1.25rem 1.5rem 1.5rem
padding: 1.25rem 1.5rem 0
height: 100%
&:last-child
padding-bottom: 1.5rem
.welcome-member.is-articles-show &
padding: .75rem 1rem
padding: .75rem 1rem 0
.welcome-member.is-articles-show &:last-child
padding-bottom: 1rem

.welcome-member__header
display: flex
Expand Down Expand Up @@ -74,3 +79,6 @@
cursor: pointer
a:hover
text-decoration: none

.welcome-member__actions
padding: 1rem
12 changes: 1 addition & 11 deletions app/models/event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@ class Event < ApplicationRecord

scope :wip, -> { where(wip: true) }
scope :related_to, ->(user) { user.job_seeker ? all : where.not(job_hunting: true) }
scope :today_events, -> { where(start_at: Time.zone.today.midnight...Time.zone.tomorrow.midnight) }
scope :tomorrow_events, -> { where(start_at: Time.zone.tomorrow.midnight...(Time.zone.tomorrow + 1.day).midnight) }
scope :day_after_tomorrow_events, -> { where(start_at: (Time.zone.tomorrow + 1.day).midnight...(Time.zone.tomorrow + 2.days).midnight) }
scope :scheduled_on, ->(date) { where(start_at: date.midnight...(date + 1.day).midnight) }

def opening?
Time.current.between?(open_start_at, open_end_at)
Expand Down Expand Up @@ -104,14 +102,6 @@ def send_notification(receiver)
ActivityDelivery.with(receiver:, event: self).notify(:moved_up_event_waiting_user)
end

def holding_today?
start_at.to_date.today?
end

def holding_tomorrow?
start_at.to_date == Date.tomorrow
end

def watched_by?(user)
watches.exists?(user_id: user.id)
end
Expand Down
Loading

0 comments on commit 01bad3b

Please sign in to comment.