-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
147 changed files
with
347 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# == Schema Information | ||
# | ||
# Table name: importers | ||
# | ||
# id :integer not null, primary key | ||
# entity_type :string | ||
# attachment_file_size :integer | ||
# attachment_file_name :string(255) | ||
# attachment_content_type :string(255) | ||
# status :string(255) | ||
# created_at :datetime | ||
# updated_at :datetime | ||
# | ||
|
||
class Importer < ActiveRecord::Base | ||
attr_accessor :status, :entity_type | ||
|
||
has_attached_file :attachment, :path => ":rails_root/public/importers/:id/:filename" | ||
|
||
# validates_attachment :attachment, presence: true, | ||
# content_type: { content_type: ['image/jpeg', 'image/jpg', 'image/png', 'image/gif'] } | ||
|
||
validates_attachment_content_type :attachment, | ||
:content_type => %w(text/xml application/xml application/vnd.ms-excel application/vnd.openxmlformats-officedocument.spreadsheetml.sheet application/x-ole-storage), | ||
:message => 'Only EXCEL files are allowed.' | ||
validates_attachment_file_name :attachment, matches: [/\.xls/, /\.xlsx?$/] | ||
|
||
|
||
ActiveSupport.run_load_hooks(:fat_free_crm_importer, self) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
= form_for(@importer, url: import_upload_campaign_path(format: "js"), method: "patch", html: { multipart: true, target: "uploading", onsubmit: "$('#import_submit').disabled = true"}) do |f| | ||
= link_to_close new_campaign_path | ||
-# todo | ||
-#= error_messages_for :avatar, object: @user.avatar, object_name: t('avatar') | ||
%p | ||
%small 'Descripcion aqui' | ||
|
||
%div 'File': | ||
= fields_for(Importer) do |a| | ||
%div= a.file_field :attachment | ||
|
||
.buttonbar | ||
= f.submit t(:upload_picture), id: "import_submit" | ||
#{t :or} | ||
= link_to_cancel new_campaign_path | ||
|
||
-#= simple_form_for(@campaign, html: one_submit_only, remote: true) do |f| | ||
-# = link_to_close new_campaign_path | ||
-# = f.hidden_field :user_id | ||
-# | ||
-# = f.error_messages object_name: t('campaign') | ||
-# | ||
-# .section | ||
-# %table | ||
-# %tr | ||
-# %td(colspan="5") | ||
-# .label.top.req 'File': | ||
-# = f.file_field :file, autofocus: true, style: "width:500px" | ||
-# | ||
-# = hook(:entity_form, self, {f: f, entity: @campaign}) | ||
-# | ||
-# .buttonbar | ||
-# = f.submit 'Import campaign' | ||
-# #{t :or} | ||
-# = link_to_cancel new_campaign_path |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
- model_name = controller_name.singularize | ||
- model_klass = model_name.camelcase.constantize | ||
|
||
.title_tools | ||
#buttons | ||
= view_buttons | ||
.create_asset | ||
= link_to_inline("create_#{model_name}".to_sym, send("new_#{model_name}_path"), text: t("create_#{model_name}".to_sym)) | ||
.import_asset | ||
= link_to_inline("import_#{model_name}".to_sym, send("import_#{model_name}_path"), text: t("import_#{model_name}".to_sym)) | ||
|
||
.title | ||
%span{id: "create_#{model_name}_title"} #{t controller_name.to_sym} | ||
= image_tag("loading.gif", size: :thumb, id: "loading", style: "display: none;") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
- import_id = "campaign_import" | ||
|
||
crm.flick('empty', 'toggle'); | ||
crm.flip_form('#{import_id}'); | ||
$('##{import_id}').html('#{ j render(partial: "import") }'); | ||
crm.set_title('#{import_id}', '#{ j t(import_id) }'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
- if not @error | ||
$('#campaign_import').html('#{ j render(partial: "import") }'); | ||
- else | ||
$('#campaign_import').html('#{ j render(partial: "import") }'); | ||
$('#campaign_import').effect("shake", { duration:250, distance: 6 }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module Paperclip | ||
class MediaTypeSpoofDetector | ||
def spoofed? | ||
false | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# frozen_string_literal: true | ||
|
||
class CreateImporters < ActiveRecord::Migration[4.2] | ||
def self.up | ||
create_table :importers do |t| | ||
t.integer :attachment_file_size # Uploaded file size | ||
t.string :attachment_file_name # Uploaded full file name | ||
t.string :attachment_content_type # MIME content type | ||
t.string :entity_type # led, campaign | ||
t.string :status # new, success, error | ||
t.timestamps | ||
end | ||
end | ||
|
||
def self.down | ||
drop_table :importers | ||
end | ||
end |
Oops, something went wrong.