diff --git a/Gemfile b/Gemfile index 9ef25d08a..0317203bb 100644 --- a/Gemfile +++ b/Gemfile @@ -6,6 +6,7 @@ gem 'rails', '~> 6.1.1' gem 'rails-i18n', '~> 6.0.0' gem 'rdiscount', '~> 2.2.0.1' gem 'activeadmin', '~> 2.9.0' +gem 'bootsnap', '~> 1.7.3', require: false gem 'has_scope', '~> 0.7.2' gem 'pundit', '~> 2.1.0' gem 'pg', '~> 1.2.1' diff --git a/Gemfile.lock b/Gemfile.lock index e95d62ae3..62465c48e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -81,6 +81,8 @@ GEM execjs bcrypt (3.1.16) bindex (0.8.1) + bootsnap (1.7.3) + msgpack (~> 1.0) bootstrap-sass (3.4.1) autoprefixer-rails (>= 5.2.1) sassc (>= 2.0.0) @@ -204,6 +206,7 @@ GEM mini_mime (1.0.2) mini_portile2 (2.5.0) minitest (5.14.4) + msgpack (1.4.2) net-scp (3.0.0) net-ssh (>= 2.6.5, < 7.0.0) net-ssh (6.1.0) @@ -406,6 +409,7 @@ PLATFORMS DEPENDENCIES activeadmin (~> 2.9.0) + bootsnap (~> 1.7.3) bootstrap-sass (~> 3.4) byebug (~> 11.0) capistrano (~> 3.1) diff --git a/app/admin/post.rb b/app/admin/post.rb index 708c38516..976788ef9 100644 --- a/app/admin/post.rb +++ b/app/admin/post.rb @@ -16,7 +16,7 @@ form do |f| f.semantic_errors *f.object.errors.keys f.inputs do - f.input :type, as: :select, collection: %w[Offer Inquiry] + f.input :type, as: :radio, collection: %w[Offer Inquiry] f.input :title f.input :organization f.input :user, hint: "* should be member of the selected organization" diff --git a/app/assets/javascripts/active_admin.js b/app/assets/javascripts/active_admin.js index d2b66c59f..b4d56b4d3 100644 --- a/app/assets/javascripts/active_admin.js +++ b/app/assets/javascripts/active_admin.js @@ -1 +1,6 @@ //= require active_admin/base +//= require select2 + +$(function() { + $("select").select2(); +}); diff --git a/app/assets/stylesheets/active_admin.scss b/app/assets/stylesheets/active_admin.scss index fb70e0687..49d8b8101 100644 --- a/app/assets/stylesheets/active_admin.scss +++ b/app/assets/stylesheets/active_admin.scss @@ -4,3 +4,4 @@ $table-stripe-color: #f5f5f5; @import "active_admin/mixins"; @import "active_admin/base"; +@import "select2"; diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index 1e03e2958..8df55ae59 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -1,12 +1,8 @@ -/* -*= require select2 -*/ - +@import "select2"; @import "application/variables"; @import "bootstrap-sprockets"; @import "application/bootstrap-custom"; -@import "application/to-categories-dropdown"; -@import "application/to-member-card"; +@import "application/member-card"; @import "application/footer"; html { diff --git a/app/assets/stylesheets/application/to-member-card.scss b/app/assets/stylesheets/application/member-card.scss similarity index 100% rename from app/assets/stylesheets/application/to-member-card.scss rename to app/assets/stylesheets/application/member-card.scss diff --git a/app/assets/stylesheets/application/to-categories-dropdown.scss b/app/assets/stylesheets/application/to-categories-dropdown.scss deleted file mode 100644 index 648d224e9..000000000 --- a/app/assets/stylesheets/application/to-categories-dropdown.scss +++ /dev/null @@ -1,5 +0,0 @@ -.to-categories-dropdown { - @media(max-width: $screen-sm-min) { - display: none; - } -} diff --git a/app/controllers/offers_controller.rb b/app/controllers/offers_controller.rb index 227da637c..232ba52e1 100644 --- a/app/controllers/offers_controller.rb +++ b/app/controllers/offers_controller.rb @@ -1,5 +1,3 @@ -# Managems of offer-type posts -# class OffersController < PostsController def model Offer diff --git a/app/helpers/transfers_helper.rb b/app/helpers/transfers_helper.rb index 074229e30..7e6cf20f0 100644 --- a/app/helpers/transfers_helper.rb +++ b/app/helpers/transfers_helper.rb @@ -12,13 +12,13 @@ def accounts_from_movements(transfer, with_links: false) account = movement.account if account.accountable.blank? - I18n.t('.deleted_user') + I18n.t('users.show.deleted_user') elsif account.accountable_type == 'Organization' link_to_if(with_links, account, organization_path(account.accountable)) elsif account.accountable.active link_to_if(with_links, account.accountable.display_name_with_uid, user_path(account.accountable.user)) else - I18n.t('.inactive_user') + I18n.t('users.show.inactive_user') end end end diff --git a/app/models/member.rb b/app/models/member.rb index ddafdc5f7..e9a05215b 100644 --- a/app/models/member.rb +++ b/app/models/member.rb @@ -13,9 +13,7 @@ class Member < ApplicationRecord delegate :balance, to: :account, prefix: true, allow_nil: true delegate :gender, :date_of_birth, to: :user, prefix: true, allow_nil: true - scope :by_month, -> (month) { - where(created_at: month.beginning_of_month..month.end_of_month) - } + scope :by_month, -> (month) { where(created_at: month.beginning_of_month..month.end_of_month) } scope :active, -> { where active: true } validates :organization_id, presence: true diff --git a/app/models/movement.rb b/app/models/movement.rb index 9c974a558..078a427c7 100644 --- a/app/models/movement.rb +++ b/app/models/movement.rb @@ -8,19 +8,16 @@ class Movement < ApplicationRecord belongs_to :account, optional: true belongs_to :transfer, optional: true - has_one :other_side, - (->(self_) { where ["NOT movements.id = #{self_.id}"] }), - through: :transfer, - source: :movements - scope :by_month, - ->(month) { - where(created_at: month.beginning_of_month..month.end_of_month) - } + scope :by_month, -> (month) { where(created_at: month.beginning_of_month..month.end_of_month) } validates :amount, numericality: { other_than: 0 } after_create do account.update_balance end + + def other_side + transfer.movements.where.not(id: id).first + end end diff --git a/app/views/shared/_movements.html.erb b/app/views/shared/_movements.html.erb index e5a786d30..f5ef75d1d 100644 --- a/app/views/shared/_movements.html.erb +++ b/app/views/shared/_movements.html.erb @@ -29,10 +29,10 @@ <%= link_to account.accountable.display_name_with_uid, user_path(account.accountable.user) %> <% else %> - <%= t(".inactive_user") %> + <%= t("users.show.inactive_user") %> <% end %> <% else %> - <%= t(".deleted_user") %> + <%= t("users.show.deleted_user") %> <% end %> <% end %> diff --git a/app/views/shared/_post_filters.html.erb b/app/views/shared/_post_filters.html.erb index 3bb46e0bb..10d1c5eb8 100644 --- a/app/views/shared/_post_filters.html.erb +++ b/app/views/shared/_post_filters.html.erb @@ -18,7 +18,7 @@ -