Questions
This commit is contained in:
parent
7993de9794
commit
a331087c5d
@ -34,6 +34,19 @@ body
|
||||
|
||||
}
|
||||
|
||||
.contact{
|
||||
|
||||
label{
|
||||
display:inline;
|
||||
}
|
||||
td{
|
||||
vertical-align:middle;
|
||||
}
|
||||
input{
|
||||
height:2em;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#top{
|
||||
|
||||
|
40
app/controllers/public/questions_controller.rb
Normal file
40
app/controllers/public/questions_controller.rb
Normal file
@ -0,0 +1,40 @@
|
||||
class Public::QuestionsController < ApplicationController
|
||||
layout "public"
|
||||
|
||||
def new
|
||||
@question = Question.new
|
||||
@title = "Me contacter"
|
||||
end
|
||||
|
||||
|
||||
def create
|
||||
@title = "Me contacter"
|
||||
@question = Question.new(params.require(:question).permit!)
|
||||
|
||||
|
||||
if @question.save
|
||||
|
||||
QuestionMailer.send_question(@question).deliver
|
||||
|
||||
@question_title = "Question de #{@question.name} - "+ActionController::Base.helpers.localize(@question.created_at).to_s
|
||||
@article = Article.new(:enabled => false, :title => @question_title, :slug => @question_title.to_slug, :tags_cache => "Question", :created_at => @question.created_at,:published_at => @question.created_at)
|
||||
|
||||
if @article.save
|
||||
|
||||
|
||||
@article.block.portlets << Portlet.create(:content => TextContent.new(:content => "<p>Question de #{@question.name} : </p><blockquote>"+ActionController::Base.helpers.simple_format(@question.content)+"</blockquote>"))
|
||||
|
||||
end
|
||||
redirect_to [:public, @question]
|
||||
else
|
||||
render :action => :new
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def show
|
||||
@title = "Me contacter"
|
||||
end
|
||||
|
||||
end
|
36
app/mailers/question_mailer.rb
Normal file
36
app/mailers/question_mailer.rb
Normal file
@ -0,0 +1,36 @@
|
||||
class QuestionMailer < ActionMailer::Base
|
||||
default from: "g.gagos@technique-eft.com"
|
||||
|
||||
# Subject can be set in your I18n file at config/locales/en.yml
|
||||
# with the following lookup:
|
||||
#
|
||||
# en.question.deliver.subject
|
||||
#
|
||||
def send_question(question)
|
||||
@question = question
|
||||
|
||||
mail to: "g.gagos@technique-eft.com, info@nicolasbally.com"
|
||||
end
|
||||
|
||||
# Subject can be set in your I18n file at config/locales/en.yml
|
||||
# with the following lookup:
|
||||
#
|
||||
# en.question.confirm.subject
|
||||
#
|
||||
def confirm
|
||||
@greeting = "Hi"
|
||||
|
||||
mail to: "to@example.org"
|
||||
end
|
||||
|
||||
# Subject can be set in your I18n file at config/locales/en.yml
|
||||
# with the following lookup:
|
||||
#
|
||||
# en.question.answer.subject
|
||||
#
|
||||
def answer
|
||||
@greeting = "Hi"
|
||||
|
||||
mail to: "to@example.org"
|
||||
end
|
||||
end
|
8
app/models/question.rb
Normal file
8
app/models/question.rb
Normal file
@ -0,0 +1,8 @@
|
||||
class Question < ActiveRecord::Base
|
||||
validates :name, :presence => true
|
||||
validates :email, :presence => true
|
||||
validates :region, :presence => true
|
||||
validates :country, :presence => true
|
||||
validates :content, :presence => true
|
||||
|
||||
end
|
@ -27,14 +27,40 @@
|
||||
#top
|
||||
=link_to "Accueil", "/"
|
||||
=render :partial => "public/shared/first_menu"
|
||||
=link_to "Une question ?", "me-contacter.html"
|
||||
|
||||
#banner
|
||||
=link_to image_tag("logo.png", :id => "logo"), "/"
|
||||
|
||||
|
||||
|
||||
|
||||
#main
|
||||
=yield
|
||||
|
||||
|
||||
#corps
|
||||
=yield
|
||||
#sidebar
|
||||
.who.widget
|
||||
%h3 Pourquoi ce blog ?
|
||||
%p
|
||||
Lorsque les Editions Marabout m’ont demandé d’écrire ce livre, j’ai accepté de suite l’opportunité qui m’était donnée de transmettre tout ce que je pouvais partager de l’EFT pour un usage personnel dans un même livre à usage de tous publics.
|
||||
%p
|
||||
C’est parce que je reçois régulièrement des mails demandant des précisions sur la pratique EFT que j’ai voulu compléter mon livre « L’EFT pour tous » par ce blog où vous pourrez poser les questions qui vous seront inspirées par sa lecture...
|
||||
%p
|
||||
%em
|
||||
Geneviève.
|
||||
.book.widget
|
||||
=link_to image_tag("livre.jpg"), "http://www.amazon.fr/gp/product/2501083083/ref=as_li_qf_sp_asin_il_tl?ie=UTF8&camp=1642&creative=6746&creativeASIN=2501083083&linkCode=as2&tag=decouvetappre-21", :target => "_blank"
|
||||
%p
|
||||
%br
|
||||
"L'EFT pour tous", livre de Geneviève Gagos, paru aux éditions Marabout en septembre 2013.
|
||||
|
||||
=render :partial => "public/articles/sidebar_recents"
|
||||
=render :partial => "public/articles/sidebar_tags"
|
||||
=render :partial => "public/articles/sidebar_archives"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1,22 +1 @@
|
||||
|
||||
#corps
|
||||
=render :partial => "public/articles/article", :collection => @articles, :as => "article"
|
||||
#sidebar
|
||||
.who.widget
|
||||
%h3 Pourquoi ce blog ?
|
||||
%p
|
||||
Lorsque les Editions Marabout m’ont demandé d’écrire ce livre, j’ai accepté de suite l’opportunité qui m’était donnée de transmettre tout ce que je pouvais partager de l’EFT pour un usage personnel dans un même livre à usage de tous publics.
|
||||
%p
|
||||
C’est parce que je reçois régulièrement des mails demandant des précisions sur la pratique EFT que j’ai voulu compléter mon livre « L’EFT pour tous » par ce blog où vous pourrez poser les questions qui vous seront inspirées par sa lecture...
|
||||
%p
|
||||
%em
|
||||
Geneviève.
|
||||
.book.widget
|
||||
=link_to image_tag("livre.jpg"), "http://www.amazon.fr/gp/product/2501083083/ref=as_li_qf_sp_asin_il_tl?ie=UTF8&camp=1642&creative=6746&creativeASIN=2501083083&linkCode=as2&tag=decouvetappre-21"
|
||||
%p
|
||||
%br
|
||||
"L'EFT pour tous", livre de Geneviève Gagos, paru aux éditions Marabout en septembre 2013.
|
||||
|
||||
=render :partial => "public/articles/sidebar_recents"
|
||||
=render :partial => "public/articles/sidebar_tags"
|
||||
=render :partial => "public/articles/sidebar_archives"
|
||||
=render :partial => "public/articles/article", :collection => @articles, :as => "article"
|
||||
|
@ -1,23 +1 @@
|
||||
|
||||
#corps
|
||||
=render @article
|
||||
#sidebar
|
||||
.who.widget
|
||||
%h3 Pourquoi ce blog ?
|
||||
%p
|
||||
Lorsque les Editions Marabout m’ont demandé d’écrire ce livre, j’ai accepté de suite l’opportunité qui m’était donnée de transmettre tout ce que je pouvais partager de l’EFT pour un usage personnel dans un même livre à usage de tous publics.
|
||||
%p
|
||||
C’est parce que je reçois régulièrement des mails demandant des précisions sur la pratique EFT que j’ai voulu compléter mon livre « L’EFT pour tous » par ce blog où vous pourrez poser les questions qui vous seront inspirées par sa lecture...
|
||||
%p
|
||||
%em
|
||||
Geneviève.
|
||||
.book.widget
|
||||
=link_to image_tag("livre.jpg"), "http://www.amazon.fr/gp/product/2501083083/ref=as_li_qf_sp_asin_il_tl?ie=UTF8&camp=1642&creative=6746&creativeASIN=2501083083&linkCode=as2&tag=decouvetappre-21"
|
||||
%p
|
||||
%br
|
||||
"L'EFT pour tous", livre de Geneviève Gagos, paru aux éditions Marabout en septembre 2013.
|
||||
|
||||
|
||||
=render :partial => "public/articles/sidebar_recents"
|
||||
=render :partial => "public/articles/sidebar_tags"
|
||||
=render :partial => "public/articles/sidebar_archives"
|
||||
=render @article
|
||||
|
@ -1,27 +1,2 @@
|
||||
|
||||
#corps
|
||||
=render :partial => "public/blocks/block", :locals => {:block => @menu_item.menu_content.blocks[0]}
|
||||
|
||||
|
||||
#sidebar
|
||||
.who.widget
|
||||
%h3 Pourquoi ce blog ?
|
||||
%p
|
||||
Lorsque les Editions Marabout m’ont demandé d’écrire ce livre, j’ai accepté de suite l’opportunité qui m’était donnée de transmettre tout ce que je pouvais partager de l’EFT pour un usage personnel dans un même livre à usage de tous publics.
|
||||
%p
|
||||
C’est parce que je reçois régulièrement des mails demandant des précisions sur la pratique EFT que j’ai voulu compléter mon livre « L’EFT pour tous » par ce blog où vous pourrez poser les questions qui vous seront inspirées par sa lecture...
|
||||
%p
|
||||
%em
|
||||
Geneviève.
|
||||
.book.widget
|
||||
=link_to image_tag("livre.jpg"), "http://www.amazon.fr/gp/product/2501083083/ref=as_li_qf_sp_asin_il_tl?ie=UTF8&camp=1642&creative=6746&creativeASIN=2501083083&linkCode=as2&tag=decouvetappre-21"
|
||||
%p
|
||||
%br
|
||||
"L'EFT pour tous", livre de Geneviève Gagos, paru aux éditions Marabout en septembre 2013.
|
||||
|
||||
|
||||
=render :partial => "public/articles/sidebar_recents"
|
||||
=render :partial => "public/articles/sidebar_tags"
|
||||
=render :partial => "public/articles/sidebar_archives"
|
||||
|
||||
=render :partial => "public/blocks/block", :locals => {:block => @menu_item.menu_content.blocks[0]}
|
||||
|
||||
|
43
app/views/public/questions/new.html.haml
Normal file
43
app/views/public/questions/new.html.haml
Normal file
@ -0,0 +1,43 @@
|
||||
%h1 Me contacter
|
||||
|
||||
<p></p><p>En remplissant le formulaire ci-dessous j’aurais les éléments nécessaires pour vous répondre. </p>
|
||||
<p>Votre adresse email restera confidentielle : ni transmise à qui que ce soit, ni affichée lors de ma réponse sur le blog. Elle me permettra de vous joindre pour obtenir plus de précisions sur votre question, si cela s’avérait nécessaire. </p>
|
||||
<p>Cette adresse ne sera pas stockée non plus. Si vous souhaitez recevoir le courrier mensuel de <a href="http://www.Technique-EFT.com"><span>www.Technique-EFT.com</span></a> vous devrez passer par son formulaire d’inscription présent dans la colonne de droite sur le site cité ici.</p>
|
||||
<p>Vous recevrez généralement une réponse dans les 48 heures.</p>
|
||||
<p>A très vite !</p>
|
||||
<p><i>Geneviève</i></p><p></p>
|
||||
%br
|
||||
%h2 Posez-moi votre question.
|
||||
=semantic_form_for [:public, @question], :url => public_questions_path do |f|
|
||||
|
||||
-if f.object.errors.size > 0
|
||||
.alert.error.alert-error
|
||||
Tout les champs doivent être remplis et le champ "email" doit être valide.
|
||||
|
||||
%table.contact{:style => "width:100%;"}
|
||||
%tr
|
||||
%td{:style => "width:100px;"}
|
||||
=f.label :name, "Prénom* :"
|
||||
%td
|
||||
=f.text_field :name
|
||||
%td{:style => "width:100px;"}
|
||||
=f.label :name, "Email* :"
|
||||
%td
|
||||
=f.text_field :email
|
||||
%tr
|
||||
%td
|
||||
=f.label :region, "Région* :"
|
||||
%td
|
||||
=f.text_field :region
|
||||
%td
|
||||
=f.label :name, "Pays* :"
|
||||
%td
|
||||
=f.text_field :country
|
||||
%br
|
||||
%p
|
||||
=f.label :content, "Votre question* :"
|
||||
%p
|
||||
=f.text_area :content, :style => "box-sizing:border-box;width:100%;height:400px;"
|
||||
%br
|
||||
%p
|
||||
=f.submit "Envoyer", :class => "btn btn-primary btn-large"
|
1
app/views/public/questions/show.html.haml
Normal file
1
app/views/public/questions/show.html.haml
Normal file
@ -0,0 +1 @@
|
||||
%h1 Merci pour votre question.
|
3
app/views/question_mailer/answer.text.haml
Normal file
3
app/views/question_mailer/answer.text.haml
Normal file
@ -0,0 +1,3 @@
|
||||
Question#answer
|
||||
|
||||
= @greeting + ", find me in app/views/question/answer.text.haml"
|
3
app/views/question_mailer/confirm.text.haml
Normal file
3
app/views/question_mailer/confirm.text.haml
Normal file
@ -0,0 +1,3 @@
|
||||
Question#confirm
|
||||
|
||||
= @greeting + ", find me in app/views/question/confirm.text.haml"
|
24
app/views/question_mailer/send_question.html.haml
Normal file
24
app/views/question_mailer/send_question.html.haml
Normal file
@ -0,0 +1,24 @@
|
||||
%table.contact{:style => "width:100%;"}
|
||||
%tr
|
||||
%td{:style => "width:100px;"}
|
||||
Prénom :
|
||||
%td
|
||||
=@question.name
|
||||
%td{:style => "width:100px;"}
|
||||
Email :
|
||||
%td
|
||||
=@question.email
|
||||
%tr
|
||||
%td
|
||||
Région :
|
||||
%td
|
||||
=@question.region
|
||||
%td
|
||||
Pays :
|
||||
%td
|
||||
=@question.country
|
||||
%br
|
||||
%p
|
||||
Votre question :
|
||||
%p
|
||||
=simple_format @question.content
|
@ -5,6 +5,10 @@ CMSnb::Application.routes.draw do
|
||||
# You can have the root of your site routed with "root"
|
||||
|
||||
|
||||
get ':id/merci-pour-votre-question.html' => "public/questions#show", :as => "public_question"
|
||||
get 'me-contacter.html' => "public/questions#new", :as => "new_public_question"
|
||||
post 'me-contacter.html' => "public/questions#create", :as => "public_questions"
|
||||
|
||||
|
||||
get 'newsletters/:id.html' => "public/newsletters#show", :as => "newsletter"
|
||||
get 'newsletters.html' => "public/newsletters#index", :as => "newsletters"
|
||||
@ -17,7 +21,7 @@ CMSnb::Application.routes.draw do
|
||||
get "articles/tags/:id.html"=> "public/articles#tags", :as => :public_tag
|
||||
|
||||
namespace :public do
|
||||
|
||||
resources :questions
|
||||
resources :articles
|
||||
resources :testimonies
|
||||
resources :portfolios
|
||||
|
14
db/migrate/20130909221956_create_questions.rb
Normal file
14
db/migrate/20130909221956_create_questions.rb
Normal file
@ -0,0 +1,14 @@
|
||||
class CreateQuestions < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :questions do |t|
|
||||
t.string :name
|
||||
t.string :email
|
||||
t.string :region
|
||||
t.string :country
|
||||
t.text :content
|
||||
t.text :answer
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
13
db/schema.rb
13
db/schema.rb
@ -11,7 +11,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20130818141526) do
|
||||
ActiveRecord::Schema.define(version: 20130909221956) do
|
||||
|
||||
create_table "admins", force: true do |t|
|
||||
t.string "name"
|
||||
@ -298,6 +298,17 @@ ActiveRecord::Schema.define(version: 20130818141526) do
|
||||
t.datetime "updated_at"
|
||||
end
|
||||
|
||||
create_table "questions", force: true do |t|
|
||||
t.string "name"
|
||||
t.string "email"
|
||||
t.string "region"
|
||||
t.string "country"
|
||||
t.text "content"
|
||||
t.text "answer"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
end
|
||||
|
||||
create_table "table_contents", force: true do |t|
|
||||
t.integer "style"
|
||||
t.integer "nbr_rows"
|
||||
|
17
test/fixtures/questions.yml
vendored
Normal file
17
test/fixtures/questions.yml
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
|
||||
|
||||
one:
|
||||
name: MyString
|
||||
email: MyString
|
||||
region: MyString
|
||||
country: MyString
|
||||
content: MyText
|
||||
answer: MyText
|
||||
|
||||
two:
|
||||
name: MyString
|
||||
email: MyString
|
||||
region: MyString
|
||||
country: MyString
|
||||
content: MyText
|
||||
answer: MyText
|
28
test/mailers/question_test.rb
Normal file
28
test/mailers/question_test.rb
Normal file
@ -0,0 +1,28 @@
|
||||
require 'test_helper'
|
||||
|
||||
class QuestionTest < ActionMailer::TestCase
|
||||
test "deliver" do
|
||||
mail = Question.deliver
|
||||
assert_equal "Deliver", mail.subject
|
||||
assert_equal ["to@example.org"], mail.to
|
||||
assert_equal ["from@example.com"], mail.from
|
||||
assert_match "Hi", mail.body.encoded
|
||||
end
|
||||
|
||||
test "confirm" do
|
||||
mail = Question.confirm
|
||||
assert_equal "Confirm", mail.subject
|
||||
assert_equal ["to@example.org"], mail.to
|
||||
assert_equal ["from@example.com"], mail.from
|
||||
assert_match "Hi", mail.body.encoded
|
||||
end
|
||||
|
||||
test "answer" do
|
||||
mail = Question.answer
|
||||
assert_equal "Answer", mail.subject
|
||||
assert_equal ["to@example.org"], mail.to
|
||||
assert_equal ["from@example.com"], mail.from
|
||||
assert_match "Hi", mail.body.encoded
|
||||
end
|
||||
|
||||
end
|
7
test/models/question_test.rb
Normal file
7
test/models/question_test.rb
Normal file
@ -0,0 +1,7 @@
|
||||
require 'test_helper'
|
||||
|
||||
class QuestionTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
Loading…
x
Reference in New Issue
Block a user