Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LET-1379 [BE] Add new attributes and form fields for projects #783

Merged
merged 10 commits into from
Nov 23, 2023
2 changes: 1 addition & 1 deletion backend/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ GEM
railties (>= 5.0)
retriable (3.1.2)
rexml (3.2.5)
rgeo (2.4.0)
rgeo (3.0.1)
rgeo-activerecord (7.0.1)
activerecord (>= 5.0)
rgeo (>= 1.0.0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ def update_params
:progress_impact_tracking,
:description,
:relevant_links,
:positive_financial_returns,
:last_year_sales_revenue,
:climate_change_risks_details,
:climate_change_risks_identified,
target_groups: [],
impact_areas: [],
sdgs: [],
Expand Down
4 changes: 4 additions & 0 deletions backend/app/controllers/backoffice/projects_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ def update_params
:description,
:relevant_links,
:verified,
:positive_financial_returns,
:last_year_sales_revenue,
:climate_change_risks_details,
:climate_change_risks_identified,
instrument_types: [],
impact_areas: [],
sdgs: [],
Expand Down
5 changes: 4 additions & 1 deletion backend/app/models/project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ class Project < ApplicationRecord
:replicability,
:funding_plan,
:progress_impact_tracking,
:relevant_links
:relevant_links,
:positive_financial_returns,
:last_year_sales_revenue,
:climate_change_risks_details

enum status: ProjectStatus::TYPES_WITH_CODE, _default: :published
ransacker :status, formatter: proc { |v| statuses[v] }
Expand Down
6 changes: 5 additions & 1 deletion backend/app/serializers/api/v1/project_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@ class ProjectSerializer < BaseSerializer
:priority_landscape_water_impact,
:priority_landscape_community_impact,
:priority_landscape_total_impact,
:impact_calculated
:impact_calculated,
:positive_financial_returns,
:last_year_sales_revenue,
:climate_change_risks_details,
:climate_change_risks_identified

belongs_to :project_developer
belongs_to :country, serializer: LocationSerializer
Expand Down
6 changes: 5 additions & 1 deletion backend/app/views/backoffice/projects/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
<%= localized_input f, :solution, content_language, label: t("simple_form.labels.project.solution"), as: :text, input_html: {rows: 5} %>
<%= f.input :target_groups, collection: ProjectTargetGroup.all, label: t("simple_form.labels.project.target_groups"), as: :check_boxes %>
<%= localized_input f, :expected_impact, content_language, label: t("simple_form.labels.project.expected_impact"), as: :text, input_html: {rows: 5} %>

<h2 class="mb-4 mt-6 text-gray-600 font-semibold text-xl">
<%= t(".impact") %>
</h2>
Expand All @@ -71,6 +71,10 @@
<%= f.input :received_funding_amount_usd, label: t("simple_form.labels.project.received_funding_amount_usd") %>
<%= f.input :received_funding_investor, label: t("simple_form.labels.project.received_funding_investor"), as: :string %>
</div>
<%= localized_input f, :positive_financial_returns, content_language, label: t("simple_form.labels.project.positive_financial_returns"), as: :text, input_html: {rows: 5} %>
<%= localized_input f, :last_year_sales_revenue, content_language, label: t("simple_form.labels.project.last_year_sales_revenue"), as: :text, input_html: {rows: 5} %>
<%= f.input :climate_change_risks_identified, label: t("simple_form.labels.project.climate_change_risks_identified"), as: :radio_buttons %>
<%= localized_input f, :climate_change_risks_details, content_language, label: t("simple_form.labels.project.climate_change_risks_details"), as: :text, input_html: {rows: 5} %>

<h2 class="mb-4 mt-6 text-gray-600 font-semibold text-xl">
<%= t(".how_will_project_grow") %>
Expand Down
4 changes: 4 additions & 0 deletions backend/config/locales/zu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ zu:
progress_impact_tracking: Progress and impact tracking
description: Short description of the project
relevant_links: Relevant links (optional)
positive_financial_returns: If your current business model generates positive financial returns, please explain what they consist of
last_year_sales_revenue: What was the sales revenue in the last fiscal year-end?
climate_change_risks_identified: Has the project identified the risks of climate change to which the business is exposed and potential mitigation strategies?
climate_change_risks_details: If yes, please, discribe these risks
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small typo at discribe

open_call:
name: Open call name
picture: Picture
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
class AddFinancialAndClimateChangeDataToProjects < ActiveRecord::Migration[7.0]
def change
add_column :projects, :positive_financial_returns_en, :text, null: true
add_column :projects, :positive_financial_returns_es, :text, null: true
add_column :projects, :positive_financial_returns_pt, :text, null: true
add_column :projects, :last_year_sales_revenue_en, :text, null: true
add_column :projects, :last_year_sales_revenue_es, :text, null: true
add_column :projects, :last_year_sales_revenue_pt, :text, null: true
add_column :projects, :climate_change_risks_details_en, :text, null: true
add_column :projects, :climate_change_risks_details_es, :text, null: true
add_column :projects, :climate_change_risks_details_pt, :text, null: true
add_column :projects, :climate_change_risks_identified, :boolean, default: false
end
end
12 changes: 11 additions & 1 deletion backend/db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions backend/spec/factories/project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,22 @@
Faker::Lorem.paragraph(sentence_count: 4)
end

sequence(:positive_financial_returns) do |n|
Faker::Config.random = Random.new(n)
Faker::Lorem.paragraph(sentence_count: 2)
end
sequence(:last_year_sales_revenue) do |n|
Faker::Config.random = Random.new(n)
Faker::Lorem.paragraph(sentence_count: 1)
end

climate_change_risks_identified { true }

sequence(:climate_change_risks_details) do |n|
Faker::Config.random = Random.new(n)
Faker::Lorem.paragraph(sentence_count: 2)
end

looking_for_funding { true }
instrument_types { %w[grant loan] }
ticket_size { "scaling" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,11 @@
"latitude": 39.21309022641362,
"longitude": -5.87810037515931,
"favourite": false,
"funded": null
"funded": null,
"positive_financial_returns": "Enim repellat pariatur. Earum modi eos.",
"last_year_sales_revenue": "Enim repellat pariatur.",
"climate_change_risks_details": "Enim repellat pariatur. Earum modi eos.",
"climate_change_risks_identified": true
},
"relationships": {
"project_developer": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,11 @@
"latitude": 39.21309022641362,
"longitude": -5.87810037515931,
"favourite": true,
"funded": null
"funded": null,
"positive_financial_returns": "Enim repellat pariatur. Earum modi eos.",
"last_year_sales_revenue": "Enim repellat pariatur.",
"climate_change_risks_details": "Enim repellat pariatur. Earum modi eos.",
"climate_change_risks_identified": true
},
"relationships": {
"project_developer": {
Expand Down
18 changes: 15 additions & 3 deletions backend/spec/fixtures/snapshots/api/v1/account/projects.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,11 @@
"latitude": 39.21309022641362,
"longitude": -5.87810037515931,
"favourite": false,
"funded": null
"funded": null,
"positive_financial_returns": "Dolores fugiat nesciunt. Ut laborum dolores.",
"last_year_sales_revenue": "Dolores fugiat nesciunt.",
"climate_change_risks_details": "Dolores fugiat nesciunt. Ut laborum dolores.",
"climate_change_risks_identified": true
},
"relationships": {
"project_developer": {
Expand Down Expand Up @@ -254,7 +258,11 @@
"latitude": 39.21309022641362,
"longitude": -5.87810037515931,
"favourite": false,
"funded": null
"funded": null,
"positive_financial_returns": "Placeat commodi libero. Quo recusandae repellat.",
"last_year_sales_revenue": "Placeat commodi libero.",
"climate_change_risks_details": "Placeat commodi libero. Quo recusandae repellat.",
"climate_change_risks_identified": true
},
"relationships": {
"project_developer": {
Expand Down Expand Up @@ -402,7 +410,11 @@
"latitude": 39.21309022641362,
"longitude": -5.87810037515931,
"favourite": false,
"funded": null
"funded": null,
"positive_financial_returns": "Enim repellat pariatur. Earum modi eos.",
"last_year_sales_revenue": "Enim repellat pariatur.",
"climate_change_risks_details": "Enim repellat pariatur. Earum modi eos.",
"climate_change_risks_identified": true
},
"relationships": {
"project_developer": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,11 @@
"project_climate_impact": null,
"project_water_impact": null,
"project_community_impact": null,
"project_total_impact": null
"project_total_impact": null,
"positive_financial_returns": null,
"last_year_sales_revenue": null,
"climate_change_risks_details": null,
"climate_change_risks_identified": false
},
"relationships": {
"project_developer": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,11 @@
"project_climate_impact": null,
"project_water_impact": null,
"project_community_impact": null,
"project_total_impact": null
"project_total_impact": null,
"positive_financial_returns": "Updated financial returns data",
"last_year_sales_revenue": "Updated year sales revenues",
"climate_change_risks_details": "Updated climate risk details",
"climate_change_risks_identified": true
},
"relationships": {
"project_developer": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,11 @@
"latitude": 39.21309022641362,
"longitude": -5.87810037515931,
"favourite": null,
"funded": null
"funded": null,
"positive_financial_returns": "Enim repellat pariatur. Earum modi eos.",
"last_year_sales_revenue": "Enim repellat pariatur.",
"climate_change_risks_details": "Enim repellat pariatur. Earum modi eos.",
"climate_change_risks_identified": true
},
"relationships": {
"project_developer": {
Expand Down Expand Up @@ -278,7 +282,11 @@
"latitude": 39.21309022641362,
"longitude": -5.87810037515931,
"favourite": null,
"funded": null
"funded": null,
"positive_financial_returns": "Placeat commodi libero. Quo recusandae repellat.",
"last_year_sales_revenue": "Placeat commodi libero.",
"climate_change_risks_details": "Placeat commodi libero. Quo recusandae repellat.",
"climate_change_risks_identified": true
},
"relationships": {
"project_developer": {
Expand Down
6 changes: 5 additions & 1 deletion backend/spec/fixtures/snapshots/api/v1/get-project.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,11 @@
"project_climate_impact": null,
"project_water_impact": null,
"project_community_impact": null,
"project_total_impact": null
"project_total_impact": null,
"positive_financial_returns": "Enim repellat pariatur. Earum modi eos.",
"last_year_sales_revenue": "Enim repellat pariatur.",
"climate_change_risks_details": "Enim repellat pariatur. Earum modi eos.",
"climate_change_risks_identified": true
},
"relationships": {
"project_developer": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,11 @@
"latitude": 39.21309022641362,
"longitude": -5.87810037515931,
"favourite": null,
"funded": null
"funded": null,
"positive_financial_returns": "Enim repellat pariatur. Earum modi eos.",
"last_year_sales_revenue": "Enim repellat pariatur.",
"climate_change_risks_details": "Enim repellat pariatur. Earum modi eos.",
"climate_change_risks_identified": true
},
"relationships": {
"project_developer": {
Expand Down Expand Up @@ -406,7 +410,11 @@
"latitude": 39.21309022641362,
"longitude": -5.87810037515931,
"favourite": null,
"funded": null
"funded": null,
"positive_financial_returns": "Placeat commodi libero. Quo recusandae repellat.",
"last_year_sales_revenue": "Placeat commodi libero.",
"climate_change_risks_details": "Placeat commodi libero. Quo recusandae repellat.",
"climate_change_risks_identified": true
},
"relationships": {
"project_developer": {
Expand Down
Loading
Loading