Add notification table and model
This commit is contained in:
parent
b952b0239c
commit
a681564b39
7 changed files with 58 additions and 1 deletions
|
@ -27,6 +27,7 @@ class Dossier < ActiveRecord::Base
|
|||
has_many :invites, dependent: :destroy
|
||||
has_many :invites_user, class_name: 'InviteUser', dependent: :destroy
|
||||
has_many :follows
|
||||
has_many :notifications, dependent: :destroy
|
||||
|
||||
belongs_to :procedure
|
||||
belongs_to :user
|
||||
|
|
4
app/models/notification.rb
Normal file
4
app/models/notification.rb
Normal file
|
@ -0,0 +1,4 @@
|
|||
class Notification < ActiveRecord::Base
|
||||
belongs_to :dossier
|
||||
|
||||
end
|
|
@ -1,5 +1,8 @@
|
|||
%table#dossiers_list.table
|
||||
%thead
|
||||
- if smart_listing.name.to_s == 'follow_dossiers'
|
||||
%th
|
||||
%i.fa.fa-bell
|
||||
- @facade_data_view.preference_list_dossiers_filter.each do |preference|
|
||||
%th{class: "col-md-#{preference.bootstrap_lg} col-lg-#{preference.bootstrap_lg}"}
|
||||
- if preference.table.to_s.include? 'champs'
|
||||
|
@ -16,6 +19,15 @@
|
|||
- unless smart_listing.empty?
|
||||
- smart_listing.collection.each do |dossier|
|
||||
%tr{id: "tr_dossier_#{dossier.id}", 'data-dossier_url' => backoffice_dossier_url(id: dossier.id)}
|
||||
- if smart_listing.name.to_s == 'follow_dossiers'
|
||||
%td.center
|
||||
- total_notif = dossier.notifications.count
|
||||
- if total_notif == 0
|
||||
.badge.progress-bar-default
|
||||
= total_notif
|
||||
- else
|
||||
.badge.progress-bar-danger
|
||||
= total_notif
|
||||
- @facade_data_view.preference_list_dossiers_filter.each_with_index do |preference, index|
|
||||
%td
|
||||
- if preference.table.nil? || preference.table.empty?
|
||||
|
|
16
db/migrate/20161221153929_create_notification.rb
Normal file
16
db/migrate/20161221153929_create_notification.rb
Normal file
|
@ -0,0 +1,16 @@
|
|||
class CreateNotification < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
create_table :notifications do |t|
|
||||
|
||||
t.boolean :already_read, default: false
|
||||
t.string :liste, array: true
|
||||
t.boolean :multiple, default: false
|
||||
t.string :type_notif
|
||||
t.datetime :created_at
|
||||
t.datetime :updated_at
|
||||
|
||||
end
|
||||
|
||||
add_belongs_to :notifications, :dossier
|
||||
end
|
||||
end
|
13
db/schema.rb
13
db/schema.rb
|
@ -10,7 +10,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20161205110427) do
|
||||
ActiveRecord::Schema.define(version: 20161221153929) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
@ -249,6 +249,17 @@ ActiveRecord::Schema.define(version: 20161205110427) do
|
|||
t.index ["procedure_id"], name: "index_module_api_cartos_on_procedure_id", unique: true, using: :btree
|
||||
end
|
||||
|
||||
create_table "notifications", force: :cascade do |t|
|
||||
t.boolean "already_read", default: false
|
||||
t.string "liste", array: true
|
||||
t.boolean "multiple", default: false
|
||||
t.string "type_notif"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.integer "dossier_id"
|
||||
t.index ["dossier_id"], name: "index_notifications_on_dossier_id", using: :btree
|
||||
end
|
||||
|
||||
create_table "pieces_justificatives", force: :cascade do |t|
|
||||
t.string "content"
|
||||
t.integer "dossier_id"
|
||||
|
|
|
@ -27,6 +27,7 @@ describe Dossier do
|
|||
it { is_expected.to belong_to(:user) }
|
||||
it { is_expected.to have_many(:invites) }
|
||||
it { is_expected.to have_many(:follows) }
|
||||
it { is_expected.to have_many(:notifications) }
|
||||
end
|
||||
|
||||
describe 'delegation' do
|
||||
|
|
12
spec/models/notification_spec.rb
Normal file
12
spec/models/notification_spec.rb
Normal file
|
@ -0,0 +1,12 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Notification do
|
||||
it { is_expected.to have_db_column(:already_read) }
|
||||
it { is_expected.to have_db_column(:liste) }
|
||||
it { is_expected.to have_db_column(:multiple) }
|
||||
it { is_expected.to have_db_column(:type_notif) }
|
||||
it { is_expected.to have_db_column(:created_at) }
|
||||
it { is_expected.to have_db_column(:updated_at) }
|
||||
|
||||
it { is_expected.to belong_to(:dossier) }
|
||||
end
|
Loading…
Reference in a new issue