Don't care about buddies (for now). Needs to be re-done properly.

This commit is contained in:
Roland Jesse 2011-12-18 22:33:06 +01:00
parent b0edffd36c
commit 3f9dd940a4

View file

@ -15,28 +15,29 @@ class ContactsController < ApplicationController
c.firstname = params[:contact][:firstname]
c.lastname = params[:contact][:lastname]
# FIXME: DONT CARE ABOUT BUDDIES (for now)
# Do we have a buddy? If so, share the address.
if params[:contact][:has_buddy] = 1
# look up buddy address
buddy_fn = params[:buddy_firstname]
buddy_ln = params[:buddy_lastname]
addr = Address.by_first_and_last_name(buddy_fn, buddy_ln)
if addr.nil?
flash[:error] = "Den Buddy " + buddy_fn + " " + buddy_ln + " gibt's nicht."
# preserve all contact data to avoid user having to enter anything twice
prepare_for_new(params[:contact])
render(:action => "new") and return
end
# Buddy's address is OK.
c.address = addr
else # It's someone without a buddy.
# if params[:contact][:has_buddy] = 1
# # look up buddy address
# buddy_fn = params[:buddy_firstname]
# buddy_ln = params[:buddy_lastname]
# addr = Address.by_first_and_last_name(buddy_fn, buddy_ln)
# if addr.nil?
# flash[:error] = "Den Buddy " + buddy_fn + " " + buddy_ln + " gibt's nicht."
# # preserve all contact data to avoid user having to enter anything twice
# prepare_for_new(params[:contact])
# render(:action => "new") and return
# end
# # Buddy's address is OK.
# c.address = addr
# else # It's someone without a buddy.
c.build_address
c.address.street = params[:contact][:address_attributes][:street]
c.address.housenr = params[:contact][:address_attributes][:housenr]
c.address.zipcode = params[:contact][:address_attributes][:zipcode]
c.address.place = params[:contact][:address_attributes][:place]
c.address.country = params[:contact][:address_attributes][:country]
end
# end
# birthdate comes with the year as optional value
c.birth_year = params[:birth_year].to_i unless params[:birth_year].blank?