Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
rescheduled 🗓️
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
c3lingo
rescheduled 🗓️
Commits
7430405e
Commit
7430405e
authored
5 months ago
by
Teal
Browse files
Options
Downloads
Patches
Plain Diff
feat: add a separate ical feed including unconfirmed, make default show ony confirmed
parent
c973de66
No related branches found
No related tags found
No related merge requests found
Pipeline
#39567
passed
5 months ago
Stage: test
Stage: deploy
Changes
3
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
app/controllers/assignments_controller.rb
+8
-7
8 additions, 7 deletions
app/controllers/assignments_controller.rb
app/models/system_setting.rb
+11
-5
11 additions, 5 deletions
app/models/system_setting.rb
app/views/assignments/by_user.html.erb
+2
-2
2 additions, 2 deletions
app/views/assignments/by_user.html.erb
with
21 additions
and
14 deletions
app/controllers/assignments_controller.rb
+
8
−
7
View file @
7430405e
require
"icalendar/tzinfo"
require
"icalendar/tzinfo"
class
AssignmentsController
<
ApplicationController
class
AssignmentsController
<
ApplicationController
before_action
:authorize_permission
,
except:
%i[index by_user]
before_action
:authorize_permission
,
except:
%i[index by_user
by_user_with_candidates
]
before_action
:set_session
,
:set_users
before_action
:set_session
,
:set_users
def
index
def
index
...
@@ -90,7 +90,8 @@ class AssignmentsController < ApplicationController
...
@@ -90,7 +90,8 @@ class AssignmentsController < ApplicationController
@active_standby_assignments
=
@user
.
standby_assignments
.
joins
(
standby_block: :conference
).
where
(
conferences:
{
active:
true
}).
includes
(
standby_block: :conference
)
@active_standby_assignments
=
@user
.
standby_assignments
.
joins
(
standby_block: :conference
).
where
(
conferences:
{
active:
true
}).
includes
(
standby_block: :conference
)
# Include candidates if feature flag is enabled
# Include candidates if feature flag is enabled
if
include_candidate_sessions?
@show_candidates_feature_enabled
=
include_candidate_sessions?
# Set instance variable
if
@show_candidates_feature_enabled
@active_candidates
=
@user
.
candidates
.
joins
(
session: :conference
).
where
(
conferences:
{
active:
true
}).
includes
(
:session
,
session:
[
:conference
,
:stage
])
@active_candidates
=
@user
.
candidates
.
joins
(
session: :conference
).
where
(
conferences:
{
active:
true
}).
includes
(
:session
,
session:
[
:conference
,
:stage
])
end
end
...
@@ -122,13 +123,14 @@ class AssignmentsController < ApplicationController
...
@@ -122,13 +123,14 @@ class AssignmentsController < ApplicationController
# but for .ics, build_ical_for_user will handle queries.
# but for .ics, build_ical_for_user will handle queries.
@active_assignments
=
@user
.
assignments
.
joins
(
session: :conference
).
where
(
conferences:
{
active:
true
}).
includes
(
:session
,
session:
[
:conference
,
:stage
])
@active_assignments
=
@user
.
assignments
.
joins
(
session: :conference
).
where
(
conferences:
{
active:
true
}).
includes
(
:session
,
session:
[
:conference
,
:stage
])
@active_standby_assignments
=
@user
.
standby_assignments
.
joins
(
standby_block: :conference
).
where
(
conferences:
{
active:
true
}).
includes
(
standby_block: :conference
)
@active_standby_assignments
=
@user
.
standby_assignments
.
joins
(
standby_block: :conference
).
where
(
conferences:
{
active:
true
}).
includes
(
standby_block: :conference
)
if
include_candidate_sessions?
@show_candidates_feature_enabled
=
include_candidate_sessions?
# Set instance variable
if
@show_candidates_feature_enabled
@active_candidates
=
@user
.
candidates
.
joins
(
session: :conference
).
where
(
conferences:
{
active:
true
}).
includes
(
:session
,
session:
[
:conference
,
:stage
])
@active_candidates
=
@user
.
candidates
.
joins
(
session: :conference
).
where
(
conferences:
{
active:
true
}).
includes
(
:session
,
session:
[
:conference
,
:stage
])
end
end
respond_to
do
|
format
|
respond_to
do
|
format
|
format
.
ics
do
format
.
ics
do
if
include
_candidate
_sessions?
if
@show
_candidate
s_feature_enabled
# Use instance variable
calendar
=
build_ical_for_user
(
@user
,
include_candidates:
true
)
calendar
=
build_ical_for_user
(
@user
,
include_candidates:
true
)
calendar
.
publish
calendar
.
publish
headers
[
"Content-Type"
]
=
"text/calendar; charset=UTF-8"
headers
[
"Content-Type"
]
=
"text/calendar; charset=UTF-8"
...
@@ -257,8 +259,7 @@ class AssignmentsController < ApplicationController
...
@@ -257,8 +259,7 @@ class AssignmentsController < ApplicationController
def
include_candidate_sessions?
def
include_candidate_sessions?
# Feature flag to include candidate sessions in iCal feed
# Feature flag to include candidate sessions in iCal feed
# Can be controlled via environment variable or system setting
# Controlled via system setting
ENV
.
fetch
(
"INCLUDE_CANDIDATE_SESSIONS"
,
"false"
).
downcase
==
"true"
||
SystemSetting
.
include_candidate_sessions?
SystemSetting
.
include_candidate_sessions?
end
end
end
end
This diff is collapsed.
Click to expand it.
app/models/system_setting.rb
+
11
−
5
View file @
7430405e
...
@@ -10,11 +10,17 @@ class SystemSetting < ApplicationRecord
...
@@ -10,11 +10,17 @@ class SystemSetting < ApplicationRecord
# Set the invitation token
# Set the invitation token
def
self
.
set_invitation_token
(
token
)
def
self
.
set_invitation_token
(
token
)
setting
=
find_or_initialize_by
(
key:
"invitation_token"
)
# Atomically find or create the record by its unique key.
setting
.
value
=
token
.
to_s
# The block is only executed if a new record is being created.
setting
.
description
=
"Token required for user registration/signup"
setting
=
find_or_create_by!
(
key:
"invitation_token"
)
do
|
s
|
setting
.
setting_type
=
"string"
s
.
description
=
"Token required for user registration/signup"
setting
.
save!
s
.
setting_type
=
"string"
# The token value will be set/updated outside the block.
end
# Update the value. If it was just created, this sets its initial value.
# If it already existed, its value is updated.
setting
.
update!
(
value:
token
.
to_s
)
setting
setting
end
end
...
...
...
...
This diff is collapsed.
Click to expand it.
app/views/assignments/by_user.html.erb
+
2
−
2
View file @
7430405e
...
@@ -9,13 +9,13 @@
...
@@ -9,13 +9,13 @@
<%=
link_to
user_assignments_path
(
@user
,
format:
'ics'
),
class:
"btn btn-info-light ml-4"
do
%>
<%=
link_to
user_assignments_path
(
@user
,
format:
'ics'
),
class:
"btn btn-info-light ml-4"
do
%>
<svg
xmlns=
"http://www.w3.org/2000/svg"
viewBox=
"0 0 20 24"
fill=
"currentColor"
aria-hidden=
"true"
class=
"size-5 inline-block mr-1"
><path
fill-rule=
"evenodd"
d=
"M5.75 2a.75.75 0 01.75.75V4h7V2.75a.75.75 0 011.5 0V4h.25A2.75 2.75 0 0118 6.75v8.5A2.75 2.75 0 0115.25 18H4.75A2.75 2.75 0 012 15.25v-8.5A2.75 2.75 0 014.75 4H5V2.75A.75.75 0 015.75 2zm-1 5.5c-.69 0-1.25.56-1.25 1.25v6.5c0 .69.56 1.25 1.25 1.25h10.5c.69 0 1.25-.56 1.25-1.25v-6.5c0-.69-.56-1.25-1.25-1.25H4.75z"
clip-rule=
"evenodd"
></path></svg>
iCal (Confirmed)
<svg
xmlns=
"http://www.w3.org/2000/svg"
viewBox=
"0 0 20 24"
fill=
"currentColor"
aria-hidden=
"true"
class=
"size-5 inline-block mr-1"
><path
fill-rule=
"evenodd"
d=
"M5.75 2a.75.75 0 01.75.75V4h7V2.75a.75.75 0 011.5 0V4h.25A2.75 2.75 0 0118 6.75v8.5A2.75 2.75 0 0115.25 18H4.75A2.75 2.75 0 012 15.25v-8.5A2.75 2.75 0 014.75 4H5V2.75A.75.75 0 015.75 2zm-1 5.5c-.69 0-1.25.56-1.25 1.25v6.5c0 .69.56 1.25 1.25 1.25h10.5c.69 0 1.25-.56 1.25-1.25v-6.5c0-.69-.56-1.25-1.25-1.25H4.75z"
clip-rule=
"evenodd"
></path></svg>
iCal (Confirmed)
<%
end
%>
<%
end
%>
<%
if
@
controller
.
send
(
:include_candidate_sessions?
)
%>
<%
if
@
show_candidates_feature_enabled
%>
<%=
link_to
user_with_candidates_assignments_path
(
@user
,
format:
'ics'
),
class:
"btn btn-warning-light ml-2"
do
%>
<%=
link_to
user_with_candidates_assignments_path
(
@user
,
format:
'ics'
),
class:
"btn btn-warning-light ml-2"
do
%>
<svg
xmlns=
"http://www.w3.org/2000/svg"
viewBox=
"0 0 20 24"
fill=
"currentColor"
aria-hidden=
"true"
class=
"size-5 inline-block mr-1"
><path
fill-rule=
"evenodd"
d=
"M5.75 2a.75.75 0 01.75.75V4h7V2.75a.75.75 0 011.5 0V4h.25A2.75 2.75 0 0118 6.75v8.5A2.75 2.75 0 0115.25 18H4.75A2.75 2.75 0 012 15.25v-8.5A2.75 2.75 0 014.75 4H5V2.75A.75.75 0 015.75 2zm-1 5.5c-.69 0-1.25.56-1.25 1.25v6.5c0 .69.56 1.25 1.25 1.25h10.5c.69 0 1.25-.56 1.25-1.25v-6.5c0-.69-.56-1.25-1.25-1.25H4.75z"
clip-rule=
"evenodd"
></path></svg>
iCal (Incl. Unconfirmed)
<svg
xmlns=
"http://www.w3.org/2000/svg"
viewBox=
"0 0 20 24"
fill=
"currentColor"
aria-hidden=
"true"
class=
"size-5 inline-block mr-1"
><path
fill-rule=
"evenodd"
d=
"M5.75 2a.75.75 0 01.75.75V4h7V2.75a.75.75 0 011.5 0V4h.25A2.75 2.75 0 0118 6.75v8.5A2.75 2.75 0 0115.25 18H4.75A2.75 2.75 0 012 15.25v-8.5A2.75 2.75 0 014.75 4H5V2.75A.75.75 0 015.75 2zm-1 5.5c-.69 0-1.25.56-1.25 1.25v6.5c0 .69.56 1.25 1.25 1.25h10.5c.69 0 1.25-.56 1.25-1.25v-6.5c0-.69-.56-1.25-1.25-1.25H4.75z"
clip-rule=
"evenodd"
></path></svg>
iCal (Incl. Unconfirmed)
<%
end
%>
<%
end
%>
<%
end
%>
<%
end
%>
</div>
</div>
<%
if
@active_candidates
&&
@
controller
.
send
(
:include_candidate_sessions?
)
%>
<%
if
@active_candidates
&&
@
show_candidates_feature_enabled
%>
<div
class=
"flex items-center"
>
<div
class=
"flex items-center"
>
<label
class=
"inline-flex items-center cursor-pointer"
>
<label
class=
"inline-flex items-center cursor-pointer"
>
<input
type=
"checkbox"
id=
"showCandidates"
class=
"sr-only peer"
checked
>
<input
type=
"checkbox"
id=
"showCandidates"
class=
"sr-only peer"
checked
>
...
...
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
sign in
to comment