petitions
This commit is contained in:
parent
7befa4610e
commit
1e33360cc6
@ -1,6 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
|
|
||||||
*= require_self
|
*= require_self
|
||||||
|
*= require shared/formtastic
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
64
app/controllers/admin/petitions_controller.rb
Normal file
64
app/controllers/admin/petitions_controller.rb
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
# -*- encoding : utf-8 -*-
|
||||||
|
|
||||||
|
class Admin::PetitionsController < ApplicationController
|
||||||
|
layout "admin"
|
||||||
|
before_filter :authenticate_admin!
|
||||||
|
|
||||||
|
def index
|
||||||
|
@petitions = Petition.all
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
def show
|
||||||
|
@petition = Petition.find(params[:id])
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
def new
|
||||||
|
@petition = Petition.new
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
def edit
|
||||||
|
@petition = Petition.find(params[:id])
|
||||||
|
end
|
||||||
|
|
||||||
|
def create
|
||||||
|
@petition = Petition.new(params[:petition])
|
||||||
|
|
||||||
|
|
||||||
|
if @petition.save
|
||||||
|
redirect_to admin_petitions_url, notice: 'La pétition a été crée.'
|
||||||
|
|
||||||
|
else
|
||||||
|
render action: "new"
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
def update
|
||||||
|
@petition = Petition.find(params[:id])
|
||||||
|
|
||||||
|
|
||||||
|
if @petition.update_attributes(params[:petition])
|
||||||
|
redirect_to admin_petitions_url, notice: 'Les infos sur la pétition ont été mise à jour.'
|
||||||
|
|
||||||
|
else
|
||||||
|
render action: "edit"
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
def destroy
|
||||||
|
@petition = Petition.find(params[:id])
|
||||||
|
@petition.destroy
|
||||||
|
|
||||||
|
redirect_to admin_petitions_url
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
50
app/controllers/petitions_controller.rb
Normal file
50
app/controllers/petitions_controller.rb
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
# -*- encoding : utf-8 -*-
|
||||||
|
|
||||||
|
class PetitionsController < ApplicationController
|
||||||
|
|
||||||
|
before_filter :authenticate_admin!
|
||||||
|
|
||||||
|
def show
|
||||||
|
@petition = Petition.find_by_slug(params[:id])
|
||||||
|
@signator = @petition.signators.new(:country => "France")
|
||||||
|
@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])
|
||||||
|
|
||||||
|
@petition = @signator.petition
|
||||||
|
@title = "Le Pic Vert - "+@petition.name
|
||||||
|
|
||||||
|
if @signator.save
|
||||||
|
PetitionMails.confirmation(@signator).deliver
|
||||||
|
render action: "create"
|
||||||
|
else
|
||||||
|
render action: "show"
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
def confirm
|
||||||
|
@signator = PetitionSignator.find_by_token(params[:id])
|
||||||
|
@petition = @signator.petition
|
||||||
|
@title = "Le Pic Vert - "+@petition.name
|
||||||
|
@signator.enabled = true
|
||||||
|
|
||||||
|
@signator.save!
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
end
|
@ -9,8 +9,11 @@ class SurveySetsController < ApplicationController
|
|||||||
end
|
end
|
||||||
def new
|
def new
|
||||||
|
|
||||||
|
|
||||||
@survey = SurveyType.find_by_slug(params[:slug])
|
@survey = SurveyType.find_by_slug(params[:slug])
|
||||||
@survey_set = @survey.to_survey_set
|
@survey_set = @survey.to_survey_set
|
||||||
|
@title = "Le Pic Vert - Sondage : "+@survey_set.survey_type.name
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
@ -18,7 +21,11 @@ class SurveySetsController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
|
|
||||||
@survey_set = SurveySet.new(params[:survey_set])
|
@survey_set = SurveySet.new(params[:survey_set])
|
||||||
|
|
||||||
|
@title = "Le Pic Vert - Sondage : "+@survey_set.survey_type.name
|
||||||
|
|
||||||
if @survey_set.save
|
if @survey_set.save
|
||||||
redirect_to thank_survey_set_path(:slug => @survey_set.survey_type.slug)
|
redirect_to thank_survey_set_path(:slug => @survey_set.survey_type.slug)
|
||||||
else
|
else
|
||||||
@ -27,10 +34,13 @@ class SurveySetsController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
|
|
||||||
@survey = SurveyType.find_by_slug(params[:slug])
|
@survey = SurveyType.find_by_slug(params[:slug])
|
||||||
end
|
end
|
||||||
|
|
||||||
def thank
|
def thank
|
||||||
|
|
||||||
@survey = SurveyType.find_by_slug(params[:slug])
|
@survey = SurveyType.find_by_slug(params[:slug])
|
||||||
|
@title = "Le Pic Vert - Sondage : "+@survey.name
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
19
app/mailers/petition_mails.rb
Normal file
19
app/mailers/petition_mails.rb
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
# -*- encoding : utf-8 -*-
|
||||||
|
class PetitionMails < ActionMailer::Base
|
||||||
|
layout 'mail'
|
||||||
|
|
||||||
|
default from: "Le Pic Vert <contact@lepicvert.asso.fr>"
|
||||||
|
|
||||||
|
def confirmation(signator)
|
||||||
|
@signator = signator
|
||||||
|
@email = @signator.email
|
||||||
|
@title = "Important : pour valider votre signature."
|
||||||
|
|
||||||
|
mail(:to => @email, :from => @from, :subject => @title)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
end
|
14
app/models/petition.rb
Normal file
14
app/models/petition.rb
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
class Petition < ActiveRecord::Base
|
||||||
|
attr_accessible :description, :enabled, :name, :slug
|
||||||
|
|
||||||
|
has_many :signators, :class_name => "PetitionSignator"
|
||||||
|
|
||||||
|
def signators_number
|
||||||
|
self.signators.count
|
||||||
|
end
|
||||||
|
|
||||||
|
def confirmed_signators_number
|
||||||
|
self.signators.where(:enabled => true).count
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
19
app/models/petition_signator.rb
Normal file
19
app/models/petition_signator.rb
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
class PetitionSignator < ActiveRecord::Base
|
||||||
|
belongs_to :petition
|
||||||
|
attr_accessor :email_confirmation
|
||||||
|
attr_accessible :address, :address2, :city, :enabled, :token, :country, :cp, :email, :email_confirmation, :firstname, :name, :petition_id
|
||||||
|
|
||||||
|
validates :email, :presence => true, :confirmation => true, :uniqueness => { :scope => :petition_id }
|
||||||
|
|
||||||
|
validates :name, :presence => true
|
||||||
|
validates :firstname, :presence => true
|
||||||
|
validates :address, :presence => true
|
||||||
|
validates :cp, :presence => true
|
||||||
|
validates :city, :presence => true
|
||||||
|
validates :country, :presence => true
|
||||||
|
|
||||||
|
before_create do
|
||||||
|
self.token = (Digest::MD5.hexdigest "#{SecureRandom.hex(10)}-#{DateTime.now.to_s}")
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
28
app/views/admin/petitions/_form.haml
Executable file
28
app/views/admin/petitions/_form.haml
Executable file
@ -0,0 +1,28 @@
|
|||||||
|
=form_for [:admin, @petition] do |f|
|
||||||
|
=f.submit "sauvegarder", :class => "btn"
|
||||||
|
%p
|
||||||
|
Nom :
|
||||||
|
=f.text_field :name
|
||||||
|
%p
|
||||||
|
Permalink :
|
||||||
|
=f.text_field :slug
|
||||||
|
|
||||||
|
|
||||||
|
%p
|
||||||
|
=f.text_area :description, :class => "redactor_content", :style => "height:600px;width:100%;max-width:100%"
|
||||||
|
|
||||||
|
:javascript
|
||||||
|
|
||||||
|
$('.redactor_content').redactor({
|
||||||
|
|
||||||
|
fixed: true,
|
||||||
|
lang: 'fr',
|
||||||
|
buttons : ['html', '|', 'formatting', '|', 'bold', 'italic', 'deleted','underline','|', 'alignleft', 'aligncenter', 'alignright', 'justify', '|', 'unorderedlist', 'orderedlist', 'outdent', 'indent', '|', 'table', 'link', '|','fontcolor', 'backcolor','|', 'horizontalrule'],
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
=f.submit "sauvegarder", :class => "btn"
|
||||||
|
|
||||||
|
|
6
app/views/admin/petitions/edit.html.haml
Normal file
6
app/views/admin/petitions/edit.html.haml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
%h1 Modifier l'url
|
||||||
|
|
||||||
|
= render 'form'
|
||||||
|
|
||||||
|
= link_to 'Show', @tiny_url
|
||||||
|
= link_to 'Back', tiny_urls_path
|
25
app/views/admin/petitions/index.html.haml
Normal file
25
app/views/admin/petitions/index.html.haml
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
= link_to i(:plus)+' Ajouter une petition', new_admin_petition_path, :class => "btn"
|
||||||
|
%h1 Liste des petitions en ligne
|
||||||
|
|
||||||
|
%table.stat_table.table.table-striped
|
||||||
|
%tr
|
||||||
|
%th Nom
|
||||||
|
%th Url
|
||||||
|
%th Nbr sign.
|
||||||
|
%th
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
- @petitions.each do |petition|
|
||||||
|
%tr
|
||||||
|
%td= petition.name
|
||||||
|
%td=link_to petition_url(:id => petition.slug),petition_url(:id => petition.slug)
|
||||||
|
|
||||||
|
%td
|
||||||
|
=petition.confirmed_signators_number
|
||||||
|
="("+(petition.signators_number-petition.confirmed_signators_number).to_s+" en attente)" if petition.signators_number-petition.confirmed_signators_number > 0
|
||||||
|
%td
|
||||||
|
= link_to i(:"eye-open"), [:admin, petition]
|
||||||
|
= link_to i(:pencil), edit_admin_petition_path(petition)
|
||||||
|
= link_to i(:trash), [:admin, petition], method: :delete, data: { confirm: 'Voulez-vous vraiment supprimer cette petition ? Les signatures seront également supprimées.' }
|
||||||
|
|
6
app/views/admin/petitions/new.html.haml
Normal file
6
app/views/admin/petitions/new.html.haml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
%h1 Ajouter une url
|
||||||
|
|
||||||
|
= render 'form'
|
||||||
|
|
||||||
|
= link_to 'Back', tiny_urls_path
|
||||||
|
|
39
app/views/admin/petitions/show.html.haml
Normal file
39
app/views/admin/petitions/show.html.haml
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
%h1=@petition.name
|
||||||
|
.alert.alert-info
|
||||||
|
Adresse publique de la pétition :
|
||||||
|
=link_to petition_url(:id => @petition.slug),petition_url(:id => @petition.slug)
|
||||||
|
=raw @petition.description
|
||||||
|
|
||||||
|
%hr
|
||||||
|
|
||||||
|
|
||||||
|
%h1
|
||||||
|
Liste des signataires
|
||||||
|
|
||||||
|
%p
|
||||||
|
%span.badge.badge-success=@petition.confirmed_signators_number
|
||||||
|
=raw "- "+raw(content_tag("span", (@petition.signators_number-@petition.confirmed_signators_number).to_s, :class => "badge badge-warning"))+" en attente" if @petition.signators_number-@petition.confirmed_signators_number > 0
|
||||||
|
%table.table.table.table-striped.table-bordered
|
||||||
|
%tr
|
||||||
|
%th Nom
|
||||||
|
%th Prénom
|
||||||
|
%th Adresse
|
||||||
|
%th Adresse suite
|
||||||
|
%th Ville
|
||||||
|
%th Pays
|
||||||
|
%th Email
|
||||||
|
%th
|
||||||
|
|
||||||
|
-@petition.signators.each do |signator|
|
||||||
|
%tr{:class => (signator.enabled ? "success" : "warning")}
|
||||||
|
%td=signator.name
|
||||||
|
%td=signator.firstname
|
||||||
|
%td=signator.address
|
||||||
|
%td=signator.address2
|
||||||
|
%td
|
||||||
|
=signator.cp
|
||||||
|
=signator.city
|
||||||
|
%td=signator.country
|
||||||
|
%td=signator.email
|
||||||
|
%td
|
||||||
|
|
@ -26,7 +26,7 @@
|
|||||||
|
|
||||||
%li.dropdown
|
%li.dropdown
|
||||||
%a{:href => "#", :class => "dropdown-toggle", :data => {:toggle => "dropdown"}}
|
%a{:href => "#", :class => "dropdown-toggle", :data => {:toggle => "dropdown"}}
|
||||||
=image_tag (current_admin.file? ? current_admin.file.square.url : ""), :class => "avatar", :style => "height:15px;"
|
=image_tag (current_admin.file? ? current_admin.file.square.url : ""), :class => "img img-rounded", :style => "height:15px;"
|
||||||
=current_admin.firstname
|
=current_admin.firstname
|
||||||
=current_admin.name
|
=current_admin.name
|
||||||
%b.caret
|
%b.caret
|
||||||
@ -51,6 +51,7 @@
|
|||||||
%li=link_to "gestion newsletters", newsletters_path
|
%li=link_to "gestion newsletters", newsletters_path
|
||||||
%li.divider
|
%li.divider
|
||||||
%li=link_to "Sondages", admin_surveys_path
|
%li=link_to "Sondages", admin_surveys_path
|
||||||
|
%li=link_to "Petitions", admin_petitions_path
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
!!!
|
!!!
|
||||||
%html
|
%html
|
||||||
%head
|
%head
|
||||||
%title Le Pic Vert - Votre avis sur les sorties du Pic Vert
|
%title= @title || "Le Pic Vert."
|
||||||
= stylesheet_link_tag "application", :media => "all"
|
= stylesheet_link_tag "application", :media => "all"
|
||||||
= javascript_include_tag "application"
|
= javascript_include_tag "application"
|
||||||
= csrf_meta_tags
|
= csrf_meta_tags
|
||||||
|
28
app/views/petition_mails/confirmation.haml
Normal file
28
app/views/petition_mails/confirmation.haml
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
%p
|
||||||
|
Bonjour
|
||||||
|
=@signator.firstname+","
|
||||||
|
|
||||||
|
%p
|
||||||
|
Vous venez de signer "
|
||||||
|
=@signator.petition.name
|
||||||
|
='",'
|
||||||
|
merci pour votre soutient.
|
||||||
|
|
||||||
|
%p
|
||||||
|
Pour que votre signature soit bien prise en compte, merci de cliquer sur ce lien, où de le copier dans la barre d'adresse de votre navigateur :
|
||||||
|
|
||||||
|
%p{:style => "text-align:center"}
|
||||||
|
=link_to confirm_petition_url(:id => @signator.token),confirm_petition_url(:id => @signator.token)
|
||||||
|
|
||||||
|
%p
|
||||||
|
%strong Association Le Pic Vert
|
||||||
|
%br
|
||||||
|
24 place de la Mairie
|
||||||
|
%br
|
||||||
|
38140 Réaumont
|
||||||
|
|
||||||
|
%p
|
||||||
|
Tel : 04 76 91 34 33
|
||||||
|
Site internet : www.lepicvert.asso.fr
|
||||||
|
Mail : contact@lepicvert.asso.fr
|
||||||
|
|
32
app/views/petitions/_answer_set.html.haml
Normal file
32
app/views/petitions/_answer_set.html.haml
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
.answer_p
|
||||||
|
|
||||||
|
|
||||||
|
=f.check_box :is_checked, :class => "checkboxe_#{answer.survey_item.id}"
|
||||||
|
-checkboxe_class = "checkboxe_#{answer.survey_item.id}"
|
||||||
|
=f.label :is_checked, answer.label_text
|
||||||
|
|
||||||
|
=f.text_field :content if answer.field_type == 2
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
-if 1 == 2
|
||||||
|
%script
|
||||||
|
= raw '$("input[type=checkbox][class='+checkboxe_class+']").click(function() {'
|
||||||
|
|
||||||
|
= raw 'var bol = $("input[type=checkbox][class='+checkboxe_class+']:checked").length >= 1000;'
|
||||||
|
= raw '$("input[type=checkbox][class='+checkboxe_class+']").not(":checked").attr("disabled",bol);'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
21
app/views/petitions/_form.html.haml
Normal file
21
app/views/petitions/_form.html.haml
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
%h2 Ajouter ma signature.
|
||||||
|
=semantic_form_for @signator, :url => petitions_path, :method => :post do |f|
|
||||||
|
=f.hidden_field :petition_id
|
||||||
|
|
||||||
|
=f.inputs do
|
||||||
|
=f.input :name, :label => "Nom :"
|
||||||
|
=f.input :firstname, :label => "Prénom :"
|
||||||
|
=f.input :address, :label => "Adresse :"
|
||||||
|
=f.input :address2, :label => "Adresse (suite) :"
|
||||||
|
=f.input :cp, :label => "Code postal :"
|
||||||
|
=f.input :city, :label => "Ville :"
|
||||||
|
=f.input :country, :label => "Pays :", :as => :string
|
||||||
|
=f.input :email, :label => "Email :"
|
||||||
|
=f.input :email_confirmation, :label => "Email (confirmation) :"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
%p=f.submit "Envoyer ma signature", :style => "margin-bottom:1em;"
|
||||||
|
|
||||||
|
%p
|
||||||
|
Attention, afin de valider votre signature il faut absolument cliquer sur le lien de validation que vous allez recevoir dans un mail envoyé à l'adresse email que vous avez indiquée.
|
31
app/views/petitions/_question_set.html.haml
Normal file
31
app/views/petitions/_question_set.html.haml
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
|
||||||
|
.question=item.title
|
||||||
|
|
||||||
|
-if item.questions_type == 1
|
||||||
|
.answer_p
|
||||||
|
=f.radio_button :boolean_content, true
|
||||||
|
=f.label :boolean_content_true, "oui"
|
||||||
|
=f.radio_button :boolean_content, false
|
||||||
|
=f.label :boolean_content_false, "non"
|
||||||
|
|
||||||
|
-elsif item.questions_type == 2
|
||||||
|
.answer_p
|
||||||
|
-if item.text_presentation == 2
|
||||||
|
=f.text_area :content, :class => "large"
|
||||||
|
-else
|
||||||
|
=f.text_field :content, :class => "large"
|
||||||
|
-elsif item.questions_type == 3
|
||||||
|
= f.fields_for(:answer_sets) do |f|
|
||||||
|
=f.hidden_field :survey_item_answer_id
|
||||||
|
=render :partial => "survey_sets/answer_set", :locals => {:f => f, :answer => f.object.survey_item_answer}
|
||||||
|
|
||||||
|
-elsif item.questions_type == 4
|
||||||
|
|
||||||
|
-item.answers.each do |answer|
|
||||||
|
.answer_p{:style =>( "display:inline;" if item.display_type == 1)}
|
||||||
|
=f.radio_button :content, answer.label_text
|
||||||
|
=f.label :content, answer.label_text, :value => answer.label_text
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
5
app/views/petitions/confirm.html.haml
Normal file
5
app/views/petitions/confirm.html.haml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
%h1 Votre signature a bien été validée !
|
||||||
|
|
||||||
|
%p Merci d'avoir agi pour la protection de la nature.
|
||||||
|
%p N'hésitez pas à diffuser le lien pour cette action :
|
||||||
|
%p{:style => "text-align:center;"}=link_to petition_url(@petition.slug), petition_url(@petition.slug)
|
7
app/views/petitions/create.html.haml
Normal file
7
app/views/petitions/create.html.haml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
%p Merci beaucoup pour votre soutien
|
||||||
|
|
||||||
|
%h1 ... encore une petite étape pour valider votre signature :
|
||||||
|
|
||||||
|
%p Pour valider votre signature, il faut cliquer sur le lien que vous venez de recevoir dans votre boite mail. Sans validation de votre part, votre signature ne sera pas prise en compte.
|
||||||
|
|
||||||
|
|
6
app/views/petitions/show.html.haml
Normal file
6
app/views/petitions/show.html.haml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
%h1=@petition.name
|
||||||
|
=raw @petition.description
|
||||||
|
|
||||||
|
%hr
|
||||||
|
|
||||||
|
=render :partial => "form"
|
@ -1,6 +0,0 @@
|
|||||||
<h1>Editing tiny_url</h1>
|
|
||||||
|
|
||||||
<%= render 'form' %>
|
|
||||||
|
|
||||||
<%= link_to 'Show', @tiny_url %> |
|
|
||||||
<%= link_to 'Back', tiny_urls_path %>
|
|
6
app/views/tiny_urls/edit.html.haml
Normal file
6
app/views/tiny_urls/edit.html.haml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
%h1 Modifier l'url
|
||||||
|
|
||||||
|
= render 'form'
|
||||||
|
|
||||||
|
= link_to 'Show', @tiny_url
|
||||||
|
= link_to 'Back', tiny_urls_path
|
@ -1,5 +0,0 @@
|
|||||||
<h1>New tiny_url</h1>
|
|
||||||
|
|
||||||
<%= render 'form' %>
|
|
||||||
|
|
||||||
<%= link_to 'Back', tiny_urls_path %>
|
|
6
app/views/tiny_urls/new.html.haml
Normal file
6
app/views/tiny_urls/new.html.haml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
%h1 Ajouter une url
|
||||||
|
|
||||||
|
= render 'form'
|
||||||
|
|
||||||
|
= link_to 'Back', tiny_urls_path
|
||||||
|
|
@ -9,6 +9,7 @@ Survey::Application.routes.draw do
|
|||||||
root :to => "dashboard#index"
|
root :to => "dashboard#index"
|
||||||
resources :admins
|
resources :admins
|
||||||
resources :surveys
|
resources :surveys
|
||||||
|
resources :petitions
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -84,8 +85,15 @@ Survey::Application.routes.draw do
|
|||||||
match 'sondages/:slug.:f' => 'survey_sets#new', :as => :new_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"
|
match 'sondages/:slug/resultats.:f' => 'survey_sets#show', :as => :survey_set, :f => "html"
|
||||||
|
|
||||||
|
match 'petitions/:id.:f' => 'petitions#show', :as => :petition, :f => "html"
|
||||||
|
|
||||||
|
|
||||||
|
resources :petitions do
|
||||||
|
member do
|
||||||
|
get :confirm
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
resources :survey_sets do
|
resources :survey_sets do
|
||||||
collection do
|
collection do
|
||||||
get 'thanks'
|
get 'thanks'
|
||||||
|
12
db/migrate/20130628153912_create_petitions.rb
Normal file
12
db/migrate/20130628153912_create_petitions.rb
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
class CreatePetitions < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
create_table :petitions do |t|
|
||||||
|
t.string :name
|
||||||
|
t.text :description
|
||||||
|
t.string :slug
|
||||||
|
t.boolean :enabled
|
||||||
|
|
||||||
|
t.timestamps
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
20
db/migrate/20130628154116_create_petition_signators.rb
Normal file
20
db/migrate/20130628154116_create_petition_signators.rb
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
class CreatePetitionSignators < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
create_table :petition_signators do |t|
|
||||||
|
t.references :petition
|
||||||
|
t.string :firstname
|
||||||
|
t.string :name
|
||||||
|
t.string :address
|
||||||
|
t.string :address2
|
||||||
|
t.string :cp
|
||||||
|
t.string :city
|
||||||
|
t.string :country
|
||||||
|
t.string :email
|
||||||
|
t.boolean :enabled
|
||||||
|
t.string :token
|
||||||
|
|
||||||
|
t.timestamps
|
||||||
|
end
|
||||||
|
add_index :petition_signators, :petition_id
|
||||||
|
end
|
||||||
|
end
|
29
db/schema.rb
29
db/schema.rb
@ -11,7 +11,7 @@
|
|||||||
#
|
#
|
||||||
# It's strongly recommended to check this file into your version control system.
|
# It's strongly recommended to check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(:version => 20130319095715) do
|
ActiveRecord::Schema.define(:version => 20130628154116) do
|
||||||
|
|
||||||
create_table "admins", :force => true do |t|
|
create_table "admins", :force => true do |t|
|
||||||
t.string "email", :default => "", :null => false
|
t.string "email", :default => "", :null => false
|
||||||
@ -191,6 +191,33 @@ ActiveRecord::Schema.define(:version => 20130319095715) do
|
|||||||
t.datetime "updated_at"
|
t.datetime "updated_at"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
create_table "petition_signators", :force => true do |t|
|
||||||
|
t.integer "petition_id"
|
||||||
|
t.string "firstname"
|
||||||
|
t.string "name"
|
||||||
|
t.string "address"
|
||||||
|
t.string "address2"
|
||||||
|
t.string "cp"
|
||||||
|
t.string "city"
|
||||||
|
t.string "country"
|
||||||
|
t.string "email"
|
||||||
|
t.boolean "enabled"
|
||||||
|
t.string "token"
|
||||||
|
t.datetime "created_at", :null => false
|
||||||
|
t.datetime "updated_at", :null => false
|
||||||
|
end
|
||||||
|
|
||||||
|
add_index "petition_signators", ["petition_id"], :name => "index_petition_signators_on_petition_id"
|
||||||
|
|
||||||
|
create_table "petitions", :force => true do |t|
|
||||||
|
t.string "name"
|
||||||
|
t.text "description"
|
||||||
|
t.string "slug"
|
||||||
|
t.boolean "enabled"
|
||||||
|
t.datetime "created_at", :null => false
|
||||||
|
t.datetime "updated_at", :null => false
|
||||||
|
end
|
||||||
|
|
||||||
create_table "question_sets", :force => true do |t|
|
create_table "question_sets", :force => true do |t|
|
||||||
t.integer "survey_item_id"
|
t.integer "survey_item_id"
|
||||||
t.integer "survey_set_id"
|
t.integer "survey_set_id"
|
||||||
|
25
test/fixtures/petition_signators.yml
vendored
Normal file
25
test/fixtures/petition_signators.yml
vendored
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
|
||||||
|
|
||||||
|
one:
|
||||||
|
petition:
|
||||||
|
firstname: MyString
|
||||||
|
name: MyString
|
||||||
|
address: MyString
|
||||||
|
address2: MyString
|
||||||
|
cp: MyString
|
||||||
|
city: MyString
|
||||||
|
country: MyString
|
||||||
|
email: MyString
|
||||||
|
confirmed: false
|
||||||
|
|
||||||
|
two:
|
||||||
|
petition:
|
||||||
|
firstname: MyString
|
||||||
|
name: MyString
|
||||||
|
address: MyString
|
||||||
|
address2: MyString
|
||||||
|
cp: MyString
|
||||||
|
city: MyString
|
||||||
|
country: MyString
|
||||||
|
email: MyString
|
||||||
|
confirmed: false
|
13
test/fixtures/petitions.yml
vendored
Normal file
13
test/fixtures/petitions.yml
vendored
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
|
||||||
|
|
||||||
|
one:
|
||||||
|
name: MyString
|
||||||
|
description: MyText
|
||||||
|
slug: MyString
|
||||||
|
enabled: false
|
||||||
|
|
||||||
|
two:
|
||||||
|
name: MyString
|
||||||
|
description: MyText
|
||||||
|
slug: MyString
|
||||||
|
enabled: false
|
7
test/unit/petition_signator_test.rb
Normal file
7
test/unit/petition_signator_test.rb
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
require 'test_helper'
|
||||||
|
|
||||||
|
class PetitionSignatorTest < ActiveSupport::TestCase
|
||||||
|
# test "the truth" do
|
||||||
|
# assert true
|
||||||
|
# end
|
||||||
|
end
|
7
test/unit/petition_test.rb
Normal file
7
test/unit/petition_test.rb
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
require 'test_helper'
|
||||||
|
|
||||||
|
class PetitionTest < ActiveSupport::TestCase
|
||||||
|
# test "the truth" do
|
||||||
|
# assert true
|
||||||
|
# end
|
||||||
|
end
|
Loading…
x
Reference in New Issue
Block a user