To rename members.title_format to members.dmsf_title_format #628

This commit is contained in:
Karel Picman 2018-02-16 15:33:45 +01:00
parent 395e53d712
commit 0e83f00a67
6 changed files with 40 additions and 9 deletions

View File

@ -58,8 +58,8 @@ class DmsfFilesController < ApplicationController
access.action = DmsfFileRevisionAccess::DownloadAction access.action = DmsfFileRevisionAccess::DownloadAction
access.save! access.save!
member = Member.where(:user_id => User.current.id, :project_id => @file.project.id).first member = Member.where(:user_id => User.current.id, :project_id => @file.project.id).first
if member && !member.title_format.nil? && !member.title_format.empty? if member && !member.dmsf_title_format.nil? && !member.dmsf_title_format.empty?
title_format = member.title_format title_format = member.dmsf_title_format
else else
title_format = Setting.plugin_redmine_dmsf['dmsf_global_title_format'] title_format = Setting.plugin_redmine_dmsf['dmsf_global_title_format']
end end

View File

@ -30,8 +30,8 @@ class DmsfStateController < ApplicationController
member = @project.members.where(:user_id => User.current.id).first member = @project.members.where(:user_id => User.current.id).first
if member if member
member.dmsf_mail_notification = params[:email_notify] member.dmsf_mail_notification = params[:email_notify]
member.title_format = params[:title_format] member.dmsf_title_format = params[:title_format]
if format_valid?(member.title_format) && member.save if format_valid?(member.dmsf_title_format) && member.save
flash[:notice] = l(:notice_your_preferences_were_saved) flash[:notice] = l(:notice_your_preferences_were_saved)
else else
flash[:error] = l(:notice_your_preferences_were_not_saved) flash[:error] = l(:notice_your_preferences_were_not_saved)

View File

@ -393,8 +393,8 @@ class DmsfFile < ActiveRecord::Base
def display_name def display_name
member = Member.where(:user_id => User.current.id, :project_id => self.project_id).first member = Member.where(:user_id => User.current.id, :project_id => self.project_id).first
if member && !member.title_format.nil? && !member.title_format.empty? if member && !member.dmsf_title_format.nil? && !member.dmsf_title_format.empty?
title_format = member.title_format title_format = member.dmsf_title_format
else else
title_format = Setting.plugin_redmine_dmsf['dmsf_global_title_format'] title_format = Setting.plugin_redmine_dmsf['dmsf_global_title_format']
end end

View File

@ -21,7 +21,7 @@
<% member = @project.members.where(:user_id => User.current.id).first %> <% member = @project.members.where(:user_id => User.current.id).first %>
<% if member %> <% if member %>
<% mail_notification = member.dmsf_mail_notification %> <% mail_notification = member.dmsf_mail_notification %>
<% title_format = member.title_format %> <% title_format = member.dmsf_title_format %>
<% end %> <% end %>
<%= form_tag(dmsf_user_pref_save_path(@project)) do %> <%= form_tag(dmsf_user_pref_save_path(@project)) do %>

View File

@ -0,0 +1,31 @@
# encoding: utf-8
#
# Redmine plugin for Document Management System "Features"
#
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
#
# 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

View File

@ -45,8 +45,8 @@ class DmsfZip
unless @files.include?(file) unless @files.include?(file)
string_path = file.dmsf_folder.nil? ? '' : "#{file.dmsf_folder.dmsf_path_str}/" 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 string_path = string_path[(root_path.length + 1) .. string_path.length] if root_path
if member && !member.title_format.nil? && !member.title_format.empty? if member && !member.dmsf_title_format.nil? && !member.dmsf_title_format.empty?
string_path += file.formatted_name(member.title_format) string_path += file.formatted_name(member.dmsf_title_format)
else else
string_path += file.formatted_name(Setting.plugin_redmine_dmsf['dmsf_global_title_format']) string_path += file.formatted_name(Setting.plugin_redmine_dmsf['dmsf_global_title_format'])
end end