Skip to content

Commit

Permalink
Import 'lead' OK
Browse files Browse the repository at this point in the history
  • Loading branch information
ruby232 committed Dec 27, 2020
1 parent 02bcb62 commit 08a567e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/views/campaigns/_title_bar.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
.title_tools#menu
= link_to_inline(:edit_campaign, edit_campaign_path(@campaign), text: t(:edit)) + " | "
= link_to_function(t(:delete) + '?', confirm_delete(@campaign)) + " | "
= link_to_inline(:import_leads, import_leads_campaign_path(@campaign), text: t("import_leads".to_sym))
= link_to_inline(:new_importer, new_importer_path(:lead,@campaign), text: t(:import_leads))

.title_tools#buttons
= view_buttons
Expand Down
2 changes: 1 addition & 1 deletion app/views/campaigns/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
= render 'campaigns/title_bar', campaign: @campaign

= render "comments/new", commentable: @campaign
.remote#create_importer{ hidden }
.remote#new_importer{ hidden }

= render partial: "shared/timeline", collection: @timeline

Expand Down
10 changes: 8 additions & 2 deletions lib/fat_free_crm/import_handle.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,13 @@ def process(importer)
values[att] = value
end
end
item = importer.entity_type.capitalize().constantize.create(values)

# Todo Do this more geneic
if importer.entity_type == 'lead'
values[:campaign_id] = importer.entity_id
end

item = importer.entity_type.capitalize.constantize.create(values)
if item.valid?
item.save
else
Expand All @@ -45,7 +51,7 @@ def process(importer)
end
end

if errors.length() == 0
if errors.length == 0
importer.status = :imported
else
importer.status = :error
Expand Down

0 comments on commit 08a567e

Please sign in to comment.