diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb index d0f94b119..02163889b 100644 --- a/app/controllers/account_controller.rb +++ b/app/controllers/account_controller.rb @@ -110,6 +110,8 @@ class AccountController < ApplicationController @cache_city = params[:city]||"" #城市 @cache_enterprise_name = params[:enterprise_name]||"" #企业 + firstname_code = "" + lastname_code = "" (redirect_to(home_url); return) unless Setting.self_registration? || session[:auth_source_registration] if request.get? session[:auth_source_registration] = nil @@ -119,6 +121,8 @@ class AccountController < ApplicationController @user = User.new @user.safe_attributes = user_params if params[:identity] == "2" # 2 企业 + firstname_code = @user.firstname + lastname_code = @user.lastname @user.firstname = params[:enterprise_name] @user.lastname = l(:field_enterprise) end @@ -141,10 +145,18 @@ class AccountController < ApplicationController end if(@cache_identityy == "") + if params[:identity] == "2" + @user.firstname = firstname_code + @user.lastname = lastname_code + end flash.now[:error]= l(:label_identity)+l(:'activerecord.errors.messages.empty') return end if(@cache_city == "") + if params[:identity] == "2" + @user.firstname = firstname_code + @user.lastname = lastname_code + end flash.now[:error]= l(:label_location)+l(:'activerecord.errors.messages.empty') return end @@ -174,6 +186,10 @@ class AccountController < ApplicationController end end + if params[:identity] == "2" + @user.firstname = firstname_code + @user.lastname = lastname_code + end end # Token based account activation diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index 4525176ac..62bef8fb1 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -361,7 +361,7 @@ private def login_without_softapplication referer = request.headers['Referer'] - require_login unless referer =~ /softapplication/ + require_login unless referer =~ /softapplication/ || referer =~ /memos/ end def renderTag diff --git a/app/controllers/contest_notification_controller.rb b/app/controllers/contest_notification_controller.rb index 8c6e51bd5..461b62457 100644 --- a/app/controllers/contest_notification_controller.rb +++ b/app/controllers/contest_notification_controller.rb @@ -1,4 +1,5 @@ class ContestNotificationController < ApplicationController + layout 'contest_base' def show @notification = ContestNotification.find(params[:id]) end diff --git a/app/controllers/journals_controller.rb b/app/controllers/journals_controller.rb index 28505a047..77ee9d648 100644 --- a/app/controllers/journals_controller.rb +++ b/app/controllers/journals_controller.rb @@ -54,6 +54,11 @@ class JournalsController < ApplicationController end (render_404; return false) unless @issue && @detail @diff = Redmine::Helpers::Diff.new(@detail.value, @detail.old_value) + respond_to do |format| + format.html { + render :layout => 'project_base' + } + end end def new diff --git a/app/controllers/memos_controller.rb b/app/controllers/memos_controller.rb index 1e537ff75..aad575ee5 100644 --- a/app/controllers/memos_controller.rb +++ b/app/controllers/memos_controller.rb @@ -62,7 +62,7 @@ class MemosController < ApplicationController format.html { redirect_to back_memo_url, notice: "#{l :label_memo_create_succ}" } format.json { render json: @memo, status: :created, location: @memo } else - flash[:error] = "#{l :label_memo_create_fail}: #{@memo.errors.full_messages[0]}" + flash.now[:error] = "#{l :label_memo_create_fail}: #{@memo.errors.full_messages[0]}" # back_error_page = @memo.parent_id.nil? ? forum_path(@forum) : forum_memo_path(@forum, @memo.parent_id) pre_count = REPLIES_PER_PAGE diff --git a/app/controllers/my_controller.rb b/app/controllers/my_controller.rb index 32ae2efc2..1e58c53f1 100644 --- a/app/controllers/my_controller.rb +++ b/app/controllers/my_controller.rb @@ -75,6 +75,7 @@ class MyController < ApplicationController # Edit user's account def account @user = User.current + lg=@user.login @pref = @user.pref diskfile = disk_filename('User', @user.id) diskfile1 = diskfile + 'temp' @@ -137,7 +138,7 @@ class MyController < ApplicationController if File.exist?(diskfile1) File.delete(diskfile1) end - @user + @user.login = lg end else # 确保文件被删除 diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index c1593e320..c40ac384a 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -555,7 +555,6 @@ class ProjectsController < ApplicationController # Show @project def show - @project_type = params[:project_type] # try to redirect to the requested menu item @@ -842,7 +841,6 @@ class ProjectsController < ApplicationController @project = nil end -# added by bai def show_projects_score render :layout => false end diff --git a/app/controllers/welcome_controller.rb b/app/controllers/welcome_controller.rb index ca168ccb8..dee79bc31 100644 --- a/app/controllers/welcome_controller.rb +++ b/app/controllers/welcome_controller.rb @@ -110,7 +110,7 @@ class WelcomeController < ApplicationController def contest @contest_page = FirstPage.where("page_type = 'contest'").first - @contest_notifications = ContestNotification.order("id desc") + @contest_notifications = Contestnotification.order("created_at desc").limit(5) end def search diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index ef18793ab..f976918d8 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -122,6 +122,18 @@ module ApplicationHelper s end + # Generates a link to an attachment. + # Options: + # * :text - Link text (default to attachment filename) + # * :download - Force download (default: false) + def link_to_short_attachment(attachment, options={}) + text = h(truncate(options.delete(:text) || attachment.filename, length: 25, omission: '...')) + route_method = options.delete(:download) ? :download_named_attachment_path : :named_attachment_path + html_options = options.slice!(:only_path) + url = send(route_method, attachment, attachment.filename, options) + link_to text, url, html_options + end + # Generates a link to an attachment. # Options: # * :text - Link text (default to attachment filename) @@ -635,6 +647,11 @@ module ApplicationHelper end def html_title(*args) + #點擊項目版本庫 多觸發一次 字符串為"/" + #暫時解決方法 直接判斷 + if(args == ["/"]) + args = [] + end first_page = FirstPage.where("page_type = 'project'").first if args.empty? title = @html_title || [] diff --git a/app/helpers/logger_helper.rb b/app/helpers/logger_helper.rb new file mode 100644 index 000000000..af04e38d3 --- /dev/null +++ b/app/helpers/logger_helper.rb @@ -0,0 +1,27 @@ +module LoggerHelper + + #输出日志 + def OutLogger + #日志输出级别 + #Rails.logger.level = Logger::INFO + + if(!File.exist?("database")) + Dir.mkdir("database") + end + if(!File.exist?("database/get")) + Dir.mkdir("database/get") + end + if(!File.exist?("database/sql")) + Dir.mkdir("database/sql") + end + if(!File.exist?("database/controller")) + Dir.mkdir("database/controller") + end + + Rails.logger = Logger.new("database/get/#{Date.today.to_s}.log", "daily") + ActiveRecord::Base.logger = Logger.new("database/sql/#{Date.today.to_s}.log", "daily") + ActionController::Base.logger = Logger.new("database/controller/#{Date.today.to_s}.log", "daily") + end + +end + diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index dfacff864..a19819a02 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -152,9 +152,9 @@ module ProjectsHelper tabs.select {|tab| User.current.allowed_to?(tab[:action], @project)} end # Ended by young - - + + def parent_project_select_tag(project) selected = project.parent @@ -175,18 +175,15 @@ module ProjectsHelper render_project_nested_lists(projects) do |project| #Modified by young if project.try(:project_type) == Project::ProjectType_course - # modified by longjun # never use unless and else # unless project.is_public == 1 - if project.is_public != 1 - s = "#{l(:lable_private)}".html_safe + s = "#{l(:label_private)}".html_safe else s = "".html_safe end # end longjun - # modified by Longjun s += link_to_project(project, {}, :class => "#{project.css_classes} #{User.current.member_of?(project) ? 'my-project' : nil}").html_safe @@ -194,10 +191,9 @@ module ProjectsHelper else # modified by longjun # unless project.is_public - if !project.is_public # end longjun - s = "#{l(:lable_private)}".html_safe + s = "#{l(:label_private)}".html_safe else s = "".html_safe end diff --git a/app/models/enabled_module.rb b/app/models/enabled_module.rb index 94539ec00..fe668e02c 100644 --- a/app/models/enabled_module.rb +++ b/app/models/enabled_module.rb @@ -22,7 +22,6 @@ class EnabledModule < ActiveRecord::Base validates_uniqueness_of :name, :scope => :project_id after_create :module_enabled - private # after_create callback used to do things when a module is enabled @@ -35,4 +34,6 @@ class EnabledModule < ActiveRecord::Base end end end + + end diff --git a/app/views/attachments/_app_link.html.erb b/app/views/attachments/_app_link.html.erb index 6934b76e1..263f51dc8 100644 --- a/app/views/attachments/_app_link.html.erb +++ b/app/views/attachments/_app_link.html.erb @@ -3,13 +3,15 @@ <% if attachments.count > 1 && attachment != attachments.first%>
                 <% end %> - <%= link_to_attachment attachment, :class => 'icon icon-attachment', :download => true -%> + <%= link_to_short_attachment attachment, :class => 'icon icon-attachment', :download => true -%> <% if attachment.is_text? %> <%= link_to image_tag('magnifier.png'), :controller => 'attachments', :action => 'show', :id => attachment, :filename => attachment.filename %> <% end %> - <%= h(" - #{attachment.description}") unless attachment.description.blank? %> + + <%= h(truncate(" - #{attachment.description}", length: 20, omission: '...')) unless attachment.description.blank? %> + (<%= number_to_human_size attachment.filesize %>) <% end -%> diff --git a/app/views/attachments/_links.html.erb b/app/views/attachments/_links.html.erb index b9d91d5b5..de43dce4c 100644 --- a/app/views/attachments/_links.html.erb +++ b/app/views/attachments/_links.html.erb @@ -2,14 +2,18 @@ <% for attachment in attachments %>

- <%= link_to_attachment attachment, :class => 'icon icon-attachment', :download => true -%> + <%= link_to_short_attachment attachment, :class => 'icon icon-attachment', :download => true -%> <% if attachment.is_text? %> <%= link_to image_tag('magnifier.png'), - :controller => 'attachments', :action => 'show', - :id => attachment, :filename => attachment.filename %> + :controller => 'attachments', + :action => 'show', + :id => attachment, + :filename => attachment.filename%> <% end %> - <%= h(" - #{attachment.description}") unless attachment.description.blank? %> + + <%= h(truncate(" - #{attachment.description}", length: 20, omission: '...')) unless attachment.description.blank? %> + (<%= number_to_human_size attachment.filesize %>) <% if options[:deletable] %> <% if attachment.container_type == 'HomeworkAttach' %> @@ -18,13 +22,6 @@ :method => :delete, :class => 'delete', :title => l(:button_delete) %> - <%# elsif attachment.container_type == 'Softapplication'%> - <%#= link_to image_tag('delete.png'), delete_softapplications_attachments_path(:id => attachment.id), - :data => {:confirm => l(:text_are_you_sure)}, - :method => :delete, - :class => 'delete', - :remote => true, - :title => l(:button_delete) %> <% else %> <%= link_to image_tag('delete.png'), attachment_path(attachment), :data => {:confirm => l(:text_are_you_sure)}, diff --git a/app/views/contestnotifications/index.html.erb b/app/views/contestnotifications/index.html.erb index 0cf722851..870c4cd4c 100644 --- a/app/views/contestnotifications/index.html.erb +++ b/app/views/contestnotifications/index.html.erb @@ -1,16 +1,12 @@ <%= l(:label_notification) %> - -<% if User.current.logged? && User.current == @contest.author %> +<% if User.current.logged? && (User.current.admin? ||User.current == @contest.author) %> <%= link_to(l(:bale_news_notice), new_contest_contestnotification_path(@contest), :class => 'icon icon-add', :onclick => 'showAndScrollTo("add-contestnotifications", "contestnotifications_title"); return false;') %> <% end %> - - - <% if @contest %>