diff --git a/app/assets/javascripts/public.js.coffee b/app/assets/javascripts/public.js.coffee index d0c868d..22327f9 100755 --- a/app/assets/javascripts/public.js.coffee +++ b/app/assets/javascripts/public.js.coffee @@ -236,6 +236,9 @@ $("document").ready -> offset= 0 resize = -> + + $(".customer_message_list .height_frame").css + "height" : $(".customer_message_show").height()+"px" min_height = 0 min_height = $(window).height() - $(".top").height() - $(".top_home").height() - $(".bottom").height() - 30 diff --git a/app/assets/stylesheets/public.scss b/app/assets/stylesheets/public.scss index 16091e6..2a6293d 100755 --- a/app/assets/stylesheets/public.scss +++ b/app/assets/stylesheets/public.scss @@ -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%; + +} + + + diff --git a/app/controllers/admin/reseauxes_controller.rb b/app/controllers/admin/reseauxes_controller.rb index 849d7c7..075eed0 100755 --- a/app/controllers/admin/reseauxes_controller.rb +++ b/app/controllers/admin/reseauxes_controller.rb @@ -3,11 +3,11 @@ class Admin::ReseauxesController < ApplicationController def index - @reseauxes = Reseaux.order(:name) + @reseauxes = Reseaux.where(:parent_id => nil).order(:name) end def new - @reseaux = Reseaux.new() + @reseaux = Reseaux.new(:parent_id => params[:parent_id]) end @@ -16,7 +16,13 @@ class Admin::ReseauxesController < ApplicationController if @reseaux.save 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 render "new" @@ -37,7 +43,12 @@ class Admin::ReseauxesController < ApplicationController @reseaux = Reseaux.find(params[:id]) if @reseaux.update_attributes(reseaux_params) 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 render :action => "edit" @@ -49,7 +60,8 @@ class Admin::ReseauxesController < ApplicationController if @reseaux.destroy flash[:notice] = "Reseaux supprimée avec succès." else - flash[:error] = "Impossible de supprimer ce reseaux." + flash[:error] = "Impossible de supprimer ce reseaux + ." end redirect_to :action => :index diff --git a/app/controllers/public/conversations_controller.rb b/app/controllers/public/conversations_controller.rb new file mode 100644 index 0000000..da02966 --- /dev/null +++ b/app/controllers/public/conversations_controller.rb @@ -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 diff --git a/app/controllers/public/customer_messages_controller.rb b/app/controllers/public/customer_messages_controller.rb index 3151bce..80631ce 100644 --- a/app/controllers/public/customer_messages_controller.rb +++ b/app/controllers/public/customer_messages_controller.rb @@ -14,6 +14,12 @@ class Public::CustomerMessagesController < ApplicationController @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 @@ -57,6 +63,9 @@ class Public::CustomerMessagesController < ApplicationController def new + @customer_message = CustomerMessage.new(:conversation_id => params[:conversation_id], :thing_type => params[:thing_type], :thing_id => params[:thing_id]) + + end @@ -68,12 +77,23 @@ class Public::CustomerMessagesController < ApplicationController def create @customer_message = CustomerMessage.new(params.require(:customer_message).permit!) - @customer_message.expediteur = current_customer if current_customer - @customer_message.remote_ip = request.remote_ip - @customer_message.last_message_at = Time.now - + @customer_message.expediteur = current_customer + 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 + else + render :action => :new end end diff --git a/app/models/conversation.rb b/app/models/conversation.rb new file mode 100644 index 0000000..488e80b --- /dev/null +++ b/app/models/conversation.rb @@ -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 diff --git a/app/models/customer.rb b/app/models/customer.rb index 51616df..b829091 100755 --- a/app/models/customer.rb +++ b/app/models/customer.rb @@ -1,5 +1,14 @@ class Customer < ActiveRecord::Base + + + + has_many :thing_conversations, :as => :thing + + has_many :conversations, :through => :thing_conversations + + + has_many :domains, :through => :domain_customers has_many :domain_customers, :dependent => :destroy diff --git a/app/models/customer_message.rb b/app/models/customer_message.rb index 21a1533..0d1ba62 100644 --- a/app/models/customer_message.rb +++ b/app/models/customer_message.rb @@ -6,6 +6,9 @@ class CustomerMessage < ActiveRecord::Base validates :message, :presence => true acts_as_tree + belongs_to :conversation + + attr_accessor :thing_type, :thing_id def not_blocked true diff --git a/app/models/reseaux.rb b/app/models/reseaux.rb index db4174c..1acd109 100644 --- a/app/models/reseaux.rb +++ b/app/models/reseaux.rb @@ -9,6 +9,14 @@ class Reseaux < ActiveRecord::Base has_many :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 self.generate_token end diff --git a/app/models/thing_conversation.rb b/app/models/thing_conversation.rb new file mode 100644 index 0000000..a63b5ff --- /dev/null +++ b/app/models/thing_conversation.rb @@ -0,0 +1,5 @@ +class ThingConversation < ActiveRecord::Base + belongs_to :conversation + + belongs_to :thing, :polymorphic => true +end diff --git a/app/views/admin/customers/_form.html.haml b/app/views/admin/customers/_form.html.haml index 71a9bb1..aa0f8f0 100755 --- a/app/views/admin/customers/_form.html.haml +++ b/app/views/admin/customers/_form.html.haml @@ -11,7 +11,13 @@ .col-sm-6 =f.input :domains, :label => "Domaine : ", :collection => Domain.all, :as => :check_boxes .col-sm-6 - =f.input :reseauxes, :label => "Réseaux : ", :collection => Reseaux.all, :as => :check_boxes + + + + %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é : " diff --git a/app/views/admin/reseauxes/_form.html.haml b/app/views/admin/reseauxes/_form.html.haml index 4862479..f9ff6ac 100755 --- a/app/views/admin/reseauxes/_form.html.haml +++ b/app/views/admin/reseauxes/_form.html.haml @@ -1,9 +1,16 @@ =semantic_form_for [:admin, @reseaux] do |f| .content - + =f.hidden_field :parent_id + -if @reseaux.parent + %p + Sous réseau de + %strong + =@reseaux.parent.name =f.inputs do =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" diff --git a/app/views/admin/reseauxes/_reseaux_form.html.haml b/app/views/admin/reseauxes/_reseaux_form.html.haml new file mode 100644 index 0000000..702cdd1 --- /dev/null +++ b/app/views/admin/reseauxes/_reseaux_form.html.haml @@ -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} + + + + + \ No newline at end of file diff --git a/app/views/admin/reseauxes/show.html.haml b/app/views/admin/reseauxes/show.html.haml index 2e578f0..7c7da4e 100644 --- a/app/views/admin/reseauxes/show.html.haml +++ b/app/views/admin/reseauxes/show.html.haml @@ -3,6 +3,27 @@ %h1 Détail d'un réseau %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 diff --git a/app/views/public/conversations/_conversation.html.haml b/app/views/public/conversations/_conversation.html.haml new file mode 100644 index 0000000..60a8e47 --- /dev/null +++ b/app/views/public/conversations/_conversation.html.haml @@ -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 \ No newline at end of file diff --git a/app/views/public/conversations/_customer_message_show.html.haml b/app/views/public/conversations/_customer_message_show.html.haml new file mode 100644 index 0000000..10f1ad3 --- /dev/null +++ b/app/views/public/conversations/_customer_message_show.html.haml @@ -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 + \ No newline at end of file diff --git a/app/views/public/conversations/_show.html.haml b/app/views/public/conversations/_show.html.haml new file mode 100644 index 0000000..2009e96 --- /dev/null +++ b/app/views/public/conversations/_show.html.haml @@ -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 diff --git a/app/views/public/conversations/show.html.haml b/app/views/public/conversations/show.html.haml new file mode 100644 index 0000000..eca5e0d --- /dev/null +++ b/app/views/public/conversations/show.html.haml @@ -0,0 +1 @@ +=render :partial => "show" \ No newline at end of file diff --git a/app/views/public/conversations/show.js.erb b/app/views/public/conversations/show.js.erb new file mode 100644 index 0000000..b2d329d --- /dev/null +++ b/app/views/public/conversations/show.js.erb @@ -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(); diff --git a/app/views/public/customer_messages/_customer_message.html.haml b/app/views/public/customer_messages/_customer_message.html.haml index 5e7e7f3..e49678e 100644 --- a/app/views/public/customer_messages/_customer_message.html.haml +++ b/app/views/public/customer_messages/_customer_message.html.haml @@ -13,6 +13,9 @@ moi -else = customer_message.expediteur.anonyme_nick + DF + -customer_message.expediteur.reseauxes.where("parent_id is not null").each do |reseaux| + .sub_reseaux=reseaux.name diff --git a/app/views/public/customer_messages/_customer_message_show.html.haml b/app/views/public/customer_messages/_customer_message_show.html.haml index 759e6ac..c669bf8 100644 --- a/app/views/public/customer_messages/_customer_message_show.html.haml +++ b/app/views/public/customer_messages/_customer_message_show.html.haml @@ -20,7 +20,10 @@ =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 diff --git a/app/views/public/customer_messages/_form.html.haml b/app/views/public/customer_messages/_form.html.haml index eb7c7f2..c5a002d 100644 --- a/app/views/public/customer_messages/_form.html.haml +++ b/app/views/public/customer_messages/_form.html.haml @@ -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 :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.hidden_field :destinataire_id + + =f.submit "Envoyer mon message", :class => "btn btn-primary" \ No newline at end of file diff --git a/app/views/public/customer_messages/index.html.haml b/app/views/public/customer_messages/index.html.haml index ee08797..bdd2ec9 100644 --- a/app/views/public/customer_messages/index.html.haml +++ b/app/views/public/customer_messages/index.html.haml @@ -1,13 +1,15 @@ .center.padding - %h1 Boite de réception + %h1 Conversations + + .col-md-3.customer_message_list .inner.height_frame{:style => "overflow:auto;height:300px;"} - =render @customer_messages + =render @conversations .col-md-9.customer_message_show_container .customer_message_show.inner.height_frame{:style => "overflow:auto;height:300px;"} diff --git a/app/views/public/customer_messages/new.haml b/app/views/public/customer_messages/new.haml new file mode 100644 index 0000000..94aebc3 --- /dev/null +++ b/app/views/public/customer_messages/new.haml @@ -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" \ No newline at end of file diff --git a/app/views/public/customer_messages/new.js.erb b/app/views/public/customer_messages/new.js.erb new file mode 100644 index 0000000..2ed8a69 --- /dev/null +++ b/app/views/public/customer_messages/new.js.erb @@ -0,0 +1,3 @@ +$("#message_form").html("<%= escape_javascript(render(:partial => "form")) %>"); +$(".answer_link").hide(); + diff --git a/app/views/public/customers/_customer.html.haml b/app/views/public/customers/_customer.html.haml index abfdce4..e5d4499 100755 --- a/app/views/public/customers/_customer.html.haml +++ b/app/views/public/customers/_customer.html.haml @@ -27,5 +27,5 @@ %td.actions{:style => "width:150px;text-align:right;"} =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) \ No newline at end of file diff --git a/app/views/public/my_account/index.html.haml b/app/views/public/my_account/index.html.haml index d4646b7..86d9608 100755 --- a/app/views/public/my_account/index.html.haml +++ b/app/views/public/my_account/index.html.haml @@ -45,6 +45,51 @@ #{ current_customer.full_address} %p =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 %h3 Mes offres acceptées diff --git a/app/views/public/reseauxes/_reseaux.html.haml b/app/views/public/reseauxes/_reseaux.html.haml index 8bdb85d..e286e04 100755 --- a/app/views/public/reseauxes/_reseaux.html.haml +++ b/app/views/public/reseauxes/_reseaux.html.haml @@ -8,3 +8,4 @@ %td.actions{:style => "width:150px;text-align:right"} = link_to i(:eye), public_reseaux_path(reseaux) + =link_to i(:envelope), new_public_customer_message_path(:thing_type => "Reseaux", :thing_id => reseaux.id) diff --git a/app/views/public/reseauxes/show.html.haml b/app/views/public/reseauxes/show.html.haml index 0c1cc52..ef46d0c 100644 --- a/app/views/public/reseauxes/show.html.haml +++ b/app/views/public/reseauxes/show.html.haml @@ -1,9 +1,32 @@ -@read_only = true .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 Mon réseau : =@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 @@ -74,7 +97,7 @@ %td.actions{:style => "width:150px;text-align:right;"} =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;"} diff --git a/app/views/public/thing_conversations/_thing_conversation.html.haml b/app/views/public/thing_conversations/_thing_conversation.html.haml new file mode 100644 index 0000000..03a77b4 --- /dev/null +++ b/app/views/public/thing_conversations/_thing_conversation.html.haml @@ -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 \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 9b8a59c..025a958 100755 --- a/config/routes.rb +++ b/config/routes.rb @@ -20,7 +20,7 @@ Rails.application.routes.draw do get 'p/:mlm_token' => "public/customers#parrainage", :as => :mlm_token namespace :public do - + resources :conversations get 'documents/:download_token', to: 'documents#download', as: :download_document diff --git a/db/migrate/20170605075024_add_parent_id_to_reseauxes.rb b/db/migrate/20170605075024_add_parent_id_to_reseauxes.rb new file mode 100644 index 0000000..03f17f7 --- /dev/null +++ b/db/migrate/20170605075024_add_parent_id_to_reseauxes.rb @@ -0,0 +1,5 @@ +class AddParentIdToReseauxes < ActiveRecord::Migration + def change + add_column :reseauxes, :parent_id, :integer + end +end diff --git a/db/migrate/20170605133047_create_conversations.rb b/db/migrate/20170605133047_create_conversations.rb new file mode 100644 index 0000000..6e7d3c6 --- /dev/null +++ b/db/migrate/20170605133047_create_conversations.rb @@ -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 diff --git a/db/migrate/20170605133630_create_thing_conversations.rb b/db/migrate/20170605133630_create_thing_conversations.rb new file mode 100644 index 0000000..1231479 --- /dev/null +++ b/db/migrate/20170605133630_create_thing_conversations.rb @@ -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 diff --git a/db/migrate/20170605134146_add_conversation_to_customer_messages.rb b/db/migrate/20170605134146_add_conversation_to_customer_messages.rb new file mode 100644 index 0000000..f353b83 --- /dev/null +++ b/db/migrate/20170605134146_add_conversation_to_customer_messages.rb @@ -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 diff --git a/db/schema.rb b/db/schema.rb index f89a45b..12a6dd8 100755 --- a/db/schema.rb +++ b/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: 20170523073951) do +ActiveRecord::Schema.define(version: 20170605134146) do create_table "accepted_offers", force: :cascade do |t| t.datetime "created_at", null: false @@ -158,6 +158,14 @@ ActiveRecord::Schema.define(version: 20170523073951) do t.datetime "updated_at", null: false 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| t.string "title", limit: 255 t.text "message", limit: 65535 @@ -173,8 +181,11 @@ ActiveRecord::Schema.define(version: 20170523073951) do t.boolean "readed", limit: 1 t.datetime "created_at", null: false t.datetime "updated_at", null: false + t.integer "conversation_id", limit: 4 end + add_index "customer_messages", ["conversation_id"], name: "index_customer_messages_on_conversation_id", using: :btree + create_table "customer_newsgroups", force: :cascade do |t| t.integer "customer_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 "updated_at", null: false t.string "token", limit: 255 + t.integer "parent_id", limit: 4 end create_table "sessions", force: :cascade do |t| @@ -659,6 +671,16 @@ ActiveRecord::Schema.define(version: 20170523073951) do t.datetime "updated_at" 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| t.text "content", limit: 65535 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 end + add_foreign_key "customer_messages", "conversations" add_foreign_key "customer_newsgroups", "customers" add_foreign_key "customer_newsgroups", "newsgroups" 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 "reseaux_customers", "customers" add_foreign_key "reseaux_customers", "reseauxes" + add_foreign_key "thing_conversations", "conversations" end diff --git a/test/fixtures/conversations.yml b/test/fixtures/conversations.yml new file mode 100644 index 0000000..83a1511 --- /dev/null +++ b/test/fixtures/conversations.yml @@ -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 diff --git a/test/fixtures/customer_conversations.yml b/test/fixtures/customer_conversations.yml new file mode 100644 index 0000000..81fdb20 --- /dev/null +++ b/test/fixtures/customer_conversations.yml @@ -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: diff --git a/test/fixtures/reseaux_conversations.yml b/test/fixtures/reseaux_conversations.yml new file mode 100644 index 0000000..9f4ed29 --- /dev/null +++ b/test/fixtures/reseaux_conversations.yml @@ -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: diff --git a/test/fixtures/thing_conversations.yml b/test/fixtures/thing_conversations.yml new file mode 100644 index 0000000..1138638 --- /dev/null +++ b/test/fixtures/thing_conversations.yml @@ -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: diff --git a/test/models/conversation_test.rb b/test/models/conversation_test.rb new file mode 100644 index 0000000..3afa08b --- /dev/null +++ b/test/models/conversation_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class ConversationTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/test/models/customer_conversation_test.rb b/test/models/customer_conversation_test.rb new file mode 100644 index 0000000..cba89b7 --- /dev/null +++ b/test/models/customer_conversation_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class CustomerConversationTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/test/models/reseaux_conversation_test.rb b/test/models/reseaux_conversation_test.rb new file mode 100644 index 0000000..a024890 --- /dev/null +++ b/test/models/reseaux_conversation_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class ReseauxConversationTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/test/models/thing_conversation_test.rb b/test/models/thing_conversation_test.rb new file mode 100644 index 0000000..40caab8 --- /dev/null +++ b/test/models/thing_conversation_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class ThingConversationTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end