Skip to content

Commit

Permalink
Show preferred name field for contacts. Also search looks for preferr…
Browse files Browse the repository at this point in the history
…ed name. Update registration edit form.
  • Loading branch information
reubenjs committed May 9, 2014
1 parent 814d3bd commit 2a18d08
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 21 deletions.
6 changes: 5 additions & 1 deletion app/controllers/entities/contacts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def myc_webhooks

contact.update_attributes(
:first_name => params[:first_name],
:preferred_name => params[:preferred_name],
:preferred_name => params[:preferred_name].gsub(/N\/A/, ""),
:last_name => params[:last_name],
:email => params[:email],
:cf_gender => params[:gender],
Expand All @@ -145,6 +145,10 @@ def myc_webhooks
:cf_emergency_contact_relationship => params[:emergency_contact_relationship],
:cf_emergency_contact_number => params[:emergency_contact_phone]
)

if contact.first_name == contact.preferred_name
contact.preferred_name = nil
end

if params[:first_time] == "yes"
contact.tag_list << "first-myc-2014" unless contact.tag_list.include?("first-myc-2014")
Expand Down
6 changes: 3 additions & 3 deletions app/models/entities/contact.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class Contact < ActiveRecord::Base
rest.map{|r| scope = scope.or(r)} if scope
scope
else
t[:first_name].matches("%#{query}%").or(t[:last_name].matches("%#{query}%"))
t[:first_name].matches("%#{query}%").or(t[:last_name].matches("%#{query}%")).or(t[:preferred_name].matches("%#{query}%"))
end

other = t[:email].matches("%#{query}%").or(t[:alt_email].matches("%#{query}%"))
Expand Down Expand Up @@ -129,10 +129,10 @@ def full_name(format = nil)
if !self.cf_mailing_first_name.blank? && self.cf_mailing_first_name != self.first_name
"#{self.first_name} #{self.last_name} (#{self.cf_mailing_first_name})"
else
"#{self.first_name} #{self.last_name}"
"#{self.first_name} #{self.preferred_name.present? ? "(#{self.preferred_name})" : ""} #{self.last_name}"
end
else
"#{self.last_name}, #{self.first_name}"
"#{self.last_name}, #{self.first_name} #{self.preferred_name.present? ? "(#{self.preferred_name})" : ""}"
end
end
alias :name :full_name
Expand Down
4 changes: 4 additions & 0 deletions app/views/contacts/_top_section.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
%td
.label.top{ :class => "#{Setting.require_last_names ? 'req' : nil}" } #{t :last_name}:
= f.text_field :last_name
%tr
%td
.label.top #{t :preferred_name}:
= f.text_field :preferred_name
%tr
%td
.label #{t :email}:
Expand Down
18 changes: 2 additions & 16 deletions app/views/events/contact_list.xls.builder
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,11 @@ xml.Worksheet 'ss:Name' => (@event.name + " contact list") do
I18n.t('name'),
I18n.t('first_name'),
I18n.t('last_name'),
I18n.t('preferred_name'),
I18n.t('email'),
I18n.t('alt_email'),
I18n.t('phone'),
I18n.t('mobile'),
I18n.t('fax'),
I18n.t('born_on'),
I18n.t('background_info'),
I18n.t('blog'),
I18n.t('linked_in'),
I18n.t('facebook'),
I18n.t('twitter'),
I18n.t('skype'),
I18n.t('date_created'),
I18n.t('date_updated'),
I18n.t('assigned_to'),
Expand Down Expand Up @@ -71,18 +64,11 @@ xml.Worksheet 'ss:Name' => (@event.name + " contact list") do
contact.name,
contact.first_name,
contact.last_name,
contact.preferred_name,
contact.email,
contact.alt_email,
contact.phone,
contact.mobile,
contact.fax,
contact.born_on,
contact.background_info,
contact.blog,
contact.linkedin,
contact.facebook,
contact.twitter,
contact.skype,
contact.created_at,
contact.updated_at,
contact.assignee.try(:name),
Expand Down
12 changes: 11 additions & 1 deletion app/views/registrations/_top_section.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@
.label
First time
= f.check_box :first_time, :style => "float:left;"
%tr
%td
.label
International student (FOCUS)
= f.check_box :international_student, :style => "float:left;"
%td=spacer
%td
.label
Reqiures sleeping bag
= f.check_box :requires_sleeping_bag, :style => "float:left;"
%tr
%td
.label
Expand Down Expand Up @@ -42,7 +52,7 @@
%tr
%td
.label
Number of T-Shirts ordered
Number of T-Shirts/jumpers ordered
= f.text_field :t_shirt_ordered
%tr
%td
Expand Down
4 changes: 4 additions & 0 deletions app/views_mobile/contacts/_top_section.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
%td
.label.top{ :class => "#{Setting.require_last_names ? 'req' : ''}" } #{t :last_name}:
= f.text_field :last_name
%tr
%td
.label.top #{t :preferred_name}:
= f.text_field :preferred_name
%tr
%td
.label #{t :email}:
Expand Down
1 change: 1 addition & 0 deletions config/locales/en-US_fat_free_crm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ en-US:
current_password: Current password
edit_profile: Edit Profile
first_name: First name
preferred_name: Preferred name
google: Google IM
gravatar_help: Not familiar with Gravatars? Learn about Gravatars
image_file: Image file
Expand Down

0 comments on commit 2a18d08

Please sign in to comment.