diff --git a/app/controllers/admin/budgets_controller.rb b/app/controllers/admin/budgets_controller.rb index 7953aae75..d6f2789e6 100644 --- a/app/controllers/admin/budgets_controller.rb +++ b/app/controllers/admin/budgets_controller.rb @@ -7,6 +7,22 @@ class Admin::BudgetsController < Admin::BaseController end def new + @budget = Budget.new end + def create + @budget = Budget.new(budget_params) + if @budget.save + redirect_to admin_budgets_path, notice: t('admin.budgets.create.notice') + else + render :new + end + end + + private + + def budget_params + params.require(:budget).permit(:name, :description, :phase, :currency_symbol) + end + end diff --git a/app/views/admin/budgets/new.html.erb b/app/views/admin/budgets/new.html.erb index f71e7c7a5..c7985b98f 100644 --- a/app/views/admin/budgets/new.html.erb +++ b/app/views/admin/budgets/new.html.erb @@ -2,142 +2,29 @@

<%= t("admin.budgets.new.title") %>

-
- - "> - - + <%= form_for [:admin, @budget] do |f| %> + + <%= f.label :name, t("admin.budgets.new.name") %> + <%= f.text_field :name, + label: false, + maxlength: 30, + placeholder: t("admin.budgets.new.name") %> + + <%= f.label :description, t("admin.budgets.new.description") %> + <%= f.text_area :description, rows: 3, maxlength: 6000, label: false, placeholder: t("admin.budgets.new.description") %> +
- + <%= f.label :description, t("admin.budgets.new.phase") %> + <%= f.select :phase, budget_phases_select_options, {label: false} %>
- + <%= f.label :description, t("admin.budgets.new.currency") %> + <%= f.select :currency_symbol, budget_currency_symbol_select_options, {label: false} %>
" class="button success"> -
+ <% end %>
-
-
-

Nombre del budget

- - <%= link_to t("admin.budgets.new.add_group"), "#", class: "button float-right" %> - -
-
- - - - "> -
- ", class="button success"> -
-
-
-
-
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- Nombre del grupo - <%= link_to t("admin.budgets.new.add_heading"), "#", class: "button float-right" %> -
<%= t("admin.budgets.new.table_heading") %><%= t("admin.budgets.new.table_amount") %><%= t("admin.budgets.new.table_geozone") %>
-
- <%= t("admin.budgets.new.no_heading") %> -
-
-
- - "> - -
-
- - "> -
-
- - -
-
- - ", class="button success"> -
-
- Heading 1 name - - 190.000€ - - Geozone B -
- Heading 2 name - - 24.000.000€ - - Does not apply -
- Heading 3 name - - 1.265.000€ - - Geozone A -
-
-
diff --git a/config/locales/admin.en.yml b/config/locales/admin.en.yml index a778f6745..d55d24726 100755 --- a/config/locales/admin.en.yml +++ b/config/locales/admin.en.yml @@ -65,6 +65,8 @@ en: filters: open: Open finished: Finished + create: + notice: New participatory budget created successfully! new: title: New participatory budget create: Create budget diff --git a/config/locales/admin.es.yml b/config/locales/admin.es.yml index 3154060bf..8ed57d4d8 100644 --- a/config/locales/admin.es.yml +++ b/config/locales/admin.es.yml @@ -65,6 +65,8 @@ es: filters: open: Abiertos finished: Terminados + create: + notice: ¡Nueva campaña de presupuestos participativos creada con éxito! new: title: Nuevo presupuesto ciudadano create: Crear presupuesto diff --git a/config/locales/es.yml b/config/locales/es.yml index 282340395..195a80766 100755 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -35,7 +35,7 @@ es: menu: Menú budget: phase: - on_hold: Pausa + on_hold: En pausa accepting: Aceptando propuestas selecting: Fase de selección balloting: Fase de Votación diff --git a/spec/features/admin/budgets_spec.rb b/spec/features/admin/budgets_spec.rb index 8326a5dac..c684d8a55 100644 --- a/spec/features/admin/budgets_spec.rb +++ b/spec/features/admin/budgets_spec.rb @@ -7,7 +7,7 @@ feature 'Admin budgets' do login_as(admin.user) end - context "Feature flag" do + context 'Feature flag' do xscenario 'Disabled with a feature flag' do Setting['feature.budgets'] = nil @@ -16,7 +16,7 @@ feature 'Admin budgets' do end - context "Index" do + context 'Index' do scenario 'Displaying budgets' do budget = create(:budget) @@ -40,14 +40,14 @@ feature 'Admin budgets' do expect(page).to have_content(budget4.name) expect(page).to_not have_content(budget5.name) - click_link "Finished" + click_link 'Finished' expect(page).to_not have_content(budget1.name) expect(page).to_not have_content(budget2.name) expect(page).to_not have_content(budget3.name) expect(page).to_not have_content(budget4.name) expect(page).to have_content(budget5.name) - click_link "Open" + click_link 'Open' expect(page).to have_content(budget1.name) expect(page).to have_content(budget2.name) expect(page).to have_content(budget3.name) @@ -56,7 +56,7 @@ feature 'Admin budgets' do end - scenario "Current filter is properly highlighted" do + scenario 'Current filter is properly highlighted' do filters_links = {'open' => 'Open', 'finished' => 'Finished'} visit admin_budgets_path @@ -76,4 +76,29 @@ feature 'Admin budgets' do end end + + context 'New' do + scenario 'Create budget' do + visit admin_budgets_path + click_link 'Create new' + + fill_in 'budget_name', with: 'M30 - Summer campaign' + fill_in 'budget_description', with: 'Budgeting for summer 2017 maintenance and improvements of the road M-30' + select 'Accepting proposals', from: 'budget[phase]' + + click_button 'Create budget' + + expect(page).to have_content 'New participatory budget created successfully!' + expect(page).to have_content 'M30 - Summer campaign' + end + + scenario 'Name is mandatory' do + visit new_admin_budget_path + click_button 'Create budget' + + expect(page).to_not have_content 'New participatory budget created successfully!' + expect(page).to have_css("label.error", text: "Budget's name") + end + + end end \ No newline at end of file