diff --git a/app/controllers/admin/budgets_controller.rb b/app/controllers/admin/budgets_controller.rb index e5e73a346..e7e462fc8 100644 --- a/app/controllers/admin/budgets_controller.rb +++ b/app/controllers/admin/budgets_controller.rb @@ -15,7 +15,17 @@ class Admin::BudgetsController < Admin::BaseController end def new - @budget = Budget.new + end + + def edit + end + + def update + if @budget.update(budget_params) + redirect_to admin_budget_path(@budget), notice: t('admin.budgets.update.notice') + else + render :edit + end end def create diff --git a/app/models/budget.rb b/app/models/budget.rb index 4d6f1341f..26c32e5f9 100644 --- a/app/models/budget.rb +++ b/app/models/budget.rb @@ -1,9 +1,10 @@ class Budget < ActiveRecord::Base include Sanitizable + include Measurable - VALID_PHASES = %W{on_hold accepting selecting balloting finished} - CURRENCY_SYMBOLS = %W{€ $ £ ¥} + VALID_PHASES = %W{on_hold accepting selecting balloting finished}.freeze + CURRENCY_SYMBOLS = %W{€ $ £ ¥}.freeze validates :name, presence: true validates :phase, inclusion: { in: VALID_PHASES } diff --git a/app/views/admin/budgets/_form.html.erb b/app/views/admin/budgets/_form.html.erb new file mode 100644 index 000000000..615e0ae67 --- /dev/null +++ b/app/views/admin/budgets/_form.html.erb @@ -0,0 +1,16 @@ +<%= form_for [:admin, @budget] do |f| %> + + <%= f.text_field :name, maxlength: Budget.title_max_length %> + + <%= f.cktext_area :description, maxlength: Budget.description_max_length, ckeditor: { language: I18n.locale } %> + +
+
+ <%= f.select :phase, budget_phases_select_options %> +
+
+ <%= f.select :currency_symbol, budget_currency_symbol_select_options %> +
+
+ <%= f.submit t("shared.send"), class: "button success" %> +<% end %> diff --git a/app/views/admin/budgets/edit.html.erb b/app/views/admin/budgets/edit.html.erb new file mode 100644 index 000000000..6fd1e3e1f --- /dev/null +++ b/app/views/admin/budgets/edit.html.erb @@ -0,0 +1,7 @@ +
+
+

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

+ + <%= render '/admin/budgets/form' %> +
+
diff --git a/app/views/admin/budgets/new.html.erb b/app/views/admin/budgets/new.html.erb index 9ca0f34a5..3fa0fac89 100644 --- a/app/views/admin/budgets/new.html.erb +++ b/app/views/admin/budgets/new.html.erb @@ -2,28 +2,6 @@

<%= 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} %> -
-
- <%= f.submit t("admin.budgets.new.create"), class: "button success" %> - <% end %> + <%= render '/admin/budgets/form' %>
- \ No newline at end of file + diff --git a/app/views/admin/budgets/show.html.erb b/app/views/admin/budgets/show.html.erb index 847aa2f60..4468f7599 100644 --- a/app/views/admin/budgets/show.html.erb +++ b/app/views/admin/budgets/show.html.erb @@ -1,8 +1,8 @@
-

<%= @budget.name %>

+

<%= @budget.name %> <%= link_to(t('shared.edit'), edit_admin_budget_path(@budget)) %>

- <%= simple_format(text_with_links(@budget.description), {}, sanitize: false) %> + <%= @budget.description %>

<%= t('admin.budgets.show.phase') %>: <%= t("budget.phase.#{@budget.phase}") %> | @@ -13,4 +13,4 @@

<%= render "groups", groups: @budget.groups %> -
\ No newline at end of file +
diff --git a/config/locales/activerecord.en.yml b/config/locales/activerecord.en.yml index 8ba93bb99..9feabbb8a 100644 --- a/config/locales/activerecord.en.yml +++ b/config/locales/activerecord.en.yml @@ -41,6 +41,11 @@ en: one: "Spending proposal" other: "Spending proposals" attributes: + budget: + name: "Name" + descripcion: "Description" + phase: "Phase" + currency_symbol: "Currency" budget/investment: administrator_id: "Administrator" description: "Description" diff --git a/config/locales/activerecord.es.yml b/config/locales/activerecord.es.yml index 46888ad5a..631d18741 100644 --- a/config/locales/activerecord.es.yml +++ b/config/locales/activerecord.es.yml @@ -41,6 +41,11 @@ es: one: "Propuesta de inversión" other: "Propuestas de inversión" attributes: + budget: + name: "Nombre" + description: "Descripción" + phase: "Fase" + currency_symbol: "Divisa" budget/investment: administrator_id: "Administrador" description: "Descripción" @@ -111,4 +116,4 @@ es: attributes: document_number: not_in_census: 'No verificado por Padrón' - already_voted: 'Ya ha votado esta propuesta' \ No newline at end of file + already_voted: 'Ya ha votado esta propuesta' diff --git a/config/locales/admin.en.yml b/config/locales/admin.en.yml index 2684b8c27..51d3fa841 100755 --- a/config/locales/admin.en.yml +++ b/config/locales/admin.en.yml @@ -68,23 +68,22 @@ en: finished: Finished create: notice: New participatory budget created successfully! + update: + notice: Participatory budget updated successfully + edit: + title: Edit Participatory budget new: title: New participatory budget - create: Create budget - name: Budget's name - description: Description - phase: Phase - currency: Currency show: phase: Current phase currency: Currency groups: Groups of budget headings form: - group: Group's name + group: Group name no_groups: No groups created yet. Each user will be able to vote in only one heading per group. add_group: Add new group create_group: Create group - heading: Heading's name + heading: Heading name add_heading: Add heading amount: Amount save_heading: Save heading diff --git a/config/locales/admin.es.yml b/config/locales/admin.es.yml index bc37013cc..cef210035 100644 --- a/config/locales/admin.es.yml +++ b/config/locales/admin.es.yml @@ -68,13 +68,12 @@ es: finished: Terminados create: notice: ¡Nueva campaña de presupuestos participativos creada con éxito! + update: + notice: Campaña de presupuestos participativos actualizada + edit: + title: Editar campaña de presupuestos participativos new: title: Nuevo presupuesto ciudadano - create: Crear presupuesto - name: Nombre del presupuesto - description: Descripción - phase: Fase - currency: Divisa show: phase: Fase actual currency: Divisa diff --git a/config/locales/en.yml b/config/locales/en.yml index 298a3c513..4ec62ddf9 100755 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -441,6 +441,8 @@ en: collective: Collective flag: Flag as inappropriate hide: Hide + send: Send + edit: Editar print: print_button: Print this info search: Search diff --git a/config/locales/es.yml b/config/locales/es.yml index bf1e656c0..d082d4783 100755 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -445,6 +445,8 @@ es: print_button: Imprimir esta información search: Buscar show: Mostrar + send: Enviar + edit: Editar suggest: debate: found: