From 4db1ce8f2f490e8ef4559f4ab5949ef1f68f8fcc Mon Sep 17 00:00:00 2001 From: Jorge Morante Date: Tue, 19 Mar 2019 14:16:01 +0100 Subject: [PATCH 1/5] add is_group feature --- app/assets/stylesheets/application.css.scss | 10 ++++++++++ app/controllers/posts_controller.rb | 2 +- app/views/shared/_post.html.erb | 3 +++ app/views/shared/_post_form.html.erb | 6 ++++++ app/views/shared/_posts.html.erb | 3 +++ config/locales/en.yml | 1 + db/migrate/20190319121401_add_is_group_to_post.rb | 5 +++++ db/schema.rb | 5 +++-- 8 files changed, 32 insertions(+), 3 deletions(-) create mode 100644 db/migrate/20190319121401_add_is_group_to_post.rb diff --git a/app/assets/stylesheets/application.css.scss b/app/assets/stylesheets/application.css.scss index 086a5c238..30da15afe 100644 --- a/app/assets/stylesheets/application.css.scss +++ b/app/assets/stylesheets/application.css.scss @@ -179,6 +179,10 @@ html { margin: 14px 0; padding: 5px 20px; + .post__group_label { + margin-left: 10px; + } + h4 { font-weight: bold; display: block; @@ -710,3 +714,9 @@ label[required]::after{ line-height: 1.6em; } } + +.inline-checkbox { + vertical-align: middle; + display: inline; + margin: 0 !important; +} diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb index 71c35f9b1..83d88fea2 100644 --- a/app/controllers/posts_controller.rb +++ b/app/controllers/posts_controller.rb @@ -108,7 +108,7 @@ def set_user_id(p) def post_params permitted_fields = [:description, :end_on, :global, :joinable, :permanent, - :start_on, :title, :category_id, :user_id, + :start_on, :title, :category_id, :user_id, :is_group, :publisher_id, :active, tag_list: []] params.fetch(resource, {}).permit(*permitted_fields).tap do |p| diff --git a/app/views/shared/_post.html.erb b/app/views/shared/_post.html.erb index 3751e5de3..e9118dd10 100644 --- a/app/views/shared/_post.html.erb +++ b/app/views/shared/_post.html.erb @@ -7,6 +7,9 @@

<%= post.class.model_name.human %> + <% if post.is_group %> +
<%= I18n.t('activerecord.attributes.post.is_group') %>
+ <% end %>

diff --git a/app/views/shared/_post_form.html.erb b/app/views/shared/_post_form.html.erb index 7717e54c2..4d5d264bf 100644 --- a/app/views/shared/_post_form.html.erb +++ b/app/views/shared/_post_form.html.erb @@ -24,6 +24,12 @@ { include_blank: true }, class: "form-control" %>
+ <% if post.class.to_s == 'Offer' %> +
+ <%= f.label :is_group, required: true %> + <%= f.check_box :is_group, class: 'inline-checkbox' %> +
+ <% end %>
<%= f.label :tag_list %> <%= f.select :tag_list, diff --git a/app/views/shared/_posts.html.erb b/app/views/shared/_posts.html.erb index 1e2dc89e6..6e9de9ee0 100644 --- a/app/views/shared/_posts.html.erb +++ b/app/views/shared/_posts.html.erb @@ -2,6 +2,9 @@

<%= link_to post.title, post %> + <% if post.is_group %> +
<%= I18n.t('activerecord.attributes.post.is_group') %>
+ <% end %>

<%= strip_tags(post.rendered_description.to_html) %> diff --git a/config/locales/en.yml b/config/locales/en.yml index 199e837fc..1cba69b94 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -44,6 +44,7 @@ en: start_on: Start on tag_list: Tags title: Title + is_group: Group offer updated_at: Updated transfer: amount: Quantity diff --git a/db/migrate/20190319121401_add_is_group_to_post.rb b/db/migrate/20190319121401_add_is_group_to_post.rb new file mode 100644 index 000000000..5e62aee63 --- /dev/null +++ b/db/migrate/20190319121401_add_is_group_to_post.rb @@ -0,0 +1,5 @@ +class AddIsGroupToPost < ActiveRecord::Migration + def change + add_column :posts, :is_group, :boolean, default: false + end +end diff --git a/db/schema.rb b/db/schema.rb index 38963d039..bcb4a05c1 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: 20181004200104) do +ActiveRecord::Schema.define(version: 20190319121401) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -146,10 +146,11 @@ t.boolean "global" t.datetime "created_at" t.datetime "updated_at" - t.text "tags", array: true + t.text "tags", array: true t.integer "publisher_id" t.integer "organization_id" t.boolean "active", default: true + t.boolean "is_group", default: false end add_index "posts", ["category_id"], name: "index_posts_on_category_id", using: :btree From 265961c728bdb00d022216522c271fae770d605c Mon Sep 17 00:00:00 2001 From: Jorge Morante Date: Thu, 21 Mar 2019 15:37:07 +0100 Subject: [PATCH 2/5] use different copies in form, for offers and inquiries --- app/views/shared/_post.html.erb | 2 +- app/views/shared/_post_form.html.erb | 10 ++++------ app/views/shared/_posts.html.erb | 2 +- config/locales/en.yml | 7 ++++++- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/app/views/shared/_post.html.erb b/app/views/shared/_post.html.erb index e9118dd10..15ee103f5 100644 --- a/app/views/shared/_post.html.erb +++ b/app/views/shared/_post.html.erb @@ -8,7 +8,7 @@

<%= post.class.model_name.human %> <% if post.is_group %> -
<%= I18n.t('activerecord.attributes.post.is_group') %>
+
<%= I18n.t("activerecord.attributes.#{post.class.name.downcase}.is_group") %>
<% end %>

diff --git a/app/views/shared/_post_form.html.erb b/app/views/shared/_post_form.html.erb index 4d5d264bf..59613136a 100644 --- a/app/views/shared/_post_form.html.erb +++ b/app/views/shared/_post_form.html.erb @@ -24,12 +24,10 @@ { include_blank: true }, class: "form-control" %>
- <% if post.class.to_s == 'Offer' %> -
- <%= f.label :is_group, required: true %> - <%= f.check_box :is_group, class: 'inline-checkbox' %> -
- <% end %> +
+ <%= label :post, :is_group, I18n.t("shared.post_form.group_#{post.class.name.downcase}"), required: true %> + <%= f.check_box :is_group, class: 'inline-checkbox' %> +
<%= f.label :tag_list %> <%= f.select :tag_list, diff --git a/app/views/shared/_posts.html.erb b/app/views/shared/_posts.html.erb index 6e9de9ee0..69fbd1e7c 100644 --- a/app/views/shared/_posts.html.erb +++ b/app/views/shared/_posts.html.erb @@ -3,7 +3,7 @@

<%= link_to post.title, post %> <% if post.is_group %> -
<%= I18n.t('activerecord.attributes.post.is_group') %>
+
<%= I18n.t("activerecord.attributes.#{post.class.name.downcase}.is_group") %>
<% end %>

diff --git a/config/locales/en.yml b/config/locales/en.yml index 1cba69b94..0bdfdcba8 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -34,6 +34,10 @@ en: reg_number_seq: User sequence number theme: Theme updated_at: Updated + offer: + is_group: Group offer + inquiry: + is_group: Group inquiry post: category: Category created_at: Created @@ -44,7 +48,6 @@ en: start_on: Start on tag_list: Tags title: Title - is_group: Group offer updated_at: Updated transfer: amount: Quantity @@ -420,6 +423,8 @@ en: delete_reason: Are you sure to delete this comment? movements: Movements post_form: + group_offer: Is it a group offer? + group_inquiry: Is it a group inquiry? you_can_use: You can use simple_form: error_notification: From 9aa2b48218096ffbadab9a364ecfb0c47fa09b92 Mon Sep 17 00:00:00 2001 From: Jorge Morante Date: Thu, 21 Mar 2019 15:47:06 +0100 Subject: [PATCH 3/5] update view tests --- spec/views/inquiries/show.html.erb_spec.rb | 37 ++++++++++++++++++++++ spec/views/offers/show.html.erb_spec.rb | 21 ++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 spec/views/inquiries/show.html.erb_spec.rb diff --git a/spec/views/inquiries/show.html.erb_spec.rb b/spec/views/inquiries/show.html.erb_spec.rb new file mode 100644 index 000000000..6fea82f5c --- /dev/null +++ b/spec/views/inquiries/show.html.erb_spec.rb @@ -0,0 +1,37 @@ +require 'spec_helper' + +RSpec.describe 'inquiries/show' do + let(:organization) { Fabricate(:organization) } + let(:member) { Fabricate(:member, organization: organization) } + let(:inquiry) { Fabricate(:inquiry, user: member.user, organization: organization) } + let(:group_inquiry) { Fabricate(:inquiry, user: member.user, organization: organization, is_group: true) } + let(:destination_account) { Fabricate(:account) } + + + context 'when the user is not logged in' do + before do + allow(view).to receive(:current_user).and_return(nil) + allow(view).to receive(:current_organization).and_return(nil) + end + + context 'when it is not a group inquiry' do + it 'displays a label' do + assign :inquiry, inquiry + assign :destination_account, destination_account + render template: 'inquiries/show' + + expect(rendered).to_not include(I18n.t('activerecord.attributes.inquiry.is_group')) + end + end + + context 'when it is a group inquiry' do + it 'displays a label' do + assign :inquiry, group_inquiry + assign :destination_account, destination_account + render template: 'inquiries/show' + + expect(rendered).to include(I18n.t('activerecord.attributes.inquiry.is_group')) + end + end + end +end diff --git a/spec/views/offers/show.html.erb_spec.rb b/spec/views/offers/show.html.erb_spec.rb index 42b992c78..f7cdf4338 100644 --- a/spec/views/offers/show.html.erb_spec.rb +++ b/spec/views/offers/show.html.erb_spec.rb @@ -4,6 +4,7 @@ let(:organization) { Fabricate(:organization) } let(:member) { Fabricate(:member, organization: organization) } let(:offer) { Fabricate(:offer, user: member.user, organization: organization) } + let(:group_offer) { Fabricate(:offer, user: member.user, organization: organization, is_group: true) } let(:destination_account) { Fabricate(:account) } before do @@ -152,5 +153,25 @@ expect(rendered).to_not include(offer.user.email) end + + context 'when it is not a group offer' do + it 'displays a label' do + assign :offer, offer + assign :destination_account, destination_account + render template: 'offers/show' + + expect(rendered).to_not include(I18n.t('activerecord.attributes.offer.is_group')) + end + end + + context 'when it is a group offer' do + it 'displays a label' do + assign :offer, group_offer + assign :destination_account, destination_account + render template: 'offers/show' + + expect(rendered).to include(I18n.t('activerecord.attributes.offer.is_group')) + end + end end end From 4f09cda42f476ac8f97e3b975b18baa6998d7627 Mon Sep 17 00:00:00 2001 From: sseerrggii Date: Wed, 3 Apr 2019 07:32:21 +0200 Subject: [PATCH 4/5] New translations --- config/locales/ca.yml | 6 ++++++ config/locales/es.yml | 6 ++++++ config/locales/eu.yml | 6 ++++++ config/locales/gl.yml | 28 +++++++++++++++++----------- config/locales/pt-BR.yml | 6 ++++++ 5 files changed, 41 insertions(+), 11 deletions(-) diff --git a/config/locales/ca.yml b/config/locales/ca.yml index 201011210..2e86d63a7 100644 --- a/config/locales/ca.yml +++ b/config/locales/ca.yml @@ -21,6 +21,10 @@ ca: common: created_at: Creat updated_at: Actualitzat + inquiry: + is_group: Demanda Grupal + offer: + is_group: Oferta Grupal organization: address: Direcció city: Ciutat @@ -419,6 +423,8 @@ ca: delete_reason: Esteu segur d'esborrar aquest comentari? movements: Moviments post_form: + group_inquiry: És una demanda grupal? + group_offer: És una oferta grupal? you_can_use: Pots fer servir simple_form: error_notification: diff --git a/config/locales/es.yml b/config/locales/es.yml index b9654ca8f..f6af5bcac 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -21,6 +21,10 @@ es: common: created_at: Creado updated_at: Actualizado + inquiry: + is_group: Demanda Grupal + offer: + is_group: Oferta Grupal organization: address: Dirección city: Ciudad @@ -419,6 +423,8 @@ es: delete_reason: "¿Está seguro de borrar este comentario?" movements: Movimientos post_form: + group_inquiry: Es una demanda grupal? + group_offer: Es una oferta grupal? you_can_use: Puedes usar simple_form: error_notification: diff --git a/config/locales/eu.yml b/config/locales/eu.yml index b2cf066e8..b75c4b0d5 100644 --- a/config/locales/eu.yml +++ b/config/locales/eu.yml @@ -21,6 +21,10 @@ eu: common: created_at: Sortua updated_at: Eguneratua + inquiry: + is_group: + offer: + is_group: organization: address: Helbidea city: Herria @@ -425,6 +429,8 @@ eu: delete_reason: Zihur zaude , azalpen hau ezabatu nahi duzula? movements: Mugimenduak post_form: + group_inquiry: + group_offer: you_can_use: Erabil dezakezu simple_form: error_notification: diff --git a/config/locales/gl.yml b/config/locales/gl.yml index 740e70946..4fb04e053 100644 --- a/config/locales/gl.yml +++ b/config/locales/gl.yml @@ -21,6 +21,10 @@ gl: common: created_at: Creado updated_at: Actualizado + inquiry: + is_group: Solicitude grupal + offer: + is_group: Oferta grupal organization: address: Dirección city: Cidade @@ -96,8 +100,8 @@ gl: one: Comentario other: Comentarios inquiry: - one: Enquisa - other: Enquisas + one: Demanda + other: Demandas offer: one: Oferta other: Ofertas @@ -137,9 +141,9 @@ gl: demographics: Datos demográficos global_activity: Actividade global inactive_users: Persoas suarias inactivas - inquiry_public_link: Consultas de enlace público + inquiry_public_link: Demandas de enlace público last_login: Último inicio de sesión - offer_public_link: Ofrece unha conexión pública + offer_public_link: Enlace público a ofertas organizations: Organizacións reports: Informes sign_out: Saír @@ -316,7 +320,7 @@ gl: edit: submit: Cambiar consulta index: - new_inquiry: Nova consulta + new_inquiry: Nova Demanda new: submit: Crear consulta layouts: @@ -394,13 +398,13 @@ gl: empower-text-3: O código fonte de TimeOverflow está dispoñible en base a unha licenza de código aberto e pode descargala en %{github_link} empower-title: Empoderando os bancos de tempo feature-group-1: Xestión de Banco de tempo con funcións de administración - feature-group-2: Rede social e banca en liña accesibles polas persoas membros - feature-text-1: Creación / eliminación / actualizacións das persoas membros do banco + feature-group-2: Rede social e banca en liña accesibles polas persoas usuarias + feature-text-1: Creación / eliminación / actualizacións das persoas usuarias do banco feature-text-2: Publicación de ofertas e consultas feature-text-3: Inclúe controis e xestión da contabilidade - feature-text-4: As persoas membros dun Banco de Tempo poden acceder ao sistema e conectarse con outras persoas membros + feature-text-4: As persoas usuarias dun Banco de Tempo poden acceder ao sistema e conectarse con outras persoas usuarias feature-text-5: Publicación de ofertas e consultas - feature-text-6: Pague horas a outras persoas membros + feature-text-6: Pague horas a outras persoas usuarias impulsem-link: Aumenta o que fas subtitle: TimeOverflow é de código aberto, gratuíto e colaborativo title: O software deseñado por e para @@ -419,6 +423,8 @@ gl: delete_reason: Estás seguro/a de borrar este comentario? movements: Movementos post_form: + group_inquiry: É unha solicitude grupal? + group_offer: É unha oferta grupal? you_can_use: Podes usar simple_form: error_notification: @@ -452,7 +458,7 @@ gl: num_people: "# de persoas" unknown: Descoñecido statistics_global_activity: - bank_activity: Actividade bancaria + bank_activity: Actividade do Peto end_date: final mm/aaaa global_activity: Actividade global ini_date: ini mm/aaaa @@ -512,7 +518,7 @@ gl: create: Crea unha nova persoa usuaria manage_warning: Vas cambiar privilexios para o usuario/a %{username} manage_warning_angular: Vas cambiar privilexios para o usuario/a {{username}} - members: Persoas membros + members: Persoas usuarias user_created: O usuario/a %{uid} %{name} gardouse member_card: active_ago: Tempo activo %{time} diff --git a/config/locales/pt-BR.yml b/config/locales/pt-BR.yml index b3c5fde3f..be2496192 100644 --- a/config/locales/pt-BR.yml +++ b/config/locales/pt-BR.yml @@ -21,6 +21,10 @@ pt-BR: common: created_at: Criado updated_at: Atualizado + inquiry: + is_group: + offer: + is_group: organization: address: Endereço city: Cidade @@ -419,6 +423,8 @@ pt-BR: delete_reason: Tem certeza de que quer apagar este comentário? movements: Movimentos post_form: + group_inquiry: + group_offer: you_can_use: Você pode usar simple_form: error_notification: From 1d75844bef0a8c170da2096b3732792313e0472c Mon Sep 17 00:00:00 2001 From: sseerrggii Date: Wed, 3 Apr 2019 19:21:29 +0200 Subject: [PATCH 5/5] remove capitals --- config/locales/ca.yml | 4 ++-- config/locales/es.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/config/locales/ca.yml b/config/locales/ca.yml index 2e86d63a7..ac0405a9b 100644 --- a/config/locales/ca.yml +++ b/config/locales/ca.yml @@ -22,9 +22,9 @@ ca: created_at: Creat updated_at: Actualitzat inquiry: - is_group: Demanda Grupal + is_group: Demanda grupal offer: - is_group: Oferta Grupal + is_group: Oferta grupal organization: address: Direcció city: Ciutat diff --git a/config/locales/es.yml b/config/locales/es.yml index f6af5bcac..91d5c69fa 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -22,9 +22,9 @@ es: created_at: Creado updated_at: Actualizado inquiry: - is_group: Demanda Grupal + is_group: Demanda grupal offer: - is_group: Oferta Grupal + is_group: Oferta grupal organization: address: Dirección city: Ciudad