mdwa_contato 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. data/.gitignore +17 -0
  2. data/Gemfile +4 -0
  3. data/LICENSE.txt +22 -0
  4. data/README.md +29 -0
  5. data/Rakefile +1 -0
  6. data/app/controllers/a/mdwa_contato_configuracao_controller.rb +21 -0
  7. data/app/views/a/mdwa_contato_configuracao/index.html.erb +45 -0
  8. data/lib/generators/mdwa_contato/install/install_generator.rb +67 -0
  9. data/lib/generators/mdwa_contato/install/templates/config/initializers/mdwa_contato_config.rb +11 -0
  10. data/lib/generators/mdwa_contato/install/templates/config/initializers/mdwa_contato_inflections.rb +5 -0
  11. data/lib/generators/mdwa_contato/install/templates/config/locales/mdwa_contato.en.yml +63 -0
  12. data/lib/generators/mdwa_contato/install/templates/config/locales/mdwa_contato.pt-BR.yml +64 -0
  13. data/lib/generators/mdwa_contato/install/templates/entidades/contato_site.rb +18 -0
  14. data/lib/generators/mdwa_contato/install/templates/mailers/contatos_site_mailer.rb +19 -0
  15. data/lib/generators/mdwa_contato/install/templates/mailers/views/avisar_administrador.text.erb +14 -0
  16. data/lib/generators/mdwa_contato/install/templates/mailers/views/avisar_cliente.text.erb +14 -0
  17. data/lib/generators/mdwa_contato/install/templates/requisitos/gerenciar_contatos.rb +10 -0
  18. data/lib/generators/mdwa_contato/install/templates/templates/a/controller.erb +167 -0
  19. data/lib/generators/mdwa_contato/install/templates/templates/a/helper.erb +7 -0
  20. data/lib/generators/mdwa_contato/install/templates/templates/a/model.erb +58 -0
  21. data/lib/generators/mdwa_contato/install/templates/templates/a/views/_form.html.erb +26 -0
  22. data/lib/generators/mdwa_contato/install/templates/templates/a/views/_form_fields.html.erb +54 -0
  23. data/lib/generators/mdwa_contato/install/templates/templates/a/views/_list.html.erb +60 -0
  24. data/lib/generators/mdwa_contato/install/templates/templates/a/views/create.js.erb +11 -0
  25. data/lib/generators/mdwa_contato/install/templates/templates/a/views/destroy.js.erb +6 -0
  26. data/lib/generators/mdwa_contato/install/templates/templates/a/views/edit.html.erb +13 -0
  27. data/lib/generators/mdwa_contato/install/templates/templates/a/views/index.html.erb +65 -0
  28. data/lib/generators/mdwa_contato/install/templates/templates/a/views/index.js.erb +5 -0
  29. data/lib/generators/mdwa_contato/install/templates/templates/a/views/new.html.erb +13 -0
  30. data/lib/generators/mdwa_contato/install/templates/templates/a/views/show.html.erb +42 -0
  31. data/lib/generators/mdwa_contato/install/templates/templates/a/views/update.js.erb +16 -0
  32. data/lib/generators/mdwa_contato/install/templates/templates/frontend/controller.erb +24 -0
  33. data/lib/generators/mdwa_contato/install/templates/templates/frontend/views/new.html.erb +46 -0
  34. data/lib/generators/mdwa_contato/install/templates/templates/frontend/views/salvar.js.erb +5 -0
  35. data/lib/mdwa_contato/version.rb +4 -0
  36. data/lib/mdwa_contato.rb +9 -0
  37. data/mdwa_contato.gemspec +21 -0
  38. metadata +98 -0
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in mdwa_contato.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Marcelo Theodoro
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # MdwaContato
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'mdwa_contato'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install mdwa_contato
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,21 @@
1
+ class A::MdwaContatoConfiguracaoController < A::BackendController
2
+
3
+ skip_load_and_authorize_resource
4
+ skip_authorization_check
5
+
6
+ def index
7
+ end
8
+
9
+ def salvar
10
+
11
+ Settings['MDWA_CONTATO.email_administrador'] = params[:email_administrador]
12
+ Settings['MDWA_CONTATO.nome_site'] = params[:nome_site]
13
+ Settings['MDWA_CONTATO.url_site'] = params[:url_site]
14
+ Settings['MDWA_CONTATO.assinatura_email'] = params[:assinatura_email]
15
+
16
+ respond_to do |format|
17
+ format.html {redirect_to a_mdwa_contato_configuracao_index_path, notice: t('mdwa_contato.configuracao.salvar_notice')}
18
+ end
19
+ end
20
+
21
+ end
@@ -0,0 +1,45 @@
1
+ <div id"mdwa_contato_configuracao_index">
2
+ <div class="page_header">
3
+ <%= t 'mdwa_contato.configuracao.index_title' %>
4
+ </div>
5
+
6
+ <div class="inside">
7
+
8
+ <%= form_tag a_mdwa_contato_configuracao_salvar_path do %>
9
+
10
+ <div class="yui3-g">
11
+
12
+ <div class="yui3-u-1-2">
13
+ <div class="field">
14
+ <%= label_tag :email_administrador, t('mdwa_contato.configuracao.email_administrador') %>
15
+ <%= text_field_tag :email_administrador, Settings['MDWA_CONTATO.email_administrador'] %>
16
+ </div>
17
+ <div class="field">
18
+ <%= label_tag :nome_site, t('mdwa_contato.configuracao.nome_site') %>
19
+ <%= text_field_tag :nome_site, Settings['MDWA_CONTATO.nome_site'] %>
20
+ </div>
21
+ <div class="field">
22
+ <%= label_tag :url_site, t('mdwa_contato.configuracao.url_site') %>
23
+ <%= text_field_tag :url_site, Settings['MDWA_CONTATO.url_site'] %>
24
+ </div>
25
+ </div>
26
+
27
+ <div class="yui3-u-1-2">
28
+ <div class="field">
29
+ <%= label_tag :assinatura_email, t('mdwa_contato.configuracao.assinatura_email') %>
30
+ <%= text_area_tag :assinatura_email, Settings['MDWA_CONTATO.assinatura_email'] %>
31
+ </div>
32
+ </div>
33
+
34
+ </div>
35
+
36
+ <div class="actions">
37
+ <%= link_to t('system.cancel_button'), '#', :class => :cancel %>
38
+ <%= submit_tag t('system.save_button'), :class => :button %>
39
+ </div>
40
+
41
+ <% end %>
42
+
43
+ </div>
44
+
45
+ </div>
@@ -0,0 +1,67 @@
1
+ # -*- encoding : utf-8 -*-
2
+
3
+ require 'rails/generators'
4
+ require 'mdwa/dsl'
5
+
6
+ module MdwaContato
7
+ class InstallGenerator < Rails::Generators::Base
8
+
9
+ source_root File.expand_path("../templates", __FILE__)
10
+
11
+ def instalacao
12
+
13
+ # Inclui Rails Settings
14
+ gem 'rails-settings', :git => "git://github.com/100hz/rails-settings.git"
15
+ run 'bundle install'
16
+ generate 'settings Settings'
17
+ rake 'db:migrate'
18
+
19
+ end
20
+
21
+ def config
22
+ copy_file 'config/initializers/mdwa_contato_inflections.rb', 'config/initializers/mdwa_contato_inflections.rb'
23
+ copy_file 'config/initializers/mdwa_contato_config.rb', 'config/initializers/mdwa_contato_config.rb'
24
+ copy_file 'config/locales/mdwa_contato.pt-BR.yml', 'config/locales/mdwa_contato.pt-BR.yml'
25
+ copy_file 'config/locales/mdwa_contato.en.yml', 'config/locales/mdwa_contato.en.yml'
26
+ end
27
+
28
+ def mdwa
29
+ copy_file 'requisitos/gerenciar_contatos.rb', MDWA::DSL::REQUIREMENTS_PATH + 'gerenciar_contatos.rb'
30
+ copy_file 'entidades/contato_site.rb', MDWA::DSL::STRUCTURAL_PATH + 'contato_site.rb'
31
+ end
32
+
33
+ def geradores
34
+ generate 'mdwa:templates'
35
+ # copia os templates MDWA - admin e frontend
36
+ directory 'templates', MDWA::DSL::TEMPLATES_PATH + 'contato_site'
37
+ # roda a transformação
38
+ generate 'mdwa:transform ContatoSite --skip-locales'
39
+ end
40
+
41
+ def mailers
42
+ copy_file 'mailers/contatos_site_mailer.rb', 'app/mailers/contatos_site_mailer.rb'
43
+ copy_file 'mailers/views/avisar_administrador.text.erb', 'app/views/contatos_site_mailer/avisar_administrador.text.erb'
44
+ copy_file 'mailers/views/avisar_cliente.text.erb', 'app/views/contatos_site_mailer/avisar_cliente.text.erb'
45
+ end
46
+
47
+ def routes
48
+ route "
49
+ ##########################################
50
+ # Rotas para a configuração mdwa_contato #
51
+ ##########################################
52
+ namespace :a do
53
+ controller :mdwa_contato_configuracao do
54
+ get 'mdwa_contato_configuracao/index' => 'mdwa_contato_configuracao#index', :as => 'mdwa_contato_configuracao_index'
55
+ post 'mdwa_contato_configuracao/salvar' => 'mdwa_contato_configuracao#salvar', :as => 'mdwa_contato_configuracao_salvar'
56
+ end
57
+ end
58
+
59
+ controller :contatos_site do
60
+ get 'contato' => 'contatos_site#new', :as => 'contato'
61
+ post 'contatos_site/salvar' => 'contatos_site#salvar', :as => 'contatos_site_salvar'
62
+ end
63
+ "
64
+ end
65
+
66
+ end
67
+ end
@@ -0,0 +1,11 @@
1
+ # -*- encoding : utf-8 -*-
2
+ ActionMailer::Base.delivery_method = :smtp
3
+ ActionMailer::Base.smtp_settings = {
4
+ :address => "smtp.gmail.com",
5
+ :port => 587,
6
+ :domain => "qw3.com.br",
7
+ :user_name => "no-reply@qw3.com.br",
8
+ :password => "",
9
+ :authentication => "plain",
10
+ :enable_starttls_auto => true
11
+ }
@@ -0,0 +1,5 @@
1
+ # -*- encoding : utf-8 -*-
2
+ ActiveSupport::Inflector.inflections do |inflect|
3
+ inflect.irregular 'contato_site', 'contatos_site'
4
+ inflect.irregular 'ContatoSite', 'ContatosSite'
5
+ end
@@ -0,0 +1,63 @@
1
+ en:
2
+ mdwa_contato:
3
+ assunto_administrador: "[Contato - Site] %{assunto}"
4
+ assunto_cliente: "%{nome}, obrigado por entrar em contato."
5
+ configuracao:
6
+ salvar_notice: "Configurações salvas com sucesso."
7
+ index_title: "Configurações de contato"
8
+ email_administrador: "E-mails de administração (recebem os envios do site)"
9
+ nome_site: "Nome do site"
10
+ url_site: "URL do site"
11
+ assinatura_email: "Assinatura dos emails automáticos"
12
+
13
+
14
+ contatos_site:
15
+ notice:
16
+ create: "Contato enviado com sucesso."
17
+ update: "Contato salvo com sucesso."
18
+ destroy: "Contato removido."
19
+ title:
20
+ index: "Contatos"
21
+ show: "Contato"
22
+ new: "Novo Contato"
23
+ edit: "Editar Contato"
24
+ index:
25
+ add: 'Adicionar'
26
+ edit: 'Editar'
27
+ edit_label: 'Editar'
28
+ remove: 'Remover'
29
+ remove_label: 'Remover'
30
+ confirm_deletion: 'Você tem certeza?'
31
+ nome: "Nome"
32
+ email: "Email"
33
+ telefone: "Telefone"
34
+ assunto: "Assunto"
35
+ mensagem: "Mensagem"
36
+ id: "ID"
37
+ created_at: "Criado em"
38
+ updated_at: "Salvo em"
39
+ edit:
40
+ nome: "Nome"
41
+ email: "Email"
42
+ telefone: "Telefone"
43
+ assunto: "Assunto"
44
+ mensagem: "Mensagem"
45
+ id: "ID"
46
+ created_at: "Criado em"
47
+ updated_at: "Salvo em"
48
+ show:
49
+ nome: "Nome"
50
+ email: "Email"
51
+ telefone: "Telefone"
52
+ assunto: "Assunto"
53
+ mensagem: "Mensagem"
54
+ id: "ID"
55
+ created_at: "Criado em"
56
+ updated_at: "Salvo em"
57
+ frontend:
58
+ salvar_notice: "Contato enviado com sucesso."
59
+ nome: "Nome"
60
+ email: "Email"
61
+ telefone: "Telefone"
62
+ assunto: "Assunto"
63
+ mensagem: "Mensagem"
@@ -0,0 +1,64 @@
1
+ pt-BR:
2
+
3
+ mdwa_contato:
4
+ assunto_administrador: "[Contato - Site] %{assunto}"
5
+ assunto_cliente: "%{nome}, obrigado por entrar em contato."
6
+ configuracao:
7
+ salvar_notice: "Configurações salvas com sucesso."
8
+ index_title: "Configurações de contato"
9
+ email_administrador: "E-mails de administração (recebem os envios do site)"
10
+ nome_site: "Nome do site"
11
+ url_site: "URL do site"
12
+ assinatura_email: "Assinatura dos emails automáticos"
13
+
14
+
15
+ contatos_site:
16
+ notice:
17
+ create: "Contato enviado com sucesso."
18
+ update: "Contato salvo com sucesso."
19
+ destroy: "Contato removido."
20
+ title:
21
+ index: "Contatos"
22
+ show: "Contato"
23
+ new: "Novo Contato"
24
+ edit: "Editar Contato"
25
+ index:
26
+ add: 'Adicionar'
27
+ edit: 'Editar'
28
+ edit_label: 'Editar'
29
+ remove: 'Remover'
30
+ remove_label: 'Remover'
31
+ confirm_deletion: 'Você tem certeza?'
32
+ nome: "Nome"
33
+ email: "Email"
34
+ telefone: "Telefone"
35
+ assunto: "Assunto"
36
+ mensagem: "Mensagem"
37
+ id: "ID"
38
+ created_at: "Criado em"
39
+ updated_at: "Salvo em"
40
+ edit:
41
+ nome: "Nome"
42
+ email: "Email"
43
+ telefone: "Telefone"
44
+ assunto: "Assunto"
45
+ mensagem: "Mensagem"
46
+ id: "ID"
47
+ created_at: "Criado em"
48
+ updated_at: "Salvo em"
49
+ show:
50
+ nome: "Nome"
51
+ email: "Email"
52
+ telefone: "Telefone"
53
+ assunto: "Assunto"
54
+ mensagem: "Mensagem"
55
+ id: "ID"
56
+ created_at: "Criado em"
57
+ updated_at: "Salvo em"
58
+ frontend:
59
+ salvar_notice: "Contato enviado com sucesso."
60
+ nome: "Nome"
61
+ email: "Email"
62
+ telefone: "Telefone"
63
+ assunto: "Assunto"
64
+ mensagem: "Mensagem"
@@ -0,0 +1,18 @@
1
+ # -*- encoding : utf-8 -*-
2
+ require 'mdwa/dsl'
3
+ MDWA::DSL.entities.register "ContatoSite" do |e|
4
+
5
+ e.resource = true
6
+ e.ajax = true
7
+ e.scaffold_name = 'a/contato_site'
8
+ e.model_name = 'a/contato_site'
9
+
10
+ e.attribute 'nome', 'string', {default: true, filtered: true}
11
+ e.attribute 'email', 'string', {filtered: true}
12
+ e.attribute 'telefone', 'string'
13
+ e.attribute 'assunto', 'string', {filtered: true}
14
+ e.attribute 'mensagem', 'text'
15
+
16
+ end
17
+
18
+ MDWA::DSL.entity('ContatoSite').in_requirements << 'gerenciar_contatos'
@@ -0,0 +1,19 @@
1
+ # -*- encoding : utf-8 -*-
2
+
3
+ class ContatosSiteMailer < ActionMailer::Base
4
+
5
+ def avisar_administrador( contato_site )
6
+ @contato_site = contato_site
7
+ mail( :to => Settings['MDWA_CONTATO.email_administrador'], :subject => I18n.t('mdwa_contato.assunto_administrador', :assunto => contato_site.assunto) ) do |format|
8
+ format.text
9
+ end
10
+ end
11
+
12
+ def avisar_cliente( contato_site )
13
+ @contato_site = contato_site
14
+ mail( :to => contato_site.email, :subject => I18n.t('mdwa_contato.assunto_cliente', :nome => contato_site.nome) ) do |format|
15
+ format.text
16
+ end
17
+ end
18
+
19
+ end
@@ -0,0 +1,14 @@
1
+ ====================================================================
2
+ Consulta enviada pelo site: <%= Settings['MDWA_CONTATO.url_site'] %>
3
+ ====================================================================
4
+
5
+ Nome: <%= @contato_site.nome %>
6
+ E-mail: <%= @contato_site.email %>
7
+ Telefone: <%= @contato_site.telefone %>
8
+ Assunto: <%= @contato_site.assunto %>
9
+
10
+ Mensagem:
11
+ <%= @contato_site.mensagem %>
12
+
13
+
14
+ <%= Settings['MDWA_CONTATO.assinatura_email'] %>
@@ -0,0 +1,14 @@
1
+ ===============================================================
2
+ Essa é uma mensagem automática. Por favor, não responda.
3
+ ===============================================================
4
+
5
+ <%= @contato_site.nome %>,
6
+
7
+ Agradecemos seu contato no <%= Settings['MDWA_CONTATO.url_site'] %>.
8
+ Responderemos o mais breve possível.
9
+
10
+ <%= Settings['MDWA_CONTATO.assinatura_email'] %>
11
+
12
+ ===============================================================
13
+ Essa é uma mensagem automática. Por favor, não responda.
14
+ ===============================================================
@@ -0,0 +1,10 @@
1
+ # -*- encoding : utf-8 -*-
2
+ require 'mdwa/dsl'
3
+ MDWA::DSL.requirements.register do |r|
4
+
5
+ r.summary = 'Gerenciar contatos.'
6
+ r.alias = 'gerenciar_contatos'
7
+ r.description = %q{Gerencia a entrada de novos contatos, armazenando em banco de dados e enviando um email.}
8
+
9
+ r.entities = ['ContatoSite']
10
+ end
@@ -0,0 +1,167 @@
1
+ # -*- encoding : utf-8 -*-
2
+ <%-
3
+ @entity = MDWA::DSL.entity('ContatoSite')
4
+ @model = @entity.generator_model
5
+ -%>
6
+ class <%= @model.controller_name %>Controller < <%= (@model.space == 'a') ? 'A::BackendController' : 'ApplicationController' %>
7
+
8
+ <%- if @entity.resource? -%>
9
+ load_and_authorize_resource :class => "<%= @model.klass %>"
10
+ <%- end -%>
11
+
12
+ # Hook for code generations. Do not delete.
13
+ #===controller_init===
14
+
15
+ def index
16
+ conditions = []
17
+ <%-
18
+ atributos_com_filtro = @entity.attributes.values.select {|attr| attr.options[:filtered]}
19
+ associacoes_com_filtro = @entity.associations.values.select {|assoc| assoc.options[:filtered]}
20
+ -%>
21
+ <%- if !atributos_com_filtro.count.zero? -%>
22
+ <%- atributos_com_filtro.each do |atributo| -%>
23
+ <%- if [:integer, :float, :decimal, :boolean].include? atributo.type.to_sym -%>
24
+ conditions << "(<%= @model.plural_name %>.<%= atributo.name %> = '#{params[:<%= atributo.name %>]}')" unless params[:<%= atributo.name %>].blank?
25
+ <%- elsif [:string, :text].include? atributo.type.to_sym -%>
26
+ conditions << "(<%= @model.plural_name %>.<%= atributo.name %> LIKE '%#{params[:<%= atributo.name %>]}%')" unless params[:<%= atributo.name %>].blank?
27
+ <%- elsif [:date].include? atributo.type.to_sym -%>
28
+ conditions << "(<%= @model.plural_name %>.<%= atributo.name %> BETWEEN '#{params[:<%= atributo.name %>_0].to_date}' AND '#{params[:<%= atributo.name %>_1].to_date}')" if !params[:<%= atributo.name %>_0].blank? and !params[:<%= atributo.name %>_1].blank?
29
+ conditions << "(<%= @model.plural_name %>.<%= atributo.name %> >= '#{params[:<%= atributo.name %>_0].to_date}')" if !params[:<%= atributo.name %>_0].blank? and params[:<%= atributo.name %>_0].blank?
30
+ conditions << "(<%= @model.plural_name %>.<%= atributo.name %> <= '#{params[:<%= atributo.name %>_1].to_date}')" if params[:<%= atributo.name %>_0].blank? and !params[:<%= atributo.name %>_1].blank?
31
+ <%- elsif [:datetime, :timestamp].include? atributo.type.to_sym -%>
32
+ conditions << "(<%= @model.plural_name %>.<%= atributo.name %> BETWEEN '#{params[:<%= atributo.name %>_0].to_date.beginning_of_day}' AND '#{params[:<%= atributo.name %>_1].to_date.end_of_day}')" if !params[:<%= atributo.name %>_0].blank? and !params[:<%= atributo.name %>_1].blank?
33
+ conditions << "(<%= @model.plural_name %>.<%= atributo.name %> >= '#{params[:<%= atributo.name %>_0].to_date.beginning_of_day}')" if !params[:<%= atributo.name %>_0].blank? and params[:<%= atributo.name %>_0].blank?
34
+ conditions << "(<%= @model.plural_name %>.<%= atributo.name %> <= '#{params[:<%= atributo.name %>_1].to_date.end_of_day}')" if params[:<%= atributo.name %>_0].blank? and !params[:<%= atributo.name %>_1].blank?
35
+ <%- end -%>
36
+ <%- end -%>
37
+ <%- end -%>
38
+
39
+ <%- associacoes_com_filtro.each do |associacao| -%>
40
+ conditions << "(<%= @model.plural_name %>.<%= associacao.name %>_id = #{params[:<%= associacao.name %>_id]})" unless params[:<%= associacao.name %>_id].blank?
41
+ <%- end -%>
42
+
43
+ @<%= @model.plural_name %> = <%= @model.klass %>.paginate :page => params[:page], :per_page => params[:per_page], :conditions => conditions.join(' AND ')
44
+
45
+ respond_to do |format|
46
+ format.html
47
+ format.js
48
+ end
49
+ end
50
+
51
+
52
+ def show
53
+ @<%= @model.singular_name %> = <%= @model.klass %>.find(params[:id])
54
+
55
+ <%- if @entity.ajax? -%>
56
+ render :layout => false
57
+ <%- else -%>
58
+ respond_to do |format|
59
+ format.html
60
+ end
61
+ <%- end -%>
62
+ end
63
+
64
+ def new
65
+ @<%= @model.singular_name %> = <%= @model.klass %>.new
66
+ <%- @model.associations.select {|a| a.nested_one?}.each do |assoc| -%>
67
+ @<%= @model.singular_name %>.<%= assoc.model2.singular_name %> = <%= assoc.model2.klass %>.new
68
+ <%- end -%>
69
+
70
+ <%- if @entity.ajax? -%>
71
+ render :layout => false
72
+ <%- else -%>
73
+ respond_to do |format|
74
+ format.html
75
+ end
76
+ <%- end -%>
77
+ end
78
+
79
+ def edit
80
+ @<%= @model.singular_name %> = <%= @model.klass %>.find(params[:id])
81
+
82
+ <%- if @entity.ajax? -%>
83
+ render :layout => false
84
+ <%- else -%>
85
+ respond_to do |format|
86
+ format.html
87
+ end
88
+ <%- end -%>
89
+ end
90
+
91
+ def create
92
+ @<%= @model.singular_name %> = <%= @model.klass %>.new(params[:<%= @model.to_params %>])
93
+ saved_ok = @<%= @model.singular_name %>.save
94
+ @system_notice = t('<%= @model.plural_name %>.notice.create') if saved_ok
95
+
96
+ <%- @model.associations.select{|a| a.has_and_belongs_to_many? and a.composition?}.each do |association| -%>
97
+ unless params[:<%= association.model2.plural_name %>].nil?
98
+ @<%= @model.singular_name %>.<%= association.model2.plural_name %>.clear
99
+ params[:<%= association.model2.plural_name %>].each do |<%= association.model2.singular_name.foreign_key %>|
100
+ @<%= @model.singular_name %>.<%= association.model2.plural_name %>.push <%= association.model2.klass %>.find <%= association.model2.singular_name.foreign_key %>
101
+ end
102
+ end
103
+ <%- end -%>
104
+
105
+ respond_to do |format|
106
+ <%- if @entity.ajax? -%>
107
+ format.js
108
+ <%- else -%>
109
+ if saved_ok
110
+ format.html { redirect_to <%= @model.object_name.pluralize %>_path, notice: @system_notice }
111
+ else
112
+ format.html { render action: "new" }
113
+ end
114
+ <%- end -%>
115
+ end
116
+ end
117
+
118
+ def update
119
+ @<%= @model.singular_name %> = <%= @model.klass %>.find(params[:id])
120
+ <%- if @entity.user? -%>
121
+ # if password is blank, delete from params
122
+ if params[:<%= @model.object_name %>][:password].blank?
123
+ params[:<%= @model.object_name %>].delete :password
124
+ params[:<%= @model.object_name %>].delete :password_confirmation
125
+ end
126
+ <%- end -%>
127
+ @<%= @model.singular_name %>.attributes = params[:<%= @model.to_params %>]
128
+ saved_ok = @<%= @model.singular_name %>.save
129
+ @system_notice = t('<%= @model.plural_name %>.notice.update') if saved_ok
130
+
131
+ <%- @model.associations.select{|a| a.has_and_belongs_to_many? and a.composition?}.each do |association| -%>
132
+ unless params[:<%= association.model2.plural_name %>].nil?
133
+ @<%= @model.singular_name %>.<%= association.model2.plural_name %>.clear
134
+ params[:<%= association.model2.plural_name %>].each do |<%= association.model2.singular_name.foreign_key %>|
135
+ @<%= @model.singular_name %>.<%= association.model2.plural_name %>.push <%= association.model2.klass %>.find <%= association.model2.singular_name.foreign_key %>
136
+ end
137
+ end
138
+ <%- end -%>
139
+
140
+ respond_to do |format|
141
+ <%- if @entity.ajax? -%>
142
+ format.js
143
+ <%- else -%>
144
+ if saved_ok
145
+ format.html { redirect_to <%= @model.object_name.pluralize %>_path, notice: @system_notice }
146
+ else
147
+ format.html { render action: "edit" }
148
+ end
149
+ <%- end -%>
150
+ end
151
+ end
152
+
153
+ def destroy
154
+ @<%= @model.singular_name %> = <%= @model.klass %>.find(params[:id])
155
+ @system_notice = t('<%= @model.plural_name %>.notice.destroy') if @<%= @model.singular_name %>.destroy
156
+
157
+ respond_to do |format|
158
+ <%- if @entity.ajax? -%>
159
+ format.js
160
+ <%- else -%>
161
+ format.html { redirect_to <%= @model.object_name.pluralize %>_path, notice: @system_notice }
162
+ <%- end -%>
163
+ end
164
+ end
165
+
166
+
167
+ end
@@ -0,0 +1,7 @@
1
+ # -*- encoding : utf-8 -*-
2
+ <%-
3
+ @entity = MDWA::DSL.entity('ContatoSite')
4
+ @model = @entity.generator_model
5
+ -%>
6
+ module <%= @model.controller_name %>Helper
7
+ end
@@ -0,0 +1,58 @@
1
+ # -*- encoding : utf-8 -*-
2
+ <%-
3
+ @entity = MDWA::DSL.entity('ContatoSite')
4
+ @model = @entity.generator_model
5
+ -%>
6
+
7
+ class <%= @model.klass %> < <%= !@entity.user? ? 'ActiveRecord::Base' : 'User' %>
8
+
9
+ <%- # model attributes -%>
10
+ <%- unless @model.attributes.count.zero? -%>
11
+ attr_accessible <%= @model.attributes.select{|a| !['id', 'created_at', 'updated_at'].include?(a.name)}.collect {|a| ":" + a.name }.join(', ') %>
12
+ <%- end -%>
13
+ <%- # paperclip file uploads -%>
14
+ <%- unless @model.attributes.select{|attr| attr.type.to_sym == :file}.count.zero? -%>
15
+ has_attached_file <%= @model.attributes.select{|attr| attr.type.to_sym == :file}.collect {|a| ":" + a.name }.join(', ') %>
16
+ <%- end -%>
17
+
18
+ <%- if @entity.user? -%>
19
+ <%- require_all "#{MDWA::DSL::USERS_PATH}#{@entity.file_name}.rb" -%>
20
+ <%- @roles = MDWA::DSL.user(@entity.name).nil? ? @roles = [@model.name] : MDWA::DSL.user(@entity.name).user_roles -%>
21
+ <%- @roles.each do |role| -%>
22
+ after_create :create_<%= role.underscore %>_permission
23
+ def create_<%= role.underscore %>_permission
24
+ <%= role.underscore %>_permission = Permission.find_by_name('<%= role.underscore %>')
25
+ <%= role.underscore %>_permission = Permission.create(:name => '<%= role.underscore %>') if <%= role.underscore %>_permission.nil?
26
+ self.permissions.push <%= role.underscore %>_permission
27
+ end
28
+ <%- end -%>
29
+ <%- end -%>
30
+
31
+ <%- # model associations -%>
32
+ <%- @model.associations.each do |association| -%>
33
+ <%- if association.belongs_to? -%>
34
+ belongs_to :<%= association.model2.singular_name %>, :class_name => '<%= association.model2.klass %>'
35
+ attr_accessible :<%= association.model2.singular_name.foreign_key %>
36
+ <%- end -%>
37
+ <%- if association.has_one? -%>
38
+ has_one :<%= association.model2.singular_name %>, :class_name => '<%= association.model2.klass %>'
39
+ <%- end -%>
40
+ <%- if association.has_many? -%>
41
+ has_many :<%= association.model2.plural_name %>, :class_name => '<%= association.model2.klass %>'
42
+ <%- end -%>
43
+ <%- if association.has_and_belongs_to_many? -%>
44
+ has_and_belongs_to_many :<%= association.model2.plural_name %>, :join_table => :<%= association.ordered.first.plural_name %>_<%= association.ordered.last.plural_name %>
45
+ <%- end -%>
46
+ <%- if association.nested_one? -%>
47
+ belongs_to :<%= association.model2.singular_name %>, :class_name => '<%= association.model2.klass %>'
48
+ attr_accessible :<%= association.model2.singular_name %>_attributes, :<%= association.model2.singular_name.foreign_key %>
49
+ accepts_nested_attributes_for :<%= association.model2.singular_name %>, :allow_destroy => true
50
+ <%- end -%>
51
+ <%- if association.nested_many? -%>
52
+ has_many :<%= association.model2.plural_name %>, :class_name => '<%= association.model2.klass %>', :dependent => :destroy
53
+ attr_accessible :<%= association.model2.plural_name %>_attributes
54
+ accepts_nested_attributes_for :<%= association.model2.plural_name %>, :allow_destroy => true
55
+ <%- end -%>
56
+ <%- end -%>
57
+
58
+ end
@@ -0,0 +1,26 @@
1
+ <%-
2
+ @entity = MDWA::DSL.entity('ContatoSite')
3
+ @model = @entity.generator_model
4
+ -%>
5
+ <%%= <%= 'nested_' if @model.nested_many? %>form_for(<%= @model.to_route_object('@') %><%= ", :remote => true, :html => {:class => :mdwa_ajax #{',:multipart => true' unless @model.attributes.select{|attr| attr.type.to_sym == :file}.count.zero?}}" if @entity.ajax %>) do |f| %>
6
+
7
+ <div id="mdwa_error">
8
+ <%%= render '/template/mdwa/crud_error', :object => @<%= @model.singular_name %> %>
9
+ </div>
10
+
11
+ <div class="yui3-g">
12
+ <div class="yui3-u">
13
+ <%%= render 'form_fields', :f => f %>
14
+ </div>
15
+ </div>
16
+
17
+ <div class="actions">
18
+ <%- if !@entity.ajax -%>
19
+ <%%= link_to t('system.cancel_button'), <%= @model.object_name.pluralize %>_path, :class => :cancel %>
20
+ <%- else -%>
21
+ <%%= link_to t('system.cancel_button'), '#', :class => :cancel %>
22
+ <%- end -%>
23
+ <%%= f.submit t('system.save_button'), :class => :button %>
24
+ </div>
25
+
26
+ <%% end %>
@@ -0,0 +1,54 @@
1
+ <%-
2
+ @entity = MDWA::DSL.entity('ContatoSite')
3
+ @model = @entity.generator_model
4
+ -%>
5
+ <%- @model.attributes.select{|a| !['id', 'created_at', 'updated_at'].include?(a.name)}.each do |attr| -%>
6
+ <div class="field">
7
+ <%%= f.label :<%= attr.name %>, t('<%= @model.plural_name %>.edit.<%= attr.name %>') %>
8
+ <%- if attr.type.to_sym == :file -%>
9
+ <%% unless @<%= @model.singular_name %>.new_record? %>
10
+ <span><%%= link_to image_tag(file_icon_path(@<%= @model.singular_name %>.<%= attr.name %>_file_name)), @<%= @model.singular_name %>.<%= attr.name %>.url, :target => '_blank' %></span>
11
+ <%% end %>
12
+ <%- end -%>
13
+ <%%= f.<%= attr.form_field %> :<%= attr.name %> %>
14
+ </div>
15
+ <%- end # model.attributes.each -%>
16
+
17
+ <%- @model.associations.each do |assoc| -%>
18
+ <%- next if assoc.skip_views? %>
19
+ <%- if assoc.belongs_to? -%>
20
+ <div class="field">
21
+ <%%= f.label :<%= assoc.model2.singular_name.foreign_key %>, t('<%= @model.plural_name %>.edit.<%= assoc.model2.singular_name %>') %>
22
+ <%%= f.select :<%= assoc.model2.singular_name.foreign_key %>,
23
+ options_for_select( <%= assoc.model2.klass %>.order('<%= assoc.reference_field %> ASC').collect{ |c| [c.<%= assoc.reference_field %>, c.id] }, f.object.<%= assoc.model2.singular_name.foreign_key %> ),
24
+ :prompt => t('<%= @model.plural_name %>.edit.<%= assoc.model2.singular_name %>_select') %>
25
+ </div>
26
+ <%- end # if -%>
27
+
28
+ <%- if assoc.has_and_belongs_to_many? and assoc.composition? -%>
29
+ <div class="nested">
30
+ <%%- <%= assoc.model2.klass %>.order('<%= assoc.reference_field %> ASC').each do |<%= assoc.model2.singular_name %>| -%>
31
+ <div class="checkbox">
32
+ <%%= check_box_tag '<%= assoc.model2.plural_name %>[]', <%= assoc.model2.singular_name %>.id, (@<%= @model.singular_name %>.<%= assoc.model2.plural_name %>.include?(<%= assoc.model2.singular_name %>) ? true : false) %>
33
+ <span><%%= <%= assoc.model2.singular_name %>.<%= assoc.reference_field %> %></span>
34
+ </div>
35
+ <%%- end -%>
36
+ </div>
37
+ <%- end -%>
38
+
39
+ <%- if assoc.nested? -%>
40
+ <div class="nested">
41
+ <%%= f.fields_for :<%= (assoc.nested_many?) ? assoc.model2.plural_name : assoc.model2.singular_name %> do |ff| %>
42
+ <%%= render '<%= assoc.model2.space %>/<%= assoc.model2.plural_name %>/form_fields', :f => ff %>
43
+ <%- unless assoc.nested_one? -%>
44
+ <%%= ff.link_to_remove t('nested.remove') %>
45
+ <%- end -%>
46
+
47
+ <%% end %>
48
+ <%- unless assoc.nested_one? -%>
49
+ <%%= f.link_to_add t('nested.add', :name => '<%= assoc.model2.singular_name %>'), :<%= assoc.model2.plural_name %> %>
50
+ <%- end -%>
51
+ </div>
52
+ <%- end # if -%>
53
+
54
+ <%- end # associations loop -%>
@@ -0,0 +1,60 @@
1
+ <%-
2
+ @entity = MDWA::DSL.entity('ContatoSite')
3
+ @model = @entity.generator_model
4
+ -%>
5
+ <table class="list">
6
+ <thead>
7
+ <th class="list_show"><%%= t '<%= @model.plural_name %>.index.id' %></th>
8
+ <th class="list_edit"><%%= t '<%= @model.plural_name %>.index.edit' %></th>
9
+ <%- @model.attributes.select{|a| !['id', 'created_at', 'updated_at'].include?(a.name)}.each do |attr| -%>
10
+ <th><%%= t '<%= @model.plural_name %>.index.<%= attr.name %>' %></th>
11
+ <%- end -%>
12
+ <%- @model.associations.each do |assoc| -%>
13
+ <th><%%= t '<%= @model.plural_name %>.index.<%= assoc.model2.singular_name %>' %></th>
14
+ <%- end -%>
15
+ <th class="list_remove"><%%= t '<%= @model.plural_name %>.index.remove' %></th>
16
+ </thead>
17
+
18
+ <%% @<%= @model.plural_name %>.each do |<%= @model.singular_name %>| %>
19
+ <tr class="<%%= cycle 'odd_line', 'even_line' %>" >
20
+ <td class="list_show">
21
+ <%%= link_to <%= @model.singular_name %>.id, <%= @model.object_name %>_path(<%= @model.singular_name %>) <%= ", :class => 'lightbox various fancybox.ajax'" if @entity.ajax %> %>
22
+ </td>
23
+ <td class="list_edit">
24
+ <%%= link_to t('<%= @model.plural_name %>.index.edit_label'), edit_<%= @model.object_name %>_path(<%= @model.singular_name %>) <%= ", :class => 'lightbox various fancybox.ajax'" if @entity.ajax %> %>
25
+ </td>
26
+ <%- @model.attributes.select{|a| a.name != 'id' and a.name != 'created_at' and a.name != 'updated_at'}.each do |attr| -%>
27
+ <td>
28
+ <%- if attr.type.to_sym == :file -%>
29
+ <%% unless <%= @model.singular_name %>.<%= attr.name %>_file_name.blank? %>
30
+ <%%= link_to image_tag(file_icon_path(<%= @model.singular_name %>.<%= attr.name %>_file_name)), <%= @model.singular_name %>.<%= attr.name %>.url, :target => '_blank' %>
31
+ <%% else %>
32
+ <%%= t 'system.no_file' %>
33
+ <%% end %>
34
+ <%- else -%>
35
+ <%%= <%= @model.singular_name %>.<%= attr.name %> %>
36
+ <%- end -%>
37
+ </td>
38
+ <%- end -%>
39
+
40
+ <%- @model.associations.each do |assoc| -%>
41
+ <td>
42
+ <%- if assoc.belongs_to? || assoc.nested_one? || assoc.has_one? -%>
43
+ <%%= <%= @model.singular_name %>.<%= assoc.model2.singular_name %>.<%= assoc.reference_field %> unless <%= @model.singular_name %>.<%= assoc.model2.singular_name %>.nil? %>
44
+ <%- elsif assoc.has_many? or assoc.has_and_belongs_to_many? or assoc.nested_many? -%>
45
+ <ul>
46
+ <%% <%= @model.singular_name %>.<%= assoc.model2.plural_name %>.each do |<%= assoc.model2.singular_name %>| %>
47
+ <li><%%= <%= assoc.model2.singular_name %>.<%= assoc.reference_field %> %> </li>
48
+ <%% end %>
49
+ </ul>
50
+ <%- end -%>
51
+ </td>
52
+ <%- end -%>
53
+ <td class="list_remove">
54
+ <%%= link_to t('<%= @model.plural_name %>.index.remove_label'), <%= @model.to_route_object %>, :method => :delete, <%= ':remote => true,' if @entity.ajax %> :data => {:confirm => t('<%= @model.plural_name %>.index.confirm_deletion')} %>
55
+ </td>
56
+ </tr>
57
+ <%% end %>
58
+ </table>
59
+
60
+ <%%= pagination_footer @<%= @model.plural_name %> %>
@@ -0,0 +1,11 @@
1
+ <%-
2
+ @entity = MDWA::DSL.entity('ContatoSite')
3
+ @model = @entity.generator_model
4
+ -%>
5
+ <%% if @<%= @model.singular_name %>.errors.any? %>
6
+ $("#mdwa_error").html("<%%= j( render '/template/mdwa/crud_error', :object => @<%= @model.singular_name %> )%>");
7
+ <%% else %>
8
+ $.fancybox.close(true);
9
+ $('#<%= @model.plural_name %>_filter_form').submit();
10
+ $('body').append("<%%= j( render '/template/mdwa/notice', :notice => @system_notice )%>");
11
+ <%% end %>
@@ -0,0 +1,6 @@
1
+ <%-
2
+ @entity = MDWA::DSL.entity('ContatoSite')
3
+ @model = @entity.generator_model
4
+ -%>
5
+ $('#<%= @model.plural_name %>_filter_form').submit();
6
+ $('body').append("<%%= j( render '/template/mdwa/notice', :notice => @system_notice )%>");
@@ -0,0 +1,13 @@
1
+ <%-
2
+ @entity = MDWA::DSL.entity('ContatoSite')
3
+ @model = @entity.generator_model
4
+ -%>
5
+ <div id="<%= @model.plural_name %>_edit" class="mdwa_edit">
6
+ <div class="page_header">
7
+ <h1><%%= t('<%= @model.plural_name %>.title.edit') %></h1>
8
+ </div>
9
+
10
+ <div class="inside">
11
+ <%%= render 'form' %>
12
+ </div>
13
+ </div>
@@ -0,0 +1,65 @@
1
+ <%-
2
+ @entity = MDWA::DSL.entity('ContatoSite')
3
+ @model = @entity.generator_model
4
+ -%>
5
+ <div id="<%= @model.plural_name %>_index" class="mdwa_index">
6
+ <div class="page_header">
7
+ <h1><%%= t '<%= @model.plural_name %>.title.index' %></h1>
8
+ <%- if @entity.ajax -%>
9
+ <div class="page_header_right_tab">
10
+ <%%= link_to t('<%= @model.plural_name %>.index.add'), new_<%= @model.object_name %>_path, :class => 'lightbox various fancybox.ajax' %>
11
+ </div>
12
+ <%- end -%>
13
+ </div>
14
+
15
+ <div class="inside">
16
+
17
+ <div class="topo">
18
+ <div class="yui3-g">
19
+ <%%= form_tag <%= @model.object_name.pluralize %>_path, :method => :get, :remote => true, :id => '<%= @model.plural_name %>_filter_form' do %>
20
+
21
+ <%-
22
+ atributos_com_filtro = @entity.attributes.values.select {|attr| attr.options[:filtered]}
23
+ associacoes_com_filtro = @entity.associations.values.select {|assoc| assoc.options[:filtered]}
24
+ -%>
25
+ <%- if !atributos_com_filtro.count.zero? or !associacoes_com_filtro.count.zero? -%>
26
+ <%- atributos_com_filtro.each do |atributo| -%>
27
+ <div class="yui3-u-1-5">
28
+ <div class="field">
29
+ <%%= label_tag :<%= atributo.name %>, t('<%= @model.plural_name %>.filtros.<%= atributo.name %>') %>
30
+ <%- atributo.to_model_attribute.filter_input.each do |input| -%>
31
+ <%%= <%= input %> %>
32
+ <%- end -%>
33
+ </div>
34
+ </div>
35
+ <%- end -%>
36
+
37
+ <%- associacoes_com_filtro.each do |associacao| -%>
38
+ <div class="yui3-u-1-5">
39
+ <div class="field">
40
+ <%%= label_tag :<%= associacao.name %>, t('<%= @model.plural_name %>.filtros.<%= associacao.name %>') %>
41
+ <%- associacao.to_model_association.filter_input(associacao.options[:filter_field]).each do |input| -%>
42
+ <%%= <%= input %> %>
43
+ <%- end -%>
44
+ </div>
45
+ </div>
46
+ <%- end -%>
47
+
48
+ <!-- Botão buscar -->
49
+ <div class="yui3-u-1-5">
50
+ <div class="field">
51
+ <label>&nbsp;</label>
52
+ <%%= submit_tag t('system.search_button'), :class => :button %>
53
+ </div>
54
+ </div>
55
+ <%- end -%>
56
+
57
+ <%% end %>
58
+ </div>
59
+ </div>
60
+
61
+ <div id="<%= @model.plural_name %>_list">
62
+ <%%= render 'list' %>
63
+ </div>
64
+ </div>
65
+ </div>
@@ -0,0 +1,5 @@
1
+ <%-
2
+ @entity = MDWA::DSL.entity('ContatoSite')
3
+ @model = @entity.generator_model
4
+ -%>
5
+ $("#<%= @model.plural_name %>_list").html("<%%= j( render 'list' )%>");
@@ -0,0 +1,13 @@
1
+ <%-
2
+ @entity = MDWA::DSL.entity('ContatoSite')
3
+ @model = @entity.generator_model
4
+ -%>
5
+ <div id="<%= @model.plural_name %>_new" class="mdwa_new">
6
+ <div class="page_header">
7
+ <h1><%%= t('<%= @model.plural_name %>.title.new') %></h1>
8
+ </div>
9
+
10
+ <div class="inside">
11
+ <%%= render 'form' %>
12
+ </div>
13
+ </div>
@@ -0,0 +1,42 @@
1
+ <%-
2
+ @entity = MDWA::DSL.entity('ContatoSite')
3
+ @model = @entity.generator_model
4
+ -%>
5
+ <div id="<%= @model.plural_name %>_show" class="mdwa_show">
6
+ <div class="page_header">
7
+ <h1><%%= t('<%= @model.plural_name %>.title.show') %></h1>
8
+ </div>
9
+
10
+ <div class="inside">
11
+ <%- @model.attributes.each do |attr| -%>
12
+ <div class="field">
13
+ <label><%%= t '<%= @model.plural_name %>.show.<%= attr.name %>' %></label>
14
+ <%- if attr.type.to_sym == :file -%>
15
+ <%% unless @<%= @model.singular_name %>.<%= attr.name %>.nil? %>
16
+ <span><%%= link_to image_tag(file_icon_path(@<%= @model.singular_name %>.<%= attr.name %>_file_name)), @<%= @model.singular_name %>.<%= attr.name %>.url, :target => '_blank' %></span>
17
+ <%% else %>
18
+ <%%= t('system.no_file') %>
19
+ <%% end %>
20
+ <%- else -%>
21
+ <span><%%= @<%= @model.singular_name %>.<%= attr.name %> %></span>
22
+ <%- end -%>
23
+ </div>
24
+ <%- end -%>
25
+ <%- @model.associations.each do |assoc| -%>
26
+ <div class="field">
27
+ <label><%%= t '<%= @model.plural_name %>.show.<%= assoc.model2.singular_name %>' %></label>
28
+ <span>
29
+ <%- if assoc.belongs_to? || assoc.nested_one? -%>
30
+ <%%= @<%= @model.singular_name %>.<%= assoc.model2.singular_name %>.<%= assoc.reference_field %> unless @<%= @model.singular_name %>.<%= assoc.model2.singular_name %>.nil? %>
31
+ <%- elsif assoc.has_many? or assoc.nested_many? -%>
32
+ <ul>
33
+ <%% @<%= @model.singular_name %>.<%= assoc.model2.plural_name %>.each do |<%= assoc.model2.singular_name %>| %>
34
+ <li><%%= <%= assoc.model2.singular_name %>.<%= assoc.reference_field %> %> </li>
35
+ <%% end %>
36
+ </ul>
37
+ <%- end -%>
38
+ </span>
39
+ </div>
40
+ <%- end -%>
41
+ </div>
42
+ </div>
@@ -0,0 +1,16 @@
1
+ <%-
2
+ @entity = MDWA::DSL.entity('ContatoSite')
3
+ @model = @entity.generator_model
4
+ -%>
5
+ <%% if @<%= @model.singular_name %>.errors.any? %>
6
+ $("#mdwa_error").html("<%%= j( render '/template/mdwa/crud_error', :object => @<%= @model.singular_name %> )%>");
7
+ <%% else %>
8
+ if( $('#<%= @model.plural_name %>_list').length > 0 ) {
9
+ $.fancybox.close(true);
10
+ $('#<%= @model.plural_name %>_filter_form').submit();
11
+ }
12
+ else if( $("#edit_<%= @model.plural_name %>").length > 0 ) {
13
+ $("#edit_<%= @model.plural_name %> .inside").html("<%%= j( render 'form' )%>");
14
+ }
15
+ $('body').append("<%%= j( render '/template/mdwa/notice', :notice => @system_notice )%>");
16
+ <%% end %>
@@ -0,0 +1,24 @@
1
+ class ContatosSiteController < ApplicationController
2
+
3
+ def new
4
+ @contato_site = A::ContatoSite.new
5
+ end
6
+
7
+ def salvar
8
+ @contato_site = A::ContatoSite.new( params[:a_contato_site] )
9
+ salvou = @contato_site.save
10
+
11
+ # se salvou, envia emails para o admin e o cliente
12
+ if salvou
13
+ @system_notice = t('contatos_site.frontend.salvar_notice')
14
+ ContatosSiteMailer.avisar_administrador(@contato_site).deliver
15
+ ContatosSiteMailer.avisar_cliente(@contato_site).deliver
16
+ end
17
+
18
+ respond_to do |format|
19
+ format.js
20
+ end
21
+
22
+ end
23
+
24
+ end
@@ -0,0 +1,46 @@
1
+ <div id="mdwa_contato">
2
+
3
+ <%%= form_for(@contato_site, :url => '/contatos_site/salvar', :remote => true) do |f| %>
4
+
5
+ <div id="mdwa_error">
6
+ <%%= render '/template/mdwa/crud_error', :object => @contato_site %>
7
+ </div>
8
+
9
+ <div class="yui3-g">
10
+ <div class="yui3-u-2-3">
11
+ <div class="field">
12
+ <%%= f.label :nome, t('contatos_site.frontend.nome') %>
13
+ <%%= f.text_field :nome %>
14
+ </div>
15
+ <div class="field">
16
+ <%%= f.label :email, t('contatos_site.frontend.email') %>
17
+ <%%= f.text_field :email %>
18
+ </div>
19
+ <div class="field">
20
+ <%%= f.label :telefone, t('contatos_site.frontend.telefone') %>
21
+ <%%= f.text_field :telefone %>
22
+ </div>
23
+ <div class="field">
24
+ <%%= f.label :assunto, t('contatos_site.frontend.assunto') %>
25
+ <%%= f.text_field :assunto %>
26
+ </div>
27
+ </div>
28
+
29
+ <div class="yui3-u-1-3">
30
+ <div class="field">
31
+ <%%= f.label :mensagem, t('contatos_site.frontend.mensagem') %>
32
+ <%%= f.text_area :mensagem %>
33
+ </div>
34
+ </div>
35
+
36
+ </div>
37
+ </div>
38
+
39
+ <div class="actions">
40
+ <%%= link_to t('system.cancel_button'), '#', :class => :cancel %>
41
+ <%%= f.submit t('system.save_button'), :class => :button %>
42
+ </div>
43
+
44
+ <%% end %>
45
+
46
+ </div>
@@ -0,0 +1,5 @@
1
+ <%% if @contato_site.errors.any? %>
2
+ $("#mdwa_error").html("<%%= j( render '/template/mdwa/crud_error', :object => @contato_site )%>");
3
+ <%% else %>
4
+ $('body').append("<%%= j( render '/template/mdwa/notice', :notice => @system_notice )%>");
5
+ <%% end %>
@@ -0,0 +1,4 @@
1
+ # -*- encoding : utf-8 -*-
2
+ module MdwaContato
3
+ VERSION = "1.0.0"
4
+ end
@@ -0,0 +1,9 @@
1
+ # -*- encoding : utf-8 -*-
2
+ require 'rails/engine'
3
+ require "mdwa_contato/version"
4
+
5
+ module MdwaContato
6
+ class MdwaContato < Rails::Engine
7
+ config.autoload_paths << File.expand_path("../app", __FILE__)
8
+ end
9
+ end
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'mdwa_contato/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "mdwa_contato"
8
+ gem.version = MdwaContato::VERSION
9
+ gem.authors = ["Marcelo Theodoro"]
10
+ gem.email = ["contato@qw3.com.br"]
11
+ gem.description = %q{Faz o gerenciamento de contatos que entram em um site.}
12
+ gem.summary = %q{Gerenciador de contatos MDWA}
13
+ gem.homepage = "https://github.com/qw3/mdwa_contato"
14
+
15
+ gem.add_dependency 'mdd', '>= 3.1.0'
16
+
17
+ gem.files = `git ls-files`.split($/)
18
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
19
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
20
+ gem.require_paths = ["lib"]
21
+ end
metadata ADDED
@@ -0,0 +1,98 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mdwa_contato
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Marcelo Theodoro
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-02-27 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: mdd
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 3.1.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 3.1.0
30
+ description: Faz o gerenciamento de contatos que entram em um site.
31
+ email:
32
+ - contato@qw3.com.br
33
+ executables: []
34
+ extensions: []
35
+ extra_rdoc_files: []
36
+ files:
37
+ - .gitignore
38
+ - Gemfile
39
+ - LICENSE.txt
40
+ - README.md
41
+ - Rakefile
42
+ - app/controllers/a/mdwa_contato_configuracao_controller.rb
43
+ - app/views/a/mdwa_contato_configuracao/index.html.erb
44
+ - lib/generators/mdwa_contato/install/install_generator.rb
45
+ - lib/generators/mdwa_contato/install/templates/config/initializers/mdwa_contato_config.rb
46
+ - lib/generators/mdwa_contato/install/templates/config/initializers/mdwa_contato_inflections.rb
47
+ - lib/generators/mdwa_contato/install/templates/config/locales/mdwa_contato.en.yml
48
+ - lib/generators/mdwa_contato/install/templates/config/locales/mdwa_contato.pt-BR.yml
49
+ - lib/generators/mdwa_contato/install/templates/entidades/contato_site.rb
50
+ - lib/generators/mdwa_contato/install/templates/mailers/contatos_site_mailer.rb
51
+ - lib/generators/mdwa_contato/install/templates/mailers/views/avisar_administrador.text.erb
52
+ - lib/generators/mdwa_contato/install/templates/mailers/views/avisar_cliente.text.erb
53
+ - lib/generators/mdwa_contato/install/templates/requisitos/gerenciar_contatos.rb
54
+ - lib/generators/mdwa_contato/install/templates/templates/a/controller.erb
55
+ - lib/generators/mdwa_contato/install/templates/templates/a/helper.erb
56
+ - lib/generators/mdwa_contato/install/templates/templates/a/model.erb
57
+ - lib/generators/mdwa_contato/install/templates/templates/a/views/_form.html.erb
58
+ - lib/generators/mdwa_contato/install/templates/templates/a/views/_form_fields.html.erb
59
+ - lib/generators/mdwa_contato/install/templates/templates/a/views/_list.html.erb
60
+ - lib/generators/mdwa_contato/install/templates/templates/a/views/create.js.erb
61
+ - lib/generators/mdwa_contato/install/templates/templates/a/views/destroy.js.erb
62
+ - lib/generators/mdwa_contato/install/templates/templates/a/views/edit.html.erb
63
+ - lib/generators/mdwa_contato/install/templates/templates/a/views/index.html.erb
64
+ - lib/generators/mdwa_contato/install/templates/templates/a/views/index.js.erb
65
+ - lib/generators/mdwa_contato/install/templates/templates/a/views/new.html.erb
66
+ - lib/generators/mdwa_contato/install/templates/templates/a/views/show.html.erb
67
+ - lib/generators/mdwa_contato/install/templates/templates/a/views/update.js.erb
68
+ - lib/generators/mdwa_contato/install/templates/templates/frontend/controller.erb
69
+ - lib/generators/mdwa_contato/install/templates/templates/frontend/views/new.html.erb
70
+ - lib/generators/mdwa_contato/install/templates/templates/frontend/views/salvar.js.erb
71
+ - lib/mdwa_contato.rb
72
+ - lib/mdwa_contato/version.rb
73
+ - mdwa_contato.gemspec
74
+ homepage: https://github.com/qw3/mdwa_contato
75
+ licenses: []
76
+ post_install_message:
77
+ rdoc_options: []
78
+ require_paths:
79
+ - lib
80
+ required_ruby_version: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ required_rubygems_version: !ruby/object:Gem::Requirement
87
+ none: false
88
+ requirements:
89
+ - - ! '>='
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ requirements: []
93
+ rubyforge_project:
94
+ rubygems_version: 1.8.24
95
+ signing_key:
96
+ specification_version: 3
97
+ summary: Gerenciador de contatos MDWA
98
+ test_files: []