suite
This commit is contained in:
parent
89940776ff
commit
78af6420c1
71
app/controllers/admin/contact_actions_controller.rb
Normal file
71
app/controllers/admin/contact_actions_controller.rb
Normal file
@ -0,0 +1,71 @@
|
||||
class Admin::ContactActionsController < ApplicationController
|
||||
layout "admin"
|
||||
|
||||
before_filter :auth_admin
|
||||
|
||||
def index
|
||||
|
||||
@contact_actions = ContactAction.order("created_at DESC").all
|
||||
end
|
||||
|
||||
|
||||
def show
|
||||
@contact_action = ContactAction.find(params[:id])
|
||||
|
||||
@contact_action_actions = @contact_action.contact_action_actions
|
||||
|
||||
end
|
||||
|
||||
|
||||
def new
|
||||
@contact_action = ContactAction.new(:contact_id => params[:contact_id],:admin_id => current_admin.id, :action_at => Time.now)
|
||||
|
||||
end
|
||||
|
||||
def edit
|
||||
@contact_action = ContactAction.find(params[:id])
|
||||
@contact_action.action_at = @contact_action.action_at.in_time_zone("Paris")
|
||||
end
|
||||
|
||||
def create
|
||||
@contact_action = ContactAction.new(contact_action_params)
|
||||
@contact = @contact_action.contact
|
||||
|
||||
if @contact_action.save
|
||||
@contact_actions = @contact.contact_actions.order("action_at DESC").all
|
||||
else
|
||||
render :action => "new"
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
@contact_action = ContactAction.find(params[:id])
|
||||
@contact = @contact_action.contact
|
||||
|
||||
if @contact_action.update_attributes(contact_action_params)
|
||||
@contact_actions = @contact.contact_actions.order("action_at DESC").all
|
||||
else
|
||||
render :action => "edit"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
def destroy
|
||||
@contact_action = ContactAction.find(params[:id])
|
||||
|
||||
@contact_action.destroy
|
||||
@contact = @contact_action.contact
|
||||
@contact_actions = @contact.contact_actions.order("action_at DESC").all
|
||||
|
||||
end
|
||||
|
||||
private
|
||||
def contact_action_params
|
||||
params.require(:contact_action).permit!
|
||||
end
|
||||
|
||||
|
||||
|
||||
end
|
60
app/controllers/admin/contact_files_controller.rb
Normal file
60
app/controllers/admin/contact_files_controller.rb
Normal file
@ -0,0 +1,60 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
class Admin::ContactFilesController < ApplicationController
|
||||
before_filter :auth_admin
|
||||
|
||||
|
||||
layout "admin"
|
||||
|
||||
def index
|
||||
params[:file_folder_id] = params[:file_folder_id] || 1
|
||||
|
||||
@file_folder = FileFolder.find(params[:file_folder_id])
|
||||
@file_folders = FileFolder.all(:order => :name)
|
||||
@contact_files = DataFile.all(:order => "created_at DESC", :conditions => {:file_folder_id => @file_folder.id})
|
||||
@contact_file = DataFile.new(:file_folder_id => @file_folder.id)
|
||||
if request.xhr?
|
||||
render :layout => false
|
||||
end
|
||||
end
|
||||
|
||||
def new
|
||||
end
|
||||
|
||||
def edit
|
||||
end
|
||||
|
||||
def create
|
||||
@contact_file_create = true
|
||||
@contact_file = ContactFile.new(:name => params[:files].original_filename, :contact_id => params[:contact_id], :file =>params[:files])
|
||||
|
||||
if @contact_file.save
|
||||
|
||||
else
|
||||
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
def update
|
||||
@contact_file = DataFile.find(params[:id])
|
||||
if @contact_file.update_attributes(params.require(:contact_file).permit!)
|
||||
|
||||
else
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
@contact_file = DataFile.find(params[:id])
|
||||
@contact_file.destroy
|
||||
|
||||
flash[:notice] = "Le fichier à bien été supprimée."
|
||||
end
|
||||
|
||||
def show
|
||||
@contact_file = DataFile.find(params[:id])
|
||||
|
||||
end
|
||||
|
||||
end
|
135
app/controllers/admin/contacts_controller.rb
Executable file → Normal file
135
app/controllers/admin/contacts_controller.rb
Executable file → Normal file
@ -1,22 +1,119 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
|
||||
class Admin::ContactsController < ApplicationController
|
||||
before_filter :auth_admin
|
||||
|
||||
layout "admin"
|
||||
|
||||
|
||||
|
||||
|
||||
def index
|
||||
@contacts = Contact.where(:raison_id => params[:raison_id].to_i).order("created_at DESC")
|
||||
end
|
||||
|
||||
|
||||
def show
|
||||
@contact = Contact.find(params[:id])
|
||||
end
|
||||
|
||||
|
||||
layout "admin"
|
||||
|
||||
before_filter :auth_admin, :except => :api
|
||||
skip_before_filter :verify_authenticity_token, :only => :api
|
||||
def index
|
||||
|
||||
@contacts = Contact.order("created_at DESC")
|
||||
|
||||
if params[:status]
|
||||
@contacts = @contacts.where(:contact_status => params[:status])
|
||||
else
|
||||
@contacts = @contacts.where(:contact_status => "En cours")
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
def show
|
||||
@contact = Contact.find(params[:id])
|
||||
|
||||
if @contact.readed != true
|
||||
@contact.readed = true
|
||||
@contact.save
|
||||
end
|
||||
|
||||
@contact_actions = @contact.contact_actions
|
||||
|
||||
end
|
||||
|
||||
|
||||
def new
|
||||
@contact = Contact.new
|
||||
|
||||
end
|
||||
|
||||
def edit
|
||||
@contact = Contact.find(params[:id])
|
||||
|
||||
end
|
||||
|
||||
def create
|
||||
@contact = Contact.new(contact_params)
|
||||
|
||||
if @contact.save
|
||||
@contacts = Contact.order("created_at DESC").all
|
||||
else
|
||||
render :action => "new"
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
@contact = Contact.find(params[:id])
|
||||
|
||||
if @contact.update_attributes(contact_params)
|
||||
|
||||
else
|
||||
render :action => "edit"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
def destroy
|
||||
@contact = Contact.find(params[:id])
|
||||
|
||||
@contact.destroy if @contact != @current_contact
|
||||
|
||||
end
|
||||
|
||||
|
||||
def api
|
||||
|
||||
contact_api_params = {
|
||||
:name => params[:name],
|
||||
|
||||
:firstname => params[:firstname],
|
||||
|
||||
:corporate => params[:corporate],
|
||||
|
||||
:email => params[:email],
|
||||
|
||||
:phone => params[:phone],
|
||||
|
||||
:message => params[:message],
|
||||
|
||||
:provenance_id => params[:provenance_id],
|
||||
|
||||
:contact_status => "En cours"
|
||||
|
||||
}
|
||||
|
||||
@contact = Contact.new(contact_api_params)
|
||||
|
||||
if @contact.save(:validate => false)
|
||||
render :inline => "ok"
|
||||
puts "OK"
|
||||
else
|
||||
render :inline => "erreur"
|
||||
puts "ERREUR"
|
||||
@contact.errors.each do |error|
|
||||
puts error
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
private
|
||||
def contact_params
|
||||
params.require(:contact).permit!
|
||||
end
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
49
app/models/contact.old.rb
Executable file
49
app/models/contact.old.rb
Executable file
@ -0,0 +1,49 @@
|
||||
class Contact < ActiveRecord::Base
|
||||
|
||||
|
||||
|
||||
has_many :data_files, :through => :document_orders
|
||||
|
||||
|
||||
|
||||
validates :name, :presence => true
|
||||
validates :firstname, :presence => true
|
||||
|
||||
|
||||
# validates :address, :presence => true, :if => :postal_need
|
||||
# validates :cp, :presence => true, :if => :postal_need
|
||||
# validates :city, :presence => true, :if => :postal_need
|
||||
# validates :country, :presence => true, :if => :postal_need
|
||||
|
||||
|
||||
validates :email, :presence => true, :format => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i, :if => :email_need
|
||||
validates :message, :presence => true, :if => :message_need
|
||||
|
||||
#raison_id
|
||||
# 1 => contact classique
|
||||
|
||||
|
||||
def message_need
|
||||
true if raison_id != 3
|
||||
end
|
||||
|
||||
def email_need
|
||||
if raison_id == 1
|
||||
true
|
||||
else
|
||||
false
|
||||
end
|
||||
end
|
||||
|
||||
def postal_need
|
||||
if raison_id == 2 or raison_id == 3
|
||||
true
|
||||
else
|
||||
false
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
end
|
48
app/models/contact.rb
Executable file → Normal file
48
app/models/contact.rb
Executable file → Normal file
@ -1,49 +1,21 @@
|
||||
class Contact < ActiveRecord::Base
|
||||
|
||||
|
||||
|
||||
has_many :data_files, :through => :document_orders
|
||||
|
||||
|
||||
|
||||
belongs_to :admin
|
||||
has_many :contact_actions
|
||||
validates :name, :presence => true
|
||||
validates :firstname, :presence => true
|
||||
|
||||
validates :email, :presence => true, :format => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i
|
||||
#validates :message, :presence => true
|
||||
validates :message, :presence => true
|
||||
|
||||
# validates :address, :presence => true, :if => :postal_need
|
||||
# validates :cp, :presence => true, :if => :postal_need
|
||||
# validates :city, :presence => true, :if => :postal_need
|
||||
# validates :country, :presence => true, :if => :postal_need
|
||||
has_many :contact_files
|
||||
|
||||
|
||||
validates :email, :presence => true, :format => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i, :if => :email_need
|
||||
validates :message, :presence => true, :if => :message_need
|
||||
|
||||
#raison_id
|
||||
# 1 => contact classique
|
||||
|
||||
|
||||
def message_need
|
||||
true if raison_id != 3
|
||||
before_validation do
|
||||
self.contact_status = "En cours" if !self.contact_status?
|
||||
|
||||
end
|
||||
|
||||
def email_need
|
||||
if raison_id == 1
|
||||
true
|
||||
else
|
||||
false
|
||||
end
|
||||
end
|
||||
STATUS = ["En cours","A abouti","Offre à faire","Pas de suite à donner", "Offre refusée"]
|
||||
|
||||
def postal_need
|
||||
if raison_id == 2 or raison_id == 3
|
||||
true
|
||||
else
|
||||
false
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
5
app/models/contact_action.rb
Normal file
5
app/models/contact_action.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class ContactAction < ActiveRecord::Base
|
||||
belongs_to :contact
|
||||
belongs_to :admin
|
||||
belongs_to :contact_action_pattern
|
||||
end
|
26
app/models/contact_file.rb
Normal file
26
app/models/contact_file.rb
Normal file
@ -0,0 +1,26 @@
|
||||
class ContactFile < ActiveRecord::Base
|
||||
mount_uploader :file, ContactFileUploader
|
||||
|
||||
belongs_to :admin
|
||||
belongs_to :contact
|
||||
|
||||
def file_type
|
||||
|
||||
|
||||
mime = `file --mime -br "#{self.file.path}"`.strip.split(';')[0]
|
||||
mime
|
||||
|
||||
end
|
||||
|
||||
|
||||
before_create { generate_token() }
|
||||
|
||||
def generate_token()
|
||||
begin
|
||||
self[:token] = SecureRandom.urlsafe_base64
|
||||
end while ContactFile.exists?(:token => self[:token])
|
||||
end
|
||||
|
||||
|
||||
|
||||
end
|
@ -29,6 +29,12 @@
|
||||
|
||||
= f.input :password_confirmation, :label => "Confirmation :"
|
||||
|
||||
= f.input :color, :label => "Couleur pour identification dans contacts"
|
||||
|
||||
= f.input :cms, :label => "Possibilité de gérer le contenu du site ?"
|
||||
|
||||
|
||||
= f.input :contact_role, :label => "Possibilité de gérer les contacts ?"
|
||||
|
||||
|
||||
|
||||
|
27
app/views/admin/contact_actions/_contact_action.html.haml
Normal file
27
app/views/admin/contact_actions/_contact_action.html.haml
Normal file
@ -0,0 +1,27 @@
|
||||
.contact_action#contact_action{:id => contact_action.id, :style => ("border-color:#{contact_action.admin.color};" if contact_action.admin)}
|
||||
%p.name
|
||||
|
||||
-if contact_action.admin
|
||||
%span{:style => "background:#{contact_action.admin.color};padding:5px 10px;color:white"}
|
||||
=contact_action.admin.username
|
||||
%p
|
||||
=l contact_action.action_at
|
||||
|
||||
%p
|
||||
%strong
|
||||
-if contact_action.contact_action_pattern
|
||||
=contact_action.contact_action_pattern.title
|
||||
|
||||
%p
|
||||
= contact_action.action_message
|
||||
|
||||
.actions
|
||||
|
||||
|
||||
= link_to i(:"trash-o"), [:admin, contact_action], :confirm => 'Voulez-vous vraiment supprimer cette action ?', :method => :delete, :remote => true
|
||||
|
||||
= link_to i(:pencil), edit_admin_contact_action_path(contact_action), :remote => true
|
||||
|
||||
|
||||
|
||||
|
15
app/views/admin/contact_actions/_form.haml
Normal file
15
app/views/admin/contact_actions/_form.haml
Normal file
@ -0,0 +1,15 @@
|
||||
= semantic_form_for [:admin, @contact_action], :remote => true do |f|
|
||||
.content
|
||||
=f.hidden_field :contact_id
|
||||
=f.inputs do
|
||||
|
||||
= f.input :action_at, :label => "Date", :as =>:qi_datetime_picker
|
||||
= f.input :admin_id, :label => "Par ?", :collection => Admin.where(:contact_role => true).all.map{|u|[ u.firstname.to_s+" "+u.name.to_s, u.id]}, :as => :select
|
||||
|
||||
= f.input :action_message, :label => "Message"
|
||||
|
||||
|
||||
.actions
|
||||
=f.submit "Sauvegarder", :class => "btn btn-primary"
|
||||
|
||||
|
63
app/views/admin/contact_actions/_show.html.haml
Normal file
63
app/views/admin/contact_actions/_show.html.haml
Normal file
@ -0,0 +1,63 @@
|
||||
|
||||
%table.table
|
||||
%tr
|
||||
%td
|
||||
Date
|
||||
%td
|
||||
=l @contact.created_at
|
||||
%tr
|
||||
%td
|
||||
Nom
|
||||
%td
|
||||
=@contact.name
|
||||
%tr
|
||||
%td
|
||||
Email
|
||||
%td
|
||||
=@contact.email
|
||||
%tr
|
||||
%td
|
||||
Téléphone
|
||||
%td
|
||||
=@contact.tel
|
||||
%tr
|
||||
%td
|
||||
Lieu
|
||||
%td
|
||||
=@contact.place
|
||||
|
||||
|
||||
|
||||
%hr
|
||||
=simple_format @contact.message
|
||||
%hr
|
||||
|
||||
|
||||
%table.table
|
||||
%tr
|
||||
%td
|
||||
Adresse
|
||||
%td
|
||||
=@contact.address
|
||||
%tr
|
||||
%td
|
||||
Adresse suite
|
||||
%td
|
||||
=@contact.address2
|
||||
%tr
|
||||
%td
|
||||
Ville
|
||||
%td
|
||||
=@contact.cp
|
||||
=@contact.city
|
||||
|
||||
%tr
|
||||
%td
|
||||
Pays
|
||||
|
||||
%td
|
||||
=@contact.country
|
||||
|
||||
%hr
|
||||
=simple_format @contact.notes
|
||||
%hr
|
2
app/views/admin/contact_actions/create.js.erb
Normal file
2
app/views/admin/contact_actions/create.js.erb
Normal file
@ -0,0 +1,2 @@
|
||||
$('#contact_actions').html("<%= escape_javascript(render(@contact_actions))%>");
|
||||
close_pane_hover();
|
1
app/views/admin/contact_actions/destroy.js.erb
Normal file
1
app/views/admin/contact_actions/destroy.js.erb
Normal file
@ -0,0 +1 @@
|
||||
$('#contact_action_<%= @contact_action.id %>').remove();
|
4
app/views/admin/contact_actions/edit.haml
Normal file
4
app/views/admin/contact_actions/edit.haml
Normal file
@ -0,0 +1,4 @@
|
||||
.container
|
||||
%h1 Modifier une fiche étudiant
|
||||
|
||||
=render :partial => "form"
|
1
app/views/admin/contact_actions/edit.js.erb
Normal file
1
app/views/admin/contact_actions/edit.js.erb
Normal file
@ -0,0 +1 @@
|
||||
show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",700,900);
|
43
app/views/admin/contact_actions/index.html.haml
Normal file
43
app/views/admin/contact_actions/index.html.haml
Normal file
@ -0,0 +1,43 @@
|
||||
= link_to 'Ajouter une action', new_admin_contact_action_path, :class => "btn btn-primary", :style => "float:right;", :remote => true
|
||||
|
||||
|
||||
%h1 Liste des contact_actions
|
||||
|
||||
|
||||
%table.table.table-hover
|
||||
%thead#Admin_rows_header.rows_header
|
||||
|
||||
%tr
|
||||
%td
|
||||
%td
|
||||
Date
|
||||
%td
|
||||
Nom
|
||||
%td
|
||||
Coordonnées
|
||||
|
||||
|
||||
%td Géré par
|
||||
|
||||
%td{:style => "width:150px"}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
%tbody#admin_rows.rows
|
||||
|
||||
=render @contact_actions
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
2
app/views/admin/contact_actions/index.js.erb
Normal file
2
app/views/admin/contact_actions/index.js.erb
Normal file
@ -0,0 +1,2 @@
|
||||
|
||||
$('#Admin_index_block').replaceWith("<%= escape_javascript(render(:partial => "index_block")) %>");
|
4
app/views/admin/contact_actions/new.haml
Normal file
4
app/views/admin/contact_actions/new.haml
Normal file
@ -0,0 +1,4 @@
|
||||
.container
|
||||
%h1 Ajouter une action
|
||||
|
||||
=render :partial => "form"
|
1
app/views/admin/contact_actions/new.js.erb
Normal file
1
app/views/admin/contact_actions/new.js.erb
Normal file
@ -0,0 +1 @@
|
||||
show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",700,900);
|
6
app/views/admin/contact_actions/show.html.haml
Normal file
6
app/views/admin/contact_actions/show.html.haml
Normal file
@ -0,0 +1,6 @@
|
||||
= link_to i(:pencil), edit_admin_contact_path(@contact), :remote => true
|
||||
= link_to "retour", admin_contacts_path(), :class => "btn btn-primary"
|
||||
#show=render :partial => "show"
|
||||
|
||||
|
||||
|
2
app/views/admin/contact_actions/update.js.erb
Normal file
2
app/views/admin/contact_actions/update.js.erb
Normal file
@ -0,0 +1,2 @@
|
||||
$('#contact_actions').html("<%= escape_javascript(render(@contact_actions))%>");
|
||||
close_pane_hover();
|
18
app/views/admin/contact_files/_contact_file.html.haml
Normal file
18
app/views/admin/contact_files/_contact_file.html.haml
Normal file
@ -0,0 +1,18 @@
|
||||
- if contact_file.file?
|
||||
|
||||
|
||||
%tr#contact_file.contact_file{:id => contact_file.id, :class => ("new" if @contact_file_create)}
|
||||
|
||||
%td{:style => "width:32px;text-align:center;"}
|
||||
-ext = File.extname(contact_file.file.path)[1..-1]
|
||||
=image_tag "file_types/"+ext+".png", :style => "height:30px;"
|
||||
%td
|
||||
=contact_file.name
|
||||
%td{:style => "width:300px;"}
|
||||
|
||||
|
||||
=contact_file.file_type
|
||||
%td{:style => "width:100px;"}
|
||||
= link_to i(:"trash-o"), admin_contact_file_path(:id => contact_file.id, :manager => params[:manager], :multiple => params[:multiple]), :data => {:confirm => 'Voulez-vous vraiment supprimer cette pièce jointe ?'}, :method => :delete, :remote => true
|
||||
=link_to i(:"download"), contact_file.file.url
|
||||
|
4
app/views/admin/contact_files/create.js.erb
Normal file
4
app/views/admin/contact_files/create.js.erb
Normal file
@ -0,0 +1,4 @@
|
||||
$("#contact_files").prepend("<%= escape_javascript(render(@contact_file)) %>");
|
||||
$('#contact_file_<%=@contact_file.id %>').addClass('active');
|
||||
|
||||
<%= flash_js %>
|
@ -1,8 +1,42 @@
|
||||
%tr
|
||||
%tr.vertical_center.contact#contact{:id => contact.id}
|
||||
|
||||
%td
|
||||
-if contact.urgent
|
||||
%span{:style => "display:inline-block;width:10px;height:10px;border-radius:50%;background:red;"}
|
||||
%td{:style => "vertical-align:middle;"}
|
||||
-if !contact.readed
|
||||
%span{:style => "display:inline-block;width:10px;height:10px;border-radius:50%;background:#00B3EC"}
|
||||
|
||||
%td{:style => "vertical-align:middle;"}
|
||||
-if contact.provenance_id
|
||||
=Category.find(contact.provenance_id).name
|
||||
|
||||
%td
|
||||
=l contact.created_at
|
||||
%td
|
||||
=contact.firstname
|
||||
=contact.name
|
||||
%td
|
||||
= link_to i(:eye), admin_contact_path(contact)
|
||||
=contact.cp
|
||||
=contact.city
|
||||
%td
|
||||
=contact.small_comment
|
||||
|
||||
%td
|
||||
|
||||
-if contact.admin
|
||||
|
||||
%span{:style => "background:#{contact.admin.color};padding:5px 10px;"}
|
||||
=contact.admin.firstname
|
||||
=contact.admin.name
|
||||
%td.actions{:style => "width:430px;text-align:right;"}
|
||||
|
||||
|
||||
= link_to ic(:"trash-o"), [:admin, contact], :confirm => 'Voulez-vous vraiment supprimer cet utilisateur ?', :method => :delete, :remote => true, :class => "btn btn-danger"
|
||||
|
||||
= link_to ic(:pencil)+" modifier / attribuer la fiche", edit_admin_contact_path(contact), :remote => true, :class => "btn btn-warning"
|
||||
|
||||
= link_to ic(:eye)+ " détail de la fiche ", [:admin, contact], :class => "btn btn-primary"
|
||||
|
||||
|
||||
|
||||
|
||||
|
39
app/views/admin/contacts/_form.haml
Normal file
39
app/views/admin/contacts/_form.haml
Normal file
@ -0,0 +1,39 @@
|
||||
= semantic_form_for [:admin, @contact], :remote => true do |f|
|
||||
.content
|
||||
=f.inputs do
|
||||
=# f.input :provenance_id, :label => "Provenance :", :collection => Category.all.map{|u|[ u.name, u.id]}, :as => :select , :include_blank => false
|
||||
= f.input :contact_status, :label => "Status :", :collection => Contact::STATUS, :include_blank => false
|
||||
= f.input :urgent, :label => "Urgent ?"
|
||||
= f.input :readed, :label => "Lu ?"
|
||||
= f.input :admin_id, :label => "Géré par ?", :collection => Admin.where(:contact_role => true).all.map{|u|[ u.firstname.to_s+" "+u.name.to_s, u.id]}, :as => :select
|
||||
=#.where(:contact_role => true)
|
||||
= f.input :archived, :label => "Archivé ?"
|
||||
= f.input :corporate, :label => "Organisation"
|
||||
= f.input :name, :label => "Nom"
|
||||
= f.input :firstname, :label => "Prénom"
|
||||
= f.input :email, :label => "Email"
|
||||
= f.input :phone, :label => "Téléphone"
|
||||
|
||||
|
||||
= f.input :message, :label => "Message"
|
||||
|
||||
|
||||
|
||||
= f.input :small_comment, :label => "Commentaire court"
|
||||
|
||||
= f.input :notes, :label => "Notes"
|
||||
|
||||
= 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
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
.actions
|
||||
=f.submit "Sauvegarder", :class => "btn btn-primary"
|
||||
|
||||
|
70
app/views/admin/contacts/_show.html.haml
Normal file
70
app/views/admin/contacts/_show.html.haml
Normal file
@ -0,0 +1,70 @@
|
||||
|
||||
|
||||
%table.table
|
||||
%tr
|
||||
%td
|
||||
Date
|
||||
%td
|
||||
=l @contact.created_at
|
||||
%tr
|
||||
%td
|
||||
Organisation
|
||||
%td
|
||||
=@contact.corporate
|
||||
%tr
|
||||
%td
|
||||
Prénom
|
||||
%td
|
||||
=@contact.firstname
|
||||
%tr
|
||||
%td
|
||||
Nom
|
||||
%td
|
||||
=@contact.name
|
||||
%tr
|
||||
%td
|
||||
Email
|
||||
%td
|
||||
=@contact.email
|
||||
%tr
|
||||
%td
|
||||
Téléphone
|
||||
%td
|
||||
=@contact.phone
|
||||
|
||||
|
||||
|
||||
|
||||
%hr
|
||||
=simple_format @contact.message
|
||||
%hr
|
||||
|
||||
|
||||
%table.table
|
||||
%tr
|
||||
%td
|
||||
Adresse
|
||||
%td
|
||||
=@contact.address
|
||||
%tr
|
||||
%td
|
||||
Adresse suite
|
||||
%td
|
||||
=@contact.address2
|
||||
%tr
|
||||
%td
|
||||
Ville
|
||||
%td
|
||||
=@contact.cp
|
||||
=@contact.city
|
||||
|
||||
%tr
|
||||
%td
|
||||
Pays
|
||||
|
||||
%td
|
||||
=@contact.country
|
||||
|
||||
%hr
|
||||
=simple_format @contact.notes
|
||||
%hr
|
2
app/views/admin/contacts/create.js.erb
Normal file
2
app/views/admin/contacts/create.js.erb
Normal file
@ -0,0 +1,2 @@
|
||||
$('#admin_rows').html("<%= escape_javascript(render(@contacts))%>");
|
||||
close_pane_hover();
|
1
app/views/admin/contacts/destroy.js.erb
Normal file
1
app/views/admin/contacts/destroy.js.erb
Normal file
@ -0,0 +1 @@
|
||||
$('#contact_<%= @contact.id %>').remove();
|
4
app/views/admin/contacts/edit.haml
Normal file
4
app/views/admin/contacts/edit.haml
Normal file
@ -0,0 +1,4 @@
|
||||
.container
|
||||
%h1 Modifier une fiche étudiant
|
||||
|
||||
=render :partial => "form"
|
1
app/views/admin/contacts/edit.js.erb
Normal file
1
app/views/admin/contacts/edit.js.erb
Normal file
@ -0,0 +1 @@
|
||||
show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",700,900);
|
75
app/views/admin/contacts/index.html.haml
Executable file → Normal file
75
app/views/admin/contacts/index.html.haml
Executable file → Normal file
@ -1,20 +1,67 @@
|
||||
|
||||
|
||||
.qi_header
|
||||
%h1
|
||||
.right= link_to 'Ajouter un contact', new_admin_contact_path, :class => "btn btn-primary", :style => "float:right;", :remote => true
|
||||
%h1
|
||||
Contacts
|
||||
%span
|
||||
Demande de docs
|
||||
|
||||
|
||||
|
||||
|
||||
.qi_row
|
||||
|
||||
|
||||
.qi_pannel.qi_plain.padding
|
||||
%table.table
|
||||
%tr
|
||||
%th Date
|
||||
%th
|
||||
Nom
|
||||
%th
|
||||
.header
|
||||
|
||||
|
||||
|
||||
|
||||
%p
|
||||
-Contact::STATUS.each do |status|
|
||||
|
||||
=render @contacts
|
||||
=link_to status, admin_contacts_path(:status => status)
|
||||
|
||||
|
||||
:scss
|
||||
table{
|
||||
td{
|
||||
vertical-align:middle !important;
|
||||
}
|
||||
}
|
||||
%table.table.table-hover
|
||||
%thead#Admin_rows_header.rows_header
|
||||
|
||||
%tr
|
||||
%td
|
||||
%td
|
||||
%td
|
||||
%td
|
||||
Date
|
||||
%td
|
||||
Nom
|
||||
%td
|
||||
Coordonnées
|
||||
%td Commentaire
|
||||
|
||||
|
||||
%td Géré par
|
||||
|
||||
%td{:style => "width:150px"}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
%tbody#admin_rows.rows
|
||||
|
||||
=render @contacts
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
2
app/views/admin/contacts/index.js.erb
Normal file
2
app/views/admin/contacts/index.js.erb
Normal file
@ -0,0 +1,2 @@
|
||||
|
||||
$('#Admin_index_block').replaceWith("<%= escape_javascript(render(:partial => "index_block")) %>");
|
4
app/views/admin/contacts/new.haml
Normal file
4
app/views/admin/contacts/new.haml
Normal file
@ -0,0 +1,4 @@
|
||||
.container
|
||||
%h1 Ajouter une fiche étudiant
|
||||
|
||||
=render :partial => "form"
|
1
app/views/admin/contacts/new.js.erb
Normal file
1
app/views/admin/contacts/new.js.erb
Normal file
@ -0,0 +1 @@
|
||||
show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",700,900);
|
109
app/views/admin/contacts/show.html.haml
Executable file → Normal file
109
app/views/admin/contacts/show.html.haml
Executable file → Normal file
@ -1,87 +1,50 @@
|
||||
|
||||
|
||||
.qi_header
|
||||
.right
|
||||
= link_to ic(:pencil)+" modifier / attribuer la fiche", edit_admin_contact_path(@contact), :remote => true, :class => "btn btn-warning"
|
||||
%h1
|
||||
=link_to "Contacts", admin_contacts_path()
|
||||
%span
|
||||
Détails
|
||||
|
||||
|
||||
|
||||
Demande de contact
|
||||
|
||||
|
||||
|
||||
.qi_row
|
||||
|
||||
|
||||
.qi_pannel.qi_plain.padding
|
||||
|
||||
|
||||
%p
|
||||
%strong
|
||||
-if @contact.raison_id == 1
|
||||
Demande de contact générale
|
||||
-elsif @contact.raison_id == 2
|
||||
Demande de contact pour legs, assurance, donation
|
||||
.header
|
||||
|
||||
|
||||
%table
|
||||
%tr
|
||||
%td Civilité
|
||||
%td=@contact.civilite
|
||||
%tr
|
||||
%td Nom
|
||||
%td=@contact.name
|
||||
%tr
|
||||
%td Prénom
|
||||
%td=@contact.firstname
|
||||
%tr
|
||||
%td Adresse
|
||||
%td=@contact.address
|
||||
%tr
|
||||
%td Code postal
|
||||
%td=@contact.cp
|
||||
%tr
|
||||
%td Ville
|
||||
%td=@contact.city
|
||||
%tr
|
||||
%td Pays
|
||||
%td=@contact.country
|
||||
%tr
|
||||
%td Email
|
||||
%td=@contact.email
|
||||
%tr
|
||||
%td Téléphone
|
||||
%td=@contact.phone
|
||||
|
||||
|
||||
#show=render :partial => "show"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
= link_to 'Ajouter une action', new_admin_contact_action_path(:contact_id => @contact.id), :class => "btn btn-success", :style => "float:right;", :remote => true
|
||||
|
||||
%h2 Interactions
|
||||
|
||||
|
||||
%hr
|
||||
=simple_format @contact.message
|
||||
|
||||
|
||||
|
||||
%hr
|
||||
#contact_actions
|
||||
=render @contact_actions
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
.row
|
||||
-@contact.document_orders.each do |document_order|
|
||||
-data_file = document_order.data_file
|
||||
-if data_file.image_file
|
||||
|
||||
.data_file#data_file{:id => data_file.token}
|
||||
=image_tag data_file.image_file.file.large.medium.small.thumb.url
|
||||
|
||||
=data_file.title
|
||||
%br
|
||||
Quantité :
|
||||
=document_order.qte
|
||||
%br
|
||||
%br
|
||||
.clear{:style => "clear:both;"}
|
||||
|
||||
|
||||
:scss
|
||||
.data_file{
|
||||
img{
|
||||
float:left;
|
||||
width:70px;
|
||||
margin-right:5px;
|
||||
|
||||
}
|
||||
margin-bottom:10px;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
4
app/views/admin/contacts/update.js.erb
Normal file
4
app/views/admin/contacts/update.js.erb
Normal file
@ -0,0 +1,4 @@
|
||||
$('#show').html("<%= escape_javascript(render(:partial => "show"))%>");
|
||||
$('#contact_<%= @contact.id %>').replaceWith("<%= escape_javascript(render(@contact))%>");
|
||||
|
||||
close_pane_hover();
|
@ -33,51 +33,53 @@
|
||||
|
||||
#bs-example-navbar-collapse-1.collapse.navbar-collapse
|
||||
%ul.nav.navbar-nav
|
||||
|
||||
%li.dropdown
|
||||
%a.dropdown-toggle{"data-toggle" => "dropdown", href: "#"}
|
||||
Menus
|
||||
%b.caret
|
||||
-if current_admin.cms
|
||||
%li.dropdown
|
||||
%a.dropdown-toggle{"data-toggle" => "dropdown", href: "#"}
|
||||
Menus
|
||||
%b.caret
|
||||
|
||||
%ul.dropdown-menu
|
||||
-Menu.all.each do |menu|
|
||||
%li= link_to menu.name, admin_menu_items_path(:menu_id => menu.id)
|
||||
%ul.dropdown-menu
|
||||
-Menu.all.each do |menu|
|
||||
%li= link_to menu.name, admin_menu_items_path(:menu_id => menu.id)
|
||||
|
||||
|
||||
%li.dropdown
|
||||
%a{:href => "#", :class => "dropdown-toggle", :data => {:toggle => "dropdown"}}
|
||||
Blog
|
||||
%b.caret
|
||||
%ul.dropdown-menu
|
||||
%li.dropdown
|
||||
%a{:href => "#", :class => "dropdown-toggle", :data => {:toggle => "dropdown"}}
|
||||
Blog
|
||||
%b.caret
|
||||
%ul.dropdown-menu
|
||||
|
||||
%li= link_to "Articles", admin_articles_path
|
||||
%li= link_to "Commentaires", admin_comments_path
|
||||
%li= link_to "Catégories", admin_categories_path
|
||||
%li= link_to "Tags", admin_tags_path
|
||||
%li= link_to "Auteurs", admin_article_authors_path
|
||||
%li= link_to "Articles", admin_articles_path
|
||||
%li= link_to "Commentaires", admin_comments_path
|
||||
%li= link_to "Catégories", admin_categories_path
|
||||
%li= link_to "Tags", admin_tags_path
|
||||
%li= link_to "Auteurs", admin_article_authors_path
|
||||
|
||||
%li.dropdown
|
||||
%a{:href => "#", :class => "dropdown-toggle", :data => {:toggle => "dropdown"}}
|
||||
Médias
|
||||
%b.caret
|
||||
%ul.dropdown-menu
|
||||
%li= link_to "Images", admin_image_files_path
|
||||
%li= link_to "Fichiers", admin_data_files_path
|
||||
%li= link_to "Vidéos", admin_video_files_path
|
||||
%li= link_to "Sliders", admin_home_slider_path(1)
|
||||
%li= link_to "Image d'actualités", admin_image_actus_path
|
||||
%li.dropdown
|
||||
%a{:href => "#", :class => "dropdown-toggle", :data => {:toggle => "dropdown"}}
|
||||
Médias
|
||||
%b.caret
|
||||
%ul.dropdown-menu
|
||||
%li= link_to "Images", admin_image_files_path
|
||||
%li= link_to "Fichiers", admin_data_files_path
|
||||
%li= link_to "Vidéos", admin_video_files_path
|
||||
%li= link_to "Sliders", admin_home_slider_path(1)
|
||||
%li= link_to "Image d'actualités", admin_image_actus_path
|
||||
|
||||
%li.dropdown
|
||||
%a{:href => "#", :class => "dropdown-toggle", :data => {:toggle => "dropdown"}}
|
||||
Contenu spécifique
|
||||
%b.caret
|
||||
%ul.dropdown-menu
|
||||
%li= link_to "Traductions textes spécifiques", admin_translations_path
|
||||
%li= link_to "Timelines", admin_timeline_histories_path
|
||||
%li= link_to "Communiqués de presse", admin_press_releases_path
|
||||
|
||||
%li= link_to "Url courte", admin_tiny_urls_path
|
||||
%li.dropdown
|
||||
%a{:href => "#", :class => "dropdown-toggle", :data => {:toggle => "dropdown"}}
|
||||
Contenu spécifique
|
||||
%b.caret
|
||||
%ul.dropdown-menu
|
||||
%li= link_to "Traductions textes spécifiques", admin_translations_path
|
||||
%li= link_to "Timelines", admin_timeline_histories_path
|
||||
%li= link_to "Communiqués de presse", admin_press_releases_path
|
||||
|
||||
%li= link_to "Url courte", admin_tiny_urls_path
|
||||
|
||||
-if current_admin.contact_role
|
||||
%li= link_to "Contacts", admin_contacts_path
|
||||
|
||||
|
||||
|
||||
|
@ -498,7 +498,13 @@ end
|
||||
|
||||
end
|
||||
|
||||
resources :contacts
|
||||
resources :contact_files
|
||||
resources :contacts do
|
||||
collection do
|
||||
post :api
|
||||
end
|
||||
end
|
||||
resources :contact_actions
|
||||
|
||||
resources :survey_types do
|
||||
member do
|
||||
|
14
db/migrate/20180628223331_create_contact_actions.rb
Normal file
14
db/migrate/20180628223331_create_contact_actions.rb
Normal file
@ -0,0 +1,14 @@
|
||||
class CreateContactActions < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :contact_actions do |t|
|
||||
t.integer :admin_id
|
||||
t.datetime :action_at
|
||||
t.references :contact, index: true
|
||||
t.string :action_title
|
||||
t.text :action_message
|
||||
t.references :contact_action_pattern
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
19
db/migrate/20180628223332_add_infos_to_contacts.rb
Normal file
19
db/migrate/20180628223332_add_infos_to_contacts.rb
Normal file
@ -0,0 +1,19 @@
|
||||
class AddInfosToContacts < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :contacts, :statut, :string
|
||||
add_column :contacts, :readed, :boolean, :default => false
|
||||
add_column :contacts, :admin_id, :integer
|
||||
add_column :contacts, :archived, :boolean, :default => false
|
||||
add_column :contacts, :provenance_id, :integer
|
||||
add_column :contacts, :small_comment, :text
|
||||
add_column :contacts, :contact_status, :string
|
||||
add_column :contacts, :corporate, :string
|
||||
add_column :contacts, :urgent, :boolean, :default => false
|
||||
add_column :contacts, :objet, :text
|
||||
add_column :contacts, :raison_text, :string
|
||||
|
||||
Contact.all.each do |c|
|
||||
c.save
|
||||
end
|
||||
end
|
||||
end
|
6
db/migrate/20180628225938_add_color_to_admins.rb
Normal file
6
db/migrate/20180628225938_add_color_to_admins.rb
Normal file
@ -0,0 +1,6 @@
|
||||
class AddColorToAdmins < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :admins, :color, :string
|
||||
add_column :admins, :contact_role, :boolean
|
||||
end
|
||||
end
|
62
db/schema.rb
62
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: 20180227213707) do
|
||||
ActiveRecord::Schema.define(version: 20180628225938) do
|
||||
|
||||
create_table "admins", force: :cascade do |t|
|
||||
t.string "name", limit: 255
|
||||
@ -39,6 +39,8 @@ ActiveRecord::Schema.define(version: 20180227213707) do
|
||||
t.boolean "newsletter"
|
||||
t.boolean "moderateur"
|
||||
t.boolean "label_role"
|
||||
t.string "color", limit: 255
|
||||
t.boolean "contact_role"
|
||||
end
|
||||
|
||||
create_table "albums", force: :cascade do |t|
|
||||
@ -199,25 +201,49 @@ ActiveRecord::Schema.define(version: 20180227213707) do
|
||||
t.integer "lang_site_id", limit: 4, default: 1
|
||||
end
|
||||
|
||||
create_table "contacts", force: :cascade do |t|
|
||||
t.string "civilite", limit: 255
|
||||
t.string "firstname", limit: 255
|
||||
t.string "name", limit: 255
|
||||
t.string "address", limit: 255
|
||||
t.string "address2", limit: 255
|
||||
t.string "cp", limit: 255
|
||||
t.string "city", limit: 255
|
||||
t.string "country", limit: 255
|
||||
t.string "phone", limit: 255
|
||||
t.string "token", limit: 255
|
||||
t.string "email", limit: 255
|
||||
t.string "website", limit: 255
|
||||
t.integer "raison_id", limit: 4
|
||||
t.text "message", limit: 65535
|
||||
create_table "contact_actions", force: :cascade do |t|
|
||||
t.integer "admin_id", limit: 4
|
||||
t.datetime "action_at"
|
||||
t.integer "contact_id", limit: 4
|
||||
t.string "action_title", limit: 255
|
||||
t.text "action_message", limit: 65535
|
||||
t.integer "contact_action_pattern_id", limit: 4
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.text "notes", limit: 65535
|
||||
t.integer "survey_set_id", limit: 4
|
||||
end
|
||||
|
||||
add_index "contact_actions", ["contact_id"], name: "index_contact_actions_on_contact_id", using: :btree
|
||||
|
||||
create_table "contacts", force: :cascade do |t|
|
||||
t.string "civilite", limit: 255
|
||||
t.string "firstname", limit: 255
|
||||
t.string "name", limit: 255
|
||||
t.string "address", limit: 255
|
||||
t.string "address2", limit: 255
|
||||
t.string "cp", limit: 255
|
||||
t.string "city", limit: 255
|
||||
t.string "country", limit: 255
|
||||
t.string "phone", limit: 255
|
||||
t.string "token", limit: 255
|
||||
t.string "email", limit: 255
|
||||
t.string "website", limit: 255
|
||||
t.integer "raison_id", limit: 4
|
||||
t.text "message", limit: 65535
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.text "notes", limit: 65535
|
||||
t.integer "survey_set_id", limit: 4
|
||||
t.string "statut", limit: 255
|
||||
t.boolean "readed", default: false
|
||||
t.integer "admin_id", limit: 4
|
||||
t.boolean "archived", default: false
|
||||
t.integer "provenance_id", limit: 4
|
||||
t.text "small_comment", limit: 65535
|
||||
t.string "contact_status", limit: 255
|
||||
t.string "corporate", limit: 255
|
||||
t.boolean "urgent", default: false
|
||||
t.text "objet", limit: 65535
|
||||
t.string "raison_text", limit: 255
|
||||
end
|
||||
|
||||
create_table "data_file_categories", force: :cascade do |t|
|
||||
|
Loading…
x
Reference in New Issue
Block a user