From 1f86c03556b7d728f7b0c028823a8c54292c1387 Mon Sep 17 00:00:00 2001 From: Nicolas Bally Date: Mon, 27 Aug 2018 18:46:03 +0200 Subject: [PATCH] suite --- app/controllers/application_controller.rb | 12 ++++++++---- app/controllers/public/abonnements_controller.rb | 10 +++++++++- app/controllers/public/needs_controller.rb | 8 +++++++- app/models/need.rb | 1 + app/views/admin/needs/_form.html.haml | 2 ++ app/views/admin/needs/_need.html.haml | 2 ++ app/views/admin/needs/index.html.haml | 2 ++ app/views/admin/reseauxes/_form.html.haml | 5 +++++ .../confirmation_cheque.html.haml | 12 ++++++++++-- app/views/public/abonnements/new.html.haml | 8 +++++++- app/views/public/my_account/my_reseauxes.html.haml | 2 +- .../20180827132748_add_reseaux_id_to_reseauxes.rb | 5 +++++ .../20180827152648_add_abo_price_to_reseauxes.rb | 8 ++++++++ .../20180827155325_add_reseaux_to_abonnements.rb | 5 +++++ db/schema.rb | 12 +++++++++--- 15 files changed, 81 insertions(+), 13 deletions(-) create mode 100644 db/migrate/20180827132748_add_reseaux_id_to_reseauxes.rb create mode 100644 db/migrate/20180827152648_add_abo_price_to_reseauxes.rb create mode 100644 db/migrate/20180827155325_add_reseaux_to_abonnements.rb diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 7d2bfdb..d9cba69 100755 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -3,16 +3,20 @@ class ApplicationController < ActionController::Base # For APIs, you may want to use :null_session instead. protect_from_forgery with: :exception - + before_filter :get_reseaux before_filter :set_order + def get_reseaux - if session[:reseaux_id] and current_customer + if session[:reseaux_id] and current_customer and !params[:no_reseaux] @reseaux = current_customer.reseauxes.find(session[:reseaux_id]) @reseaux_layout = true + elsif !params[:no_reseaux] + session[:reseaux_id] = nil end + end @@ -63,12 +67,12 @@ class ApplicationController < ActionController::Base def current_abo if current_customer - abo = current_customer.abonnements.where(:paid => true).where("start_at <= ? and end_at >= ?", Time.now, Time.now).first + abo = current_customer.abonnements.where(:paid => true, :reseaux_id => session[:reseaux_id]).where("start_at <= ? and end_at >= ?", Time.now, Time.now).first end end def require_negos_abo - if !current_abo + if !current_abo and (!session[:reseaux_id] or (@reseaux and @reseaux.abo_needed)) redirect_to new_public_abonnement_path end end diff --git a/app/controllers/public/abonnements_controller.rb b/app/controllers/public/abonnements_controller.rb index eee8d8b..d6ee284 100755 --- a/app/controllers/public/abonnements_controller.rb +++ b/app/controllers/public/abonnements_controller.rb @@ -6,12 +6,20 @@ class Public::AbonnementsController < ApplicationController layout "public" def new + + @abonnement = current_customer.abonnements.new(:price => 300.0, :start_at => Time.now, :end_at => (Time.now+14.months).end_of_day, :slug => "negos-principal") + if @reseaux and @reseaux.abo_needed + @abonnement.price = @reseaux.abo_price + end end def create @abonnement = current_customer.abonnements.new(:price => 300.0, :start_at => Time.now, :end_at => (Time.now+14.months).end_of_day, :slug => "negos-principal") - + if @reseaux and @reseaux.abo_needed + @abonnement.price = @reseaux.abo_price + @abonnement.reseaux_id = @reseaux.id + end if @abonnement.save session[:abonnement_id] = @abonnement diff --git a/app/controllers/public/needs_controller.rb b/app/controllers/public/needs_controller.rb index 976aa8c..f5d0651 100755 --- a/app/controllers/public/needs_controller.rb +++ b/app/controllers/public/needs_controller.rb @@ -10,9 +10,14 @@ class Public::NeedsController < ApplicationController before_filter :check_owner, only: [:destroy,:edit,:update] def index - + session[:reseaux_id] = nil if params[:no_reseaux] # Get only public needs @needs = Need.shared + if session[:reseaux_id].to_i > 0 + @needs = @needs.where(:reseaux_id => session[:reseaux_id]) + else + @needs = @needs.where(:reseaux_id => nil) + end @needs = @needs.domain_in(current_customer.domain_ids) # filters default value @@ -117,6 +122,7 @@ class Public::NeedsController < ApplicationController def create @need = Need.new(need_params) + @need.reseaux_id = session[:reseaux_id] @need.author = current_customer if !@need.devis? && !@need.note? diff --git a/app/models/need.rb b/app/models/need.rb index 29cf65b..b925c00 100755 --- a/app/models/need.rb +++ b/app/models/need.rb @@ -2,6 +2,7 @@ class Need < ActiveRecord::Base include Workflow + belongs_to :reseaux belongs_to :referent_technique, :class_name => "Customer" belongs_to :referent_negos, :class_name => "Customer" diff --git a/app/views/admin/needs/_form.html.haml b/app/views/admin/needs/_form.html.haml index 5157bba..750a4e0 100755 --- a/app/views/admin/needs/_form.html.haml +++ b/app/views/admin/needs/_form.html.haml @@ -6,6 +6,8 @@ =f.inputs do + =f.input :reseaux_id, :label => "Réseau :", :collection => Reseaux.where(:parent_id => nil).all, :as => :select, :include_blank => false + =f.input :title, :label => "Titre : " =f.input :category, include_blank: "Toute catégorie", :as => :select, :collection => @tree.map{|c| [(c.level > 0 ? ('   ' * (c.level - 1)) + "|- ": "").html_safe + c.name, c.id]}, label: "Catégorie de besoin" =f.input :description, :label => "Description : ", :rows => 5, :input_html => {:style => "height:100px;"} diff --git a/app/views/admin/needs/_need.html.haml b/app/views/admin/needs/_need.html.haml index 570e9a3..bc5f6e8 100755 --- a/app/views/admin/needs/_need.html.haml +++ b/app/views/admin/needs/_need.html.haml @@ -2,6 +2,8 @@ -css_class = "danger" if need.failed? -css_class = "success" if need.negociated? %tr{:id => need.id, class: css_class} + %td + = need.reseaux.name if need.reseaux %td =link_to need.title, edit_admin_need_path(need) %td diff --git a/app/views/admin/needs/index.html.haml b/app/views/admin/needs/index.html.haml index e6355ba..3506c00 100755 --- a/app/views/admin/needs/index.html.haml +++ b/app/views/admin/needs/index.html.haml @@ -16,6 +16,7 @@ %thead.rows_header %tr + %th Réseaux %th Titre %th @@ -45,6 +46,7 @@ %thead.rows_header %tr + %th Réseaux %th Titre %th diff --git a/app/views/admin/reseauxes/_form.html.haml b/app/views/admin/reseauxes/_form.html.haml index fcc5c81..7e07873 100755 --- a/app/views/admin/reseauxes/_form.html.haml +++ b/app/views/admin/reseauxes/_form.html.haml @@ -18,6 +18,11 @@ =f.input :logo_image_file_id, :label => "Logo :", :as => :qi_image_select =f.input :background_image_file_id, :label => "Image de fond :", :as => :qi_image_select + =f.input :abo_needed, :label => "Abonnement nécessaire ?" + =f.input :abo_price, :label => "Prix de l'abonnement ?" + =f.input :offres_enabled, :label => "Besoins activés ?" + =f.input :needs_enabled, :label => "Offres activées ?" + .actions= f.submit "Sauvegarder", :class => "btn btn-primary" diff --git a/app/views/product_orders_mails/confirmation_cheque.html.haml b/app/views/product_orders_mails/confirmation_cheque.html.haml index 8559595..61d8497 100755 --- a/app/views/product_orders_mails/confirmation_cheque.html.haml +++ b/app/views/product_orders_mails/confirmation_cheque.html.haml @@ -11,8 +11,16 @@ %p Par ailleurs, celle-ci vous sera expédiée dès que nous aurons reçu votre règlement. %p - Pour cela, vous pouvez contacter LA VOUISIENNE au 04 76 55 30 94 ou par mail: - =link_to "contact@lavouisienne.fr.", "mailto:contact@lavouisienne.fr" + Pour cela, vous pouvez régler directement le montant de la commande par virement au RIB suivant : + %p + Bic : + %strong AGRIFRPP878 + %p + IBAN : + %strong FR76 1780 6002 3404 1182 1505 832 + %p + Adresse : + %strong SAS Negos, 15 Chemin du Goulet, 38140 Apprieu %p Vous trouverez ci-dessous le récapitulatif de votre commande : diff --git a/app/views/public/abonnements/new.html.haml b/app/views/public/abonnements/new.html.haml index 7782fbd..1ddd044 100644 --- a/app/views/public/abonnements/new.html.haml +++ b/app/views/public/abonnements/new.html.haml @@ -13,7 +13,13 @@ .center - %p{:style => "text-align:center;font-weight:bold;font-size:18px"} Pour profiter des fonctions de Négos, vous pouvez dès à présent souscrire à un abonnement annuel de 300€ HT (360€ TTC) + %p{:style => "text-align:center;font-weight:bold;font-size:18px"} + Pour profiter des fonctions de Négos, vous pouvez dès à présent souscrire à un abonnement annuel de + =number_to_currency @abonnement.price + HT + ( + =number_to_currency (@abonnement.price.to_f*1.2) + TTC) %center %p=submit_tag "Souscrire maintenant >", :class => "btn btn-primary" diff --git a/app/views/public/my_account/my_reseauxes.html.haml b/app/views/public/my_account/my_reseauxes.html.haml index 42aa294..a762502 100644 --- a/app/views/public/my_account/my_reseauxes.html.haml +++ b/app/views/public/my_account/my_reseauxes.html.haml @@ -12,7 +12,7 @@ %br Choissisez le réseaux sur lequel vous souhaitez vous connecter : .reseauxes_home - =link_to public_needs_path, :class => "reseauxes" do + =link_to public_needs_path(:no_reseaux => true), :class => "reseauxes" do .arrow =ic :"angle-right" Plateforme Négos diff --git a/db/migrate/20180827132748_add_reseaux_id_to_reseauxes.rb b/db/migrate/20180827132748_add_reseaux_id_to_reseauxes.rb new file mode 100644 index 0000000..79c56ea --- /dev/null +++ b/db/migrate/20180827132748_add_reseaux_id_to_reseauxes.rb @@ -0,0 +1,5 @@ +class AddReseauxIdToReseauxes < ActiveRecord::Migration + def change + add_column :needs, :reseaux_id, :integer + end +end diff --git a/db/migrate/20180827152648_add_abo_price_to_reseauxes.rb b/db/migrate/20180827152648_add_abo_price_to_reseauxes.rb new file mode 100644 index 0000000..b80de61 --- /dev/null +++ b/db/migrate/20180827152648_add_abo_price_to_reseauxes.rb @@ -0,0 +1,8 @@ +class AddAboPriceToReseauxes < ActiveRecord::Migration + def change + add_column :reseauxes, :abo_price, :decimal, precision: 10, scale: 2 + add_column :reseauxes, :abo_needed, :boolean, :default => false + add_column :reseauxes, :offres_enabled, :boolean, :default => false + add_column :reseauxes, :needs_enabled, :boolean, :default => false + end +end diff --git a/db/migrate/20180827155325_add_reseaux_to_abonnements.rb b/db/migrate/20180827155325_add_reseaux_to_abonnements.rb new file mode 100644 index 0000000..77dc614 --- /dev/null +++ b/db/migrate/20180827155325_add_reseaux_to_abonnements.rb @@ -0,0 +1,5 @@ +class AddReseauxToAbonnements < ActiveRecord::Migration + def change + add_column :abonnements, :reseaux_id, :integer + end +end diff --git a/db/schema.rb b/db/schema.rb index 76d24cf..3c59b6a 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: 20180816172810) do +ActiveRecord::Schema.define(version: 20180827155325) do create_table "abonnements", force: :cascade do |t| t.integer "abonnement_type_id", limit: 4 @@ -24,6 +24,7 @@ ActiveRecord::Schema.define(version: 20180816172810) do t.integer "customer_id", limit: 4 t.datetime "created_at", null: false t.datetime "updated_at", null: false + t.integer "reseaux_id", limit: 4 end create_table "accepted_offers", force: :cascade do |t| @@ -567,6 +568,7 @@ ActiveRecord::Schema.define(version: 20180816172810) do t.text "note", limit: 65535 t.integer "referent_negos_id", limit: 4 t.integer "referent_technique_id", limit: 4 + t.integer "reseaux_id", limit: 4 end add_index "needs", ["author_id"], name: "index_needs_on_author_id", using: :btree @@ -1021,8 +1023,8 @@ ActiveRecord::Schema.define(version: 20180816172810) do t.string "name", limit: 255 t.text "description", limit: 65535 t.integer "chef_reseau_id", limit: 4 - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false t.string "token", limit: 255 t.integer "parent_id", limit: 4 t.integer "logo_image_file_id", limit: 4 @@ -1030,6 +1032,10 @@ ActiveRecord::Schema.define(version: 20180816172810) do t.string "title", limit: 255 t.string "baseline", limit: 255 t.string "sub_domain", limit: 255 + t.decimal "abo_price", precision: 10 + t.boolean "abo_needed", default: false + t.boolean "offres_enabled", default: false + t.boolean "needs_enabled", default: false end create_table "sessions", force: :cascade do |t|