Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into pdf_entry
Browse files Browse the repository at this point in the history
  • Loading branch information
takaishi committed Nov 17, 2024
2 parents be6daef + 1de6887 commit 67cc9c7
Show file tree
Hide file tree
Showing 70 changed files with 1,098 additions and 639 deletions.
4 changes: 4 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,7 @@ Style/WordArray:

Lint/Debugger:
Enabled: false

# channels.size.positive? を channels.size > 0 の代わりに強制されるのは困る
Style/NumericPredicate:
Enabled: false
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -126,5 +126,7 @@ gem "rqrcode", "~> 2.0"

gem 'ulid'

gem 'acts_as_list'

# PDF tool
gem 'ferrum'
4 changes: 4 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ GEM
i18n (>= 1.6, < 2)
minitest (>= 5.1)
tzinfo (~> 2.0)
acts_as_list (1.2.3)
activerecord (>= 6.1)
activesupport (>= 6.1)
addressable (2.8.5)
public_suffix (>= 2.0.2, < 6.0)
annotate (3.2.0)
Expand Down Expand Up @@ -689,6 +692,7 @@ PLATFORMS
DEPENDENCIES
active_hash
activerecord-nulldb-adapter
acts_as_list
annotate
awesome_nested_set
aws-sdk-cloudfront
Expand Down
Binary file added app/assets/images/cndw2024/cruiser-lt.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/cndw2024/handson.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/cndw2024/lt.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/cndw2024/networking.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/cndw2024/oss.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions app/assets/images/icons/check.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions app/assets/images/icons/grip-vertical.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 13 additions & 9 deletions app/controllers/admin/harvest_jobs_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,13 @@ def new
end

def create
@talk = Talk.find(harvest_job_params[:talk_id])
@job = MediaPackageHarvestJob.new(harvest_job_params.merge(conference_id: @conference.id))

respond_to do |format|
if @job.save
@job.create_media_package_resources
format.html { redirect_to(admin_tracks_path, notice: 'HarvestJob was successfully updated.') }
format.json { render(:show, status: :ok, location: @job) }
else
format.html { redirect_to(admin_tracks_path, flash: { error: @job.errors.messages }) }
format.json { render(json: @job.errors, status: :unprocessable_entity) }
end
if @job.save && @job.create_media_package_resources
flash.now.notice = "#{@talk.title} のアーカイブ作成用HarvestJobの作成に成功しました"
else
render(:edit, status: :unprocessable_entity)
end
end

Expand All @@ -39,4 +35,12 @@ def initial_date
def harvest_job_params
params.require(:media_package_harvest_job).permit(:conference_id, :media_package_channel_id, :talk_id, :start_time, :end_time)
end

helper_method :turbo_stream_flash

private

def turbo_stream_flash
turbo_stream.append('flashes', partial: 'flash')
end
end
8 changes: 8 additions & 0 deletions app/controllers/admin/qr_code_for_stamp_rallies_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class Admin::QrCodeForStampRalliesController < ApplicationController
include SecuredAdmin

def show
@stamp_rally_check_point = StampRallyCheckPoint.find(params[:id])
@qr_code_for_stamp_rally = QrCodeForStampRally.new(@stamp_rally_check_point, @conference)
end
end
15 changes: 12 additions & 3 deletions app/controllers/admin/stamp_rally_check_points_controller.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
class Admin::StampRallyCheckPointsController < ApplicationController
include SecuredAdmin

def reorder
@stamp_rally_check_point = StampRallyCheckPoint.find(params[:id])
@stamp_rally_check_point.insert_at(params[:position].to_i)
head(:ok)
end

def index
@stamp_rally_check_points = conference.stamp_rally_check_points
@stamp_rally_check_points = conference.stamp_rally_check_points.order(:position)
@stamp_rally_configure = conference.stamp_rally_configure || StampRallyConfigure.new
end

def new
Expand Down Expand Up @@ -30,6 +37,8 @@ def edit

def update
@stamp_rally_check_point = StampRallyCheckPoint.find(params[:id])
@sponsors = conference.sponsors
@type_options = StampRallyCheckPoint::Type::KLASSES.map(&:name)
if @stamp_rally_check_point.update(stamp_rally_check_point_params)
flash.now.notice = "スタンプラリーチェックポイント #{@stamp_rally_check_point.id} を更新しました"
else
Expand All @@ -39,7 +48,7 @@ def update

def destroy
@stamp_rally_check_point = StampRallyCheckPoint.find(params[:id])
if @stamp_rally_check_point.destroy
if @stamp_rally_check_point.stamp_rally_check_ins.destroy_all && @stamp_rally_check_point.destroy
flash.now.notice = "スタンプラリーチェックポイント #{@stamp_rally_check_point.id} を削除しました"
else
flash.now.alert = "スタンプラリーチェックポイント #{@stamp_rally_check_point.id} の削除に失敗しました"
Expand All @@ -51,7 +60,7 @@ def destroy
private

def stamp_rally_check_point_params
params.require(:stamp_rally_check_point).permit(:sponsor_id, :type)
params.require(:stamp_rally_check_point).permit(:sponsor_id, :type, :name, :description)
end

def turbo_stream_flash
Expand Down
33 changes: 33 additions & 0 deletions app/controllers/admin/stamp_rally_configures_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
class Admin::StampRallyConfiguresController < ApplicationController
include SecuredAdmin

def create
@stamp_rally_configure = StampRallyConfigure.new(stamp_rally_configure_params.merge(conference:))
if @stamp_rally_configure.save
flash.now[:notice] = 'スタンプラリー設定を更新しました'
else
render(:new, status: :unprocessable_entity)
end
end

def update
@stamp_rally_configure = StampRallyConfigure.find(params[:id])
if @stamp_rally_configure.update(stamp_rally_configure_params)
flash.now[:notice] = 'スタンプラリー設定を更新しました'
else
render(:edit, status: :unprocessable_entity)
end
end

helper_method :turbo_stream_flash

private

def stamp_rally_configure_params
params.require(:stamp_rally_configure).permit(:finish_threshold)
end

def turbo_stream_flash
turbo_stream.append('flashes', partial: 'flash')
end
end
8 changes: 6 additions & 2 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ def home_controller?
controller_name == 'home'
end

def qr_code_for_stamp_rallies_controller?
controller_name == 'qr_code_for_stamp_rallies'
end

def admin_controller?
controller_name == 'admin'
end
Expand All @@ -62,8 +66,8 @@ def talk_difficulty(talk)
@talk_difficulties.find(talk.talk_difficulty_id)
end

helper_method :home_controller?, :admin_controller?, :event_name, :production?, :talks_checked?, :talk_category, :talk_difficulty, :display_speaker_dashboard_link?, :display_dashboard_link?, :display_proposals?, :display_talks?,
:display_timetable?, :display_contact_url?
helper_method :home_controller?, :qr_code_for_stamp_rallies_controller?, :admin_controller?, :event_name, :production?, :talks_checked?, :talk_category, :talk_difficulty, :display_speaker_dashboard_link?, :display_dashboard_link?,
:display_proposals?, :display_talks?, :display_timetable?, :display_contact_url?

def render_403
render(template: 'errors/error_403', status: 403, layout: 'application', content_type: 'text/html')
Expand Down
54 changes: 40 additions & 14 deletions app/controllers/stamp_rally_check_ins_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,25 @@ class StampRallyCheckInsController < ApplicationController
include Secured
before_action :set_conference, :set_profile, :set_speaker

def logged_in_using_omniauth?
current_user
end

def index
@stamp_rally_check_points = @conference.stamp_rally_check_points
@stamp_rally_check_points = @conference.stamp_rally_check_points.where.not(type: StampRallyCheckPointFinish.name)
@stamp_rally_check_point_finishes = @conference.stamp_rally_check_point_finishes
@stamp_rally_check_ins = @profile.stamp_rally_check_ins
end

def new
@stamp_rally_check_point = @conference.stamp_rally_check_points.find(params[:stamp_rally_check_point_id])
@stamp_rally_check_in = StampRallyCheckIn.new
end

def create
@stamp_rally_check_in = StampRallyCheckIn.new(stamp_rally_check_ins_params(params).merge(profile: @profile, check_in_timestamp: Time.zone.now))

if @stamp_rally_check_in.save
if StampRallyCheckIn.find_by(stamp_rally_check_point_id: params[:stamp_rally_check_point_id], profile: @profile).present?
redirect_to(stamp_rally_check_ins_path)
else
respond_to do |format|
format.html { render(:new, flash: { error: @stamp_rally_check_in.errors.messages }) }
@stamp_rally_check_in = StampRallyCheckIn.new({ stamp_rally_check_point_id: params[:stamp_rally_check_point_id], profile: @profile, check_in_timestamp: Time.zone.now })

if @stamp_rally_check_in.save
redirect_to(stamp_rally_check_ins_path, flash: { notice: @stamp_rally_check_point.name.to_s })
else
respond_to do |format|
format.html { render(:new, flash: { error: @stamp_rally_check_in.errors.messages }) }
end
end
end
end
Expand All @@ -32,4 +29,33 @@ def stamp_rally_check_ins_params(params)
params.require(:stamp_rally_check_in)
.permit(:stamp_rally_check_point_id)
end

helper_method :stamp_rally_status

def stamp_rally_status
check_points = conference.stamp_rally_check_points.where.not(type: StampRallyCheckPointFinish.name)
check_ins = check_ins(StampRallyCheckPointBooth) + check_ins(StampRallyCheckPoint)
finish_check_in = check_ins(StampRallyCheckPointFinish)
finish_threshold = if conference.stamp_rally_configure.present? && conference.stamp_rally_configure.finish_threshold >= 0
conference.stamp_rally_configure.finish_threshold
else
check_points.size
end

if @profile.stamp_rally_check_ins.empty?
:not
elsif finish_threshold > check_ins.size
:in_progress
elsif check_ins.size >= finish_threshold && finish_check_in.empty?
:pre_finished
elsif check_ins.size >= finish_threshold && finish_check_in.present?
:finished
else
:error
end
end

def check_ins(klass)
@profile.stamp_rally_check_ins.joins(:stamp_rally_check_point).where(stamp_rally_check_point: { type: klass.name })
end
end
2 changes: 1 addition & 1 deletion app/helpers/admin/talk_table_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ def alert_type(message_type)
end

def already_recorded?(talk)
talk.video.video_id.present?
talk&.video&.video_id.present?
end
end
7 changes: 6 additions & 1 deletion app/helpers/env_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ def env_name
end

def review_app_number
ENV['DREAMKAST_NAMESPACE'].gsub(/dreamkast-dk-/, '').to_i
m = ENV['DREAMKAST_NAMESPACE'].match(/dreamkast-dev-dk-(.*)-dk/)
if m
m[1]
else
raise('cannot get review app number')
end
end

def review_app?
Expand Down
36 changes: 36 additions & 0 deletions app/javascript/packs/controllers/drag_drop_controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { Controller } from "@hotwired/stimulus";
import { Sortable } from "sortablejs";

export default class extends Controller {
connect() {
this.sortable = new Sortable(this.element, {
animation: 150,
onEnd: this.end.bind(this),
});
}

async end(event) {
console.log("event: ", event);
console.log("event.item: ", event.item);
console.log("event.item.dataset: ", event.item.dataset);
const id = event.item.dataset.id;
const conferenceAbbr = event.item.dataset.conferenceAbbr;
const newPosition = event.newIndex;
console.log("event.newIndex: ", event.newIndex);

try {
const response = await fetch(`/${conferenceAbbr}/admin/stamp_rally_check_points/${id}/reorder`, {
method: "PATCH",
headers: {
"Content-Type": "application/json",
"X-CSRF-Token": document.querySelector("[name=csrf-token]").content,
},
body: JSON.stringify({ position: newPosition }),
});

if (!response.ok) throw new Error("Failed to reorder");
} catch (error) {
console.error("Reordering failed", error);
}
}
}
3 changes: 3 additions & 0 deletions app/javascript/packs/controllers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,6 @@ application.register("toast", ToastController)

import SponsorController from "./sponsor_controller.js"
application.register("sponsor", SponsorController)

import DragDropController from "./drag_drop_controller.js"
application.register("drag-drop", DragDropController)
39 changes: 38 additions & 1 deletion app/javascript/stylesheets/_admin.scss
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,41 @@ a:focus {
height: 300px;
font-size: small;
}
}
}



.square-card {
padding-top: 100%;
position: relative;
}
.square-card .content {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
}

/* ドラッグアイコンのスタイル */
.drag-handle {
cursor: grab;
color: #666;
}

.drag-handle i {
font-size: 1.2em;
}

/* 行のスタイル */
.draggable-item {
transition: background-color 0.2s ease;
}

.draggable-item:hover .drag-handle {
color: #333;
}

.draggable-item:hover {
background-color: #f9f9f9;
}
11 changes: 11 additions & 0 deletions app/javascript/stylesheets/_stamp_rally_check_in.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.square-card {
padding-top: 100%;
position: relative;
}
.square-card .content {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
}
1 change: 1 addition & 0 deletions app/javascript/stylesheets/application.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@
@import "./_talks.scss";
@import "./_team.scss";
@import "./_copy.scss";
@import "./_stamp_rally_check_in.scss";
// Import custom utilities
@import "./_utilities.scss";
1 change: 1 addition & 0 deletions app/javascript/stylesheets/cnds2024.scss
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
@import "./_checkin.scss";
@import "./_copy.scss";
@import "./_contents.scss";
@import "./_stamp_rally_check_in.scss";
@import "./cnds2024/_cnds2024.scss";
// Import custom utilities
@import "./cnds2024/_utilities.scss";
Loading

0 comments on commit 67cc9c7

Please sign in to comment.