houdini/app/models/custom_field_join.rb
Bradley M. Kuhn 6772312ea7 Relicense all .rb files under new project license.
The primary license of the project is changing to:
  AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later

with some specific files to be licensed under the one of two licenses:
   CC0-1.0
   LGPL-3.0-or-later

This commit is one of the many steps to relicense the entire codebase.

Documentation granting permission for this relicensing (from all past
contributors who hold copyrights) is on file with Software Freedom
Conservancy, Inc.
2018-03-25 15:10:40 -04:00

25 lines
689 B
Ruby

# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
class CustomFieldJoin < ActiveRecord::Base
attr_accessible \
:supporter, :supporter_id,
:custom_field_master, :custom_field_master_id,
:value
validates :custom_field_master, presence: true
belongs_to :custom_field_master
belongs_to :supporter
def self.create_with_name(nonprofit, h)
cfm = nonprofit.custom_field_masters.find_by_name(h['name'])
if cfm.nil?
cfm = nonprofit.custom_field_masters.create(name: h['name'])
end
self.create({value: h['value'], custom_field_master_id: cfm.id, supporter_id: h['supporter_id']})
end
def name; custom_field_master.name; end
end