From 9c42a4f6002acdd7d2563390aec6608476a8906d Mon Sep 17 00:00:00 2001 From: Doug Youch Date: Mon, 27 Sep 2010 09:25:15 -0400 Subject: [PATCH] Dynamically set a VIP # --- app/controllers/members_controller.rb | 8 ++++++-- app/views/members/_quick_edit_form.rhtml | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/controllers/members_controller.rb b/app/controllers/members_controller.rb index aa391a5b..1eee3983 100644 --- a/app/controllers/members_controller.rb +++ b/app/controllers/members_controller.rb @@ -99,10 +99,14 @@ def handle_table_actions custom_segment = UserSegment.find params[:path][0] custom_segment.remove_ids(uids) if custom_segment && custom_segment.segment_type == 'custom' when 'quick_edit' - quick_edit_fields = [ :referrer,:user_class_id,:user_level,:source,:lead_source,:vip_number ] + quick_edit_fields = [ :referrer,:user_class_id,:user_level,:source,:lead_source ] fields = params[:edit].slice(*quick_edit_fields) quick_edit_fields.each { |fld| fields.delete(fld) if fields[fld].blank? } - update_users.each { |usr| usr.update_attributes(fields) } + update_vip = params[:edit][:vip] + update_users.each do |usr| + usr.vip_number = EndUser.generate_vip if update_vip + usr.update_attributes(fields) + end end end end diff --git a/app/views/members/_quick_edit_form.rhtml b/app/views/members/_quick_edit_form.rhtml index 950d6b8e..6e37fbd3 100644 --- a/app/views/members/_quick_edit_form.rhtml +++ b/app/views/members/_quick_edit_form.rhtml @@ -7,7 +7,7 @@ <%= f.select :source, [['-',nil]] + EndUser.source_select_options, :label => 'Origin' %> <%= f.text_field :referrer %> <%= f.text_field :lead_source %> - <%= f.text_field :vip_number %> + <%= f.check_boxes :vip, [['Generate a VIP #', true]], :single => true %> <%= f.spacer %> <%= f.cancel_submit_buttons "Cancel", "Update", { :onclick => "RedBox.close(); return false;" }, { :onclick => "MemberEditor.quickEditSubmit($('quick_edit_form').serialize()); return false;" } %>