From 722a431b54483ab9d6cdc7e05980b680a7393348 Mon Sep 17 00:00:00 2001 From: Manu Date: Tue, 1 Jan 2019 18:19:32 -0500 Subject: [PATCH 01/14] Add cards to custom pages --- .../site_customization/cards_controller.rb | 8 + .../admin/widget/cards_controller.rb | 31 +++- app/controllers/pages_controller.rb | 1 + app/models/widget/card.rb | 8 +- .../site_customization/cards/_card.html.erb | 30 ++++ .../site_customization/cards/_cards.html.erb | 16 ++ .../site_customization/cards/index.html.erb | 16 ++ .../site_customization/pages/index.html.erb | 5 + app/views/admin/widget/cards/_form.html.erb | 1 + app/views/pages/_card.html.erb | 16 ++ app/views/pages/_cards.html.erb | 7 + app/views/pages/custom_page.html.erb | 8 + config/routes/admin.rb | 4 +- ...site_customization_page_to_widget_cards.rb | 5 + db/schema.rb | 138 +++++++++++++++++- 15 files changed, 283 insertions(+), 11 deletions(-) create mode 100644 app/controllers/admin/site_customization/cards_controller.rb create mode 100644 app/views/admin/site_customization/cards/_card.html.erb create mode 100644 app/views/admin/site_customization/cards/_cards.html.erb create mode 100644 app/views/admin/site_customization/cards/index.html.erb create mode 100644 app/views/pages/_card.html.erb create mode 100644 app/views/pages/_cards.html.erb create mode 100644 db/migrate/20181218164126_add_site_customization_page_to_widget_cards.rb diff --git a/app/controllers/admin/site_customization/cards_controller.rb b/app/controllers/admin/site_customization/cards_controller.rb new file mode 100644 index 000000000..d2737ff09 --- /dev/null +++ b/app/controllers/admin/site_customization/cards_controller.rb @@ -0,0 +1,8 @@ +class Admin::SiteCustomization::CardsController < Admin::SiteCustomization::BaseController + skip_authorization_check + + def index + @cards = ::Widget::Card.page(params[:page_id]) + end + +end diff --git a/app/controllers/admin/widget/cards_controller.rb b/app/controllers/admin/widget/cards_controller.rb index 519d5ff94..ff8c2b60f 100644 --- a/app/controllers/admin/widget/cards_controller.rb +++ b/app/controllers/admin/widget/cards_controller.rb @@ -2,14 +2,24 @@ class Admin::Widget::CardsController < Admin::BaseController include Translatable def new - @card = ::Widget::Card.new(header: header_card?) + if header_card? + @card = ::Widget::Card.new(header: header_card?) + elsif params[:page_id] != 0 + @card = ::Widget::Card.new(site_customization_page_id: params[:page_id]) + else + @card = ::Widget::Card.new + end end def create @card = ::Widget::Card.new(card_params) if @card.save notice = "Success" - redirect_to admin_homepage_url, notice: notice + if params[:page_id] != 0 + redirect_to admin_site_customization_page_cards_path(page), notice: notice + else + redirect_to admin_homepage_url, notice: notice + end else render :new end @@ -23,7 +33,11 @@ class Admin::Widget::CardsController < Admin::BaseController @card = ::Widget::Card.find(params[:id]) if @card.update(card_params) notice = "Updated" - redirect_to admin_homepage_url, notice: notice + if params[:page_id] != 0 + redirect_to admin_site_customization_page_cards_path(page), notice: notice + else + redirect_to admin_homepage_url, notice: notice + end else render :edit end @@ -34,7 +48,11 @@ class Admin::Widget::CardsController < Admin::BaseController @card.destroy notice = "Removed" - redirect_to admin_homepage_url, notice: notice + if params[:page_id] != 0 + redirect_to admin_site_customization_page_cards_path(page), notice: notice + else + redirect_to admin_homepage_url, notice: notice + end end private @@ -43,7 +61,7 @@ class Admin::Widget::CardsController < Admin::BaseController image_attributes = [:id, :title, :attachment, :cached_attachment, :user_id, :_destroy] params.require(:widget_card).permit( - :link_url, :button_text, :button_url, :alignment, :header, + :link_url, :button_text, :button_url, :alignment, :header, :site_customization_page_id, translation_params(Widget::Card), image_attributes: image_attributes ) @@ -52,6 +70,9 @@ class Admin::Widget::CardsController < Admin::BaseController def header_card? params[:header_card].present? end + def page + ::SiteCustomization::Page.find(@card.site_customization_page_id) + end def resource Widget::Card.find(params[:id]) diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index 489ea9dcf..ec512d70c 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -9,6 +9,7 @@ class PagesController < ApplicationController @banners = Banner.in_section('help_page').with_active if @custom_page.present? + @cards = Widget::Card.page(@custom_page.id) render action: :custom_page else render action: params[:id] diff --git a/app/models/widget/card.rb b/app/models/widget/card.rb index 4a7733e24..2113997f8 100644 --- a/app/models/widget/card.rb +++ b/app/models/widget/card.rb @@ -15,6 +15,12 @@ class Widget::Card < ActiveRecord::Base end def self.body - where(header: false).order(:created_at) + where(header: false, site_customization_page_id: 0).order(:created_at) end + + #add widget cards to custom pages + def self.page(page_id) + where(site_customization_page_id: page_id) + end + end diff --git a/app/views/admin/site_customization/cards/_card.html.erb b/app/views/admin/site_customization/cards/_card.html.erb new file mode 100644 index 000000000..2271f87a1 --- /dev/null +++ b/app/views/admin/site_customization/cards/_card.html.erb @@ -0,0 +1,30 @@ + + + <%= card.label %>
+ <%= card.title %> + + <%= card.description %> + + <%= card.link_text %>
+ <%= card.link_url %> + + + + + <% if card.image.present? %> + <%= link_to t("admin.shared.show_image"), card.image_url(:large), + title: card.image.title, target: "_blank" %> + <% end %> + + + <%= link_to t("admin.actions.edit"), + edit_admin_widget_card_path(card, page_id: params[:page_id]), + class: "button hollow" %> + + <%= link_to t("admin.actions.delete"), + admin_widget_card_path(card, page_id: params[:page_id]), + method: :delete, + data: { confirm: t('admin.actions.confirm') }, + class: "button hollow alert" %> + + diff --git a/app/views/admin/site_customization/cards/_cards.html.erb b/app/views/admin/site_customization/cards/_cards.html.erb new file mode 100644 index 000000000..96a836141 --- /dev/null +++ b/app/views/admin/site_customization/cards/_cards.html.erb @@ -0,0 +1,16 @@ + + + + + + + + + + + + <% cards.each do |card| %> + <%= render "card", card: card %> + <% end %> + +
<%= t("admin.homepage.cards.title") %><%= t("admin.homepage.cards.description") %><%= t("admin.homepage.cards.link_text") %> / <%= t("admin.homepage.cards.link_url") %><%= t("admin.shared.image") %><%= t("admin.shared.actions") %>
diff --git a/app/views/admin/site_customization/cards/index.html.erb b/app/views/admin/site_customization/cards/index.html.erb new file mode 100644 index 000000000..9dd4e932f --- /dev/null +++ b/app/views/admin/site_customization/cards/index.html.erb @@ -0,0 +1,16 @@ +<%= back_link_to admin_site_customization_pages_path %> +
+

<%= t("admin.homepage.cards_title") %>

+ +
+ <%= link_to t("admin.homepage.create_card"), new_admin_widget_card_path(page_id: params[:page_id]), class: "button" %> +
+ + <% if @cards.present? %> + <%= render "cards", cards: @cards %> + <% else %> +
+ <%= t("admin.homepage.no_cards") %> +
+ <% end %> +
diff --git a/app/views/admin/site_customization/pages/index.html.erb b/app/views/admin/site_customization/pages/index.html.erb index 5ff7cb5b7..e5c6afd6c 100644 --- a/app/views/admin/site_customization/pages/index.html.erb +++ b/app/views/admin/site_customization/pages/index.html.erb @@ -13,6 +13,7 @@ <%= t("admin.site_customization.pages.page.title") %> <%= t("admin.site_customization.pages.page.slug") %> + <%= t("admin.homepage.cards_title") %> <%= t("admin.site_customization.pages.page.created_at") %> <%= t("admin.site_customization.pages.page.updated_at") %> <%= t("admin.site_customization.pages.page.status") %> @@ -26,6 +27,10 @@ <%= link_to page.title, edit_admin_site_customization_page_path(page) %> <%= page.slug %> + + <%= link_to "Cards", admin_site_customization_page_cards_path(page), + class: "button hollow expanded" %> + <%= I18n.l page.created_at, format: :short %> <%= I18n.l page.created_at, format: :short %> <%= t("admin.site_customization.pages.page.status_#{page.status}") %> diff --git a/app/views/admin/widget/cards/_form.html.erb b/app/views/admin/widget/cards/_form.html.erb index d9e6a955a..c461b4942 100644 --- a/app/views/admin/widget/cards/_form.html.erb +++ b/app/views/admin/widget/cards/_form.html.erb @@ -21,6 +21,7 @@ <%= f.hidden_field :header, value: @card.header? %> + <%= f.hidden_field :site_customization_page_id, value: @card.site_customization_page_id %>
diff --git a/app/views/pages/_card.html.erb b/app/views/pages/_card.html.erb new file mode 100644 index 000000000..18e642a5b --- /dev/null +++ b/app/views/pages/_card.html.erb @@ -0,0 +1,16 @@ +
+ <%= link_to card.link_url do %> +
+
+ <% if card.image.present? %> + <%= image_tag(card.image_url(:large), alt: card.image.title) %> + <% end %> +
+ <%= card.label %>
+

<%= card.title %>

+
+
+

<%= card.description %>

+

<%= card.link_text %>

+ <% end %> +
diff --git a/app/views/pages/_cards.html.erb b/app/views/pages/_cards.html.erb new file mode 100644 index 000000000..d579e6e75 --- /dev/null +++ b/app/views/pages/_cards.html.erb @@ -0,0 +1,7 @@ +

<%= t("welcome.cards.title") %>

+ +
+ <% @cards.find_each do |card| %> + <%= render "card", card: card %> + <% end %> +
diff --git a/app/views/pages/custom_page.html.erb b/app/views/pages/custom_page.html.erb index 61e167549..0ee3b271a 100644 --- a/app/views/pages/custom_page.html.erb +++ b/app/views/pages/custom_page.html.erb @@ -1,3 +1,4 @@ +<%= content_for :body_class, "home-page" %> <% provide :title do %><%= @custom_page.title %><% end %>
@@ -16,4 +17,11 @@ <%= render '/shared/print' %>
<% end %> + + <% if @cards.any? %> +
+ <%= render "cards" %> +
+ <% end %> +
diff --git a/config/routes/admin.rb b/config/routes/admin.rb index 270a5061c..7e5c8ddeb 100644 --- a/config/routes/admin.rb +++ b/config/routes/admin.rb @@ -214,7 +214,9 @@ namespace :admin do resources :geozones, only: [:index, :new, :create, :edit, :update, :destroy] namespace :site_customization do - resources :pages, except: [:show] + resources :pages, except: [:show] do + resources :cards, only: [:index] + end resources :images, only: [:index, :update, :destroy] resources :content_blocks, except: [:show] delete '/heading_content_blocks/:id', to: 'content_blocks#delete_heading_content_block', as: 'delete_heading_content_block' diff --git a/db/migrate/20181218164126_add_site_customization_page_to_widget_cards.rb b/db/migrate/20181218164126_add_site_customization_page_to_widget_cards.rb new file mode 100644 index 000000000..7f65ed60d --- /dev/null +++ b/db/migrate/20181218164126_add_site_customization_page_to_widget_cards.rb @@ -0,0 +1,5 @@ +class AddSiteCustomizationPageToWidgetCards < ActiveRecord::Migration + def change + add_reference :widget_cards, :site_customization_page, index: true, default: 0 + end +end \ No newline at end of file diff --git a/db/schema.rb b/db/schema.rb index e3241fd8d..17da06042 100644 --- 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: 20181206153510) do +ActiveRecord::Schema.define(version: 20181218164126) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -504,6 +504,46 @@ ActiveRecord::Schema.define(version: 20181206153510) do add_index "geozones_polls", ["geozone_id"], name: "index_geozones_polls_on_geozone_id", using: :btree add_index "geozones_polls", ["poll_id"], name: "index_geozones_polls_on_poll_id", using: :btree + create_table "house_images", force: :cascade do |t| + t.integer "house_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + create_table "house_news", force: :cascade do |t| + t.string "title" + t.string "photo" + t.string "link" + t.string "house_id" + t.datetime "created_at" + t.datetime "updated_at" + end + + create_table "houses", force: :cascade do |t| + t.string "name" + t.string "address" + t.string "schedule" + t.string "phone" + t.string "email" + t.string "photo" + t.boolean "disability_access" + t.integer "zonal_administration_id" + t.datetime "created_at" + t.datetime "updated_at" + end + + create_table "houses_administrators", force: :cascade do |t| + t.integer "user_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + create_table "houses_age_ranges", force: :cascade do |t| + t.string "name" + t.datetime "created_at" + t.datetime "updated_at" + end + create_table "i18n_content_translations", force: :cascade do |t| t.integer "i18n_content_id", null: false t.string "locale", null: false @@ -792,6 +832,7 @@ ActiveRecord::Schema.define(version: 20181206153510) do t.integer "zoom" t.integer "proposal_id" t.integer "investment_id" + t.integer "house_id" end add_index "map_locations", ["investment_id"], name: "index_map_locations_on_investment_id", using: :btree @@ -838,6 +879,13 @@ ActiveRecord::Schema.define(version: 20181206153510) do add_index "moderators", ["user_id"], name: "index_moderators_on_user_id", using: :btree + create_table "neighborhoods", force: :cascade do |t| + t.string "name" + t.integer "id_parish" + t.datetime "created_at" + t.datetime "updated_at" + end + create_table "newsletters", force: :cascade do |t| t.string "subject" t.string "segment_recipient", null: false @@ -870,6 +918,12 @@ ActiveRecord::Schema.define(version: 20181206153510) do add_index "organizations", ["user_id"], name: "index_organizations_on_user_id", using: :btree + create_table "parishes", force: :cascade do |t| + t.string "name" + t.datetime "created_at" + t.datetime "updated_at" + end + create_table "poll_answers", force: :cascade do |t| t.integer "question_id" t.integer "author_id" @@ -1379,6 +1433,11 @@ ActiveRecord::Schema.define(version: 20181206153510) do t.integer "failed_email_digests_count", default: 0 t.text "former_users_data_log", default: "" t.boolean "public_interests", default: false + t.string "userlastname" + t.integer "user_parish" + t.integer "user_neighborhood" + t.string "ethnic_group" + t.string "studies_level" t.boolean "recommended_debates", default: true t.boolean "recommended_proposals", default: true end @@ -1457,6 +1516,39 @@ ActiveRecord::Schema.define(version: 20181206153510) do add_index "visits", ["started_at"], name: "index_visits_on_started_at", using: :btree add_index "visits", ["user_id"], name: "index_visits_on_user_id", using: :btree + create_table "volunt_categories", force: :cascade do |t| + t.string "name" + t.datetime "created_at" + t.datetime "updated_at" + end + + create_table "volunt_programs", force: :cascade do |t| + t.string "title" + t.text "photo" + t.string "schedule" + t.integer "quota" + t.string "short_description" + t.text "long_description" + t.integer "volunt_category_id" + t.datetime "created_at" + t.datetime "updated_at" + t.string "phone" + t.string "email" + end + + create_table "volunt_users", force: :cascade do |t| + t.integer "id_user" + t.integer "volunt_program_id" + t.datetime "created_at" + t.datetime "updated_at" + end + + create_table "volunteerings_administrators", force: :cascade do |t| + t.integer "user_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + create_table "votes", force: :cascade do |t| t.integer "votable_id" t.string "votable_type" @@ -1500,11 +1592,14 @@ ActiveRecord::Schema.define(version: 20181206153510) do t.string "link_text" t.string "link_url" t.string "label" - t.boolean "header", default: false - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.boolean "header", default: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.integer "site_customization_page_id", default: 0 end + add_index "widget_cards", ["site_customization_page_id"], name: "index_widget_cards_on_site_customization_page_id", using: :btree + create_table "widget_feeds", force: :cascade do |t| t.string "kind" t.integer "limit", default: 3 @@ -1512,6 +1607,41 @@ ActiveRecord::Schema.define(version: 20181206153510) do t.datetime "updated_at", null: false end + create_table "workshop_images", force: :cascade do |t| + t.integer "workshop_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + create_table "workshop_users", force: :cascade do |t| + t.integer "id_user" + t.integer "workshop_id" + t.datetime "created_at" + t.datetime "updated_at" + t.integer "status" + end + + create_table "workshops", force: :cascade do |t| + t.string "name" + t.string "teacher" + t.string "schedule" + t.integer "quota" + t.string "short_description" + t.text "long_description" + t.string "photo" + t.integer "house_id" + t.integer "id_age_range" + t.datetime "created_at" + t.datetime "updated_at" + t.string "status" + end + + create_table "zonal_administrations", force: :cascade do |t| + t.string "name" + t.datetime "created_at" + t.datetime "updated_at" + end + add_foreign_key "administrators", "users" add_foreign_key "annotations", "legacy_legislations" add_foreign_key "annotations", "users" From 2dd953bdfd1423a7bf460776478fda06ecd982a0 Mon Sep 17 00:00:00 2001 From: Manu Date: Thu, 10 Jan 2019 15:25:51 -0500 Subject: [PATCH 02/14] added hound corrections and removed wrong tables form the schema.rb --- .../site_customization/cards_controller.rb | 10 +- app/models/widget/card.rb | 2 +- db/schema.rb | 127 ------------------ 3 files changed, 6 insertions(+), 133 deletions(-) diff --git a/app/controllers/admin/site_customization/cards_controller.rb b/app/controllers/admin/site_customization/cards_controller.rb index d2737ff09..4f3e4d6a7 100644 --- a/app/controllers/admin/site_customization/cards_controller.rb +++ b/app/controllers/admin/site_customization/cards_controller.rb @@ -1,8 +1,8 @@ class Admin::SiteCustomization::CardsController < Admin::SiteCustomization::BaseController - skip_authorization_check - - def index - @cards = ::Widget::Card.page(params[:page_id]) - end + skip_authorization_check + + def index + @cards = ::Widget::Card.page(params[:page_id]) + end end diff --git a/app/models/widget/card.rb b/app/models/widget/card.rb index 2113997f8..69023b0ce 100644 --- a/app/models/widget/card.rb +++ b/app/models/widget/card.rb @@ -22,5 +22,5 @@ class Widget::Card < ActiveRecord::Base def self.page(page_id) where(site_customization_page_id: page_id) end - + end diff --git a/db/schema.rb b/db/schema.rb index 17da06042..df8c3b37f 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -504,46 +504,6 @@ ActiveRecord::Schema.define(version: 20181218164126) do add_index "geozones_polls", ["geozone_id"], name: "index_geozones_polls_on_geozone_id", using: :btree add_index "geozones_polls", ["poll_id"], name: "index_geozones_polls_on_poll_id", using: :btree - create_table "house_images", force: :cascade do |t| - t.integer "house_id" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - end - - create_table "house_news", force: :cascade do |t| - t.string "title" - t.string "photo" - t.string "link" - t.string "house_id" - t.datetime "created_at" - t.datetime "updated_at" - end - - create_table "houses", force: :cascade do |t| - t.string "name" - t.string "address" - t.string "schedule" - t.string "phone" - t.string "email" - t.string "photo" - t.boolean "disability_access" - t.integer "zonal_administration_id" - t.datetime "created_at" - t.datetime "updated_at" - end - - create_table "houses_administrators", force: :cascade do |t| - t.integer "user_id" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - end - - create_table "houses_age_ranges", force: :cascade do |t| - t.string "name" - t.datetime "created_at" - t.datetime "updated_at" - end - create_table "i18n_content_translations", force: :cascade do |t| t.integer "i18n_content_id", null: false t.string "locale", null: false @@ -832,7 +792,6 @@ ActiveRecord::Schema.define(version: 20181218164126) do t.integer "zoom" t.integer "proposal_id" t.integer "investment_id" - t.integer "house_id" end add_index "map_locations", ["investment_id"], name: "index_map_locations_on_investment_id", using: :btree @@ -879,13 +838,6 @@ ActiveRecord::Schema.define(version: 20181218164126) do add_index "moderators", ["user_id"], name: "index_moderators_on_user_id", using: :btree - create_table "neighborhoods", force: :cascade do |t| - t.string "name" - t.integer "id_parish" - t.datetime "created_at" - t.datetime "updated_at" - end - create_table "newsletters", force: :cascade do |t| t.string "subject" t.string "segment_recipient", null: false @@ -918,12 +870,6 @@ ActiveRecord::Schema.define(version: 20181218164126) do add_index "organizations", ["user_id"], name: "index_organizations_on_user_id", using: :btree - create_table "parishes", force: :cascade do |t| - t.string "name" - t.datetime "created_at" - t.datetime "updated_at" - end - create_table "poll_answers", force: :cascade do |t| t.integer "question_id" t.integer "author_id" @@ -1433,11 +1379,6 @@ ActiveRecord::Schema.define(version: 20181218164126) do t.integer "failed_email_digests_count", default: 0 t.text "former_users_data_log", default: "" t.boolean "public_interests", default: false - t.string "userlastname" - t.integer "user_parish" - t.integer "user_neighborhood" - t.string "ethnic_group" - t.string "studies_level" t.boolean "recommended_debates", default: true t.boolean "recommended_proposals", default: true end @@ -1516,39 +1457,6 @@ ActiveRecord::Schema.define(version: 20181218164126) do add_index "visits", ["started_at"], name: "index_visits_on_started_at", using: :btree add_index "visits", ["user_id"], name: "index_visits_on_user_id", using: :btree - create_table "volunt_categories", force: :cascade do |t| - t.string "name" - t.datetime "created_at" - t.datetime "updated_at" - end - - create_table "volunt_programs", force: :cascade do |t| - t.string "title" - t.text "photo" - t.string "schedule" - t.integer "quota" - t.string "short_description" - t.text "long_description" - t.integer "volunt_category_id" - t.datetime "created_at" - t.datetime "updated_at" - t.string "phone" - t.string "email" - end - - create_table "volunt_users", force: :cascade do |t| - t.integer "id_user" - t.integer "volunt_program_id" - t.datetime "created_at" - t.datetime "updated_at" - end - - create_table "volunteerings_administrators", force: :cascade do |t| - t.integer "user_id" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - end - create_table "votes", force: :cascade do |t| t.integer "votable_id" t.string "votable_type" @@ -1607,41 +1515,6 @@ ActiveRecord::Schema.define(version: 20181218164126) do t.datetime "updated_at", null: false end - create_table "workshop_images", force: :cascade do |t| - t.integer "workshop_id" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - end - - create_table "workshop_users", force: :cascade do |t| - t.integer "id_user" - t.integer "workshop_id" - t.datetime "created_at" - t.datetime "updated_at" - t.integer "status" - end - - create_table "workshops", force: :cascade do |t| - t.string "name" - t.string "teacher" - t.string "schedule" - t.integer "quota" - t.string "short_description" - t.text "long_description" - t.string "photo" - t.integer "house_id" - t.integer "id_age_range" - t.datetime "created_at" - t.datetime "updated_at" - t.string "status" - end - - create_table "zonal_administrations", force: :cascade do |t| - t.string "name" - t.datetime "created_at" - t.datetime "updated_at" - end - add_foreign_key "administrators", "users" add_foreign_key "annotations", "legacy_legislations" add_foreign_key "annotations", "users" From 5627d2cf23b021f5dea1a55e3750fdeca91bc02a Mon Sep 17 00:00:00 2001 From: Manu Date: Sat, 12 Jan 2019 19:45:37 -0500 Subject: [PATCH 03/14] added associations between cards and pages models --- app/models/site_customization/page.rb | 1 + app/models/widget/card.rb | 1 + 2 files changed, 2 insertions(+) diff --git a/app/models/site_customization/page.rb b/app/models/site_customization/page.rb index 9940e66d9..9d3c6b37e 100644 --- a/app/models/site_customization/page.rb +++ b/app/models/site_customization/page.rb @@ -1,5 +1,6 @@ class SiteCustomization::Page < ActiveRecord::Base VALID_STATUSES = %w(draft published) + has_many :cards, class_name: 'Widget::Card', foreign_key: 'site_customization_page_id' translates :title, touch: true translates :subtitle, touch: true diff --git a/app/models/widget/card.rb b/app/models/widget/card.rb index 69023b0ce..0ef8f591f 100644 --- a/app/models/widget/card.rb +++ b/app/models/widget/card.rb @@ -1,5 +1,6 @@ class Widget::Card < ActiveRecord::Base include Imageable + belongs_to :page, class_name: 'SiteCustomization::Page', foreign_key: 'site_customization_page_id' # table_name must be set before calls to 'translates' self.table_name = "widget_cards" From 7657a0e0b4db2deddd34f5f8829d162af1b09aa7 Mon Sep 17 00:00:00 2001 From: Manu Date: Sat, 12 Jan 2019 20:09:54 -0500 Subject: [PATCH 04/14] added i18n text to custom pages cards --- .../admin/site_customization/cards_controller.rb | 3 ++- .../admin/site_customization/cards/_cards.html.erb | 6 +++--- .../admin/site_customization/cards/index.html.erb | 8 +++++--- .../admin/site_customization/pages/index.html.erb | 4 ++-- config/locales/en/admin.yml | 10 ++++++++++ config/locales/es/admin.yml | 10 ++++++++++ 6 files changed, 32 insertions(+), 9 deletions(-) diff --git a/app/controllers/admin/site_customization/cards_controller.rb b/app/controllers/admin/site_customization/cards_controller.rb index 4f3e4d6a7..c0d06018e 100644 --- a/app/controllers/admin/site_customization/cards_controller.rb +++ b/app/controllers/admin/site_customization/cards_controller.rb @@ -2,7 +2,8 @@ class Admin::SiteCustomization::CardsController < Admin::SiteCustomization::Base skip_authorization_check def index - @cards = ::Widget::Card.page(params[:page_id]) + @page = ::SiteCustomization::Page.find(params[:page_id]) + @cards = @page.cards end end diff --git a/app/views/admin/site_customization/cards/_cards.html.erb b/app/views/admin/site_customization/cards/_cards.html.erb index 96a836141..be538c0d0 100644 --- a/app/views/admin/site_customization/cards/_cards.html.erb +++ b/app/views/admin/site_customization/cards/_cards.html.erb @@ -1,9 +1,9 @@ - - - + + + diff --git a/app/views/admin/site_customization/cards/index.html.erb b/app/views/admin/site_customization/cards/index.html.erb index 9dd4e932f..94c2b4e8f 100644 --- a/app/views/admin/site_customization/cards/index.html.erb +++ b/app/views/admin/site_customization/cards/index.html.erb @@ -1,16 +1,18 @@ <%= back_link_to admin_site_customization_pages_path %>
-

<%= t("admin.homepage.cards_title") %>

+

+ <%= @page.title %> <%= t("admin.site_customization.pages.cards.cards_title") %>

- <%= link_to t("admin.homepage.create_card"), new_admin_widget_card_path(page_id: params[:page_id]), class: "button" %> + <%= link_to t("admin.site_customization.pages.cards.create_card"), + new_admin_widget_card_path(page_id: params[:page_id]), class: "button" %>
<% if @cards.present? %> <%= render "cards", cards: @cards %> <% else %>
- <%= t("admin.homepage.no_cards") %> + <%= t("admin.site_customization.pages.cards.no_cards") %>
<% end %>
diff --git a/app/views/admin/site_customization/pages/index.html.erb b/app/views/admin/site_customization/pages/index.html.erb index e5c6afd6c..bf1b24569 100644 --- a/app/views/admin/site_customization/pages/index.html.erb +++ b/app/views/admin/site_customization/pages/index.html.erb @@ -13,7 +13,7 @@ - + @@ -28,7 +28,7 @@ diff --git a/config/locales/en/admin.yml b/config/locales/en/admin.yml index 7033fefbf..4c3d5023c 100644 --- a/config/locales/en/admin.yml +++ b/config/locales/en/admin.yml @@ -1424,6 +1424,16 @@ en: status_published: Published title: Title slug: Slug + cards_title: Cards + see_cards: See Cards + cards: + cards_title: cards + create_card: Create card + no_cards: There are no cards. + title: Title + description: Description + link_text: Link text + link_url: Link URL homepage: title: Homepage description: The active modules appear in the homepage in the same order as here. diff --git a/config/locales/es/admin.yml b/config/locales/es/admin.yml index 0075225c7..9156e445f 100644 --- a/config/locales/es/admin.yml +++ b/config/locales/es/admin.yml @@ -1423,6 +1423,16 @@ es: status_published: Publicada title: Título slug: Slug + cards_title: Tarjetas + see_cards: Ver tarjetas + cards: + cards_title: tarjetas + create_card: Crear tarjeta + no_cards: No hay tarjetas. + title: Título + description: Descripción + link_text: Texto del enlace + link_url: URL del enlace homepage: title: Título description: Los módulos activos aparecerán en la homepage en el mismo orden que aquí. From 26db37a17fe83e9723e42098dcac901901161d82 Mon Sep 17 00:00:00 2001 From: Manu Date: Sat, 12 Jan 2019 21:36:55 -0500 Subject: [PATCH 05/14] fixed wrong menu selection inside site content --- app/helpers/admin_helper.rb | 8 ++++++-- app/views/admin/_menu.html.erb | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/helpers/admin_helper.rb b/app/helpers/admin_helper.rb index 55825aba0..06e8c3eb7 100644 --- a/app/helpers/admin_helper.rb +++ b/app/helpers/admin_helper.rb @@ -54,11 +54,15 @@ module AdminHelper end def menu_customization? - ["pages", "banners", "information_texts"].include?(controller_name) || menu_homepage? + ["pages", "banners", "information_texts"].include?(controller_name) || menu_homepage? || menu_pages? end def menu_homepage? - ["homepage", "cards"].include?(controller_name) + ["homepage", "cards"].include?(controller_name) && params[:page_id].nil? + end + + def menu_pages? + ["pages", "cards"].include?(controller_name) && params[:page_id].present? end def official_level_options diff --git a/app/views/admin/_menu.html.erb b/app/views/admin/_menu.html.erb index c6ea68172..acc59b45a 100644 --- a/app/views/admin/_menu.html.erb +++ b/app/views/admin/_menu.html.erb @@ -122,7 +122,7 @@ <%= link_to t("admin.menu.site_customization.homepage"), admin_homepage_path %> -
  • > +
  • > <%= link_to t("admin.menu.site_customization.pages"), admin_site_customization_pages_path %>
  • From 86d75767e8d54cff683a46185b0867ea2ed4cf88 Mon Sep 17 00:00:00 2001 From: Manu Date: Sun, 13 Jan 2019 14:22:33 -0500 Subject: [PATCH 06/14] change h3 tag to h2 and added title of the custom page which we are adding the cards --- app/views/admin/site_customization/cards/index.html.erb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/views/admin/site_customization/cards/index.html.erb b/app/views/admin/site_customization/cards/index.html.erb index 94c2b4e8f..1256f7017 100644 --- a/app/views/admin/site_customization/cards/index.html.erb +++ b/app/views/admin/site_customization/cards/index.html.erb @@ -1,7 +1,10 @@ +<% provide :title do %> + <%= t("admin.header.title") %> - <%= t("admin.menu.site_customization.pages") %> - <%= @page.title %> +<% end %> <%= back_link_to admin_site_customization_pages_path %>
    -

    - <%= @page.title %> <%= t("admin.site_customization.pages.cards.cards_title") %>

    +

    + <%= @page.title %> <%= t("admin.site_customization.pages.cards.cards_title") %>

    <%= link_to t("admin.site_customization.pages.cards.create_card"), From 142a0403d6ab5d81ccc2bbdd892d9b98e5284e55 Mon Sep 17 00:00:00 2001 From: Manu Date: Sun, 13 Jan 2019 14:31:51 -0500 Subject: [PATCH 07/14] added new scss class 'custom-page' --- app/assets/stylesheets/layout.scss | 3 ++- app/views/pages/custom_page.html.erb | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/assets/stylesheets/layout.scss b/app/assets/stylesheets/layout.scss index 88738c072..cc28cf33a 100644 --- a/app/assets/stylesheets/layout.scss +++ b/app/assets/stylesheets/layout.scss @@ -2728,7 +2728,8 @@ table { // 24. Homepage // ------------ -.home-page { +.home-page, +.custom-page { a { diff --git a/app/views/pages/custom_page.html.erb b/app/views/pages/custom_page.html.erb index 0ee3b271a..2af339117 100644 --- a/app/views/pages/custom_page.html.erb +++ b/app/views/pages/custom_page.html.erb @@ -1,4 +1,4 @@ -<%= content_for :body_class, "home-page" %> +<%= content_for :body_class, "custom-page" %> <% provide :title do %><%= @custom_page.title %><% end %>
    From 238ddc2595fb3df556a74ed09da9be63002b6659 Mon Sep 17 00:00:00 2001 From: Manu Date: Sun, 13 Jan 2019 15:20:12 -0500 Subject: [PATCH 08/14] fixed trailing whitespace hound alert --- app/assets/stylesheets/layout.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/stylesheets/layout.scss b/app/assets/stylesheets/layout.scss index cc28cf33a..b37405d63 100644 --- a/app/assets/stylesheets/layout.scss +++ b/app/assets/stylesheets/layout.scss @@ -2728,7 +2728,7 @@ table { // 24. Homepage // ------------ -.home-page, +.home-page, .custom-page { a { From bff3a3b3795d63ffd229aef05d54cc577e8c6010 Mon Sep 17 00:00:00 2001 From: Manu Date: Sun, 13 Jan 2019 16:30:56 -0500 Subject: [PATCH 09/14] use relation between cards and page models --- app/controllers/pages_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index ec512d70c..eae9e7509 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -9,7 +9,7 @@ class PagesController < ApplicationController @banners = Banner.in_section('help_page').with_active if @custom_page.present? - @cards = Widget::Card.page(@custom_page.id) + @cards = @custom_page.cards render action: :custom_page else render action: params[:id] From 162b61f94c8237d9c32bb275d14549433cfb8486 Mon Sep 17 00:00:00 2001 From: Manu Date: Sun, 13 Jan 2019 16:33:54 -0500 Subject: [PATCH 10/14] updated test file for cards --- spec/models/widget/card_spec.rb | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/spec/models/widget/card_spec.rb b/spec/models/widget/card_spec.rb index 70c13eafa..428135b30 100644 --- a/spec/models/widget/card_spec.rb +++ b/spec/models/widget/card_spec.rb @@ -26,12 +26,25 @@ describe Widget::Card do it "returns cards for the homepage body" do header = create(:widget_card, header: true) - card1 = create(:widget_card, header: false, title: "Card 1") - card2 = create(:widget_card, header: false, title: "Card 2") - card3 = create(:widget_card, header: false, title: "Card 3") + card1 = create(:widget_card, header: false, title: "Card 1", site_customization_page_id: 0) + card2 = create(:widget_card, header: false, title: "Card 2", site_customization_page_id: 0) + card3 = create(:widget_card, header: false, title: "Card 3", site_customization_page_id: 0) expect(Widget::Card.body).to eq([card1, card2, card3]) end end + describe "#custom page" do + + it "return cards for the custom pages" do + header = create(:widget_card, header: true) + card = create(:widget_card, header: false) + card1 = create(:widget_card, header: false, title: "Card 1", site_customization_page_id: 1) + card2 = create(:widget_card, header: false, title: "Card 2", site_customization_page_id: 1) + card3 = create(:widget_card, header: false, title: "Card 3", site_customization_page_id: 1) + + expect(Widget::Card.page(1)).to eq([card1, card2, card3]) + end + end + end \ No newline at end of file From 8a643c72e7c41d720b87595440497ea7a07358e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Fri, 18 Jan 2019 13:09:07 +0100 Subject: [PATCH 11/14] Use I18n for card notice messages --- app/controllers/admin/widget/cards_controller.rb | 7 ++++--- config/locales/en/admin.yml | 7 +++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/app/controllers/admin/widget/cards_controller.rb b/app/controllers/admin/widget/cards_controller.rb index ff8c2b60f..bc4cecfd8 100644 --- a/app/controllers/admin/widget/cards_controller.rb +++ b/app/controllers/admin/widget/cards_controller.rb @@ -14,7 +14,8 @@ class Admin::Widget::CardsController < Admin::BaseController def create @card = ::Widget::Card.new(card_params) if @card.save - notice = "Success" + notice = t("admin.site_customization.pages.cards.create.notice") + if params[:page_id] != 0 redirect_to admin_site_customization_page_cards_path(page), notice: notice else @@ -32,7 +33,7 @@ class Admin::Widget::CardsController < Admin::BaseController def update @card = ::Widget::Card.find(params[:id]) if @card.update(card_params) - notice = "Updated" + notice = t("admin.site_customization.pages.cards.update.notice") if params[:page_id] != 0 redirect_to admin_site_customization_page_cards_path(page), notice: notice else @@ -47,7 +48,7 @@ class Admin::Widget::CardsController < Admin::BaseController @card = ::Widget::Card.find(params[:id]) @card.destroy - notice = "Removed" + notice = t("admin.site_customization.pages.cards.delete.notice") if params[:page_id] != 0 redirect_to admin_site_customization_page_cards_path(page), notice: notice else diff --git a/config/locales/en/admin.yml b/config/locales/en/admin.yml index 4c3d5023c..c9dc067fc 100644 --- a/config/locales/en/admin.yml +++ b/config/locales/en/admin.yml @@ -1434,6 +1434,13 @@ en: description: Description link_text: Link text link_url: Link URL + create: + notice: "Success" + update: + notice: "Updated" + destroy: + notice: "Removed" + homepage: title: Homepage description: The active modules appear in the homepage in the same order as here. From 9c050ca6bda0f93f32b15db0eb909375714dee29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Fri, 18 Jan 2019 13:12:30 +0100 Subject: [PATCH 12/14] Extract method to redirect when managing cards --- .../admin/widget/cards_controller.rb | 33 ++++++++----------- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/app/controllers/admin/widget/cards_controller.rb b/app/controllers/admin/widget/cards_controller.rb index bc4cecfd8..d2d028e9a 100644 --- a/app/controllers/admin/widget/cards_controller.rb +++ b/app/controllers/admin/widget/cards_controller.rb @@ -14,13 +14,7 @@ class Admin::Widget::CardsController < Admin::BaseController def create @card = ::Widget::Card.new(card_params) if @card.save - notice = t("admin.site_customization.pages.cards.create.notice") - - if params[:page_id] != 0 - redirect_to admin_site_customization_page_cards_path(page), notice: notice - else - redirect_to admin_homepage_url, notice: notice - end + redirect_to_customization_page_cards_or_homepage else render :new end @@ -33,12 +27,7 @@ class Admin::Widget::CardsController < Admin::BaseController def update @card = ::Widget::Card.find(params[:id]) if @card.update(card_params) - notice = t("admin.site_customization.pages.cards.update.notice") - if params[:page_id] != 0 - redirect_to admin_site_customization_page_cards_path(page), notice: notice - else - redirect_to admin_homepage_url, notice: notice - end + redirect_to_customization_page_cards_or_homepage else render :edit end @@ -48,12 +37,7 @@ class Admin::Widget::CardsController < Admin::BaseController @card = ::Widget::Card.find(params[:id]) @card.destroy - notice = t("admin.site_customization.pages.cards.delete.notice") - if params[:page_id] != 0 - redirect_to admin_site_customization_page_cards_path(page), notice: notice - else - redirect_to admin_homepage_url, notice: notice - end + redirect_to_customization_page_cards_or_homepage end private @@ -71,6 +55,17 @@ class Admin::Widget::CardsController < Admin::BaseController def header_card? params[:header_card].present? end + + def redirect_to_customization_page_cards_or_homepage + notice = t("admin.site_customization.pages.cards.#{params[:action]}.notice") + + if params[:page_id] != 0 + redirect_to admin_site_customization_page_cards_path(page), notice: notice + else + redirect_to admin_homepage_url, notice: notice + end + end + def page ::SiteCustomization::Page.find(@card.site_customization_page_id) end From 2926e4e3757e336b91ad3fe56dfa50be4d2a6d45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Fri, 18 Jan 2019 14:06:40 +0100 Subject: [PATCH 13/14] Fix managing widget cards for homepage The condition `params[:page_id] != 0` didn't work properly when editing the homepage because in that case the parameter was `nil`, and the line `SiteCustomization::Page.find(@card.site_customization_page_id)` raised an exception because it couldn't find a page with a `nil` ID. Fixing the issue while maintaining the check against `0` lead to complex code, and so allowing `nil` in the database and assuming cards with no `site_customization_page_id` belonged in the homepage seemed to be the easiest solution. --- app/controllers/admin/widget/cards_controller.rb | 6 ++---- app/models/widget/card.rb | 2 +- ...126_add_site_customization_page_to_widget_cards.rb | 2 +- db/schema.rb | 2 +- spec/models/widget/card_spec.rb | 11 +++++++---- 5 files changed, 12 insertions(+), 11 deletions(-) diff --git a/app/controllers/admin/widget/cards_controller.rb b/app/controllers/admin/widget/cards_controller.rb index d2d028e9a..d106c9e60 100644 --- a/app/controllers/admin/widget/cards_controller.rb +++ b/app/controllers/admin/widget/cards_controller.rb @@ -4,10 +4,8 @@ class Admin::Widget::CardsController < Admin::BaseController def new if header_card? @card = ::Widget::Card.new(header: header_card?) - elsif params[:page_id] != 0 - @card = ::Widget::Card.new(site_customization_page_id: params[:page_id]) else - @card = ::Widget::Card.new + @card = ::Widget::Card.new(site_customization_page_id: params[:page_id]) end end @@ -59,7 +57,7 @@ class Admin::Widget::CardsController < Admin::BaseController def redirect_to_customization_page_cards_or_homepage notice = t("admin.site_customization.pages.cards.#{params[:action]}.notice") - if params[:page_id] != 0 + if @card.site_customization_page_id redirect_to admin_site_customization_page_cards_path(page), notice: notice else redirect_to admin_homepage_url, notice: notice diff --git a/app/models/widget/card.rb b/app/models/widget/card.rb index 0ef8f591f..bc7da86d2 100644 --- a/app/models/widget/card.rb +++ b/app/models/widget/card.rb @@ -16,7 +16,7 @@ class Widget::Card < ActiveRecord::Base end def self.body - where(header: false, site_customization_page_id: 0).order(:created_at) + where(header: false, site_customization_page_id: nil).order(:created_at) end #add widget cards to custom pages diff --git a/db/migrate/20181218164126_add_site_customization_page_to_widget_cards.rb b/db/migrate/20181218164126_add_site_customization_page_to_widget_cards.rb index 7f65ed60d..f4dad35fc 100644 --- a/db/migrate/20181218164126_add_site_customization_page_to_widget_cards.rb +++ b/db/migrate/20181218164126_add_site_customization_page_to_widget_cards.rb @@ -1,5 +1,5 @@ class AddSiteCustomizationPageToWidgetCards < ActiveRecord::Migration def change - add_reference :widget_cards, :site_customization_page, index: true, default: 0 + add_reference :widget_cards, :site_customization_page, index: true end end \ No newline at end of file diff --git a/db/schema.rb b/db/schema.rb index df8c3b37f..5fe814447 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -1503,7 +1503,7 @@ ActiveRecord::Schema.define(version: 20181218164126) do t.boolean "header", default: false t.datetime "created_at", null: false t.datetime "updated_at", null: false - t.integer "site_customization_page_id", default: 0 + t.integer "site_customization_page_id" end add_index "widget_cards", ["site_customization_page_id"], name: "index_widget_cards_on_site_customization_page_id", using: :btree diff --git a/spec/models/widget/card_spec.rb b/spec/models/widget/card_spec.rb index 428135b30..b9816f213 100644 --- a/spec/models/widget/card_spec.rb +++ b/spec/models/widget/card_spec.rb @@ -26,11 +26,14 @@ describe Widget::Card do it "returns cards for the homepage body" do header = create(:widget_card, header: true) - card1 = create(:widget_card, header: false, title: "Card 1", site_customization_page_id: 0) - card2 = create(:widget_card, header: false, title: "Card 2", site_customization_page_id: 0) - card3 = create(:widget_card, header: false, title: "Card 3", site_customization_page_id: 0) + card1 = create(:widget_card, header: false) + card2 = create(:widget_card, header: false) + page_card = create(:widget_card, header: false, page: create(:site_customization_page)) - expect(Widget::Card.body).to eq([card1, card2, card3]) + expect(Widget::Card.body).to include(card1) + expect(Widget::Card.body).to include(card2) + expect(Widget::Card.body).not_to include(header) + expect(Widget::Card.body).not_to include(page_card) end end From 486100bf53cbe542e5e7f50e7d2f4b982c4ca9ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Fri, 18 Jan 2019 15:03:19 +0100 Subject: [PATCH 14/14] Add specs for custom page cards --- spec/features/admin/widgets/cards_spec.rb | 52 +++++++++++++++++++ .../site_customization/custom_pages_spec.rb | 9 ++++ 2 files changed, 61 insertions(+) diff --git a/spec/features/admin/widgets/cards_spec.rb b/spec/features/admin/widgets/cards_spec.rb index 97571bf32..27f6a4d2b 100644 --- a/spec/features/admin/widgets/cards_spec.rb +++ b/spec/features/admin/widgets/cards_spec.rb @@ -130,6 +130,58 @@ feature 'Cards' do end end + context "Page card" do + let!(:custom_page) { create(:site_customization_page) } + + scenario "Create", :js do + visit admin_site_customization_pages_path + click_link "See Cards" + click_link "Create card" + + fill_in "Title", with: "Card for a custom page" + click_button "Create card" + + expect(page).to have_current_path admin_site_customization_page_cards_path(custom_page) + expect(page).to have_content "Card for a custom page" + end + + scenario "Edit", :js do + create(:widget_card, page: custom_page, title: "Original title") + + visit admin_site_customization_page_cards_path(custom_page) + + expect(page).to have_content("Original title") + + click_link "Edit" + + within(".translatable-fields") do + fill_in "Title", with: "Updated title" + end + + click_button "Save card" + + expect(page).to have_current_path admin_site_customization_page_cards_path(custom_page) + expect(page).to have_content "Updated title" + expect(page).not_to have_content "Original title" + end + + scenario "Destroy", :js do + create(:widget_card, page: custom_page, title: "Card title") + + visit admin_site_customization_page_cards_path(custom_page) + + expect(page).to have_content("Card title") + + accept_confirm do + click_link "Delete" + end + + expect(page).to have_current_path admin_site_customization_page_cards_path(custom_page) + expect(page).not_to have_content "Card title" + end + + end + end pending "add image expectactions" diff --git a/spec/features/site_customization/custom_pages_spec.rb b/spec/features/site_customization/custom_pages_spec.rb index 662388ef2..b3b478698 100644 --- a/spec/features/site_customization/custom_pages_spec.rb +++ b/spec/features/site_customization/custom_pages_spec.rb @@ -135,6 +135,15 @@ feature "Custom Pages" do expect(page).to have_selector("h1", text: "Another custom page") expect(page).to have_content("Subtitle for custom page") end + + scenario "Show widget cards for that page" do + custom_page = create(:site_customization_page, :published) + create(:widget_card, page: custom_page, title: "Card Highlights") + + visit custom_page.url + + expect(page).to have_content "Card Highlights" + end end end end
    <%= t("admin.homepage.cards.title") %><%= t("admin.homepage.cards.description") %><%= t("admin.homepage.cards.link_text") %> / <%= t("admin.homepage.cards.link_url") %><%= t("admin.site_customization.pages.cards.title") %><%= t("admin.site_customization.pages.cards.description") %><%= t("admin.site_customization.pages.cards.link_text") %> / <%= t("admin.site_customization.pages.cards.link_url") %> <%= t("admin.shared.image") %> <%= t("admin.shared.actions") %>
    <%= t("admin.site_customization.pages.page.title") %> <%= t("admin.site_customization.pages.page.slug") %><%= t("admin.homepage.cards_title") %><%= t("admin.site_customization.pages.page.cards_title") %> <%= t("admin.site_customization.pages.page.created_at") %> <%= t("admin.site_customization.pages.page.updated_at") %> <%= t("admin.site_customization.pages.page.status") %> <%= page.slug %> - <%= link_to "Cards", admin_site_customization_page_cards_path(page), + <%= link_to t("admin.site_customization.pages.page.see_cards"), admin_site_customization_page_cards_path(page), class: "button hollow expanded" %> <%= I18n.l page.created_at, format: :short %>