Merge branch 'dashboard' into rebase_consul_master

This commit is contained in:
Juan Salvador Pérez García
2018-09-27 09:18:27 +02:00
committed by GitHub
72 changed files with 1825 additions and 536 deletions

View File

@@ -34,5 +34,6 @@ require_relative 'dev_seeds/legislation_processes'
require_relative 'dev_seeds/newsletters'
require_relative 'dev_seeds/notifications'
require_relative 'dev_seeds/widgets'
require_relative 'dev_seeds/admin_notifications'
log "All dev seeds created successfuly 👍"

View File

@@ -0,0 +1,28 @@
section "Creating Admin Notifications & Templates" do
AdminNotification.create!(
title: I18n.t('seeds.admin_notification.internal_link.title'),
body: I18n.t('seeds.admin_notification.internal_link.body'),
link: Setting['url'] + I18n.t('seeds.admin_notification.internal_link.link'),
segment_recipient: 'administrators'
).deliver
AdminNotification.create!(
title: I18n.t('seeds.admin_notification.external_link.title'),
body: I18n.t('seeds.admin_notification.external_link.body'),
link: I18n.t('seeds.admin_notification.external_link.link'),
segment_recipient: 'administrators'
).deliver
AdminNotification.create!(
title: I18n.t('seeds.admin_notification.without_link.title'),
body: I18n.t('seeds.admin_notification.without_link.body'),
segment_recipient: 'administrators'
).deliver
AdminNotification.create!(
title: I18n.t('seeds.admin_notification.not_sent.title'),
body: I18n.t('seeds.admin_notification.not_sent.body'),
segment_recipient: 'administrators',
sent_at: nil
)
end

View File

@@ -5,12 +5,6 @@ section "Creating banners" do
target_url = Rails.application.routes.url_helpers.proposal_path(proposal)
banner = Banner.create!(title: title,
description: description,
style: ["banner-style banner-style-one",
"banner-style banner-style-two",
"banner-style banner-style-three"].sample,
image: ["banner-img banner-img-one",
"banner-img banner-img-two",
"banner-img banner-img-three"].sample,
target_url: target_url,
post_started_at: rand((Time.current - 1.week)..(Time.current - 1.day)),
post_ended_at: rand((Time.current - 1.day)..(Time.current + 1.week)),

View File

@@ -1,3 +1,29 @@
INVESTMENT_IMAGE_FILES = %w{
brennan-ehrhardt-25066-unsplash_713x513.jpg
carl-nenzen-loven-381554-unsplash_713x475.jpg
carlos-zurita-215387-unsplash_713x475.jpg
hector-arguello-canals-79584-unsplash_713x475.jpg
olesya-grichina-218176-unsplash_713x475.jpg
sole-d-alessandro-340443-unsplash_713x475.jpg
}.map do |filename|
File.new(Rails.root.join("db",
"dev_seeds",
"images",
"budget",
"investments", filename))
end
def add_image_to(imageable)
# imageable should respond to #title & #author
imageable.image = Image.create!({
imageable: imageable,
title: imageable.title,
attachment: INVESTMENT_IMAGE_FILES.sample,
user: imageable.author
})
imageable.save
end
section "Creating Budgets" do
Budget.create(
name: "#{I18n.t('seeds.budgets.budget')} #{Date.current.year - 1}",
@@ -53,6 +79,8 @@ section "Creating Investments" do
skip_map: "1",
terms_of_service: "1"
)
add_image_to(investment) if Random.rand > 0.5
end
end
@@ -83,7 +111,7 @@ section "Winner Investments" do
budget = Budget.finished.first
50.times do
heading = budget.headings.all.sample
Budget::Investment.create!(
investment = Budget::Investment.create!(
author: User.all.sample,
heading: heading,
group: heading.group,
@@ -98,6 +126,7 @@ section "Winner Investments" do
skip_map: "1",
terms_of_service: "1"
)
add_image_to(investment) if Random.rand > 0.3
end
budget.headings.each do |heading|
Budget::Result.new(budget, heading).calculate_winners

Binary file not shown.

After

Width:  |  Height:  |  Size: 151 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 158 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 132 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 174 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 118 KiB

View File

@@ -0,0 +1,6 @@
class RemoveImageAndStyleFromBanners < ActiveRecord::Migration
def change
remove_column :banners, :image
remove_column :banners, :style
end
end

View File

@@ -0,0 +1,14 @@
class CreateAdminNotifications < ActiveRecord::Migration
def change
create_table :admin_notifications do |t|
t.string :title
t.text :body
t.string :link
t.string :segment_recipient
t.integer :recipients_count
t.date :sent_at, default: nil
t.timestamps null: false
end
end
end

View File

@@ -30,6 +30,17 @@ ActiveRecord::Schema.define(version: 20180726055120) do
add_index "activities", ["actionable_id", "actionable_type"], name: "index_activities_on_actionable_id_and_actionable_type", using: :btree
add_index "activities", ["user_id"], name: "index_activities_on_user_id", using: :btree
create_table "admin_notifications", force: :cascade do |t|
t.string "title"
t.text "body"
t.string "link"
t.string "segment_recipient"
t.integer "recipients_count"
t.date "sent_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
create_table "administrators", force: :cascade do |t|
t.integer "user_id"
end
@@ -74,8 +85,6 @@ ActiveRecord::Schema.define(version: 20180726055120) do
t.string "title", limit: 80
t.string "description"
t.string "target_url"
t.string "style"
t.string "image"
t.date "post_started_at"
t.date "post_ended_at"
t.datetime "hidden_at"

View File

@@ -7,11 +7,11 @@ end
# Names for the moderation console, as a hint for moderators
# to know better how to assign users with official positions
Setting["official_level_1_name"] = "Empleados públicos"
Setting["official_level_2_name"] = "Organización Municipal"
Setting["official_level_3_name"] = "Directores generales"
Setting["official_level_4_name"] = "Concejales"
Setting["official_level_5_name"] = "Alcaldesa"
Setting["official_level_1_name"] = "Cargo oficial 1"
Setting["official_level_2_name"] = "Cargo oficial 2"
Setting["official_level_3_name"] = "Cargo oficial 3"
Setting["official_level_4_name"] = "Cargo oficial 4"
Setting["official_level_5_name"] = "Cargo oficial 5"
# Max percentage of allowed anonymous votes on a debate
Setting["max_ratio_anon_votes_on_debates"] = 50
@@ -26,7 +26,7 @@ Setting["max_votes_for_proposal_edit"] = 1000
Setting['comments_body_max_length'] = 1000
# Prefix for the Proposal codes
Setting["proposal_code_prefix"] = 'MAD'
Setting["proposal_code_prefix"] = 'CONSUL'
# Number of votes needed for proposal success
Setting["votes_for_proposal_success"] = 53726