From acad2614c7e15ac670fdf670592837533e310825 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 1 Nov 2026 13:35:01 -0500 Subject: [PATCH] Separate permission for turning customer reminders off; fix the Compose recipe - Send appointment reminders now covers only Send now / Send again; the new "Turn appointment reminders off/on for customers" permission covers the customer page's button - README's Compose service runs the task through the image's entrypoint, which installs the plugins' gems first (running bundle exec rake directly failed with Bundler::GemNotFound, since the Redmine container installs them at start) Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01BiwYMjhoQvL7XsKKfRz4pM --- README.md | 22 ++++++++++--------- .../appointment_reminders/_customer.html.erb | 2 +- config/locales/en.yml | 1 + init.rb | 6 +++-- 4 files changed, 18 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index bf0b6df..190df2e 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,10 @@ cd .. bundle exec rake redmine:plugins:migrate ``` -Restart Redmine, then set it up under **Administration » Plugins » Redmine QBO Reminders plugin » Configure**, and give the roles that should send reminders or turn them off for customers the **Send appointment reminders** permission. +Restart Redmine, then set it up under **Administration » Plugins » Redmine QBO Reminders plugin » Configure**, and give roles the permissions they need (administrators always have both): + +* **Send appointment reminders**: the **Send now** / **Send again** button on an appointment. +* **Turn appointment reminders off/on for customers**: the **Turn off** / **Turn on** button on a customer. ## Sending through Google Workspace @@ -70,7 +73,7 @@ To send them whether or not anyone is using Redmine, run the rake task every 15 */15 * * * * cd /path/to/redmine && bundle exec rake redmine:appointment_reminders:send RAILS_ENV=production ``` -In Docker Compose, a small service running the same Redmine image can do it, with no cron and no Docker socket: it shares Redmine's volume and database, runs the task, sleeps 15 minutes, and repeats. +In Docker Compose, a small service running the same Redmine image can do it, with no cron and no Docker socket. It goes through the image's own start-up script each time, which installs the plugins' gems (as the Redmine container does when it starts), so the task finds everything Redmine uses; that script skips database migrations for rake tasks. ```yaml redmine-reminders: @@ -78,20 +81,19 @@ In Docker Compose, a small service running the same Redmine image can do it, wit restart: unless-stopped depends_on: - redmine - user: "1000:1000" # whoever owns Redmine's files in the volume - working_dir: /usr/src/redmine - entrypoint: ["/bin/sh", "-c"] # skip the image's start-up (database setup, migrations, the web server) + entrypoint: ["/bin/sh", "-c"] command: - | sleep 120 while true; do - bundle exec rake redmine:appointment_reminders:send || echo "Appointment reminders: run failed" + /docker-entrypoint.sh rake redmine:appointment_reminders:send || echo "Appointment reminders: run failed" sleep 900 done - environment: - HOME: /tmp - RAILS_ENV: production # the same as the Redmine service + environment: # the Redmine service's, without REDMINE_PLUGINS_MIGRATE + REDMINE_DB_MYSQL: + REDMINE_DB_PASSWORD: REDMINE_SECRET_KEY_BASE: ${REDMINE_SECRET_KEY_BASE} + RAILS_ENV: production TZ: America/New_York RAILS_LOG_TO_STDOUT: "true" volumes: @@ -100,7 +102,7 @@ In Docker Compose, a small service running the same Redmine image can do it, wit - ``` -Each run prints its result (e.g. `Appointment reminders: 2 sent, 0 failed, 0 skipped`) in that service's log. +`/docker-entrypoint.sh` is the official Redmine image's start-up script (`docker inspect --format '{{json .Config.Entrypoint}}' ` shows yours). The first run takes longer while it installs the gems. Each run prints its result (e.g. `Appointment reminders: 2 sent, 0 failed, 0 skipped`) in that service's log. (Use the `RAILS_ENV` your Redmine runs in.) The task is safe to run alongside page-load checks. diff --git a/app/views/appointment_reminders/_customer.html.erb b/app/views/appointment_reminders/_customer.html.erb index d7cad61..c4a3d9a 100644 --- a/app/views/appointment_reminders/_customer.html.erb +++ b/app/views/appointment_reminders/_customer.html.erb @@ -6,7 +6,7 @@ <%= l(:label_appointment_reminders) %>: <%= off ? l(:text_customer_reminders_off) : l(:text_customer_reminders_on) %> - <% if User.current.allowed_to?(:send_appointment_reminders, nil, global: true) %> + <% if User.current.allowed_to?(:manage_customer_reminders, nil, global: true) %> <%= button_to (off ? l(:button_reminders_on) : l(:button_reminders_off)), (off ? customer_reminders_on_path(customer) : customer_reminders_off_path(customer)), method: :post, form_class: 'customer-reminders-toggle' %> diff --git a/config/locales/en.yml b/config/locales/en.yml index 9a0a9e5..314c847 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1,5 +1,6 @@ en: permission_send_appointment_reminders: "Send appointment reminders" + permission_manage_customer_reminders: "Turn appointment reminders off/on for customers" label_appointment_reminder: "Reminder email" label_appointment_reminders: "Appointment reminders" diff --git a/init.rb b/init.rb index 589abe7..c855893 100644 --- a/init.rb +++ b/init.rb @@ -28,8 +28,10 @@ Redmine::Plugin.register :redmine_qbo_reminders do settings default: RedmineQboReminders::Settings::DEFAULTS.dup, partial: 'settings/appointment_reminders' - # Sending a reminder from the appointment page, and turning reminders on or off for a customer - permission :send_appointment_reminders, { appointment_reminders: [:send_now, :opt_out, :opt_in] }, global: true + # The Send now / Send again button on an appointment + permission :send_appointment_reminders, { appointment_reminders: [:send_now] }, global: true + # The Turn off / Turn on button on a customer + permission :manage_customer_reminders, { appointment_reminders: [:opt_out, :opt_in] }, global: true end RedmineQboReminders.setup