Fix new coding standards
This commit is contained in:
parent
bfb91c827c
commit
4318d3a731
@ -43,6 +43,7 @@ class AdditionalsAssignToMeController < ApplicationController
|
||||
def find_issue
|
||||
@issue = Issue.find(params[:issue_id])
|
||||
raise Unauthorized unless @issue.visible? && @issue.editable?
|
||||
|
||||
@project = @issue.project
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
render_404
|
||||
|
@ -55,6 +55,7 @@ class AdditionalsChangeStatusController < ApplicationController
|
||||
def find_issue
|
||||
@issue = Issue.find(params[:issue_id])
|
||||
raise Unauthorized unless @issue.visible? && @issue.editable?
|
||||
|
||||
@project = @issue.project
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
render_404
|
||||
|
@ -63,6 +63,7 @@ module AdditionalsQueriesHelper
|
||||
cond << " OR project_id = #{@project.id}" if @project
|
||||
@query = query_class.where(cond).find(query_id)
|
||||
raise ::Unauthorized unless @query.visible?
|
||||
|
||||
@query.project = @project
|
||||
@query.user_filter = options[:user_filter] if options[:user_filter]
|
||||
session[session_key] = { id: @query.id, project_id: @query.project_id }
|
||||
@ -110,6 +111,7 @@ module AdditionalsQueriesHelper
|
||||
|
||||
def additionals_result_to_xlsx(items, columns, options = {})
|
||||
raise 'option filename is mission' if options[:filename].blank?
|
||||
|
||||
require 'write_xlsx'
|
||||
export_to_xlsx(items, columns, options)
|
||||
end
|
||||
|
@ -50,6 +50,7 @@ class AdditionalsFontAwesome
|
||||
def classes(value)
|
||||
info = value_info(value)
|
||||
return '' if info.blank?
|
||||
|
||||
info[:classes]
|
||||
end
|
||||
|
||||
@ -63,8 +64,10 @@ class AdditionalsFontAwesome
|
||||
|
||||
def load_details(type, name)
|
||||
return {} unless FONTAWESOME_ICONS.key?(type)
|
||||
|
||||
values = FONTAWESOME_ICONS[type][name]
|
||||
return { unicode: "&#x#{values[:unicode]};".html_safe, label: values[:label] } if values.present?
|
||||
|
||||
{}
|
||||
end
|
||||
|
||||
@ -82,6 +85,7 @@ class AdditionalsFontAwesome
|
||||
def active_option_for_select(selected)
|
||||
info = value_info(selected, with_details: true)
|
||||
return [] if info.blank?
|
||||
|
||||
[[info[:label], selected]]
|
||||
end
|
||||
|
||||
@ -95,8 +99,10 @@ class AdditionalsFontAwesome
|
||||
def value_info(value, options = {})
|
||||
info = {}
|
||||
return [] if value.blank?
|
||||
|
||||
values = value.split('_')
|
||||
return [] unless values.count == 2
|
||||
|
||||
info[:type] = values[0].to_sym
|
||||
info[:name] = "fa-#{values[1]}"
|
||||
info[:classes] = "#{info[:type]} #{info[:name]}"
|
||||
|
@ -61,6 +61,7 @@ module Additionals
|
||||
|
||||
def true?(value)
|
||||
return true if value.to_i == 1 || value.to_s.casecmp('true').zero?
|
||||
|
||||
false
|
||||
end
|
||||
|
||||
|
@ -29,6 +29,7 @@ module Additionals
|
||||
|
||||
def render_inline_smileys(text)
|
||||
return text if text.blank?
|
||||
|
||||
inline_smileys(text)
|
||||
text
|
||||
end
|
||||
@ -54,7 +55,7 @@ module Additionals
|
||||
def inline_emojify(text)
|
||||
text.gsub!(/:([\w+-]+):/) do |match|
|
||||
emoji_code = Regexp.last_match(1)
|
||||
emoji = Emoji.find_by_alias(emoji_code)
|
||||
emoji = Emoji.find_by_alias(emoji_code) # rubocop:disable Rails/DynamicFindBy
|
||||
if emoji.present?
|
||||
tag(:img,
|
||||
src: inline_emojify_image_path(emoji.image_filename),
|
||||
|
@ -82,13 +82,16 @@ module Additionals
|
||||
|
||||
def memberships_new_issue_project_url(user, memberships, permission = :edit_issues)
|
||||
return if memberships.blank?
|
||||
|
||||
project_count = 0
|
||||
project_id = nil
|
||||
memberships.each do |m|
|
||||
project = m.is_a?(Project) ? m : Project.find_by(id: m.project_id)
|
||||
next unless User.current.allowed_to?(permission, project) && user.allowed_to?(permission, project)
|
||||
|
||||
project_count += 1
|
||||
break if project_count > 1
|
||||
|
||||
project_id = project.identifier
|
||||
end
|
||||
|
||||
@ -111,6 +114,7 @@ module Additionals
|
||||
def parse_issue_url(url, comment_id = nil)
|
||||
rc = { issue_id: nil, comment_id: nil }
|
||||
return rc if url == '' || url.is_a?(Integer) && url.zero?
|
||||
|
||||
unless url.to_i.zero?
|
||||
rc[:issue_id] = url
|
||||
return rc
|
||||
@ -125,6 +129,7 @@ module Additionals
|
||||
else
|
||||
current_uri = URI.parse(request.original_url)
|
||||
return rc unless uri.host == current_uri.host
|
||||
|
||||
s_pos = uri.path.rindex('/issues/')
|
||||
id_string = uri.path[s_pos + 8..-1]
|
||||
e_pos = id_string.index('/')
|
||||
@ -290,6 +295,7 @@ module Additionals
|
||||
locked = "#{js_name}.#{scope}"
|
||||
@alreaded_loaded = [] if @alreaded_loaded.nil?
|
||||
return true if @alreaded_loaded.include?(locked)
|
||||
|
||||
@alreaded_loaded << locked
|
||||
false
|
||||
end
|
||||
@ -356,6 +362,7 @@ module Additionals
|
||||
|
||||
def user_with_avatar(user, options = {})
|
||||
return if user.nil?
|
||||
|
||||
options[:size] = 14 if options[:size].nil?
|
||||
options[:class] = 'additionals-avatar' if options[:class].nil?
|
||||
s = []
|
||||
@ -386,8 +393,8 @@ module Additionals
|
||||
def font_awesome_icon(name, options = {})
|
||||
info = AdditionalsFontAwesome.value_info(name)
|
||||
return '' if info.blank?
|
||||
post_text = ''
|
||||
|
||||
post_text = ''
|
||||
options['aria-hidden'] = 'true'
|
||||
options[:class] = if options[:class].present?
|
||||
info[:classes] + ' ' + options[:class]
|
||||
|
@ -13,6 +13,7 @@ module Additionals
|
||||
def user_setup_with_additionals
|
||||
user_setup_without_additionals
|
||||
return unless User.current.try(:hrm_user_type_id).nil?
|
||||
|
||||
additionals_menu_item_delete(:help)
|
||||
unless Additionals.setting?(:remove_help)
|
||||
custom_url = Additionals.settings[:custom_help_url]
|
||||
|
@ -30,6 +30,7 @@ module Additionals
|
||||
watcher.anonymous? ||
|
||||
!watcher.active? ||
|
||||
watched_by?(watcher)
|
||||
|
||||
add_watcher(watcher)
|
||||
end
|
||||
|
||||
@ -53,12 +54,14 @@ module Additionals
|
||||
def editable_with_additionals?(user = User.current)
|
||||
return false unless editable_without_additionals?(user)
|
||||
return true unless closed?
|
||||
|
||||
user.allowed_to?(:edit_closed_issues, project)
|
||||
end
|
||||
end
|
||||
|
||||
def autoassign_get_group_list
|
||||
return unless Setting.issue_group_assignment?
|
||||
|
||||
project.memberships
|
||||
.active
|
||||
.where("#{Principal.table_name}.type='Group'")
|
||||
@ -81,6 +84,7 @@ module Additionals
|
||||
def status_x_affected?(new_status_id)
|
||||
return false unless Additionals.setting?(:issue_current_user_status)
|
||||
return false if Additionals.settings[:issue_assign_to_x].blank?
|
||||
|
||||
if Additionals.settings[:issue_assign_to_x].include?(new_status_id.to_s)
|
||||
true
|
||||
else
|
||||
@ -97,8 +101,8 @@ module Additionals
|
||||
assigned_to_id.present?
|
||||
|
||||
return unless Additionals.settings[:issue_auto_assign_status].include?(status_id.to_s)
|
||||
self.assigned_to_id = auto_assigned_to_user
|
||||
|
||||
self.assigned_to_id = auto_assigned_to_user
|
||||
true
|
||||
end
|
||||
|
||||
@ -113,11 +117,13 @@ module Additionals
|
||||
|
||||
def validate_change_on_closed
|
||||
return true unless closed?
|
||||
|
||||
errors.add :base, :issue_changes_not_allowed unless User.current.allowed_to?(:edit_closed_issues, project)
|
||||
end
|
||||
|
||||
def validate_open_sub_issues
|
||||
return true unless Additionals.setting?(:issue_close_with_open_children)
|
||||
|
||||
errors.add :base, :issue_cannot_close_with_open_children if subject.present? &&
|
||||
closing? &&
|
||||
descendants.find { |d| !d.closed? }
|
||||
@ -137,6 +143,7 @@ module Additionals
|
||||
return true unless Additionals.setting?(:issue_status_change)
|
||||
return true if Additionals.settings[:issue_status_x].blank?
|
||||
return true if Additionals.settings[:issue_status_y].blank?
|
||||
|
||||
if !assigned_to_id_changed? &&
|
||||
status_id_changed? &&
|
||||
(Additionals.settings[:issue_status_x].include? status_id_was.to_s) &&
|
||||
|
@ -11,6 +11,7 @@ module Additionals
|
||||
unless method_defined? :[]=
|
||||
def []=(key, value)
|
||||
return unless key == :values
|
||||
|
||||
@value = @options[:values] = value
|
||||
end
|
||||
end
|
||||
|
@ -14,12 +14,14 @@ module Additionals
|
||||
def validate_issue_allowed
|
||||
return unless issue_id && issue
|
||||
return if Setting.commit_logtime_enabled? && (issue.updated_on + 3.seconds) > Additionals.now_with_user_time_zone
|
||||
|
||||
errors.add(:issue_id, :issue_log_time_not_allowed) unless issue.log_time_allowed?
|
||||
end
|
||||
|
||||
def editable_by_with_additionals?(usr)
|
||||
return false unless editable_by_without_additionals?(usr)
|
||||
return true unless issue_id && issue
|
||||
|
||||
issue.log_time_allowed?
|
||||
end
|
||||
end
|
||||
|
@ -16,6 +16,7 @@ module Additionals
|
||||
|
||||
macro :calendar do |_obj, args|
|
||||
raise 'Only works on wiki page' unless controller_name == 'wiki' && action_name == 'show'
|
||||
|
||||
_args, options = extract_macro_options(args, :show_weeks, :year, :month, :select)
|
||||
options[:show_weeks] = 'false' if options[:show_weeks].blank?
|
||||
options[:year] = Additionals.now_with_user_time_zone.year.to_s if options[:year].blank?
|
||||
@ -47,10 +48,13 @@ module Additionals
|
||||
def self.convert_string2period(string)
|
||||
s = string.split ':'
|
||||
raise 'missing date' if s[0].blank? || s[1].blank?
|
||||
|
||||
tstart = Date.strptime(s[0], '%Y-%m-%d')
|
||||
raise 'invalid start date' if tstart.nil?
|
||||
|
||||
tend = Date.strptime(s[1], '%Y-%m-%d')
|
||||
raise 'invalid start date' if tend.nil?
|
||||
|
||||
(tstart..tend).map { |date| "new Date(#{date.year},#{date.month - 1},#{date.mday})" }
|
||||
end
|
||||
|
||||
|
@ -11,6 +11,7 @@ module Additionals
|
||||
|
||||
macro :cryptocompare do |_obj, args|
|
||||
raise 'The correct usage is {{cryptocompare(options)}}' if args.empty?
|
||||
|
||||
_args, options = extract_macro_options(args, :fsym, :fsyms, :tsym, :tsyms, :period, :type)
|
||||
|
||||
options[:fsym] = 'BTC' if options[:fsym].blank?
|
||||
|
@ -6,6 +6,7 @@ module Additionals
|
||||
|
||||
macro :gist do |_obj, args|
|
||||
raise 'The correct usage is {{gist(<gist_id>)}}' if args.empty?
|
||||
|
||||
javascript_tag(nil, src: "https://gist.github.com/#{args[0]}.js")
|
||||
end
|
||||
end
|
||||
|
@ -11,17 +11,21 @@ module Additionals
|
||||
|
||||
macro :last_updated_at do |obj, args|
|
||||
return '' unless @project
|
||||
|
||||
if args.empty?
|
||||
page = obj
|
||||
else
|
||||
raise '{{last_updated_at(project_identifier, wiki_page)}}' if args.length < 2
|
||||
|
||||
project_name = args[0].strip
|
||||
page_name = args[1].strip
|
||||
project = Project.find_by(name: project_name)
|
||||
project ||= Project.find_by(identifier: project_name)
|
||||
return '' unless project
|
||||
|
||||
wiki = Wiki.find_by(project_id: project.id)
|
||||
return '' unless wiki
|
||||
|
||||
page = wiki.find_page(page_name)
|
||||
end
|
||||
|
||||
|
@ -9,6 +9,7 @@ module Additionals
|
||||
|
||||
macro :last_updated_by do |obj, args|
|
||||
raise 'The correct usage is {{last_updated_by}}' unless args.empty?
|
||||
|
||||
content_tag(:span,
|
||||
safe_join([avatar(obj.author, size: 14), ' ', link_to_user(obj.author)]),
|
||||
class: 'last-updated-by')
|
||||
|
@ -55,6 +55,7 @@ module Additionals
|
||||
else
|
||||
project_ids = Project.visible.collect(&:id)
|
||||
return '' unless project_ids.any?
|
||||
|
||||
# members of the user's projects
|
||||
users = User.active
|
||||
.where(["#{User.table_name}.id IN (SELECT DISTINCT user_id FROM members WHERE project_id IN (?))", project_ids])
|
||||
|
@ -40,6 +40,7 @@ module Additionals
|
||||
project ||= Project.visible.find_by(identifier: project_id)
|
||||
project ||= Project.visible.find_by(name: project_id)
|
||||
return '' if project.nil? || !User.current.allowed_to?(:add_issues, project)
|
||||
|
||||
return link_to(i18n_name, new_project_issue_path(project), class: 'macro-new-issue icon icon-add')
|
||||
else
|
||||
@memberships = User.current.memberships.preload(:roles, :project).where(Project.visible_condition(User.current)).to_a
|
||||
|
@ -19,8 +19,10 @@ module Additionals
|
||||
macro :recently_updated do |obj, args|
|
||||
page = obj.page
|
||||
return nil unless page
|
||||
|
||||
project = page.project
|
||||
return nil unless project
|
||||
|
||||
days = 5
|
||||
days = args[0].strip.to_i unless args.empty?
|
||||
|
||||
|
@ -9,6 +9,7 @@ module Additionals
|
||||
|
||||
macro :reddit do |_obj, args|
|
||||
raise 'The correct usage is {{reddit(<name>)}}' if args.empty?
|
||||
|
||||
name = args[0].strip
|
||||
|
||||
case name[0..1]
|
||||
|
@ -9,6 +9,7 @@ module Additionals
|
||||
|
||||
macro :redmine_issue do |_obj, args|
|
||||
raise 'The correct usage is {{redmine_issue(<id>)}}' if args.empty?
|
||||
|
||||
args, options = extract_macro_options(args, :title)
|
||||
raw_link = args[0].to_s.strip
|
||||
|
||||
|
@ -9,6 +9,7 @@ module Additionals
|
||||
|
||||
macro :redmine_wiki do |_obj, args|
|
||||
raise 'The correct usage is {{redmine_wiki(<page>)}}' if args.empty?
|
||||
|
||||
args, options = extract_macro_options(args, :title, :name)
|
||||
|
||||
raw_link = args[0].to_s.strip
|
||||
@ -16,6 +17,7 @@ module Additionals
|
||||
if raw_link[0..3] == 'http'
|
||||
start_pos = raw_link.index('redmine.org/projects/redmine/wiki/')
|
||||
raise 'The correct usage is {{redmine_wiki(<page>)}}' if start_pos.nil? || start_pos.zero?
|
||||
|
||||
options[:name] = raw_link[(start_pos + 34)..-1] if options[:name].blank?
|
||||
link = raw_link.gsub('http://', 'https://')
|
||||
elsif raw_link[0] =~ /\w/
|
||||
|
@ -11,6 +11,7 @@ module Additionals
|
||||
|
||||
macro :tradingview do |_obj, args|
|
||||
raise 'The correct usage is {{tradingview(options)}}' if args.empty?
|
||||
|
||||
_args, options = extract_macro_options(args, :width, :height, :symbol, :interval, :timezone,
|
||||
:theme, :style, :locale, :toolbar_bg, :enable_publishing,
|
||||
:allow_symbol_change, :hideideasbutton)
|
||||
|
@ -9,6 +9,7 @@ module Additionals
|
||||
|
||||
macro :twitter do |_obj, args|
|
||||
raise 'The correct usage is {{twitter(<name>)}}' if args.empty?
|
||||
|
||||
name = args[0].strip
|
||||
case name[0]
|
||||
when '@'
|
||||
|
@ -22,6 +22,7 @@ module Additionals
|
||||
macro :user do |_obj, args|
|
||||
args, options = extract_macro_options(args, :format, :avatar)
|
||||
raise 'The correct usage is {{user(<user_id or username>, format=USER_FORMAT)}}' if args.empty?
|
||||
|
||||
user_id = args[0]
|
||||
|
||||
user = User.find_by(id: user_id)
|
||||
|
@ -8,6 +8,7 @@ class JavascriptLibraryTest < Redmine::IntegrationTest
|
||||
assert_select 'link[rel=stylesheet][href^=?]', '/plugin_assets/additionals/stylesheets/fontawesome-all.min.css'
|
||||
|
||||
return unless Redmine::Plugin.installed?('redmine_reporting')
|
||||
|
||||
assert_select 'link[rel=stylesheet][href^=?]', '/plugin_assets/additionals/stylesheets/nv.d3.min.css', count: 1
|
||||
end
|
||||
|
||||
@ -17,6 +18,7 @@ class JavascriptLibraryTest < Redmine::IntegrationTest
|
||||
assert_response :success
|
||||
|
||||
return if Redmine::Plugin.installed?('redmine_reporting')
|
||||
|
||||
assert_select 'link[rel=stylesheet][href^=?]', '/plugin_assets/additionals/stylesheets/nv.d3.min.css', count: 0
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user