messagerie privée
This commit is contained in:
parent
0f03e81385
commit
e9d2c53e22
@ -236,6 +236,9 @@ $("document").ready ->
|
|||||||
offset= 0
|
offset= 0
|
||||||
|
|
||||||
resize = ->
|
resize = ->
|
||||||
|
|
||||||
|
$(".customer_message_list .height_frame").css
|
||||||
|
"height" : $(".customer_message_show").height()+"px"
|
||||||
min_height = 0
|
min_height = 0
|
||||||
min_height = $(window).height() - $(".top").height() - $(".top_home").height() - $(".bottom").height() - 30
|
min_height = $(window).height() - $(".top").height() - $(".top_home").height() - $(".bottom").height() - 30
|
||||||
|
|
||||||
|
@ -932,3 +932,37 @@ height: 100%;
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
.things, .pseudo{
|
||||||
|
.customer, .reseaux{
|
||||||
|
display:inline-block;
|
||||||
|
margin-left:3px;
|
||||||
|
margin-right:3px;
|
||||||
|
padding:2px 8px ;
|
||||||
|
border-radius:15px;
|
||||||
|
border:1px solid #d9e0e6;
|
||||||
|
background:#d0e6fb;
|
||||||
|
font-weight:normal;
|
||||||
|
color:#20242d;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
.reseaux{
|
||||||
|
background:#cdd89f;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
.sub_commission{
|
||||||
|
font-weight:normal;
|
||||||
|
font-size:92%;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -3,11 +3,11 @@ class Admin::ReseauxesController < ApplicationController
|
|||||||
|
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@reseauxes = Reseaux.order(:name)
|
@reseauxes = Reseaux.where(:parent_id => nil).order(:name)
|
||||||
end
|
end
|
||||||
|
|
||||||
def new
|
def new
|
||||||
@reseaux = Reseaux.new()
|
@reseaux = Reseaux.new(:parent_id => params[:parent_id])
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -16,7 +16,13 @@ class Admin::ReseauxesController < ApplicationController
|
|||||||
|
|
||||||
if @reseaux.save
|
if @reseaux.save
|
||||||
flash[:notice] = "Catégorie créée avec succès."
|
flash[:notice] = "Catégorie créée avec succès."
|
||||||
redirect_to admin_reseauxes_path
|
|
||||||
|
if @reseaux.parent
|
||||||
|
redirect_to admin_reseaux_path(@reseaux.parent_id)
|
||||||
|
else
|
||||||
|
redirect_to admin_reseauxes_path
|
||||||
|
end
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
||||||
render "new"
|
render "new"
|
||||||
@ -37,7 +43,12 @@ class Admin::ReseauxesController < ApplicationController
|
|||||||
@reseaux = Reseaux.find(params[:id])
|
@reseaux = Reseaux.find(params[:id])
|
||||||
if @reseaux.update_attributes(reseaux_params)
|
if @reseaux.update_attributes(reseaux_params)
|
||||||
flash[:notice] = "Catégorie modifiée avec succès."
|
flash[:notice] = "Catégorie modifiée avec succès."
|
||||||
redirect_to admin_reseauxes_path
|
if @reseaux.parent
|
||||||
|
redirect_to admin_reseaux_path(@reseaux.parent_id)
|
||||||
|
else
|
||||||
|
redirect_to admin_reseauxes_path
|
||||||
|
end
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
||||||
render :action => "edit"
|
render :action => "edit"
|
||||||
@ -49,7 +60,8 @@ class Admin::ReseauxesController < ApplicationController
|
|||||||
if @reseaux.destroy
|
if @reseaux.destroy
|
||||||
flash[:notice] = "Reseaux supprimée avec succès."
|
flash[:notice] = "Reseaux supprimée avec succès."
|
||||||
else
|
else
|
||||||
flash[:error] = "Impossible de supprimer ce reseaux."
|
flash[:error] = "Impossible de supprimer ce reseaux
|
||||||
|
."
|
||||||
end
|
end
|
||||||
|
|
||||||
redirect_to :action => :index
|
redirect_to :action => :index
|
||||||
|
18
app/controllers/public/conversations_controller.rb
Normal file
18
app/controllers/public/conversations_controller.rb
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
class Public::ConversationsController < ApplicationController
|
||||||
|
layout "public"
|
||||||
|
|
||||||
|
before_filter :auth_customer
|
||||||
|
|
||||||
|
def index
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
def show
|
||||||
|
@conversation = Conversation.find(params[:id])
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
end
|
@ -14,6 +14,12 @@ class Public::CustomerMessagesController < ApplicationController
|
|||||||
@customer_messages = @customer_messages.order("last_message_at DESC, created_at DESC").all
|
@customer_messages = @customer_messages.order("last_message_at DESC, created_at DESC").all
|
||||||
|
|
||||||
|
|
||||||
|
reseaux_ids= current_customer.reseauxes.pluck(:id)
|
||||||
|
#current_customer.reseauxes.each do |r|
|
||||||
|
# reseaux_ids += r.children.pluck(:id)
|
||||||
|
#end
|
||||||
|
|
||||||
|
@conversations = Conversation.joins(:thing_conversations).where("(thing_conversations.thing_type = ? and thing_conversations.thing_id = ?) or (thing_conversations.thing_type = ? and thing_conversations.thing_id IN (?))", "Customer", current_customer.id, "Reseaux", reseaux_ids ).uniq
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
@ -57,6 +63,9 @@ class Public::CustomerMessagesController < ApplicationController
|
|||||||
|
|
||||||
|
|
||||||
def new
|
def new
|
||||||
|
@customer_message = CustomerMessage.new(:conversation_id => params[:conversation_id], :thing_type => params[:thing_type], :thing_id => params[:thing_id])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -68,12 +77,23 @@ class Public::CustomerMessagesController < ApplicationController
|
|||||||
|
|
||||||
def create
|
def create
|
||||||
@customer_message = CustomerMessage.new(params.require(:customer_message).permit!)
|
@customer_message = CustomerMessage.new(params.require(:customer_message).permit!)
|
||||||
@customer_message.expediteur = current_customer if current_customer
|
@customer_message.expediteur = current_customer
|
||||||
@customer_message.remote_ip = request.remote_ip
|
|
||||||
@customer_message.last_message_at = Time.now
|
|
||||||
|
|
||||||
if @customer_message.save
|
if @customer_message.save
|
||||||
|
|
||||||
|
if !@customer_message.conversation
|
||||||
|
@conversation = Conversation.create()
|
||||||
|
@conversation.thing_conversations << ThingConversation.create(:thing_type => @customer_message.thing_type, :thing_id => @customer_message.thing_id)
|
||||||
|
@conversation.thing_conversations << ThingConversation.create(:thing_type => "Customer", :thing_id => current_customer.id)
|
||||||
|
@conversation.customer_messages << @customer_message
|
||||||
|
else
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
redirect_to public_customer_messages_path
|
redirect_to public_customer_messages_path
|
||||||
|
else
|
||||||
|
render :action => :new
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
13
app/models/conversation.rb
Normal file
13
app/models/conversation.rb
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
class Conversation < ActiveRecord::Base
|
||||||
|
|
||||||
|
|
||||||
|
has_many :thing_conversations
|
||||||
|
|
||||||
|
#has_many :things, :through => :thing_conversations
|
||||||
|
|
||||||
|
has_many :customer_messages
|
||||||
|
|
||||||
|
#accepts_nested_attributes_for :customer_messages
|
||||||
|
|
||||||
|
|
||||||
|
end
|
@ -1,5 +1,14 @@
|
|||||||
class Customer < ActiveRecord::Base
|
class Customer < ActiveRecord::Base
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
has_many :thing_conversations, :as => :thing
|
||||||
|
|
||||||
|
has_many :conversations, :through => :thing_conversations
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
has_many :domains, :through => :domain_customers
|
has_many :domains, :through => :domain_customers
|
||||||
has_many :domain_customers, :dependent => :destroy
|
has_many :domain_customers, :dependent => :destroy
|
||||||
|
|
||||||
|
@ -6,6 +6,9 @@ class CustomerMessage < ActiveRecord::Base
|
|||||||
validates :message, :presence => true
|
validates :message, :presence => true
|
||||||
acts_as_tree
|
acts_as_tree
|
||||||
|
|
||||||
|
belongs_to :conversation
|
||||||
|
|
||||||
|
attr_accessor :thing_type, :thing_id
|
||||||
|
|
||||||
def not_blocked
|
def not_blocked
|
||||||
true
|
true
|
||||||
|
@ -9,6 +9,14 @@ class Reseaux < ActiveRecord::Base
|
|||||||
has_many :offer_reseauxes
|
has_many :offer_reseauxes
|
||||||
has_many :offers, :through => :offer_reseauxes
|
has_many :offers, :through => :offer_reseauxes
|
||||||
|
|
||||||
|
|
||||||
|
has_many :thing_conversations, :as => :thing
|
||||||
|
|
||||||
|
has_many :conversations, :through => :thing_conversations
|
||||||
|
|
||||||
|
acts_as_tree
|
||||||
|
|
||||||
|
|
||||||
before_create do
|
before_create do
|
||||||
self.generate_token
|
self.generate_token
|
||||||
end
|
end
|
||||||
|
5
app/models/thing_conversation.rb
Normal file
5
app/models/thing_conversation.rb
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
class ThingConversation < ActiveRecord::Base
|
||||||
|
belongs_to :conversation
|
||||||
|
|
||||||
|
belongs_to :thing, :polymorphic => true
|
||||||
|
end
|
@ -11,7 +11,13 @@
|
|||||||
.col-sm-6
|
.col-sm-6
|
||||||
=f.input :domains, :label => "Domaine : ", :collection => Domain.all, :as => :check_boxes
|
=f.input :domains, :label => "Domaine : ", :collection => Domain.all, :as => :check_boxes
|
||||||
.col-sm-6
|
.col-sm-6
|
||||||
=f.input :reseauxes, :label => "Réseaux : ", :collection => Reseaux.all, :as => :check_boxes
|
|
||||||
|
<input type="hidden" name="image_file[reseaux_ids][]" id="image_file_tags_none" value="">
|
||||||
|
|
||||||
|
%ul#reseaux_ids_form=render :partial => "admin/reseauxes/reseaux_form", :collection => Reseaux.where(:parent_id => nil).order(:name), :locals => {:form => f}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
=f.input :organisation, :label => "Société : "
|
=f.input :organisation, :label => "Société : "
|
||||||
|
|
||||||
|
@ -1,9 +1,16 @@
|
|||||||
=semantic_form_for [:admin, @reseaux] do |f|
|
=semantic_form_for [:admin, @reseaux] do |f|
|
||||||
.content
|
.content
|
||||||
|
=f.hidden_field :parent_id
|
||||||
|
-if @reseaux.parent
|
||||||
|
%p
|
||||||
|
Sous réseau de
|
||||||
|
%strong
|
||||||
|
=@reseaux.parent.name
|
||||||
|
|
||||||
=f.inputs do
|
=f.inputs do
|
||||||
=f.input :name, :label => "Nom du réseau : "
|
=f.input :name, :label => "Nom du réseau : "
|
||||||
=f.input :chef_reseau, :label => "Chef réseau : ", :collection => Customer.where(:chef_reseau => true).pluck(Arel.sql("CONCAT(`firstname`, ' ', `name`)"), :id)
|
|
||||||
|
-if !@reseaux.parent
|
||||||
|
=f.input :chef_reseau, :label => "Chef réseau : ", :collection => Customer.where(:chef_reseau => true).pluck(Arel.sql("CONCAT(`firstname`, ' ', `name`)"), :id)
|
||||||
|
|
||||||
.actions= f.submit "Sauvegarder", :class => "btn btn-primary"
|
.actions= f.submit "Sauvegarder", :class => "btn btn-primary"
|
||||||
|
16
app/views/admin/reseauxes/_reseaux_form.html.haml
Normal file
16
app/views/admin/reseauxes/_reseaux_form.html.haml
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
|
||||||
|
-reseaux = reseaux_form
|
||||||
|
%li
|
||||||
|
|
||||||
|
|
||||||
|
=check_box_tag "customer[reseaux_ids][]", reseaux.id, (true if form.object.reseaux_ids.include?(reseaux.id))
|
||||||
|
%label
|
||||||
|
=reseaux.name
|
||||||
|
-if reseaux.children.count > 0
|
||||||
|
%ul
|
||||||
|
=render :partial => "admin/reseauxes/reseaux_form", :collection => reseaux.children, :locals => {:form => form}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -3,6 +3,27 @@
|
|||||||
%h1 Détail d'un réseau
|
%h1 Détail d'un réseau
|
||||||
%h2=@reseaux.name
|
%h2=@reseaux.name
|
||||||
|
|
||||||
|
.right
|
||||||
|
= link_to "Ajouter un reseaux", new_admin_reseaux_path(:parent_id => @reseaux.id), class:"btn btn-primary"
|
||||||
|
%h2 Sous réseaux
|
||||||
|
|
||||||
|
%table.table.admin_table.table-hover.table-striped
|
||||||
|
%thead.rows_header
|
||||||
|
|
||||||
|
%tr
|
||||||
|
%th
|
||||||
|
Nom
|
||||||
|
%th
|
||||||
|
Chef réseau
|
||||||
|
%th
|
||||||
|
Code
|
||||||
|
%th Utilisateurs
|
||||||
|
%th{:style => "width:100px"}
|
||||||
|
|
||||||
|
|
||||||
|
%tbody.rows
|
||||||
|
=render @reseaux.children
|
||||||
|
|
||||||
|
|
||||||
%h2 Membres du réseau
|
%h2 Membres du réseau
|
||||||
|
|
||||||
|
8
app/views/public/conversations/_conversation.html.haml
Normal file
8
app/views/public/conversations/_conversation.html.haml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
=link_to [:public, conversation], :class => "customer_message_li", :id => "customer_message_#{conversation.id}", :remote => true do
|
||||||
|
|
||||||
|
|
||||||
|
.time
|
||||||
|
=l conversation.created_at, :format => "%d/%m/%y"
|
||||||
|
.pseudo
|
||||||
|
= render conversation.thing_conversations
|
||||||
|
.clear
|
@ -0,0 +1,45 @@
|
|||||||
|
-if customer_message.destinataire == current_customer
|
||||||
|
-customer_message.readed = true
|
||||||
|
-customer_message.save
|
||||||
|
|
||||||
|
.customer_message_container{:class => ("me" if customer_message.expediteur and customer_message.expediteur == current_customer).to_s }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
.side
|
||||||
|
|
||||||
|
.square
|
||||||
|
|
||||||
|
.pseudo
|
||||||
|
|
||||||
|
|
||||||
|
-if customer_message.expediteur and customer_message.expediteur == current_customer
|
||||||
|
moi
|
||||||
|
-else
|
||||||
|
-if current_customer.own_customers.include?(customer_message.expediteur)
|
||||||
|
=link_to customer_message.expediteur.anonyme_nick, [:public, customer_message.expediteur]
|
||||||
|
-else
|
||||||
|
=customer_message.expediteur.anonyme_nick
|
||||||
|
|
||||||
|
.sub_commission
|
||||||
|
|
||||||
|
-customer_message.expediteur.reseauxes.where("parent_id is not null").each do |reseaux|
|
||||||
|
%span=reseaux.name
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
.time
|
||||||
|
=l customer_message.created_at, :format => "%d/%m/%y"
|
||||||
|
|
||||||
|
.content
|
||||||
|
|
||||||
|
|
||||||
|
-if customer_message.title
|
||||||
|
%p
|
||||||
|
=customer_message.title
|
||||||
|
%hr
|
||||||
|
|
||||||
|
=simple_format customer_message.message
|
||||||
|
|
10
app/views/public/conversations/_show.html.haml
Normal file
10
app/views/public/conversations/_show.html.haml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
.things= render @conversation.thing_conversations
|
||||||
|
|
||||||
|
|
||||||
|
.answer_link
|
||||||
|
|
||||||
|
%p{:style => "margin:40px;"}
|
||||||
|
%center=link_to "Répondre", new_public_customer_message_path(:conversation_id => @conversation.id), :remote => true, :class => "btn btn-primary"
|
||||||
|
#message_form
|
||||||
|
#message_answers
|
||||||
|
=render :partial => "customer_message_show", :collection => @conversation.customer_messages.order("created_at DESC"), :as => :customer_message
|
1
app/views/public/conversations/show.html.haml
Normal file
1
app/views/public/conversations/show.html.haml
Normal file
@ -0,0 +1 @@
|
|||||||
|
=render :partial => "show"
|
4
app/views/public/conversations/show.js.erb
Normal file
4
app/views/public/conversations/show.js.erb
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
$(".customer_message_show").html("<%= escape_javascript(render(:partial => "show")) %>");
|
||||||
|
$(".customer_message_li").removeClass("active");
|
||||||
|
$("#customer_message_<%= @conversation.id %>").addClass("active");
|
||||||
|
$("#customer_message_<%= @conversation.id %> .new").hide();
|
@ -13,6 +13,9 @@
|
|||||||
moi
|
moi
|
||||||
-else
|
-else
|
||||||
= customer_message.expediteur.anonyme_nick
|
= customer_message.expediteur.anonyme_nick
|
||||||
|
DF
|
||||||
|
-customer_message.expediteur.reseauxes.where("parent_id is not null").each do |reseaux|
|
||||||
|
.sub_reseaux=reseaux.name
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -20,7 +20,10 @@
|
|||||||
=link_to customer_message.expediteur.anonyme_nick, [:public, customer_message.expediteur]
|
=link_to customer_message.expediteur.anonyme_nick, [:public, customer_message.expediteur]
|
||||||
|
|
||||||
|
|
||||||
|
.sub_reseaux
|
||||||
|
A
|
||||||
|
-customer_message.expediteur.reseauxes.where("parent_id is not null").each do |reseaux|
|
||||||
|
=reseaux.name
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,11 +1,19 @@
|
|||||||
=semantic_form_for [:public, @customer_message], :url => answer_save_public_customer_message_path(@parent_customer_message), :remote => true do |f|
|
=semantic_form_for [:public, @customer_message], :remote => (true if @customer_message.id ) do |f|
|
||||||
|
|
||||||
=#f.input :tel, :label => qit("votre-numero-de-telephone-label","Votre numéro de téléphone :")
|
=#f.input :tel, :label => qit("votre-numero-de-telephone-label","Votre numéro de téléphone :")
|
||||||
=#f.input :expediteur_mail, :label => qit("your-mail-label","Votre mail :")
|
=#f.input :expediteur_mail, :label => qit("your-mail-label","Votre mail :")
|
||||||
|
|
||||||
|
=f.hidden_field :conversation_id
|
||||||
|
=f.hidden_field :thing_type
|
||||||
|
=f.hidden_field :thing_id
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
=f.input :message, :label => "Message"
|
=f.input :message, :label => "Message"
|
||||||
=f.hidden_field :destinataire_id
|
=f.hidden_field :destinataire_id
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
=f.submit "Envoyer mon message", :class => "btn btn-primary"
|
=f.submit "Envoyer mon message", :class => "btn btn-primary"
|
@ -1,13 +1,15 @@
|
|||||||
|
|
||||||
.center.padding
|
.center.padding
|
||||||
|
|
||||||
%h1 Boite de réception
|
%h1 Conversations
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
.col-md-3.customer_message_list
|
.col-md-3.customer_message_list
|
||||||
|
|
||||||
.inner.height_frame{:style => "overflow:auto;height:300px;"}
|
.inner.height_frame{:style => "overflow:auto;height:300px;"}
|
||||||
|
|
||||||
=render @customer_messages
|
=render @conversations
|
||||||
|
|
||||||
.col-md-9.customer_message_show_container
|
.col-md-9.customer_message_show_container
|
||||||
.customer_message_show.inner.height_frame{:style => "overflow:auto;height:300px;"}
|
.customer_message_show.inner.height_frame{:style => "overflow:auto;height:300px;"}
|
||||||
|
8
app/views/public/customer_messages/new.haml
Normal file
8
app/views/public/customer_messages/new.haml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
.center.padding
|
||||||
|
.things
|
||||||
|
Message à
|
||||||
|
-if @customer_message.thing_type == "Reseaux"
|
||||||
|
.reseaux=Reseaux.find(@customer_message.thing_id).name
|
||||||
|
-elsif @customer_message.thing_type == "Customer"
|
||||||
|
.customer=Customer.find(@customer_message.thing_id).anonyme_nick
|
||||||
|
=render :partial => "form"
|
3
app/views/public/customer_messages/new.js.erb
Normal file
3
app/views/public/customer_messages/new.js.erb
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
$("#message_form").html("<%= escape_javascript(render(:partial => "form")) %>");
|
||||||
|
$(".answer_link").hide();
|
||||||
|
|
@ -27,5 +27,5 @@
|
|||||||
|
|
||||||
%td.actions{:style => "width:150px;text-align:right;"}
|
%td.actions{:style => "width:150px;text-align:right;"}
|
||||||
=link_to i(:eye), public_customer_path(customer)
|
=link_to i(:eye), public_customer_path(customer)
|
||||||
=link_to i(:envelope), mail_public_customer_path(customer)
|
=link_to i(:envelope), new_public_customer_message_path(:thing_type => "Customer", :thing_id => customer.id)
|
||||||
|
|
@ -45,6 +45,51 @@
|
|||||||
#{ current_customer.full_address}
|
#{ current_customer.full_address}
|
||||||
%p
|
%p
|
||||||
=link_to "Modifier mes infos", public_edit_infos_path, :class => "btn btn-primary"
|
=link_to "Modifier mes infos", public_edit_infos_path, :class => "btn btn-primary"
|
||||||
|
|
||||||
|
|
||||||
|
.padding.center.white
|
||||||
|
%h3 Mes réseaux
|
||||||
|
%table.table.admin_table.table-hover.table-striped
|
||||||
|
%thead.rows_header
|
||||||
|
|
||||||
|
%tr
|
||||||
|
%th
|
||||||
|
Nom
|
||||||
|
%th
|
||||||
|
|
||||||
|
|
||||||
|
%tbody.rows
|
||||||
|
-current_customer.reseauxes.where(:parent_id => nil).each do |reseaux|
|
||||||
|
%tr
|
||||||
|
%td
|
||||||
|
=reseaux.name
|
||||||
|
=link_to i(:envelope), new_public_customer_message_path(:thing_type => "Reseaux", :thing_id => reseaux.id)
|
||||||
|
%td
|
||||||
|
-if reseaux.chef_reseau
|
||||||
|
Chef réseaux :
|
||||||
|
=reseaux.chef_reseau.anonyme_nick
|
||||||
|
|
||||||
|
=link_to i(:envelope), new_public_customer_message_path(:thing_type => "Customer", :thing_id => reseaux.chef_reseau.id)
|
||||||
|
|
||||||
|
-current_customer.reseauxes.where(:parent_id => reseaux.id).each do |reseaux|
|
||||||
|
%tr
|
||||||
|
%td
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
=reseaux.name
|
||||||
|
=link_to i(:envelope), new_public_customer_message_path(:thing_type => "Reseaux", :thing_id => reseaux.id)
|
||||||
|
%td
|
||||||
|
-if reseaux.chef_reseau
|
||||||
|
Chef réseaux :
|
||||||
|
=reseaux.chef_reseau.anonyme_nick
|
||||||
|
|
||||||
|
=link_to i(:envelope), new_public_customer_message_path(:thing_type => "Customer", :thing_id => reseaux.chef_reseau.id)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
.padding.center.white
|
.padding.center.white
|
||||||
%h3
|
%h3
|
||||||
Mes offres acceptées
|
Mes offres acceptées
|
||||||
|
@ -8,3 +8,4 @@
|
|||||||
|
|
||||||
%td.actions{:style => "width:150px;text-align:right"}
|
%td.actions{:style => "width:150px;text-align:right"}
|
||||||
= link_to i(:eye), public_reseaux_path(reseaux)
|
= link_to i(:eye), public_reseaux_path(reseaux)
|
||||||
|
=link_to i(:envelope), new_public_customer_message_path(:thing_type => "Reseaux", :thing_id => reseaux.id)
|
||||||
|
@ -1,9 +1,32 @@
|
|||||||
-@read_only = true
|
-@read_only = true
|
||||||
|
|
||||||
.center.row
|
.center.row
|
||||||
|
|
||||||
|
.right
|
||||||
|
=link_to i(:envelope)+" Ecrire à tout mon réseau", new_public_customer_message_path(:thing_type => "Reseaux", :thing_id => @reseaux.id), :class => "btn btn-primary"
|
||||||
|
|
||||||
%h1
|
%h1
|
||||||
Mon réseau :
|
Mon réseau :
|
||||||
=@reseaux.name
|
=@reseaux.name
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
%h3 Sous réseaux
|
||||||
|
|
||||||
|
%table.table.admin_table.table-hover.table-striped
|
||||||
|
%thead.rows_header
|
||||||
|
|
||||||
|
%tr
|
||||||
|
%th
|
||||||
|
Nom
|
||||||
|
%th Utilisateurs
|
||||||
|
%th{:style => "width:100px"}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
%tbody.rows
|
||||||
|
=render @reseaux.children
|
||||||
|
|
||||||
|
|
||||||
%h3 Membres du réseau
|
%h3 Membres du réseau
|
||||||
@ -74,7 +97,7 @@
|
|||||||
|
|
||||||
%td.actions{:style => "width:150px;text-align:right;"}
|
%td.actions{:style => "width:150px;text-align:right;"}
|
||||||
=link_to i(:eye), public_customer_path(customer)
|
=link_to i(:eye), public_customer_path(customer)
|
||||||
=link_to i(:envelope), mail_public_customer_path(customer)
|
=link_to i(:envelope), new_public_customer_message_path(:thing_type => "Customer", :thing_id => customer.id)
|
||||||
|
|
||||||
|
|
||||||
%div{:style => "position:absolute;top:-30px;right:10px;"}
|
%div{:style => "position:absolute;top:-30px;right:10px;"}
|
||||||
|
@ -0,0 +1,20 @@
|
|||||||
|
-if thing_conversation.thing_type == "Customer"
|
||||||
|
|
||||||
|
.customer
|
||||||
|
-if thing_conversation.thing == current_customer
|
||||||
|
moi
|
||||||
|
-else
|
||||||
|
=#link_to thing_conversation.thing.anonyme_nick, [:public, thing_conversation.thing]
|
||||||
|
=thing_conversation.thing.anonyme_nick
|
||||||
|
|
||||||
|
-chef = false
|
||||||
|
- current_customer.reseauxes.each do |reseaux|
|
||||||
|
-if thing_conversation.thing == reseaux.chef_reseau
|
||||||
|
-chef = true
|
||||||
|
-if chef
|
||||||
|
(chef réseau)
|
||||||
|
|
||||||
|
-if thing_conversation.thing_type == "Reseaux"
|
||||||
|
|
||||||
|
.reseaux
|
||||||
|
=thing_conversation.thing.name
|
@ -20,7 +20,7 @@ Rails.application.routes.draw do
|
|||||||
get 'p/:mlm_token' => "public/customers#parrainage", :as => :mlm_token
|
get 'p/:mlm_token' => "public/customers#parrainage", :as => :mlm_token
|
||||||
|
|
||||||
namespace :public do
|
namespace :public do
|
||||||
|
resources :conversations
|
||||||
get 'documents/:download_token', to: 'documents#download', as: :download_document
|
get 'documents/:download_token', to: 'documents#download', as: :download_document
|
||||||
|
|
||||||
|
|
||||||
|
5
db/migrate/20170605075024_add_parent_id_to_reseauxes.rb
Normal file
5
db/migrate/20170605075024_add_parent_id_to_reseauxes.rb
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
class AddParentIdToReseauxes < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_column :reseauxes, :parent_id, :integer
|
||||||
|
end
|
||||||
|
end
|
11
db/migrate/20170605133047_create_conversations.rb
Normal file
11
db/migrate/20170605133047_create_conversations.rb
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
class CreateConversations < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
create_table :conversations do |t|
|
||||||
|
t.boolean :oneone
|
||||||
|
t.integer :first_customer_id
|
||||||
|
t.string :second_customer_id
|
||||||
|
|
||||||
|
t.timestamps null: false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
12
db/migrate/20170605133630_create_thing_conversations.rb
Normal file
12
db/migrate/20170605133630_create_thing_conversations.rb
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
class CreateThingConversations < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
create_table :thing_conversations do |t|
|
||||||
|
t.integer :thing_id
|
||||||
|
t.string :thing_type
|
||||||
|
t.references :conversation, index: true
|
||||||
|
|
||||||
|
t.timestamps null: false
|
||||||
|
end
|
||||||
|
add_foreign_key :thing_conversations, :conversations
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,6 @@
|
|||||||
|
class AddConversationToCustomerMessages < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_reference :customer_messages, :conversation, index: true
|
||||||
|
add_foreign_key :customer_messages, :conversations
|
||||||
|
end
|
||||||
|
end
|
26
db/schema.rb
26
db/schema.rb
@ -11,7 +11,7 @@
|
|||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 20170523073951) do
|
ActiveRecord::Schema.define(version: 20170605134146) do
|
||||||
|
|
||||||
create_table "accepted_offers", force: :cascade do |t|
|
create_table "accepted_offers", force: :cascade do |t|
|
||||||
t.datetime "created_at", null: false
|
t.datetime "created_at", null: false
|
||||||
@ -158,6 +158,14 @@ ActiveRecord::Schema.define(version: 20170523073951) do
|
|||||||
t.datetime "updated_at", null: false
|
t.datetime "updated_at", null: false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
create_table "conversations", force: :cascade do |t|
|
||||||
|
t.boolean "oneone", limit: 1
|
||||||
|
t.integer "first_customer_id", limit: 4
|
||||||
|
t.string "second_customer_id", limit: 255
|
||||||
|
t.datetime "created_at", null: false
|
||||||
|
t.datetime "updated_at", null: false
|
||||||
|
end
|
||||||
|
|
||||||
create_table "customer_messages", force: :cascade do |t|
|
create_table "customer_messages", force: :cascade do |t|
|
||||||
t.string "title", limit: 255
|
t.string "title", limit: 255
|
||||||
t.text "message", limit: 65535
|
t.text "message", limit: 65535
|
||||||
@ -173,8 +181,11 @@ ActiveRecord::Schema.define(version: 20170523073951) do
|
|||||||
t.boolean "readed", limit: 1
|
t.boolean "readed", limit: 1
|
||||||
t.datetime "created_at", null: false
|
t.datetime "created_at", null: false
|
||||||
t.datetime "updated_at", null: false
|
t.datetime "updated_at", null: false
|
||||||
|
t.integer "conversation_id", limit: 4
|
||||||
end
|
end
|
||||||
|
|
||||||
|
add_index "customer_messages", ["conversation_id"], name: "index_customer_messages_on_conversation_id", using: :btree
|
||||||
|
|
||||||
create_table "customer_newsgroups", force: :cascade do |t|
|
create_table "customer_newsgroups", force: :cascade do |t|
|
||||||
t.integer "customer_id", limit: 4
|
t.integer "customer_id", limit: 4
|
||||||
t.integer "newsgroup_id", limit: 4
|
t.integer "newsgroup_id", limit: 4
|
||||||
@ -606,6 +617,7 @@ ActiveRecord::Schema.define(version: 20170523073951) do
|
|||||||
t.datetime "created_at", null: false
|
t.datetime "created_at", null: false
|
||||||
t.datetime "updated_at", null: false
|
t.datetime "updated_at", null: false
|
||||||
t.string "token", limit: 255
|
t.string "token", limit: 255
|
||||||
|
t.integer "parent_id", limit: 4
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "sessions", force: :cascade do |t|
|
create_table "sessions", force: :cascade do |t|
|
||||||
@ -659,6 +671,16 @@ ActiveRecord::Schema.define(version: 20170523073951) do
|
|||||||
t.datetime "updated_at"
|
t.datetime "updated_at"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
create_table "thing_conversations", force: :cascade do |t|
|
||||||
|
t.integer "thing_id", limit: 4
|
||||||
|
t.string "thing_type", limit: 255
|
||||||
|
t.integer "conversation_id", limit: 4
|
||||||
|
t.datetime "created_at", null: false
|
||||||
|
t.datetime "updated_at", null: false
|
||||||
|
end
|
||||||
|
|
||||||
|
add_index "thing_conversations", ["conversation_id"], name: "index_thing_conversations_on_conversation_id", using: :btree
|
||||||
|
|
||||||
create_table "title_contents", force: :cascade do |t|
|
create_table "title_contents", force: :cascade do |t|
|
||||||
t.text "content", limit: 65535
|
t.text "content", limit: 65535
|
||||||
t.integer "level", limit: 4
|
t.integer "level", limit: 4
|
||||||
@ -677,6 +699,7 @@ ActiveRecord::Schema.define(version: 20170523073951) do
|
|||||||
t.decimal "qte", precision: 10, scale: 2, default: 1.0
|
t.decimal "qte", precision: 10, scale: 2, default: 1.0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
add_foreign_key "customer_messages", "conversations"
|
||||||
add_foreign_key "customer_newsgroups", "customers"
|
add_foreign_key "customer_newsgroups", "customers"
|
||||||
add_foreign_key "customer_newsgroups", "newsgroups"
|
add_foreign_key "customer_newsgroups", "newsgroups"
|
||||||
add_foreign_key "domain_customers", "customers"
|
add_foreign_key "domain_customers", "customers"
|
||||||
@ -689,4 +712,5 @@ ActiveRecord::Schema.define(version: 20170523073951) do
|
|||||||
add_foreign_key "offer_reseauxes", "reseauxes"
|
add_foreign_key "offer_reseauxes", "reseauxes"
|
||||||
add_foreign_key "reseaux_customers", "customers"
|
add_foreign_key "reseaux_customers", "customers"
|
||||||
add_foreign_key "reseaux_customers", "reseauxes"
|
add_foreign_key "reseaux_customers", "reseauxes"
|
||||||
|
add_foreign_key "thing_conversations", "conversations"
|
||||||
end
|
end
|
||||||
|
11
test/fixtures/conversations.yml
vendored
Normal file
11
test/fixtures/conversations.yml
vendored
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||||
|
|
||||||
|
one:
|
||||||
|
oneone: false
|
||||||
|
first_customer_id: 1
|
||||||
|
second_customer_id: MyString
|
||||||
|
|
||||||
|
two:
|
||||||
|
oneone: false
|
||||||
|
first_customer_id: 1
|
||||||
|
second_customer_id: MyString
|
9
test/fixtures/customer_conversations.yml
vendored
Normal file
9
test/fixtures/customer_conversations.yml
vendored
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||||
|
|
||||||
|
one:
|
||||||
|
customer_id:
|
||||||
|
conversation_id:
|
||||||
|
|
||||||
|
two:
|
||||||
|
customer_id:
|
||||||
|
conversation_id:
|
9
test/fixtures/reseaux_conversations.yml
vendored
Normal file
9
test/fixtures/reseaux_conversations.yml
vendored
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||||
|
|
||||||
|
one:
|
||||||
|
reseaux_id:
|
||||||
|
conversation_id:
|
||||||
|
|
||||||
|
two:
|
||||||
|
reseaux_id:
|
||||||
|
conversation_id:
|
11
test/fixtures/thing_conversations.yml
vendored
Normal file
11
test/fixtures/thing_conversations.yml
vendored
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||||
|
|
||||||
|
one:
|
||||||
|
thing_id: 1
|
||||||
|
thing_type: MyString
|
||||||
|
conversation_id:
|
||||||
|
|
||||||
|
two:
|
||||||
|
thing_id: 1
|
||||||
|
thing_type: MyString
|
||||||
|
conversation_id:
|
7
test/models/conversation_test.rb
Normal file
7
test/models/conversation_test.rb
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
require 'test_helper'
|
||||||
|
|
||||||
|
class ConversationTest < ActiveSupport::TestCase
|
||||||
|
# test "the truth" do
|
||||||
|
# assert true
|
||||||
|
# end
|
||||||
|
end
|
7
test/models/customer_conversation_test.rb
Normal file
7
test/models/customer_conversation_test.rb
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
require 'test_helper'
|
||||||
|
|
||||||
|
class CustomerConversationTest < ActiveSupport::TestCase
|
||||||
|
# test "the truth" do
|
||||||
|
# assert true
|
||||||
|
# end
|
||||||
|
end
|
7
test/models/reseaux_conversation_test.rb
Normal file
7
test/models/reseaux_conversation_test.rb
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
require 'test_helper'
|
||||||
|
|
||||||
|
class ReseauxConversationTest < ActiveSupport::TestCase
|
||||||
|
# test "the truth" do
|
||||||
|
# assert true
|
||||||
|
# end
|
||||||
|
end
|
7
test/models/thing_conversation_test.rb
Normal file
7
test/models/thing_conversation_test.rb
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
require 'test_helper'
|
||||||
|
|
||||||
|
class ThingConversationTest < ActiveSupport::TestCase
|
||||||
|
# test "the truth" do
|
||||||
|
# assert true
|
||||||
|
# end
|
||||||
|
end
|
Loading…
x
Reference in New Issue
Block a user