diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml index 41410dab..c1720f52 100644 --- a/config/locales/server.en.yml +++ b/config/locales/server.en.yml @@ -1,3 +1,4 @@ en: site_settings: discourse_simple_calendar_enabled: "Enable the discourse-simple-calendar feature. This will add support for a [calendar][/calendar] tag in the first post of a topic." + holiday_calendar_topic_id: "Topic ID of staffs holiday / absence calendar." diff --git a/config/settings.yml b/config/settings.yml index d16fa215..878d0cbd 100644 --- a/config/settings.yml +++ b/config/settings.yml @@ -2,5 +2,5 @@ plugins: discourse_simple_calendar_enabled: default: true client: true - discourse_simple_calendar_holiday_post_id: + holiday_calendar_topic_id: default: "" diff --git a/jobs/scheduled/update_holiday_usernames.rb b/jobs/scheduled/update_holiday_usernames.rb index d3b5b2cc..71ed3c8a 100644 --- a/jobs/scheduled/update_holiday_usernames.rb +++ b/jobs/scheduled/update_holiday_usernames.rb @@ -5,9 +5,10 @@ module Jobs PLUGIN_NAME ||= "discourse_simple_calendar".freeze def execute(args) - post_id = SiteSetting.discourse_simple_calendar_holiday_post_id + topic_id = SiteSetting.holiday_calendar_topic_id + return if topic_id.blank? - return if post_id.blank? + post_id = Post.find_by(topic_id: topic_id, post_number: 1) # Build a list of discourse users currently on holiday users_on_holiday = [] diff --git a/spec/jobs/update_holiday_usernames_spec.rb b/spec/jobs/update_holiday_usernames_spec.rb index 7c3b42c6..dbcbfeb3 100644 --- a/spec/jobs/update_holiday_usernames_spec.rb +++ b/spec/jobs/update_holiday_usernames_spec.rb @@ -9,7 +9,7 @@ describe DiscourseSimpleCalendar::UpdateHolidayUsernames do [/calendar] MD @topic = Fabricate(:topic, first_post: create_post(raw: raw)) - SiteSetting.discourse_simple_calendar_holiday_post_id = @topic.first_post.id + SiteSetting.holiday_calendar_topic_id = @topic.id end it "should update users on holiday list" do