From 0e83f00a67a0bc27d226e59c60dead2cc1db2127 Mon Sep 17 00:00:00 2001 From: Karel Picman Date: Fri, 16 Feb 2018 15:33:45 +0100 Subject: [PATCH] To rename members.title_format to members.dmsf_title_format #628 --- app/controllers/dmsf_files_controller.rb | 4 +-- app/controllers/dmsf_state_controller.rb | 4 +-- app/models/dmsf_file.rb | 4 +-- app/views/dmsf_state/_user_pref.html.erb | 2 +- .../20180216152501_rename_title_format.rb | 31 +++++++++++++++++++ lib/dmsf_zip.rb | 4 +-- 6 files changed, 40 insertions(+), 9 deletions(-) create mode 100644 db/migrate/20180216152501_rename_title_format.rb diff --git a/app/controllers/dmsf_files_controller.rb b/app/controllers/dmsf_files_controller.rb index 0599e299..caaa2292 100644 --- a/app/controllers/dmsf_files_controller.rb +++ b/app/controllers/dmsf_files_controller.rb @@ -58,8 +58,8 @@ class DmsfFilesController < ApplicationController access.action = DmsfFileRevisionAccess::DownloadAction access.save! member = Member.where(:user_id => User.current.id, :project_id => @file.project.id).first - if member && !member.title_format.nil? && !member.title_format.empty? - title_format = member.title_format + if member && !member.dmsf_title_format.nil? && !member.dmsf_title_format.empty? + title_format = member.dmsf_title_format else title_format = Setting.plugin_redmine_dmsf['dmsf_global_title_format'] end diff --git a/app/controllers/dmsf_state_controller.rb b/app/controllers/dmsf_state_controller.rb index 01c0161a..1d634092 100644 --- a/app/controllers/dmsf_state_controller.rb +++ b/app/controllers/dmsf_state_controller.rb @@ -30,8 +30,8 @@ class DmsfStateController < ApplicationController member = @project.members.where(:user_id => User.current.id).first if member member.dmsf_mail_notification = params[:email_notify] - member.title_format = params[:title_format] - if format_valid?(member.title_format) && member.save + member.dmsf_title_format = params[:title_format] + if format_valid?(member.dmsf_title_format) && member.save flash[:notice] = l(:notice_your_preferences_were_saved) else flash[:error] = l(:notice_your_preferences_were_not_saved) diff --git a/app/models/dmsf_file.rb b/app/models/dmsf_file.rb index 5832d387..28076e12 100644 --- a/app/models/dmsf_file.rb +++ b/app/models/dmsf_file.rb @@ -393,8 +393,8 @@ class DmsfFile < ActiveRecord::Base def display_name member = Member.where(:user_id => User.current.id, :project_id => self.project_id).first - if member && !member.title_format.nil? && !member.title_format.empty? - title_format = member.title_format + if member && !member.dmsf_title_format.nil? && !member.dmsf_title_format.empty? + title_format = member.dmsf_title_format else title_format = Setting.plugin_redmine_dmsf['dmsf_global_title_format'] end diff --git a/app/views/dmsf_state/_user_pref.html.erb b/app/views/dmsf_state/_user_pref.html.erb index b290f676..602daf4c 100644 --- a/app/views/dmsf_state/_user_pref.html.erb +++ b/app/views/dmsf_state/_user_pref.html.erb @@ -21,7 +21,7 @@ <% member = @project.members.where(:user_id => User.current.id).first %> <% if member %> <% mail_notification = member.dmsf_mail_notification %> - <% title_format = member.title_format %> + <% title_format = member.dmsf_title_format %> <% end %> <%= form_tag(dmsf_user_pref_save_path(@project)) do %> diff --git a/db/migrate/20180216152501_rename_title_format.rb b/db/migrate/20180216152501_rename_title_format.rb new file mode 100644 index 00000000..19a75866 --- /dev/null +++ b/db/migrate/20180216152501_rename_title_format.rb @@ -0,0 +1,31 @@ +# encoding: utf-8 +# +# Redmine plugin for Document Management System "Features" +# +# Copyright © 2011-18 Karel Pičman +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +class RenameTitleFormat < ActiveRecord::Migration + + def self.up + rename_column :members, :title_format, :dmsf_title_format + end + + def self.down + rename_column :members, :dmsf_title_format, :title_format + end + +end \ No newline at end of file diff --git a/lib/dmsf_zip.rb b/lib/dmsf_zip.rb index cddc0525..0dd1e6d2 100644 --- a/lib/dmsf_zip.rb +++ b/lib/dmsf_zip.rb @@ -45,8 +45,8 @@ class DmsfZip unless @files.include?(file) string_path = file.dmsf_folder.nil? ? '' : "#{file.dmsf_folder.dmsf_path_str}/" string_path = string_path[(root_path.length + 1) .. string_path.length] if root_path - if member && !member.title_format.nil? && !member.title_format.empty? - string_path += file.formatted_name(member.title_format) + if member && !member.dmsf_title_format.nil? && !member.dmsf_title_format.empty? + string_path += file.formatted_name(member.dmsf_title_format) else string_path += file.formatted_name(Setting.plugin_redmine_dmsf['dmsf_global_title_format']) end