decidim-challenges 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
 - data/LICENSE-AGPLv3.txt +661 -0
 - data/README.md +49 -0
 - data/Rakefile +9 -0
 - data/app/cells/decidim/challenges/challenge_cell.rb +21 -0
 - data/app/cells/decidim/challenges/challenge_g/show.erb +47 -0
 - data/app/cells/decidim/challenges/challenge_g_cell.rb +69 -0
 - data/app/cells/decidim/problems/problem_cell.rb +21 -0
 - data/app/cells/decidim/problems/problem_g/show.erb +35 -0
 - data/app/cells/decidim/problems/problem_g_cell.rb +61 -0
 - data/app/cells/decidim/solutions/solution_cell.rb +21 -0
 - data/app/cells/decidim/solutions/solution_g/show.erb +30 -0
 - data/app/cells/decidim/solutions/solution_g_cell.rb +84 -0
 - data/app/commands/decidim/challenges/admin/create_challenge.rb +67 -0
 - data/app/commands/decidim/challenges/admin/destroy_challenge.rb +49 -0
 - data/app/commands/decidim/challenges/admin/export_challenge_surveys.rb +45 -0
 - data/app/commands/decidim/challenges/admin/publish_challenge.rb +40 -0
 - data/app/commands/decidim/challenges/admin/unpublish_challenge.rb +40 -0
 - data/app/commands/decidim/challenges/admin/update_challenge.rb +72 -0
 - data/app/commands/decidim/challenges/admin/update_surveys.rb +43 -0
 - data/app/commands/decidim/challenges/survey_challenge.rb +67 -0
 - data/app/commands/decidim/command_utils.rb +20 -0
 - data/app/commands/decidim/problems/admin/create_problem.rb +66 -0
 - data/app/commands/decidim/problems/admin/destroy_problem.rb +49 -0
 - data/app/commands/decidim/problems/admin/publish_problem.rb +40 -0
 - data/app/commands/decidim/problems/admin/unpublish_problem.rb +40 -0
 - data/app/commands/decidim/problems/admin/update_problem.rb +69 -0
 - data/app/commands/decidim/solutions/admin/create_solution.rb +65 -0
 - data/app/commands/decidim/solutions/admin/destroy_solution.rb +43 -0
 - data/app/commands/decidim/solutions/admin/publish_solution.rb +40 -0
 - data/app/commands/decidim/solutions/admin/unpublish_solution.rb +40 -0
 - data/app/commands/decidim/solutions/admin/update_solution.rb +67 -0
 - data/app/commands/decidim/solutions/create_solution.rb +67 -0
 - data/app/controllers/concerns/decidim/challenges/admin/filterable.rb +27 -0
 - data/app/controllers/concerns/decidim/challenges/orderable_challenges.rb +37 -0
 - data/app/controllers/concerns/decidim/problems/admin/filterable.rb +27 -0
 - data/app/controllers/concerns/decidim/problems/orderable_problems.rb +37 -0
 - data/app/controllers/concerns/decidim/solutions/admin/filterable.rb +27 -0
 - data/app/controllers/concerns/decidim/solutions/orderable_solutions.rb +37 -0
 - data/app/controllers/concerns/decidim/with_default_filters.rb +23 -0
 - data/app/controllers/concerns/decidim/with_sdgs.rb +19 -0
 - data/app/controllers/decidim/challenges/admin/application_controller.rb +15 -0
 - data/app/controllers/decidim/challenges/admin/challenge_publications_controller.rb +53 -0
 - data/app/controllers/decidim/challenges/admin/challenges_controller.rb +108 -0
 - data/app/controllers/decidim/challenges/admin/survey_form_controller.rb +43 -0
 - data/app/controllers/decidim/challenges/admin/surveys_controller.rb +104 -0
 - data/app/controllers/decidim/challenges/application_controller.rb +13 -0
 - data/app/controllers/decidim/challenges/challenges_controller.rb +70 -0
 - data/app/controllers/decidim/challenges/surveys_controller.rb +61 -0
 - data/app/controllers/decidim/problems/admin/application_controller.rb +15 -0
 - data/app/controllers/decidim/problems/admin/problem_publications_controller.rb +53 -0
 - data/app/controllers/decidim/problems/admin/problems_controller.rb +102 -0
 - data/app/controllers/decidim/problems/application_controller.rb +13 -0
 - data/app/controllers/decidim/problems/problems_controller.rb +62 -0
 - data/app/controllers/decidim/sdgs/admin/application_controller.rb +15 -0
 - data/app/controllers/decidim/sdgs/admin/sdgs_controller.rb +18 -0
 - data/app/controllers/decidim/sdgs/application_controller.rb +13 -0
 - data/app/controllers/decidim/sdgs/sdgs_controller.rb +24 -0
 - data/app/controllers/decidim/solutions/admin/application_controller.rb +15 -0
 - data/app/controllers/decidim/solutions/admin/solution_publications_controller.rb +53 -0
 - data/app/controllers/decidim/solutions/admin/solutions_controller.rb +106 -0
 - data/app/controllers/decidim/solutions/application_controller.rb +13 -0
 - data/app/controllers/decidim/solutions/solutions_controller.rb +115 -0
 - data/app/forms/decidim/challenges/admin/challenge_surveys_form.rb +35 -0
 - data/app/forms/decidim/challenges/admin/challenges_form.rb +78 -0
 - data/app/forms/decidim/problems/admin/problems_form.rb +90 -0
 - data/app/forms/decidim/solutions/admin/solutions_form.rb +71 -0
 - data/app/forms/decidim/solutions/solutions_form.rb +50 -0
 - data/app/helpers/decidim/challenges/application_helper.rb +25 -0
 - data/app/helpers/decidim/challenges/challenge_cells_helper.rb +57 -0
 - data/app/helpers/decidim/challenges/challenges_helper.rb +39 -0
 - data/app/helpers/decidim/problems/application_helper.rb +10 -0
 - data/app/helpers/decidim/problems/problem_cells_helper.rb +23 -0
 - data/app/helpers/decidim/problems/problems_helper.rb +24 -0
 - data/app/helpers/decidim/sdgs/sdgs_helper.rb +28 -0
 - data/app/helpers/decidim/show_filters_helper.rb +13 -0
 - data/app/helpers/decidim/solutions/application_helper.rb +27 -0
 - data/app/helpers/decidim/solutions/solution_cells_helper.rb +56 -0
 - data/app/helpers/decidim/solutions/solutions_helper.rb +21 -0
 - data/app/models/decidim/application_record.rb +8 -0
 - data/app/models/decidim/challenges/challenge.rb +82 -0
 - data/app/models/decidim/challenges/survey.rb +19 -0
 - data/app/models/decidim/problems/problem.rb +118 -0
 - data/app/models/decidim/sdgs/sdg.rb +47 -0
 - data/app/models/decidim/solutions/application_record.rb +10 -0
 - data/app/models/decidim/solutions/solution.rb +69 -0
 - data/app/packs/entrypoints/decidim_challenges.js +4 -0
 - data/app/packs/entrypoints/decidim_challenges.scss +1 -0
 - data/app/packs/entrypoints/decidim_problems.js +1 -0
 - data/app/packs/entrypoints/decidim_problems.scss +1 -0
 - data/app/packs/entrypoints/decidim_sdgs.js +6 -0
 - data/app/packs/entrypoints/decidim_sdgs.scss +3 -0
 - data/app/packs/entrypoints/decidim_shared.js +1 -0
 - data/app/packs/entrypoints/decidim_shared.scss +1 -0
 - data/app/packs/entrypoints/decidim_solutions.js +4 -0
 - data/app/packs/entrypoints/decidim_solutions.scss +1 -0
 - data/app/packs/fonts/Oswald-Medium.ttf +0 -0
 - data/app/packs/images/decidim/challenges/decidim_challenges_icon.svg +1 -0
 - data/app/packs/images/decidim/sdgs/ods-01.svg +11 -0
 - data/app/packs/images/decidim/sdgs/ods-02.svg +11 -0
 - data/app/packs/images/decidim/sdgs/ods-03.svg +11 -0
 - data/app/packs/images/decidim/sdgs/ods-04.svg +12 -0
 - data/app/packs/images/decidim/sdgs/ods-05.svg +12 -0
 - data/app/packs/images/decidim/sdgs/ods-06.svg +20 -0
 - data/app/packs/images/decidim/sdgs/ods-07.svg +18 -0
 - data/app/packs/images/decidim/sdgs/ods-08.svg +13 -0
 - data/app/packs/images/decidim/sdgs/ods-09.svg +25 -0
 - data/app/packs/images/decidim/sdgs/ods-10.svg +13 -0
 - data/app/packs/images/decidim/sdgs/ods-11.svg +41 -0
 - data/app/packs/images/decidim/sdgs/ods-12.svg +11 -0
 - data/app/packs/images/decidim/sdgs/ods-13.svg +57 -0
 - data/app/packs/images/decidim/sdgs/ods-14.svg +14 -0
 - data/app/packs/images/decidim/sdgs/ods-15.svg +11 -0
 - data/app/packs/images/decidim/sdgs/ods-16.svg +14 -0
 - data/app/packs/images/decidim/sdgs/ods-17.svg +39 -0
 - data/app/packs/images/decidim/sdgs/sdg-wheel.png +0 -0
 - data/app/packs/images/decidim/sdgs/un_emblem_square.png +0 -0
 - data/app/packs/src/decidim/challenges/add_challenge.js +3 -0
 - data/app/packs/src/decidim/challenges/admin/challenges_form.js +3 -0
 - data/app/packs/src/decidim/sdgs/filter.js +75 -0
 - data/app/packs/stylesheets/decidim/challenges/challenges.scss +3 -0
 - data/app/packs/stylesheets/decidim/problems/problems.scss +3 -0
 - data/app/packs/stylesheets/decidim/sdgs/ods.scss +185 -0
 - data/app/packs/stylesheets/decidim/sdgs/sdgs_filter/button.scss +27 -0
 - data/app/packs/stylesheets/decidim/sdgs/sdgs_filter/modal.scss +60 -0
 - data/app/packs/stylesheets/decidim/shared/_cards.scss +52 -0
 - data/app/packs/stylesheets/decidim/shared/base.scss +9 -0
 - data/app/packs/stylesheets/decidim/solutions/solutions.scss +3 -0
 - data/app/permissions/decidim/challenges/admin/permissions.rb +88 -0
 - data/app/permissions/decidim/challenges/permissions.rb +27 -0
 - data/app/permissions/decidim/problems/admin/permissions.rb +52 -0
 - data/app/permissions/decidim/problems/permissions.rb +16 -0
 - data/app/permissions/decidim/solutions/admin/permissions.rb +58 -0
 - data/app/permissions/decidim/solutions/permissions.rb +17 -0
 - data/app/presenters/decidim/challenges/challenge_presenter.rb +134 -0
 - data/app/presenters/decidim/problems/problem_presenter.rb +108 -0
 - data/app/presenters/decidim/solutions/solution_presenter.rb +198 -0
 - data/app/serializers/decidim/challenges/data_serializer.rb +46 -0
 - data/app/serializers/decidim/challenges/survey_serializer.rb +37 -0
 - data/app/types/decidim/challenges/challenge_type.rb +28 -0
 - data/app/types/decidim/challenges/challenges_type.rb +32 -0
 - data/app/types/decidim/problems/problem_type.rb +29 -0
 - data/app/types/decidim/problems/problems_type.rb +32 -0
 - data/app/types/decidim/solutions/solution_type.rb +25 -0
 - data/app/types/decidim/solutions/solutions_type.rb +32 -0
 - data/app/views/decidim/challenges/admin/challenges/_form.html.erb +78 -0
 - data/app/views/decidim/challenges/admin/challenges/edit.html.erb +24 -0
 - data/app/views/decidim/challenges/admin/challenges/index.html.erb +88 -0
 - data/app/views/decidim/challenges/admin/challenges/new.html.erb +18 -0
 - data/app/views/decidim/challenges/admin/surveys/_form.html.erb +9 -0
 - data/app/views/decidim/challenges/admin/surveys/edit.html.erb +39 -0
 - data/app/views/decidim/challenges/admin/surveys/index.html.erb +49 -0
 - data/app/views/decidim/challenges/admin/surveys/show.html.erb +43 -0
 - data/app/views/decidim/challenges/challenges/_challenge.html.erb +1 -0
 - data/app/views/decidim/challenges/challenges/_challenges.html.erb +11 -0
 - data/app/views/decidim/challenges/challenges/_related_problems.html.erb +14 -0
 - data/app/views/decidim/challenges/challenges/_sidebar_data.html.erb +60 -0
 - data/app/views/decidim/challenges/challenges/index.html.erb +29 -0
 - data/app/views/decidim/challenges/challenges/index.js.erb +5 -0
 - data/app/views/decidim/challenges/challenges/show.html.erb +41 -0
 - data/app/views/decidim/problems/admin/problems/_form.html.erb +79 -0
 - data/app/views/decidim/problems/admin/problems/edit.html.erb +24 -0
 - data/app/views/decidim/problems/admin/problems/index.html.erb +93 -0
 - data/app/views/decidim/problems/admin/problems/new.html.erb +18 -0
 - data/app/views/decidim/problems/problems/_problem.html.erb +1 -0
 - data/app/views/decidim/problems/problems/_problems.html.erb +11 -0
 - data/app/views/decidim/problems/problems/_sidebar_data.html.erb +70 -0
 - data/app/views/decidim/problems/problems/index.html.erb +28 -0
 - data/app/views/decidim/problems/problems/index.js.erb +5 -0
 - data/app/views/decidim/problems/problems/show.html.erb +38 -0
 - data/app/views/decidim/sdgs/sdgs/_objectives.html.erb +320 -0
 - data/app/views/decidim/sdgs/sdgs/_ods.html.erb +132 -0
 - data/app/views/decidim/sdgs/sdgs/index.html.erb +64 -0
 - data/app/views/decidim/sdgs/sdgs_filter/_filter_selector.html.erb +7 -0
 - data/app/views/decidim/sdgs/sdgs_filter/_modal.html.erb +35 -0
 - data/app/views/decidim/shared/_related_solutions.html.erb +14 -0
 - data/app/views/decidim/solutions/admin/solutions/_documents.html.erb +13 -0
 - data/app/views/decidim/solutions/admin/solutions/_form.html.erb +70 -0
 - data/app/views/decidim/solutions/admin/solutions/_photos.html.erb +13 -0
 - data/app/views/decidim/solutions/admin/solutions/edit.html.erb +24 -0
 - data/app/views/decidim/solutions/admin/solutions/index.html.erb +97 -0
 - data/app/views/decidim/solutions/admin/solutions/new.html.erb +18 -0
 - data/app/views/decidim/solutions/admin/solutions/show.html.erb +114 -0
 - data/app/views/decidim/solutions/solutions/_form.html.erb +22 -0
 - data/app/views/decidim/solutions/solutions/_sidebar_data.html.erb +114 -0
 - data/app/views/decidim/solutions/solutions/_solution.html.erb +1 -0
 - data/app/views/decidim/solutions/solutions/_solutions.html.erb +13 -0
 - data/app/views/decidim/solutions/solutions/index.html.erb +37 -0
 - data/app/views/decidim/solutions/solutions/index.js.erb +5 -0
 - data/app/views/decidim/solutions/solutions/new.html.erb +20 -0
 - data/app/views/decidim/solutions/solutions/show.html.erb +72 -0
 - data/config/assets.rb +27 -0
 - data/config/i18n-tasks.yml +10 -0
 - data/config/locales/ca.yml +1244 -0
 - data/config/locales/cs.yml +668 -0
 - data/config/locales/en.yml +1245 -0
 - data/config/locales/es.yml +1250 -0
 - data/config/locales/oc.yml +1229 -0
 - data/db/migrate/20201014125000_create_decidim_challenges_challenges.rb +23 -0
 - data/db/migrate/20201103155100_create_decidim_problems_problems.rb +25 -0
 - data/db/migrate/20201116111200_create_decidim_solutions_solutions.rb +21 -0
 - data/db/migrate/20210413083244_create_decidim_challenges_surveys.rb +14 -0
 - data/db/migrate/20210413083507_add_survey_attributes_to_challenges.rb +7 -0
 - data/db/migrate/20210413083604_add_questionnaire_to_existing_challenges.rb +15 -0
 - data/db/migrate/20210413112229_add_challenge_reference_to_solutions.rb +7 -0
 - data/db/migrate/20210427091033_remove_require_null_in_problems_for_solutions.rb +7 -0
 - data/db/migrate/20220407110503_add_card_image_to_challenges.rb +7 -0
 - data/db/migrate/20240919094714_add_public_fields_to_solutions.rb +10 -0
 - data/lib/decidim/challenges/admin.rb +10 -0
 - data/lib/decidim/challenges/admin_engine.rb +37 -0
 - data/lib/decidim/challenges/component.rb +65 -0
 - data/lib/decidim/challenges/engine.rb +39 -0
 - data/lib/decidim/challenges/test/factories.rb +59 -0
 - data/lib/decidim/challenges/version.rb +14 -0
 - data/lib/decidim/challenges.rb +13 -0
 - data/lib/decidim/problems/admin.rb +10 -0
 - data/lib/decidim/problems/admin_engine.rb +25 -0
 - data/lib/decidim/problems/component.rb +51 -0
 - data/lib/decidim/problems/engine.rb +31 -0
 - data/lib/decidim/problems/test/factories.rb +39 -0
 - data/lib/decidim/sdgs/admin.rb +10 -0
 - data/lib/decidim/sdgs/admin_engine.rb +28 -0
 - data/lib/decidim/sdgs/component.rb +44 -0
 - data/lib/decidim/sdgs/engine.rb +23 -0
 - data/lib/decidim/sdgs/test/factories.rb +13 -0
 - data/lib/decidim/solutions/admin.rb +10 -0
 - data/lib/decidim/solutions/admin_engine.rb +25 -0
 - data/lib/decidim/solutions/component.rb +52 -0
 - data/lib/decidim/solutions/engine.rb +31 -0
 - data/lib/decidim/solutions/test/factories.rb +28 -0
 - metadata +316 -0
 
| 
         @@ -0,0 +1,23 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            class CreateDecidimChallengesChallenges < ActiveRecord::Migration[5.2]
         
     | 
| 
      
 4 
     | 
    
         
            +
              def change
         
     | 
| 
      
 5 
     | 
    
         
            +
                create_table :decidim_challenges_challenges do |t|
         
     | 
| 
      
 6 
     | 
    
         
            +
                  t.jsonb :title
         
     | 
| 
      
 7 
     | 
    
         
            +
                  t.jsonb :local_description
         
     | 
| 
      
 8 
     | 
    
         
            +
                  t.jsonb :global_description
         
     | 
| 
      
 9 
     | 
    
         
            +
                  t.references :decidim_component, index: true, null: false
         
     | 
| 
      
 10 
     | 
    
         
            +
                  t.jsonb :tags
         
     | 
| 
      
 11 
     | 
    
         
            +
                  t.string :sdg_code
         
     | 
| 
      
 12 
     | 
    
         
            +
                  t.references :decidim_scope, index: true
         
     | 
| 
      
 13 
     | 
    
         
            +
                  t.integer :state, null: false, default: 0
         
     | 
| 
      
 14 
     | 
    
         
            +
                  t.date :start_date
         
     | 
| 
      
 15 
     | 
    
         
            +
                  t.date :end_date
         
     | 
| 
      
 16 
     | 
    
         
            +
                  t.timestamp :published_at
         
     | 
| 
      
 17 
     | 
    
         
            +
                  t.string :coordinating_entities
         
     | 
| 
      
 18 
     | 
    
         
            +
                  t.string :collaborating_entities
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
                  t.timestamps
         
     | 
| 
      
 21 
     | 
    
         
            +
                end
         
     | 
| 
      
 22 
     | 
    
         
            +
              end
         
     | 
| 
      
 23 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,25 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            class CreateDecidimProblemsProblems < ActiveRecord::Migration[5.2]
         
     | 
| 
      
 4 
     | 
    
         
            +
              def change
         
     | 
| 
      
 5 
     | 
    
         
            +
                create_table :decidim_problems_problems do |t|
         
     | 
| 
      
 6 
     | 
    
         
            +
                  t.jsonb :title
         
     | 
| 
      
 7 
     | 
    
         
            +
                  t.jsonb :description
         
     | 
| 
      
 8 
     | 
    
         
            +
                  t.references :decidim_component, index: true, null: false
         
     | 
| 
      
 9 
     | 
    
         
            +
                  t.references :decidim_challenges_challenge, index: { name: "decidim_challenges_challenges_problems" }, null: false
         
     | 
| 
      
 10 
     | 
    
         
            +
                  t.bigint "decidim_sectorial_scope_id"
         
     | 
| 
      
 11 
     | 
    
         
            +
                  t.bigint "decidim_technological_scope_id"
         
     | 
| 
      
 12 
     | 
    
         
            +
                  t.jsonb :tags
         
     | 
| 
      
 13 
     | 
    
         
            +
                  t.string :causes
         
     | 
| 
      
 14 
     | 
    
         
            +
                  t.string :groups_affected
         
     | 
| 
      
 15 
     | 
    
         
            +
                  t.integer :state, null: false, default: 0
         
     | 
| 
      
 16 
     | 
    
         
            +
                  t.date :start_date
         
     | 
| 
      
 17 
     | 
    
         
            +
                  t.date :end_date
         
     | 
| 
      
 18 
     | 
    
         
            +
                  t.timestamp :published_at
         
     | 
| 
      
 19 
     | 
    
         
            +
                  t.string :proposing_entities
         
     | 
| 
      
 20 
     | 
    
         
            +
                  t.string :collaborating_entities
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
                  t.timestamps
         
     | 
| 
      
 23 
     | 
    
         
            +
                end
         
     | 
| 
      
 24 
     | 
    
         
            +
              end
         
     | 
| 
      
 25 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,21 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            class CreateDecidimSolutionsSolutions < ActiveRecord::Migration[5.2]
         
     | 
| 
      
 4 
     | 
    
         
            +
              def change
         
     | 
| 
      
 5 
     | 
    
         
            +
                create_table :decidim_solutions_solutions do |t|
         
     | 
| 
      
 6 
     | 
    
         
            +
                  t.jsonb :title
         
     | 
| 
      
 7 
     | 
    
         
            +
                  t.jsonb :description
         
     | 
| 
      
 8 
     | 
    
         
            +
                  t.references :decidim_component, index: true, null: false
         
     | 
| 
      
 9 
     | 
    
         
            +
                  t.references :decidim_problems_problem, index: { name: "decidim_challenges_problems_solutions" }, null: false
         
     | 
| 
      
 10 
     | 
    
         
            +
                  t.jsonb :tags
         
     | 
| 
      
 11 
     | 
    
         
            +
                  t.jsonb :indicators
         
     | 
| 
      
 12 
     | 
    
         
            +
                  t.jsonb :beneficiaries
         
     | 
| 
      
 13 
     | 
    
         
            +
                  t.jsonb :requirements
         
     | 
| 
      
 14 
     | 
    
         
            +
                  t.jsonb :financing_type
         
     | 
| 
      
 15 
     | 
    
         
            +
                  t.jsonb :objectives
         
     | 
| 
      
 16 
     | 
    
         
            +
                  t.timestamp :published_at
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
                  t.timestamps
         
     | 
| 
      
 19 
     | 
    
         
            +
                end
         
     | 
| 
      
 20 
     | 
    
         
            +
              end
         
     | 
| 
      
 21 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,14 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            class CreateDecidimChallengesSurveys < ActiveRecord::Migration[5.2]
         
     | 
| 
      
 4 
     | 
    
         
            +
              def change
         
     | 
| 
      
 5 
     | 
    
         
            +
                create_table :decidim_challenges_surveys do |t|
         
     | 
| 
      
 6 
     | 
    
         
            +
                  t.references :decidim_user, null: false, index: true
         
     | 
| 
      
 7 
     | 
    
         
            +
                  t.references :decidim_challenge, null: false, index: true
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
                  t.timestamps
         
     | 
| 
      
 10 
     | 
    
         
            +
                end
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
                add_index :decidim_challenges_surveys, [:decidim_user_id, :decidim_challenge_id], unique: true, name: "decidim_challenges_surveys_user_challenge_unique"
         
     | 
| 
      
 13 
     | 
    
         
            +
              end
         
     | 
| 
      
 14 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,15 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            class AddQuestionnaireToExistingChallenges < ActiveRecord::Migration[5.2]
         
     | 
| 
      
 4 
     | 
    
         
            +
              def change
         
     | 
| 
      
 5 
     | 
    
         
            +
                Decidim::Challenges::Challenge.transaction do
         
     | 
| 
      
 6 
     | 
    
         
            +
                  Decidim::Challenges::Challenge.find_each do |challenge|
         
     | 
| 
      
 7 
     | 
    
         
            +
                    if challenge.component.present? && challenge.questionnaire.blank?
         
     | 
| 
      
 8 
     | 
    
         
            +
                      challenge.update!(
         
     | 
| 
      
 9 
     | 
    
         
            +
                        questionnaire: Decidim::Forms::Questionnaire.new
         
     | 
| 
      
 10 
     | 
    
         
            +
                      )
         
     | 
| 
      
 11 
     | 
    
         
            +
                    end
         
     | 
| 
      
 12 
     | 
    
         
            +
                  end
         
     | 
| 
      
 13 
     | 
    
         
            +
                end
         
     | 
| 
      
 14 
     | 
    
         
            +
              end
         
     | 
| 
      
 15 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,10 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            class AddPublicFieldsToSolutions < ActiveRecord::Migration[6.1]
         
     | 
| 
      
 4 
     | 
    
         
            +
              def change
         
     | 
| 
      
 5 
     | 
    
         
            +
                add_column :decidim_solutions_solutions, :project_status, :string
         
     | 
| 
      
 6 
     | 
    
         
            +
                add_column :decidim_solutions_solutions, :project_url, :string
         
     | 
| 
      
 7 
     | 
    
         
            +
                add_column :decidim_solutions_solutions, :coordinating_entity, :string
         
     | 
| 
      
 8 
     | 
    
         
            +
                add_reference :decidim_solutions_solutions, :author, foreign_key: { to_table: :decidim_users }, index: true
         
     | 
| 
      
 9 
     | 
    
         
            +
              end
         
     | 
| 
      
 10 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,37 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            module Decidim
         
     | 
| 
      
 4 
     | 
    
         
            +
              module Challenges
         
     | 
| 
      
 5 
     | 
    
         
            +
                # This is the engine that runs on the public interface of `Challenges`.
         
     | 
| 
      
 6 
     | 
    
         
            +
                class AdminEngine < ::Rails::Engine
         
     | 
| 
      
 7 
     | 
    
         
            +
                  isolate_namespace Decidim::Challenges::Admin
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
                  paths["db/migrate"] = nil
         
     | 
| 
      
 10 
     | 
    
         
            +
                  paths["lib/tasks"] = nil
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
                  # Add admin engine routes here
         
     | 
| 
      
 13 
     | 
    
         
            +
                  routes do
         
     | 
| 
      
 14 
     | 
    
         
            +
                    get "/answer_options", to: "challenge_survey#answer_options", as: :answer_options_challenge_survey, defaults: { format: "json" }
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
                    resources :challenges do
         
     | 
| 
      
 17 
     | 
    
         
            +
                      resource :publish, controller: "challenge_publications", only: [:create, :destroy]
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
                      resource :surveys, only: [:edit, :update] do
         
     | 
| 
      
 20 
     | 
    
         
            +
                        resource :form, only: [:edit, :update], controller: "survey_form"
         
     | 
| 
      
 21 
     | 
    
         
            +
                        collection do
         
     | 
| 
      
 22 
     | 
    
         
            +
                          get :index_answers, action: :index
         
     | 
| 
      
 23 
     | 
    
         
            +
                          get :show_answers, action: :show
         
     | 
| 
      
 24 
     | 
    
         
            +
                          get :export_response, action: :export_response
         
     | 
| 
      
 25 
     | 
    
         
            +
                          get :export
         
     | 
| 
      
 26 
     | 
    
         
            +
                        end
         
     | 
| 
      
 27 
     | 
    
         
            +
                      end
         
     | 
| 
      
 28 
     | 
    
         
            +
                    end
         
     | 
| 
      
 29 
     | 
    
         
            +
                    root to: "challenges#index"
         
     | 
| 
      
 30 
     | 
    
         
            +
                  end
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
                  def load_seed
         
     | 
| 
      
 33 
     | 
    
         
            +
                    nil
         
     | 
| 
      
 34 
     | 
    
         
            +
                  end
         
     | 
| 
      
 35 
     | 
    
         
            +
                end
         
     | 
| 
      
 36 
     | 
    
         
            +
              end
         
     | 
| 
      
 37 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,65 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            require_dependency "decidim/components/namer"
         
     | 
| 
      
 4 
     | 
    
         
            +
            require "decidim/challenges/admin"
         
     | 
| 
      
 5 
     | 
    
         
            +
            require "decidim/challenges/engine"
         
     | 
| 
      
 6 
     | 
    
         
            +
            require "decidim/challenges/admin_engine"
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
            # Sustainable Development Goals
         
     | 
| 
      
 9 
     | 
    
         
            +
            Decidim.register_component(:challenges) do |component|
         
     | 
| 
      
 10 
     | 
    
         
            +
              component.engine = Decidim::Challenges::Engine
         
     | 
| 
      
 11 
     | 
    
         
            +
              component.stylesheet = "decidim/challenges/challenges"
         
     | 
| 
      
 12 
     | 
    
         
            +
              component.admin_engine = Decidim::Challenges::AdminEngine
         
     | 
| 
      
 13 
     | 
    
         
            +
              component.icon = "media/images/decidim_challenges_icon.svg"
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
              component.data_portable_entities = ["Decidim::Challenges::Survey"]
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
              # component.on(:before_destroy) do |instance|
         
     | 
| 
      
 18 
     | 
    
         
            +
              #   # Code executed before removing the component
         
     | 
| 
      
 19 
     | 
    
         
            +
              # end
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
              component.permissions_class_name = "Decidim::Challenges::Permissions"
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
              # These actions permissions can be configured in the admin panel
         
     | 
| 
      
 24 
     | 
    
         
            +
              # component.actions = %w()
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
              component.query_type = "Decidim::Challenges::ChallengesType"
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
              component.settings(:global) do |settings|
         
     | 
| 
      
 29 
     | 
    
         
            +
                # Available types: :integer, :boolean
         
     | 
| 
      
 30 
     | 
    
         
            +
                settings.attribute :announcement, type: :text, translated: true, editor: true
         
     | 
| 
      
 31 
     | 
    
         
            +
                settings.attribute :hide_filters, type: :boolean, default: false
         
     | 
| 
      
 32 
     | 
    
         
            +
                settings.attribute :allow_card_image, type: :boolean, default: false
         
     | 
| 
      
 33 
     | 
    
         
            +
              end
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
              component.settings(:step) do |settings|
         
     | 
| 
      
 36 
     | 
    
         
            +
                settings.attribute :announcement, type: :text, translated: true, editor: true
         
     | 
| 
      
 37 
     | 
    
         
            +
              end
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
              component.register_resource(:challenge) do |resource|
         
     | 
| 
      
 40 
     | 
    
         
            +
                # Register a optional resource that can be references from other resources.
         
     | 
| 
      
 41 
     | 
    
         
            +
                resource.model_class_name = "Decidim::Challenges::Challenge"
         
     | 
| 
      
 42 
     | 
    
         
            +
                resource.card = "decidim/challenges/challenge"
         
     | 
| 
      
 43 
     | 
    
         
            +
                # resource.template = "decidim/challenges/some_resources/linked_some_resources"
         
     | 
| 
      
 44 
     | 
    
         
            +
                resource.searchable = true
         
     | 
| 
      
 45 
     | 
    
         
            +
              end
         
     | 
| 
      
 46 
     | 
    
         
            +
             
     | 
| 
      
 47 
     | 
    
         
            +
              # component.register_stat :some_stat do |context, start_at, end_at|
         
     | 
| 
      
 48 
     | 
    
         
            +
              #   # Register some stat number to the application
         
     | 
| 
      
 49 
     | 
    
         
            +
              # end
         
     | 
| 
      
 50 
     | 
    
         
            +
             
     | 
| 
      
 51 
     | 
    
         
            +
              component.seeds do |participatory_space|
         
     | 
| 
      
 52 
     | 
    
         
            +
                # Add some seeds for this component
         
     | 
| 
      
 53 
     | 
    
         
            +
              end
         
     | 
| 
      
 54 
     | 
    
         
            +
             
     | 
| 
      
 55 
     | 
    
         
            +
              component.exports :answers do |exports|
         
     | 
| 
      
 56 
     | 
    
         
            +
                exports.collection do |_f, _user, resource_id|
         
     | 
| 
      
 57 
     | 
    
         
            +
                  questionnaire = Decidim::Forms::Questionnaire.find(resource_id)
         
     | 
| 
      
 58 
     | 
    
         
            +
                  Decidim::Forms::QuestionnaireUserAnswers.for(questionnaire)
         
     | 
| 
      
 59 
     | 
    
         
            +
                end
         
     | 
| 
      
 60 
     | 
    
         
            +
             
     | 
| 
      
 61 
     | 
    
         
            +
                exports.formats %w(CSV JSON Excel FormPDF)
         
     | 
| 
      
 62 
     | 
    
         
            +
             
     | 
| 
      
 63 
     | 
    
         
            +
                exports.serializer Decidim::Forms::UserAnswersSerializer
         
     | 
| 
      
 64 
     | 
    
         
            +
              end
         
     | 
| 
      
 65 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,39 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            require "rails"
         
     | 
| 
      
 4 
     | 
    
         
            +
            require "decidim/core"
         
     | 
| 
      
 5 
     | 
    
         
            +
            require "wicked_pdf"
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            module Decidim
         
     | 
| 
      
 8 
     | 
    
         
            +
              module Challenges
         
     | 
| 
      
 9 
     | 
    
         
            +
                # This is the engine that runs on the public interface of challenges.
         
     | 
| 
      
 10 
     | 
    
         
            +
                class Engine < ::Rails::Engine
         
     | 
| 
      
 11 
     | 
    
         
            +
                  isolate_namespace Decidim::Challenges
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
                  routes do
         
     | 
| 
      
 14 
     | 
    
         
            +
                    # Add engine routes here
         
     | 
| 
      
 15 
     | 
    
         
            +
                    resources :challenges do
         
     | 
| 
      
 16 
     | 
    
         
            +
                      get :data_picker_modal_content, on: :collection
         
     | 
| 
      
 17 
     | 
    
         
            +
                    end
         
     | 
| 
      
 18 
     | 
    
         
            +
                    root to: "challenges#index"
         
     | 
| 
      
 19 
     | 
    
         
            +
                    resources :challenges, only: [:index, :show] do
         
     | 
| 
      
 20 
     | 
    
         
            +
                      resource :survey, only: [:create, :destroy] do
         
     | 
| 
      
 21 
     | 
    
         
            +
                        collection do
         
     | 
| 
      
 22 
     | 
    
         
            +
                          get :answer, action: :show
         
     | 
| 
      
 23 
     | 
    
         
            +
                          post :answer
         
     | 
| 
      
 24 
     | 
    
         
            +
                        end
         
     | 
| 
      
 25 
     | 
    
         
            +
                      end
         
     | 
| 
      
 26 
     | 
    
         
            +
                    end
         
     | 
| 
      
 27 
     | 
    
         
            +
                  end
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
                  initializer "decidim_challenges.add_cells_view_paths" do
         
     | 
| 
      
 30 
     | 
    
         
            +
                    Cell::ViewModel.view_paths << File.expand_path("#{Decidim::Challenges::Engine.root}/app/cells")
         
     | 
| 
      
 31 
     | 
    
         
            +
                    Cell::ViewModel.view_paths << File.expand_path("#{Decidim::Challenges::Engine.root}/app/views") # for partials
         
     | 
| 
      
 32 
     | 
    
         
            +
                  end
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
                  initializer "decidim_challenges.webpacker.assets_path" do
         
     | 
| 
      
 35 
     | 
    
         
            +
                    Decidim.register_assets_path File.expand_path("app/packs", root)
         
     | 
| 
      
 36 
     | 
    
         
            +
                  end
         
     | 
| 
      
 37 
     | 
    
         
            +
                end
         
     | 
| 
      
 38 
     | 
    
         
            +
              end
         
     | 
| 
      
 39 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,59 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            require "decidim/core/test/factories"
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            FactoryBot.define do
         
     | 
| 
      
 6 
     | 
    
         
            +
              factory :challenges_component, parent: :component do
         
     | 
| 
      
 7 
     | 
    
         
            +
                name { Decidim::Components::Namer.new(participatory_space.organization.available_locales, :challenges).i18n_name }
         
     | 
| 
      
 8 
     | 
    
         
            +
                manifest_name { :challenges }
         
     | 
| 
      
 9 
     | 
    
         
            +
                participatory_space { association(:participatory_process, :with_steps) }
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
                trait :with_card_image_allowed do
         
     | 
| 
      
 12 
     | 
    
         
            +
                  settings do
         
     | 
| 
      
 13 
     | 
    
         
            +
                    {
         
     | 
| 
      
 14 
     | 
    
         
            +
                      allow_card_image: true,
         
     | 
| 
      
 15 
     | 
    
         
            +
                    }
         
     | 
| 
      
 16 
     | 
    
         
            +
                  end
         
     | 
| 
      
 17 
     | 
    
         
            +
                end
         
     | 
| 
      
 18 
     | 
    
         
            +
              end
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
              factory :challenge, traits: [:proposal, :execution, :finished], class: "Decidim::Challenges::Challenge" do
         
     | 
| 
      
 21 
     | 
    
         
            +
                title { generate_localized_title }
         
     | 
| 
      
 22 
     | 
    
         
            +
                local_description { Decidim::Faker::Localized.wrapped("<p>", "</p>") { generate_localized_title } }
         
     | 
| 
      
 23 
     | 
    
         
            +
                global_description { Decidim::Faker::Localized.wrapped("<p>", "</p>") { generate_localized_title } }
         
     | 
| 
      
 24 
     | 
    
         
            +
                tags { Decidim::Faker::Localized.localized { [1..5].collect { generate(:name) }.join(", ") } }
         
     | 
| 
      
 25 
     | 
    
         
            +
                state { "execution" }
         
     | 
| 
      
 26 
     | 
    
         
            +
                start_date { 1.day.from_now }
         
     | 
| 
      
 27 
     | 
    
         
            +
                end_date { start_date + 2.months }
         
     | 
| 
      
 28 
     | 
    
         
            +
                component { association(:challenges_component) }
         
     | 
| 
      
 29 
     | 
    
         
            +
                coordinating_entities { [1..5].collect { generate(:name) }.join(", ") }
         
     | 
| 
      
 30 
     | 
    
         
            +
                collaborating_entities { [1..5].collect { generate(:name) }.join(", ") }
         
     | 
| 
      
 31 
     | 
    
         
            +
                published_at { Time.current }
         
     | 
| 
      
 32 
     | 
    
         
            +
                questionnaire { association(:questionnaire) }
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
                trait :proposal do
         
     | 
| 
      
 35 
     | 
    
         
            +
                  state { 0 }
         
     | 
| 
      
 36 
     | 
    
         
            +
                end
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
                trait :execution do
         
     | 
| 
      
 39 
     | 
    
         
            +
                  state { 1 }
         
     | 
| 
      
 40 
     | 
    
         
            +
                end
         
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
      
 42 
     | 
    
         
            +
                trait :finished do
         
     | 
| 
      
 43 
     | 
    
         
            +
                  state { 2 }
         
     | 
| 
      
 44 
     | 
    
         
            +
                end
         
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
      
 46 
     | 
    
         
            +
                trait :with_survey_enabled do
         
     | 
| 
      
 47 
     | 
    
         
            +
                  survey_enabled { true }
         
     | 
| 
      
 48 
     | 
    
         
            +
                end
         
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
      
 50 
     | 
    
         
            +
                trait :with_card_image do
         
     | 
| 
      
 51 
     | 
    
         
            +
                  card_image { Decidim::Dev.test_file("city.jpeg", "image/jpeg") }
         
     | 
| 
      
 52 
     | 
    
         
            +
                end
         
     | 
| 
      
 53 
     | 
    
         
            +
              end
         
     | 
| 
      
 54 
     | 
    
         
            +
             
     | 
| 
      
 55 
     | 
    
         
            +
              factory :survey, class: "Decidim::Challenges::Survey" do
         
     | 
| 
      
 56 
     | 
    
         
            +
                challenge
         
     | 
| 
      
 57 
     | 
    
         
            +
                user
         
     | 
| 
      
 58 
     | 
    
         
            +
              end
         
     | 
| 
      
 59 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,13 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            require "decidim/challenges/component"
         
     | 
| 
      
 4 
     | 
    
         
            +
            require "decidim/problems/component"
         
     | 
| 
      
 5 
     | 
    
         
            +
            require "decidim/sdgs/component"
         
     | 
| 
      
 6 
     | 
    
         
            +
            require "decidim/solutions/component"
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
            module Decidim
         
     | 
| 
      
 9 
     | 
    
         
            +
              # This namespace holds the logic of the `Challenges` component. This component
         
     | 
| 
      
 10 
     | 
    
         
            +
              # allows users to create challenges in a participatory space.
         
     | 
| 
      
 11 
     | 
    
         
            +
              module Challenges
         
     | 
| 
      
 12 
     | 
    
         
            +
              end
         
     | 
| 
      
 13 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,25 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            module Decidim
         
     | 
| 
      
 4 
     | 
    
         
            +
              module Problems
         
     | 
| 
      
 5 
     | 
    
         
            +
                # This is the engine that runs on the public interface of `Problems`.
         
     | 
| 
      
 6 
     | 
    
         
            +
                class AdminEngine < ::Rails::Engine
         
     | 
| 
      
 7 
     | 
    
         
            +
                  isolate_namespace Decidim::Problems::Admin
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
                  paths["db/migrate"] = nil
         
     | 
| 
      
 10 
     | 
    
         
            +
                  paths["lib/tasks"] = nil
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
                  # Add admin engine routes here
         
     | 
| 
      
 13 
     | 
    
         
            +
                  routes do
         
     | 
| 
      
 14 
     | 
    
         
            +
                    resources :problems do
         
     | 
| 
      
 15 
     | 
    
         
            +
                      resource :publish, controller: "problem_publications", only: [:create, :destroy]
         
     | 
| 
      
 16 
     | 
    
         
            +
                    end
         
     | 
| 
      
 17 
     | 
    
         
            +
                    root to: "problems#index"
         
     | 
| 
      
 18 
     | 
    
         
            +
                  end
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
                  def load_seed
         
     | 
| 
      
 21 
     | 
    
         
            +
                    nil
         
     | 
| 
      
 22 
     | 
    
         
            +
                  end
         
     | 
| 
      
 23 
     | 
    
         
            +
                end
         
     | 
| 
      
 24 
     | 
    
         
            +
              end
         
     | 
| 
      
 25 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,51 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            require_dependency "decidim/components/namer"
         
     | 
| 
      
 4 
     | 
    
         
            +
            require "decidim/problems/admin"
         
     | 
| 
      
 5 
     | 
    
         
            +
            require "decidim/problems/engine"
         
     | 
| 
      
 6 
     | 
    
         
            +
            require "decidim/problems/admin_engine"
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
            # Sustainable Development Goals
         
     | 
| 
      
 9 
     | 
    
         
            +
            Decidim.register_component(:problems) do |component|
         
     | 
| 
      
 10 
     | 
    
         
            +
              component.engine = Decidim::Problems::Engine
         
     | 
| 
      
 11 
     | 
    
         
            +
              component.stylesheet = "decidim/problems/problems"
         
     | 
| 
      
 12 
     | 
    
         
            +
              component.admin_engine = Decidim::Problems::AdminEngine
         
     | 
| 
      
 13 
     | 
    
         
            +
              component.icon = "media/images/decidim_challenges_icon.svg"
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
              # component.on(:before_destroy) do |instance|
         
     | 
| 
      
 16 
     | 
    
         
            +
              #   # Code executed before removing the component
         
     | 
| 
      
 17 
     | 
    
         
            +
              # end
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
              component.permissions_class_name = "Decidim::Problems::Permissions"
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
              # These actions permissions can be configured in the admin panel
         
     | 
| 
      
 22 
     | 
    
         
            +
              # component.actions = %w()
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
              component.query_type = "Decidim::Problems::ProblemsType"
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
              component.settings(:global) do |settings|
         
     | 
| 
      
 27 
     | 
    
         
            +
                # Add your global settings
         
     | 
| 
      
 28 
     | 
    
         
            +
                # Available types: :integer, :boolean
         
     | 
| 
      
 29 
     | 
    
         
            +
                settings.attribute :hide_filters, type: :boolean, default: false
         
     | 
| 
      
 30 
     | 
    
         
            +
              end
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
              # component.settings(:step) do |settings|
         
     | 
| 
      
 33 
     | 
    
         
            +
              #   # Add your settings per step
         
     | 
| 
      
 34 
     | 
    
         
            +
              # end
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
              component.register_resource(:problem) do |resource|
         
     | 
| 
      
 37 
     | 
    
         
            +
                # Register a optional resource that can be references from other resources.
         
     | 
| 
      
 38 
     | 
    
         
            +
                resource.model_class_name = "Decidim::Problems::Problem"
         
     | 
| 
      
 39 
     | 
    
         
            +
                resource.card = "decidim/problems/problem"
         
     | 
| 
      
 40 
     | 
    
         
            +
                # resource.template = "decidim/problems/some_resources/linked_some_resources"
         
     | 
| 
      
 41 
     | 
    
         
            +
                resource.searchable = true
         
     | 
| 
      
 42 
     | 
    
         
            +
              end
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
      
 44 
     | 
    
         
            +
              # component.register_stat :some_stat do |context, start_at, end_at|
         
     | 
| 
      
 45 
     | 
    
         
            +
              #   # Register some stat number to the application
         
     | 
| 
      
 46 
     | 
    
         
            +
              # end
         
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
      
 48 
     | 
    
         
            +
              # component.seeds do |participatory_space|
         
     | 
| 
      
 49 
     | 
    
         
            +
              #   # Add some seeds for this component
         
     | 
| 
      
 50 
     | 
    
         
            +
              # end
         
     | 
| 
      
 51 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,31 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            require "rails"
         
     | 
| 
      
 4 
     | 
    
         
            +
            require "decidim/core"
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            module Decidim
         
     | 
| 
      
 7 
     | 
    
         
            +
              module Problems
         
     | 
| 
      
 8 
     | 
    
         
            +
                # This is the engine that runs on the public interface of problems.
         
     | 
| 
      
 9 
     | 
    
         
            +
                class Engine < ::Rails::Engine
         
     | 
| 
      
 10 
     | 
    
         
            +
                  isolate_namespace Decidim::Problems
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
                  routes do
         
     | 
| 
      
 13 
     | 
    
         
            +
                    # Add engine routes here
         
     | 
| 
      
 14 
     | 
    
         
            +
                    resources :problems do
         
     | 
| 
      
 15 
     | 
    
         
            +
                      get :data_picker_modal_content, on: :collection
         
     | 
| 
      
 16 
     | 
    
         
            +
                    end
         
     | 
| 
      
 17 
     | 
    
         
            +
                    root to: "problems#index"
         
     | 
| 
      
 18 
     | 
    
         
            +
                    resources :problems, only: [:index, :show]
         
     | 
| 
      
 19 
     | 
    
         
            +
                  end
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
                  initializer "decidim_problems.add_cells_view_paths" do
         
     | 
| 
      
 22 
     | 
    
         
            +
                    Cell::ViewModel.view_paths << File.expand_path("#{Decidim::Problems::Engine.root}/app/cells")
         
     | 
| 
      
 23 
     | 
    
         
            +
                    Cell::ViewModel.view_paths << File.expand_path("#{Decidim::Problems::Engine.root}/app/views") # for partials
         
     | 
| 
      
 24 
     | 
    
         
            +
                  end
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
                  initializer "decidim_problems.webpacker.assets_path" do
         
     | 
| 
      
 27 
     | 
    
         
            +
                    Decidim.register_assets_path File.expand_path("app/packs", root)
         
     | 
| 
      
 28 
     | 
    
         
            +
                  end
         
     | 
| 
      
 29 
     | 
    
         
            +
                end
         
     | 
| 
      
 30 
     | 
    
         
            +
              end
         
     | 
| 
      
 31 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,39 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            require "decidim/core/test/factories"
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            FactoryBot.define do
         
     | 
| 
      
 6 
     | 
    
         
            +
              factory :problems_component, parent: :component do
         
     | 
| 
      
 7 
     | 
    
         
            +
                name { Decidim::Components::Namer.new(participatory_space.organization.available_locales, :problems).i18n_name }
         
     | 
| 
      
 8 
     | 
    
         
            +
                manifest_name { :problems }
         
     | 
| 
      
 9 
     | 
    
         
            +
                participatory_space { association(:participatory_process, :with_steps) }
         
     | 
| 
      
 10 
     | 
    
         
            +
              end
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
              factory :problem, traits: [:proposal, :execution, :finished], class: "Decidim::Problems::Problem" do
         
     | 
| 
      
 13 
     | 
    
         
            +
                title { generate_localized_title }
         
     | 
| 
      
 14 
     | 
    
         
            +
                description { Decidim::Faker::Localized.wrapped("<p>", "</p>") { generate_localized_title } }
         
     | 
| 
      
 15 
     | 
    
         
            +
                tags { Decidim::Faker::Localized.localized { [1..5].collect { generate(:name) }.join(", ") } }
         
     | 
| 
      
 16 
     | 
    
         
            +
                state { "execution" }
         
     | 
| 
      
 17 
     | 
    
         
            +
                causes { "causes" }
         
     | 
| 
      
 18 
     | 
    
         
            +
                groups_affected { "groups affected" }
         
     | 
| 
      
 19 
     | 
    
         
            +
                start_date { 1.day.from_now }
         
     | 
| 
      
 20 
     | 
    
         
            +
                end_date { start_date + 2.months }
         
     | 
| 
      
 21 
     | 
    
         
            +
                component { association(:component, manifest_name: "problems") }
         
     | 
| 
      
 22 
     | 
    
         
            +
                challenge { association(:challenge) }
         
     | 
| 
      
 23 
     | 
    
         
            +
                proposing_entities { [1..5].collect { generate(:name) }.join(", ") }
         
     | 
| 
      
 24 
     | 
    
         
            +
                collaborating_entities { [1..5].collect { generate(:name) }.join(", ") }
         
     | 
| 
      
 25 
     | 
    
         
            +
                published_at { Time.current }
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
                trait :proposal do
         
     | 
| 
      
 28 
     | 
    
         
            +
                  state { 0 }
         
     | 
| 
      
 29 
     | 
    
         
            +
                end
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
                trait :execution do
         
     | 
| 
      
 32 
     | 
    
         
            +
                  state { 1 }
         
     | 
| 
      
 33 
     | 
    
         
            +
                end
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
                trait :finished do
         
     | 
| 
      
 36 
     | 
    
         
            +
                  state { 2 }
         
     | 
| 
      
 37 
     | 
    
         
            +
                end
         
     | 
| 
      
 38 
     | 
    
         
            +
              end
         
     | 
| 
      
 39 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,28 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            module Decidim
         
     | 
| 
      
 4 
     | 
    
         
            +
              module Sdgs
         
     | 
| 
      
 5 
     | 
    
         
            +
                # This is the engine that runs on the public interface of `Challenges`.
         
     | 
| 
      
 6 
     | 
    
         
            +
                class AdminEngine < ::Rails::Engine
         
     | 
| 
      
 7 
     | 
    
         
            +
                  isolate_namespace Decidim::Sdgs::Admin
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
                  paths["db/migrate"] = nil
         
     | 
| 
      
 10 
     | 
    
         
            +
                  paths["lib/tasks"] = nil
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
                  routes do
         
     | 
| 
      
 13 
     | 
    
         
            +
                    # Add admin engine routes here
         
     | 
| 
      
 14 
     | 
    
         
            +
                    resources :sdgs, only: :index
         
     | 
| 
      
 15 
     | 
    
         
            +
                    # resources :sdgs do
         
     | 
| 
      
 16 
     | 
    
         
            +
                    #   collection do
         
     | 
| 
      
 17 
     | 
    
         
            +
                    #     resources :exports, only: [:create]
         
     | 
| 
      
 18 
     | 
    
         
            +
                    #   end
         
     | 
| 
      
 19 
     | 
    
         
            +
                    # end
         
     | 
| 
      
 20 
     | 
    
         
            +
                    root to: "sdgs#index"
         
     | 
| 
      
 21 
     | 
    
         
            +
                  end
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
                  def load_seed
         
     | 
| 
      
 24 
     | 
    
         
            +
                    nil
         
     | 
| 
      
 25 
     | 
    
         
            +
                  end
         
     | 
| 
      
 26 
     | 
    
         
            +
                end
         
     | 
| 
      
 27 
     | 
    
         
            +
              end
         
     | 
| 
      
 28 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,44 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            require_dependency "decidim/components/namer"
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            require "decidim/sdgs/admin"
         
     | 
| 
      
 6 
     | 
    
         
            +
            require "decidim/sdgs/engine"
         
     | 
| 
      
 7 
     | 
    
         
            +
            require "decidim/sdgs/admin_engine"
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
            Decidim.register_component(:sdgs) do |component|
         
     | 
| 
      
 10 
     | 
    
         
            +
              component.engine = Decidim::Sdgs::Engine
         
     | 
| 
      
 11 
     | 
    
         
            +
              component.admin_engine = Decidim::Sdgs::AdminEngine
         
     | 
| 
      
 12 
     | 
    
         
            +
              component.icon = "media/images/decidim_challenges_icon.svg"
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
              # component.on(:before_destroy) do |instance|
         
     | 
| 
      
 15 
     | 
    
         
            +
              #   # Code executed before removing the component
         
     | 
| 
      
 16 
     | 
    
         
            +
              # end
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
              # These actions permissions can be configured in the admin panel
         
     | 
| 
      
 19 
     | 
    
         
            +
              # component.actions = %w()
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
              # component.settings(:global) do |settings|
         
     | 
| 
      
 22 
     | 
    
         
            +
              #   # Add your global settings
         
     | 
| 
      
 23 
     | 
    
         
            +
              #   # Available types: :integer, :boolean
         
     | 
| 
      
 24 
     | 
    
         
            +
              #   # settings.attribute :vote_limit, type: :integer, default: 0
         
     | 
| 
      
 25 
     | 
    
         
            +
              # end
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
              # component.settings(:step) do |settings|
         
     | 
| 
      
 28 
     | 
    
         
            +
              #   # Add your settings per step
         
     | 
| 
      
 29 
     | 
    
         
            +
              # end
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
              # component.register_resource(:some_resource) do |resource|
         
     | 
| 
      
 32 
     | 
    
         
            +
              #   # Register a optional resource that can be references from other resources.
         
     | 
| 
      
 33 
     | 
    
         
            +
              #   resource.model_class_name = "Decidim::Sdgs::SomeResource"
         
     | 
| 
      
 34 
     | 
    
         
            +
              #   resource.template = "decidim/sdgs/some_resources/linked_some_resources"
         
     | 
| 
      
 35 
     | 
    
         
            +
              # end
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
              # component.register_stat :some_stat do |context, start_at, end_at|
         
     | 
| 
      
 38 
     | 
    
         
            +
              #   # Register some stat number to the application
         
     | 
| 
      
 39 
     | 
    
         
            +
              # end
         
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
      
 41 
     | 
    
         
            +
              # component.seeds do |participatory_space|
         
     | 
| 
      
 42 
     | 
    
         
            +
              #   # Add some seeds for this component
         
     | 
| 
      
 43 
     | 
    
         
            +
              # end
         
     | 
| 
      
 44 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,23 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            require "rails"
         
     | 
| 
      
 4 
     | 
    
         
            +
            require "decidim/core"
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            module Decidim
         
     | 
| 
      
 7 
     | 
    
         
            +
              module Sdgs
         
     | 
| 
      
 8 
     | 
    
         
            +
                # This is the engine that runs on the public interface of challenges.
         
     | 
| 
      
 9 
     | 
    
         
            +
                class Engine < ::Rails::Engine
         
     | 
| 
      
 10 
     | 
    
         
            +
                  isolate_namespace Decidim::Sdgs
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
                  routes do
         
     | 
| 
      
 13 
     | 
    
         
            +
                    # Add engine routes here
         
     | 
| 
      
 14 
     | 
    
         
            +
                    resources :sdgs, only: [:index, :show]
         
     | 
| 
      
 15 
     | 
    
         
            +
                    root to: "sdgs#index"
         
     | 
| 
      
 16 
     | 
    
         
            +
                  end
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
                  initializer "decidim_sdgs.webpacker.assets_path" do
         
     | 
| 
      
 19 
     | 
    
         
            +
                    Decidim.register_assets_path File.expand_path("app/packs", root)
         
     | 
| 
      
 20 
     | 
    
         
            +
                  end
         
     | 
| 
      
 21 
     | 
    
         
            +
                end
         
     | 
| 
      
 22 
     | 
    
         
            +
              end
         
     | 
| 
      
 23 
     | 
    
         
            +
            end
         
     |