From 6f09437e1619eb7b853ed2be20d98eccefbe7639 Mon Sep 17 00:00:00 2001 From: Nicolas Bally Date: Sat, 29 Jun 2013 12:00:32 +0200 Subject: [PATCH] layout newsletter --- app/controllers/newsletters_controller.rb | 6 +- app/controllers/petitions_controller.rb | 10 --- app/models/newsletter.rb | 16 ++++- app/views/layouts/mail.html.haml | 63 +++++++++++++++++-- .../newsletter_mails/newsletter.html.haml | 13 +++- app/views/newsletters/index.html.haml | 54 ++++++++-------- app/views/newsletters/show.html.haml | 12 ++++ 7 files changed, 130 insertions(+), 44 deletions(-) create mode 100644 app/views/newsletters/show.html.haml diff --git a/app/controllers/newsletters_controller.rb b/app/controllers/newsletters_controller.rb index 85f2fdb..17085ae 100755 --- a/app/controllers/newsletters_controller.rb +++ b/app/controllers/newsletters_controller.rb @@ -51,7 +51,11 @@ class NewslettersController < ApplicationController end end - + def show + @newsletter = Newsletter.find(params[:id]) + + render :layout => "mail" + end def destroy @newsletter = Newsletter.find(params[:id]) diff --git a/app/controllers/petitions_controller.rb b/app/controllers/petitions_controller.rb index f5d9c0e..cb10076 100644 --- a/app/controllers/petitions_controller.rb +++ b/app/controllers/petitions_controller.rb @@ -1,8 +1,6 @@ # -*- encoding : utf-8 -*- class PetitionsController < ApplicationController - - before_filter :authenticate_admin! def show @petition = Petition.find_by_slug(params[:id]) @@ -10,14 +8,6 @@ class PetitionsController < ApplicationController @title = "Le Pic Vert - "+@petition.name end - def new - @petition = Petition.new - - end - - def edit - @petition = Petition.find(params[:id]) - end def create @signator = PetitionSignator.new(params[:petition_signator]) diff --git a/app/models/newsletter.rb b/app/models/newsletter.rb index b2798b6..5e9312d 100755 --- a/app/models/newsletter.rb +++ b/app/models/newsletter.rb @@ -1,7 +1,21 @@ +# -*- encoding : utf-8 -*- + class Newsletter < ActiveRecord::Base validates_presence_of :title attr_accessible :title, :content, :email_from - EMAIL_FROMS=["Le Pic Vert ", "Le Pic Vert "] + #EMAIL_FROMS=["Le Pic Vert ", "Le Pic Vert "] + + EMAIL_FROMS=["contact@lepicvert.asso.fr","m.botton@lepicvert.asso.fr","s.montchalin@lepicvert.asso.fr","c.paul@lepicvert.asso.fr","b.cambon@lepicvert.asso.fr"] + + EMAIL_TEXTES= { + "contact@lepicvert.asso.fr" => ["Le Pic Vert",""], + "s.montchalin@lepicvert.asso.fr" => ["Sonia - Le Pic Vert","Sonia Montchalin", "Animatrice nature et environnement"], + "m.botton@lepicvert.asso.fr" => ["Martial - Le Pic Vert","Martial Botton","Coordinateur"], + "c.paul@lepicvert.asso.fr" => ["Camille - Le Pic Vert","Camille Paul","Apprentie BTSA Gestion et Protection de la Nature"], + "b.cambon@lepicvert.asso.fr" => ["Bastien - Le Pic Vert","Bastien Cambon","Engagé service civique"] + + } + end diff --git a/app/views/layouts/mail.html.haml b/app/views/layouts/mail.html.haml index bd40e17..6e8235a 100755 --- a/app/views/layouts/mail.html.haml +++ b/app/views/layouts/mail.html.haml @@ -1,9 +1,62 @@ !!! %html - %head - %meta{ :"http-equiv" => "Content-Type", :content => "text/html; charset=utf-8" } + %head + %meta{ :"http-equiv" => "Content-Type", :content => "text/html; charset=utf-8" } + + :css + a { + color: #0088cc; + text-decoration: none; + } + + a:hover, a:focus { + color: #005580; + text-decoration: underline; + } + + *{ + + line-height:1.3em; + } + - %body - - = yield + %body{:style => "font-family: Helvetica,Arial;padding:0px;margin:0px;font-size:15px;"} + %table{:style => "max-width:1000px !important;width:100%;border-collapse:collapse;"} + %tr + %td{:colspan => "3", :style => "padding:20px;"}= yield + + + //#5bb1f3 + //#e16b13 + //%tr{:style => "background:#5bb1f3;"} + // %td{:colspan => "3", :style => "padding:10px;text-align:center;color:white;"} + // Consultez toutes nos actualités sur notre site internet. + + + %tr{:style => "background:#f4f3ef"} + %td{:style => "width:185px;padding:20px;padding-top:22px;padding-bottom:28px;padding-left:30px;"} + =link_to image_tag("logo.png", :style => "width:185px;border:0px;"),"http://www.lepicvert.asso.fr" + + %td{:style => "padding-top:20px;vertical-align:top;padding-left:20px;color:#2d2d2d;"} + %p + + =link_to "Association Le Pic Vert","http://www.lepicvert.asso.fr", :style => "color:#47a000;text-decoration:none;" + %br + 24 place de la mairie + %br + 38140 REAUMONT + %p + =link_to "www.lepicvert.asso.fr","http://www.lepicvert.asso.fr", :style => "color:black;text-decoration:none;border-bottom:1px solid #f4f3ef;" + %p + 04 76 91 34 33 + + %td{:style => "padding-top:20px;vertical-align:top;padding-right:30px;color:#2d2d2d;width:300px;text-align:right;"} + %p + + + %tr{:style => "background:#393939;color:#f6f6f6;text-align:center;"} + %td{:colspan => 3, :style => "padding:10px;font-size:12px;"} Vous recevez ce mail car vous êtes adhérent ou sympatisant de l'association Le Pic Vert. Si vous ne souhaitez plus recevoir de mail de notre part n'hésitez pas à nous contacter. + + + \ No newline at end of file diff --git a/app/views/newsletter_mails/newsletter.html.haml b/app/views/newsletter_mails/newsletter.html.haml index 9476369..9a42bf6 100644 --- a/app/views/newsletter_mails/newsletter.html.haml +++ b/app/views/newsletter_mails/newsletter.html.haml @@ -1 +1,12 @@ -=raw @content \ No newline at end of file +=raw @content + +-if @email_from? and @email_from != "contact@lepicvert.asso.fr" + %br + %p + %strong=Newsletter::EMAIL_TEXTES[@email_from][1] + %br + =Newsletter::EMAIL_TEXTES[@email_from][2] + %br + %br + =link_to @email_from, "mailto:#{@email_from}" + \ No newline at end of file diff --git a/app/views/newsletters/index.html.haml b/app/views/newsletters/index.html.haml index b2e5acc..4e0fe4b 100755 --- a/app/views/newsletters/index.html.haml +++ b/app/views/newsletters/index.html.haml @@ -1,30 +1,32 @@ .links - =link_to "Créer une newsletter", new_newsletter_path + =link_to "Créer une newsletter", new_newsletter_path -%table.admin_table#newsletters-list +%table.admin_table#newsletters-list.table.table-stripped.table-bordered - %tr - %th Expéditeur - %th Sujet - %th - %th - + %tr + %th Expéditeur + %th Sujet + %th + %th + - -for u in @newsletter - - %tr - %td - =u.email_from - %td - = u.title - %td - - if has_permission?('newsletter.send') - =form_tag send_test_newsletter_path(u) do - = text_field_tag :email - = submit_tag "Envoyer un email de test", :class => "lien" - %td.link-column{:style => "width:200px;"} - = link_to "Editer", edit_newsletter_path(u) - = link_to "Effacer", u, :method => :delete, :confirm => 'Voulez-vous vraiment supprimer cette newsletter ?' - = link_to "Envoyer", select_recipients_newsletter_path(u) - - + -for u in @newsletter + + %tr + %td + =u.email_from + %td + = u.title + %td + - if has_permission?('newsletter.send') + =form_tag send_test_newsletter_path(u) do + = text_field_tag :email + = submit_tag "Envoyer un email de test", :class => "lien" + %td.link-column{:style => "width:200px;"} + = link_to "Prévualiser", newsletter_path(u) + = link_to "Editer", edit_newsletter_path(u) + = link_to "Effacer", u, :method => :delete, :confirm => 'Voulez-vous vraiment supprimer cette newsletter ?' + = link_to "Envoyer", select_recipients_newsletter_path(u) + + + diff --git a/app/views/newsletters/show.html.haml b/app/views/newsletters/show.html.haml new file mode 100644 index 0000000..0e322b6 --- /dev/null +++ b/app/views/newsletters/show.html.haml @@ -0,0 +1,12 @@ +=raw @newsletter.content + +-if @newsletter.email_from? and @newsletter.email_from != "contact@lepicvert.asso.fr" + %br + %p + %strong=Newsletter::EMAIL_TEXTES[@newsletter.email_from][1] + %br + =Newsletter::EMAIL_TEXTES[@newsletter.email_from][2] + %br + %br + =link_to @newsletter.email_from, "mailto:#{@newsletter.email_from}" + \ No newline at end of file