Initial Redmine tooling and local plugin forks

This commit is contained in:
Jason Thistlethwaite
2026-04-24 22:01:18 +00:00
commit 9f682af0eb
683 changed files with 56878 additions and 0 deletions
@@ -0,0 +1,64 @@
# This file is a part of Redmine CRM (redmine_contacts) plugin,
# customer relationship management plugin for Redmine
#
# Copyright (C) 2010-2018 RedmineUP
# http://www.redmineup.com/
#
# redmine_contacts 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 3 of the License, or
# (at your option) any later version.
#
# redmine_contacts 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 redmine_contacts. If not, see <http://www.gnu.org/licenses/>.
class AddressesDrop < Liquid::Drop
def initialize(addresses)
@addresses = addresses
end
def before_method(id)
address = @addresses.where(:id => id).first || Address.new
AddressDrop.new address
end
def all
@all ||= @addresses.map do |address|
AddressDrop.new address
end
end
def visible
@visible ||= @addresses.visible.map do |address|
AddressDrop.new address
end
end
def each(&block)
all.each(&block)
end
end
class AddressDrop < Liquid::Drop
delegate :id, :address_type, :street1, :street2, :city, :region, :postcode, :country_code, :country, :full_address, :post_address, :to => :@address
def initialize(address)
@address = address
end
private
def helpers
Rails.application.routes.url_helpers
end
end
@@ -0,0 +1,91 @@
# This file is a part of Redmine CRM (redmine_contacts) plugin,
# customer relationship management plugin for Redmine
#
# Copyright (C) 2010-2018 RedmineUP
# http://www.redmineup.com/
#
# redmine_contacts 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 3 of the License, or
# (at your option) any later version.
#
# redmine_contacts 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 redmine_contacts. If not, see <http://www.gnu.org/licenses/>.
class ContactsDrop < Liquid::Drop
def initialize(contacts)
@contacts = contacts
end
def before_method(id)
contact = @contacts.where(:id => id).first || Contact.new
ContactDrop.new contact
end
def all
@all ||= @contacts.map do |contact|
ContactDrop.new contact
end
end
def visible
@visible ||= @contacts.visible.map do |contact|
ContactDrop.new contact
end
end
def each(&block)
all.each(&block)
end
end
class ContactDrop < Liquid::Drop
delegate :id, :name, :first_name, :last_name, :middle_name, :company, :phones, :emails, :primary_email, :website, :skype_name, :birthday, :age, :background, :job_title, :is_company, :tag_list, :post_address, :to => :@contact
def initialize(contact)
@contact = contact
end
def contact_company
ContactDrop.new @contact.contact_company if @contact.contact_company
end
def company_contacts
@contact.company_contacts.map{|c| ContactDrop.new c } if @contact.company_contacts
end
def avatar_diskfile
@contact.avatar.diskfile
end
def avatar_url
helpers.url_for :controller => "attachments", :action => "contacts_thumbnail", :id => @contact.avatar, :size => '64', :only_path => true
end
def notes
@contact.notes.map{|n| NoteDrop.new(n) }
end
def address
AddressDrop.new(@contact.address) if @contact.address
end
def custom_field_values
@contact.custom_field_values
end
private
def helpers
Rails.application.routes.url_helpers
end
end
@@ -0,0 +1,77 @@
# This file is a part of Redmine CRM (redmine_contacts) plugin,
# customer relationship management plugin for Redmine
#
# Copyright (C) 2010-2018 RedmineUP
# http://www.redmineup.com/
#
# redmine_contacts 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 3 of the License, or
# (at your option) any later version.
#
# redmine_contacts 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 redmine_contacts. If not, see <http://www.gnu.org/licenses/>.
class DealsDrop < Liquid::Drop
def initialize(deals)
@deals = deals
end
def before_method(id)
deal = @deals.where(:id => id).first || Deal.new
DealDrop.new deal
end
def all
@all ||= @deals.map do |deal|
DealDrop.new deal
end
end
def visible
@visible ||= @deals.visible.map do |deal|
DealDrop.new deal
end
end
def each(&block)
all.each(&block)
end
end
class DealDrop < Liquid::Drop
delegate :id, :name, :created_on, :due_date, :price, :price_type, :currency, :background, :probability, :to => :@deal
def initialize(deal)
@deal = deal
end
def notes
@deal.notes.map{|n| NoteDrop.new(n) }
end
def category
@deal.category.name if @deal.category
end
def contact
ContactDrop.new @deal.contact if @deal.contact
end
def status
@deal.status.name if @deal.status
end
def custom_field_values
@deal.custom_field_values
end
end
@@ -0,0 +1,61 @@
# This file is a part of Redmine CRM (redmine_contacts) plugin,
# customer relationship management plugin for Redmine
#
# Copyright (C) 2010-2018 RedmineUP
# http://www.redmineup.com/
#
# redmine_contacts 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 3 of the License, or
# (at your option) any later version.
#
# redmine_contacts 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 redmine_contacts. If not, see <http://www.gnu.org/licenses/>.
class NotesDrop < Liquid::Drop
def initialize(notes)
@notes = notes
end
def before_method(id)
note = @notes.where(:id => id).first || Note.new
NoteDrop.new note
end
def all
@all ||= @notes.map do |note|
NoteDrop.new note
end
end
def visible
@visible ||= @notes.visible.map do |note|
NoteDrop.new note
end
end
def each(&block)
all.each(&block)
end
end
class NoteDrop < Liquid::Drop
delegate :id, :subject, :content, :type_id, :to => :@note
def initialize(note)
@note = note
end
def custom_field_values
@note.custom_field_values
end
end
@@ -0,0 +1,97 @@
# This file is a part of Redmine CRM (redmine_contacts) plugin,
# customer relationship management plugin for Redmine
#
# Copyright (C) 2010-2018 RedmineUP
# http://www.redmineup.com/
#
# redmine_contacts 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 3 of the License, or
# (at your option) any later version.
#
# redmine_contacts 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 redmine_contacts. If not, see <http://www.gnu.org/licenses/>.
require "redmine_contacts/liquid/drops/contacts_drop"
require "redmine_contacts/liquid/drops/deals_drop"
require "redmine_contacts/liquid/drops/notes_drop"
require "redmine_contacts/liquid/drops/addresses_drop"
module RedmineContacts
module Liquid
module Filters
include RedmineCrm::MoneyHelper
def underscore(input)
input.to_s.gsub(' ', '_').gsub('/', '_').underscore
end
def dasherize(input)
input.to_s.gsub(' ', '-').gsub('/', '-').dasherize
end
def encode(input)
Rack::Utils.escape(input)
end
# alias newline_to_br
def multi_line(input)
input.to_s.gsub("\n", '<br/>').html_safe
end
def concat(input, *args)
result = input.to_s
args.flatten.each { |a| result << a.to_s }
result
end
# right justify and padd a string
def rjust(input, integer, padstr = '')
input.to_s.rjust(integer, padstr)
end
# left justify and padd a string
def ljust(input, integer, padstr = '')
input.to_s.ljust(integer, padstr)
end
def textile(input)
::RedCloth3.new(input).to_html
end
def currency(input, currency_code=nil)
price_to_currency(input, currency_code || container_currency, :converted => false)
end
def custom_field(input, field_name)
if input.respond_to?(:custom_field_values)
input.custom_field_values.detect{|cfv| cfv.custom_field.name == field_name}.try(:value)
end
end
def attachment(input, file_name)
if input.respond_to?(:attachments)
input.attachments.detect{|a| a.file_name == file_name}.try(:diskfile)
end
end
private
def container
@container ||= @context.registers[:container]
end
def container_currency
container.currency if container.respond_to?(:currency)
end
end
::Liquid::Template.register_filter(RedmineContacts::Liquid::Filters)
end
end