Skip to content

Commit

Permalink
v3.0.18
Browse files Browse the repository at this point in the history
Merge pull request #799 from TechforgoodCAST/develop
  • Loading branch information
suninthesky authored Dec 3, 2018
2 parents beb1463 + 0d4703e commit 7dec5f9
Show file tree
Hide file tree
Showing 53 changed files with 442 additions and 506 deletions.
4 changes: 0 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ gem 'bcrypt', '~> 3.1.7'
# gem 'capistrano-rails', group: :development

gem 'activerecord-import'
gem 'cells-rails' # TODO: remove
gem 'cells-slim' # TODO: remove
gem 'chartkick'
gem 'groupdate'
gem 'hamlit'
Expand All @@ -49,7 +47,6 @@ gem 'activeadmin'
gem 'devise', '~> 4.4.0'

# Monitoring & metrics
gem 'intercom-rails' # TODO: review
gem 'rollbar'
group :production do
gem 'rails_12factor'
Expand All @@ -63,7 +60,6 @@ group :development, :test do
gem 'capybara'
gem 'dotenv-rails'
gem 'factory_bot_rails'
gem 'rspec-cells' # TODO: remove
gem 'rspec-rails', '3.5.2'
gem 'selenium-webdriver'
gem 'stripe-ruby-mock', require: 'stripe_mock'
Expand Down
27 changes: 0 additions & 27 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,6 @@ GEM
rack (>= 1.6.0)
rack-test (>= 0.6.3)
xpath (~> 3.1)
cells (4.1.7)
declarative-builder (< 0.2.0)
declarative-option (< 0.2.0)
tilt (>= 1.4, < 3)
uber (< 0.2.0)
cells-rails (0.0.8)
actionpack (>= 3.0)
cells (>= 4.1.6, < 5.0.0)
cells-slim (0.0.5)
cells (>= 4.0.1, < 6.0.0)
slim (~> 3.0)
chartkick (2.2.4)
childprocess (0.9.0)
ffi (~> 1.0, >= 1.0.11)
Expand All @@ -102,9 +91,6 @@ GEM
crass (1.0.4)
dante (0.2.0)
database_cleaner (1.6.1)
declarative-builder (0.1.0)
declarative-option (< 0.2.0)
declarative-option (0.1.0)
devise (4.4.3)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
Expand Down Expand Up @@ -151,8 +137,6 @@ GEM
has_scope (~> 0.6)
railties (>= 4.2, <= 5.2)
responders
intercom-rails (0.3.5)
activesupport (> 3.0)
jbuilder (2.7.0)
activesupport (>= 4.2.0)
multi_json (>= 1.2)
Expand Down Expand Up @@ -274,9 +258,6 @@ GEM
netrc (~> 0.8)
rollbar (2.16.3)
multi_json
rspec-cells (0.3.4)
cells (>= 4.0.0, < 6.0.0)
rspec-rails (~> 3.2)
rspec-core (3.5.4)
rspec-support (~> 3.5.0)
rspec-expectations (3.5.0)
Expand Down Expand Up @@ -325,9 +306,6 @@ GEM
activemodel (> 4, < 5.2)
sitemap_generator (5.3.1)
builder (~> 3.0)
slim (3.0.8)
temple (>= 0.7.6, < 0.9)
tilt (>= 1.3.3, < 2.1)
slop (3.6.0)
spring (2.0.2)
activesupport (>= 4.2)
Expand Down Expand Up @@ -359,7 +337,6 @@ GEM
turbolinks-source (5.1.0)
tzinfo (1.2.5)
thread_safe (~> 0.1)
uber (0.1.0)
uglifier (3.2.0)
execjs (>= 0.3.0, < 3)
unf (0.1.4)
Expand Down Expand Up @@ -399,8 +376,6 @@ DEPENDENCIES
bullet
byebug
capybara
cells-rails
cells-slim
chartkick
climate_control
database_cleaner
Expand All @@ -410,7 +385,6 @@ DEPENDENCIES
groupdate
hamlit
hashids
intercom-rails
jbuilder (~> 2.5)
kaminari
listen (>= 3.0.5, < 3.2)
Expand All @@ -425,7 +399,6 @@ DEPENDENCIES
rails_12factor
redcarpet
rollbar
rspec-cells
rspec-rails (= 3.5.2)
rubocop
sass-rails (~> 5.0)
Expand Down
6 changes: 1 addition & 5 deletions app/admin/funder.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ActiveAdmin.register Funder do
permit_params :active, :microsite, :name, :primary_color, :secondary_color,
permit_params :active, :name, :primary_color, :secondary_color,
:slug, :website

controller do
Expand All @@ -16,7 +16,6 @@ def find_resource
link_to funder.name, [:admin, funder]
end
column :active
column :microsite
column :funds do |funder|
funder.funds.size
end
Expand All @@ -32,7 +31,6 @@ def find_resource
row :charity_number
row :company_number
row :active
row :microsite
row :primary_color
row :secondary_color
row :opportunities_last_updated_at
Expand All @@ -42,7 +40,6 @@ def find_resource
table_for funder.funds do
column :slug
column :active
column :microsite
column :actions do |fund|
link_to 'View', [:admin, fund]
link_to 'Edit', [:edit_admin, fund]
Expand All @@ -56,7 +53,6 @@ def find_resource
f.input :slug
f.input :name
f.input :active
f.input :microsite
f.input :primary_color, as: :string
f.input :secondary_color, as: :string
end
Expand Down
70 changes: 25 additions & 45 deletions app/admin/recipient.rb
Original file line number Diff line number Diff line change
@@ -1,66 +1,46 @@
ActiveAdmin.register Recipient do
permit_params :name, :contact_number, :website, :street_address, :city,
:region, :postal_code, :country, :charity_number,
:company_number, :founded_on, :registered_on, :mission, :status,
:registered, :active_on_beehive, organisation_ids: []
permit_params :category_name, :charity_number, :company_number, :country,
:description, :district, :income_band_name, :name,
:operating_for_name, :website

controller do
def scoped_collection
end_of_association_chain.includes(:country)
end

def find_resource
scoped_collection.where(slug: params[:id]).first!
scoped_collection.find_by_hashid(params[:id])
end
end

filter :name
filter :charity_number
filter :company_number
filter :country
filter :registered
filter :founded_on
filter :category_code
filter :created_at
filter :updated_at

index do
selectable_column
column :name
column :website
column :category_name
column :country
column :org_type
column :street_address
column :postal_code
column :latitude
column :longitude
column :created_at
actions
end

show do
tabs do
tab 'Overview' do
attributes_table do
row :id
row :name
row :mission
row :status
row :founded_on
row(:registered) { status_tag(recipient.registered) }
row :registered_on
row :contact_number
row :website
row :charity_number
row :company_number
row('Users') do |recipient|
recipient.users.each.map{|user| "<li><a href=\"#{admin_user_path(user)}\">#{user.email}</a> | Authorised: #{user.authorised}</li>"}.join("").html_safe
end
end
end

tab 'Address' do
attributes_table do
row :street_address
row :city
row :region
row :postal_code
row :country
end
end
attributes_table do
row :id
row :name
row :category_name
row :description
row :charity_number
row :company_number
row :country
row :district
row :income_band_name
row :operating_for_name
row :website
row :user
end
end
end
2 changes: 1 addition & 1 deletion app/admin/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
column :last_seen
actions
column 'Action' do |user|
link_to 'Impersonate', impersonate_admin_user_path(user), target: '_blank'
link_to 'Impersonate', impersonate_admin_user_path(user), target: '_blank', rel: 'noopener'
end
end

Expand Down
12 changes: 12 additions & 0 deletions app/assets/stylesheets/custom.sass
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
max-width: 125px
@media screen and (max-width: 25rem)
max-width: 120px
.crumb
margin: 0 5px
@media screen and (max-width: 46.875rem)
.bread, .crumb
display: none
Expand Down Expand Up @@ -146,6 +148,16 @@ article.featured
width: 32px
height: 30px

nav
@media screen and (max-width: 30rem)
a
font-size: 15px
.mx20
margin-left: 10px
margin-right: 10px
.ml20
margin-left: 10px

#navbar-logo
width: 106px
height: 20px
Expand Down
6 changes: 0 additions & 6 deletions app/cells/breadcrumb/show.slim

This file was deleted.

19 changes: 0 additions & 19 deletions app/cells/breadcrumb_cell.rb

This file was deleted.

2 changes: 0 additions & 2 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ class ApplicationController < ActionController::Base

before_action :current_user

skip_after_action :intercom_rails_auto_include

rescue_from ActionController::InvalidAuthenticityToken, with: :bad_token
rescue_from Pundit::NotAuthorizedError, with: :user_not_authorised
rescue_from ActionController::UnknownFormat do
Expand Down
24 changes: 24 additions & 0 deletions app/helpers/breadcrumbs_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
module BreadcrumbsHelper
def breadcrumbs(hash = {}, color: 'white')
items = []

hash.each_with_index do |(text, link), i|
items << tag.div('›', class: "crumb #{color}")

opts = link.blank? ? "disabled #{color}" : color

items << tag.a(
tag.div(text, class: 'truncate'),
class: "bread #{opts}", href: link
)
end

return if items.empty?

items.last.sub!('bread', 'bold bread')

"<div class='maxw1050 mx-auto px15 fs14 lh18 mb30'>" \
"<a href='#{root_path}' class='bread #{color}'>Home</a>" \
"#{items.join}</div>".html_safe
end
end
4 changes: 4 additions & 0 deletions app/helpers/reports_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ def amount_sought(proposal = @proposal)
"Between #{min} and #{max}"
end

def created_by(recipient = @proposal.recipient)
recipient.individual? ? 'an individual' : recipient.name
end

def location_description(proposal = @proposal)
"#{proposal.geographic_scale.capitalize} - " \
"#{proposal.countries.pluck(:name).to_sentence}"
Expand Down
2 changes: 1 addition & 1 deletion app/models/application_record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def markdown(str, plain: false)
options = { hard_wrap: true,
space_after_headers: true, fenced_code_blocks: true,
tables: true, footnotes: true,
link_attributes: { target: '_blank' } }
link_attributes: { target: '_blank', rel: 'noopener' } }

extensions = { autolink: true, disable_indented_code_blocks: true }

Expand Down
5 changes: 4 additions & 1 deletion app/models/assessment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class Assessment < ApplicationRecord
]).freeze

belongs_to :fund
belongs_to :proposal
belongs_to :proposal, counter_cache: true
belongs_to :recipient

validates :eligibility_status, inclusion: {
Expand All @@ -45,6 +45,9 @@ def self.analyse(funds, proposal)
def self.analyse_and_update!(funds, proposal)
updates = analyse(funds, proposal)
Assessment.import!(updates, on_duplicate_key_update: PERMITTED_COLUMNS)
Proposal.update_counters(
proposal.id, assessments_count: proposal.assessments.count
)
end

def attributes
Expand Down
Loading

0 comments on commit 7dec5f9

Please sign in to comment.