diff --git a/app/controllers/newsletters_controller.rb b/app/controllers/admin/newsletters_controller.rb similarity index 98% rename from app/controllers/newsletters_controller.rb rename to app/controllers/admin/newsletters_controller.rb index 40986e9..f8b9fa1 100755 --- a/app/controllers/newsletters_controller.rb +++ b/app/controllers/admin/newsletters_controller.rb @@ -1,6 +1,6 @@ # -*- encoding : utf-8 -*- -class NewslettersController < ApplicationController +class Admin::NewslettersController < ApplicationController layout "admin" diff --git a/app/helpers/forum/forum_user_helper.rb b/app/helpers/forum/forum_user_helper.rb deleted file mode 100644 index 0b417ba..0000000 --- a/app/helpers/forum/forum_user_helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -module Forum::ForumUserHelper -end diff --git a/app/helpers/surveys_helper.rb b/app/helpers/surveys_helper.rb deleted file mode 100644 index 1a6d485..0000000 --- a/app/helpers/surveys_helper.rb +++ /dev/null @@ -1,3 +0,0 @@ -# -*- encoding : utf-8 -*- -module SurveysHelper -end diff --git a/app/helpers/tiny_urls_helper.rb b/app/helpers/tiny_urls_helper.rb deleted file mode 100644 index b37ca74..0000000 --- a/app/helpers/tiny_urls_helper.rb +++ /dev/null @@ -1,3 +0,0 @@ -# -*- encoding : utf-8 -*- -module TinyUrlsHelper -end diff --git a/app/views/newsletters/_form.haml b/app/views/admin/newsletters/_form.haml similarity index 94% rename from app/views/newsletters/_form.haml rename to app/views/admin/newsletters/_form.haml index 971d34b..3fe480d 100755 --- a/app/views/newsletters/_form.haml +++ b/app/views/admin/newsletters/_form.haml @@ -1,4 +1,4 @@ -=form_for @newsletter do |f| +=form_for [:admin, @newsletter] do |f| =f.submit "sauvegarder" %p Sujet : diff --git a/app/views/admin/newsletters/_sheets_selecteds.html.haml b/app/views/admin/newsletters/_sheets_selecteds.html.haml new file mode 100644 index 0000000..7cefde9 --- /dev/null +++ b/app/views/admin/newsletters/_sheets_selecteds.html.haml @@ -0,0 +1,11 @@ +-if @sheets + =form_tag send_newsletter_admin_newsletter_path(params[:id]) do + %table#sheets_checkboxs.table.table-striped + -@sheets.sort{|u,v| ((u.person.surname if u.person) || u.corporate).to_s <=>(( v.person.surname if v.person )|| v.corporate).to_s}.each do |sheet| + %tr + %td + =check_box_tag "confirmed_sheets[]", sheet.id,true, :id => "confirmed_sheets_"+sheet.id.to_s + %label{:for => "confirmed_sheets_"+sheet.id.to_s, :style => "display:inline;"}=(sheet.person.name if sheet.person and (!sheet.corporate or sheet.corporate == "")) || sheet.corporate + + + =submit_tag "Envoyer la newsletter à toutes les adresses de ces fiches", :class => "btn btn-danger" \ No newline at end of file diff --git a/app/views/newsletters/edit.html.haml b/app/views/admin/newsletters/edit.html.haml similarity index 100% rename from app/views/newsletters/edit.html.haml rename to app/views/admin/newsletters/edit.html.haml diff --git a/app/views/newsletters/index.html.haml b/app/views/admin/newsletters/index.html.haml similarity index 59% rename from app/views/newsletters/index.html.haml rename to app/views/admin/newsletters/index.html.haml index 76e67ed..46dcd99 100755 --- a/app/views/newsletters/index.html.haml +++ b/app/views/admin/newsletters/index.html.haml @@ -1,6 +1,6 @@ .right - =link_to i(:plus, :icon => false)+" Créer une newsletter", new_newsletter_path, :class => "btn btn-primary" + =link_to i(:plus, :icon => false)+" Créer une newsletter", new_admin_newsletter_path, :class => "btn btn-primary" %h1 Newsletters @@ -26,16 +26,16 @@ %td{:style => "text-align:right;"} - if has_permission?('newsletter.send') - =form_tag send_test_newsletter_path(u), :style => "display:inline;" do + =form_tag send_test_admin_newsletter_path(u), :style => "display:inline;" do .input-append{:style => "display:inline-block;margin:2px;"} = text_field_tag :email,"", :class => "" = submit_tag "Envoyer un email de test", :class => "btn" %td{:style => "width:150px;text-align:right;"} - = link_to i(:trash), u, :method => :delete, :confirm => 'Voulez-vous vraiment supprimer cette newsletter ?' - = link_to i(:"envelope-alt"), select_recipients_newsletter_path(u) - = link_to i(:pencil), edit_newsletter_path(u) - = link_to i(:"eye-open"), newsletter_path(u), :target => "_blank" + = link_to i(:trash), [:admin, u], :method => :delete, :confirm => 'Voulez-vous vraiment supprimer cette newsletter ?' + = link_to i(:"envelope-alt"), select_recipients_admin_newsletter_path(u) + = link_to i(:pencil), edit_admin_newsletter_path(u) + = link_to i(:"eye-open"), admin_newsletter_path(u), :target => "_blank" diff --git a/app/views/newsletters/new.html.haml b/app/views/admin/newsletters/new.html.haml similarity index 100% rename from app/views/newsletters/new.html.haml rename to app/views/admin/newsletters/new.html.haml diff --git a/app/views/admin/newsletters/select_recipients.html.haml b/app/views/admin/newsletters/select_recipients.html.haml new file mode 100644 index 0000000..a56b38d --- /dev/null +++ b/app/views/admin/newsletters/select_recipients.html.haml @@ -0,0 +1,64 @@ + + +%h1 Envoyer une newsletter +%p + = link_to i(:"eye-open"), admin_newsletter_path(@newsletter), :target => "_blank" + + Newsletter sélectionnée : + =@newsletter.title + + + +%ul.nav.nav-tabs#myTab + %li.active + %a{:href => "#send_sheets"} + Envoyer à une selection d'adhérents + %li + %a{:href => "#groups"} + Envoyer à des groupes d'inscrits +.tab-content + .tab-pane.active#send_sheets + + %h3 Sélectionner des fiches : + + + =render :partial => "admin/sheets/sheets_search", :locals => {:url => ""} + + + %h3 Fiches sélectionnées + %a{:href => "#", :onclick => "$('#sheets_selecteds input:checkbox').attr('checked', true);return false"} Tout sélectionner. + %a{:href => "#", :onclick => "$('#sheets_selecteds input:checkbox').attr('checked', false);return false"} Tout désélectionner + #sheets_selecteds + + + + + .tab-pane#groups + =form_tag send_newsletter_admin_newsletter_path(:id => params[:id]) do + + %table.table.table-striped + -Newsgroup.all.each do |ng| + %tr + %td + =check_box_tag "confirmed_groups[]", ng.id,false, :id => "confirmed_groups_"+ng.id.to_s + %label{:for => "confirmed_groups_"+ng.id.to_s, :style => "display:inline;"}=ng.name + + %br + %br + =submit_tag "Envoyer la newsletter à toutes les personnes de ce groupe", :class => "btn btn-danger" + + + + + + + +%br +%br +%br \ No newline at end of file diff --git a/app/views/newsletters/select_recipients.js.erb b/app/views/admin/newsletters/select_recipients.js.erb similarity index 100% rename from app/views/newsletters/select_recipients.js.erb rename to app/views/admin/newsletters/select_recipients.js.erb diff --git a/app/views/newsletters/show.html.haml b/app/views/admin/newsletters/show.html.haml similarity index 100% rename from app/views/newsletters/show.html.haml rename to app/views/admin/newsletters/show.html.haml diff --git a/app/views/layouts/admin.html.haml b/app/views/layouts/admin.html.haml index 453033a..f5091d6 100644 --- a/app/views/layouts/admin.html.haml +++ b/app/views/layouts/admin.html.haml @@ -44,7 +44,7 @@ %b.caret %ul.dropdown-menu %li=link_to "liste des adhérents", admin_sheets_path - %li=link_to "gestion newsletters", newsletters_path + %li=link_to "gestion newsletters", admin_newsletters_path %li.divider %li=link_to "Sondages", admin_survey_types_path %li=link_to "Petitions", admin_petitions_path diff --git a/app/views/newsletters/_sheets_selecteds.html.haml b/app/views/newsletters/_sheets_selecteds.html.haml deleted file mode 100644 index b93dcd7..0000000 --- a/app/views/newsletters/_sheets_selecteds.html.haml +++ /dev/null @@ -1,9 +0,0 @@ --if @sheets - =form_tag send_newsletter_newsletter_path(params[:id]) do - #sheets_checkboxs - -@sheets.sort{|u,v| ((u.person.surname if u.person) || u.corporate).to_s <=>(( v.person.surname if v.person )|| v.corporate).to_s}.each do |sheet| - =check_box_tag "confirmed_sheets[]", sheet.id,true, :id => "confirmed_sheets_"+sheet.id.to_s - %label{:for => "confirmed_sheets_"+sheet.id.to_s}=(sheet.person.name if sheet.person and (!sheet.corporate or sheet.corporate == "")) || sheet.corporate - %br - - =submit_tag "Envoyer la newsletter à toutes les adresses de ces fiches" \ No newline at end of file diff --git a/app/views/newsletters/select_recipients.html.haml b/app/views/newsletters/select_recipients.html.haml deleted file mode 100644 index 5ddd1f8..0000000 --- a/app/views/newsletters/select_recipients.html.haml +++ /dev/null @@ -1,29 +0,0 @@ -%h2 - Newsletter sélectionnée : - =@newsletter.title - -%h2 Envoyer la newsletter en sélectionnant des fiches : -%h3 Sélectionner des fiches : - - -=render :partial => "sheets/sheets_search", :locals => {:url => ""} - - -%h3 Fiches sélectionnées -%a{:href => "#", :onclick => "$('#sheets_selecteds input:checkbox').attr('checked', true);return false"} Tout sélectionner. -%a{:href => "#", :onclick => "$('#sheets_selecteds input:checkbox').attr('checked', false);return false"} Tout désélectionner -#sheets_selecteds - - -%h2 Envoyer la newsletter directement à un ou plusieurs groupes d'inscrit : -=form_tag :controller => "newsletters", :action => "send_newsletter", :id => params[:id] do - -Newsgroup.all.each do |ng| - =check_box_tag "confirmed_groups[]", ng.id,false, :id => "confirmed_sheets_"+ng.id.to_s - %label{:for => "confirmed_groups_"+ng.id.to_s}=ng.name - %br - %br - %br - =submit_tag "Envoyer la newsletter à toutes les personnes de ce groupe" -%br -%br -%br \ No newline at end of file diff --git a/app/views/newsletters/send_test.html.haml b/app/views/newsletters/send_test.html.haml deleted file mode 100755 index 3240fcc..0000000 --- a/app/views/newsletters/send_test.html.haml +++ /dev/null @@ -1 +0,0 @@ -La newsletter a bien été envoyée à l'email de test \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 252216a..991bbfe 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -38,6 +38,16 @@ Survey::Application.routes.draw do get 'principal' end end + + resources :newsletters do + member do + get "select_recipients" + put "select_recipients" + post "send_test" + post "send_newsletter" + end + end + end @@ -65,25 +75,15 @@ Survey::Application.routes.draw do - resources :newsletters do - member do - get "select_recipients" - put "select_recipients" - post "send_test" - post "send_newsletter" - end - end + match 'u/:id' => 'tiny_urls#show', :as => :tiny_url - resources :tiny_urls - - get "surveys/index" - match 'sondages/:slug/merci-de-votre-participation.:f' => 'survey_sets#thank', :as => :thank_survey_set, :f => "html" + match 'sondages/:slug/merci-de-votre-participation.:f' => 'survey_sets#thank', :as => :thank_survey_set, :f => "html" match 'sondages/:slug.:f' => 'survey_sets#new', :as => :new_survey_set, :f => "html" match 'sondages/:slug/resultats.:f' => 'survey_sets#show', :as => :survey_set, :f => "html"