Permette agli admin di prolungare la scadenza dei replay.
Aggiunge data personalizzata e pulsanti rapidi nell'archivio admin così il job di purge non elimina i video fino alla nuova scadenza. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -13,7 +13,12 @@ module Recordings
|
||||
end
|
||||
|
||||
def update
|
||||
permitted = params.require(:recording).permit(:privacy_status, :title)
|
||||
if admin_expiry_update_requested?
|
||||
apply_admin_expiry_update!
|
||||
return
|
||||
end
|
||||
|
||||
permitted = recording_update_params
|
||||
attrs = {}
|
||||
privacy = permitted[:privacy_status]
|
||||
attrs[:privacy_status] = privacy if privacy.in?(Recording::PRIVACY_STATUSES)
|
||||
@@ -25,6 +30,8 @@ module Recordings
|
||||
redirect_to archive_index_path, notice: "Replay aggiornato"
|
||||
rescue ActiveRecord::RecordInvalid => e
|
||||
redirect_to archive_index_path, alert: e.record.errors.full_messages.join(", ")
|
||||
rescue Recordings::ExtendExpiry::Error => e
|
||||
redirect_to archive_index_path, alert: e.message
|
||||
end
|
||||
|
||||
def destroy
|
||||
@@ -87,5 +94,30 @@ module Recordings
|
||||
def archive_namespace
|
||||
raise NotImplementedError
|
||||
end
|
||||
|
||||
def recording_update_params
|
||||
params.require(:recording).permit(:privacy_status, :title, :expires_at, :extend_days)
|
||||
end
|
||||
|
||||
def admin_expiry_update_requested?
|
||||
return false unless archive_namespace == :admin
|
||||
|
||||
permitted = recording_update_params
|
||||
permitted[:extend_days].present? || permitted[:expires_at].present?
|
||||
end
|
||||
|
||||
def apply_admin_expiry_update!
|
||||
permitted = recording_update_params
|
||||
extender = Recordings::ExtendExpiry.new(@recording)
|
||||
|
||||
if permitted[:extend_days].present?
|
||||
extender.by_days(permitted[:extend_days])
|
||||
redirect_to archive_index_path, notice: "Scadenza replay prolungata di #{permitted[:extend_days].to_i} giorni"
|
||||
else
|
||||
expires_at = Time.zone.parse(permitted[:expires_at].to_s)&.end_of_day
|
||||
extender.to_time(expires_at)
|
||||
redirect_to archive_index_path, notice: "Scadenza replay aggiornata"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user