decidim-system 0.0.1.alpha9 → 0.0.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of decidim-system might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 049202f8155f63f2fdd8da4aefc536f871934592
4
- data.tar.gz: 43c3afa69a8f8a4fdf95254a311ae418ae5c9887
3
+ metadata.gz: 525c1412b0bf33316dd63efc0a5ab1805c2c24ae
4
+ data.tar.gz: 970cac38620dc1f03d06690f2df4f96b116addea
5
5
  SHA512:
6
- metadata.gz: f7eba15af4852467b06b13d1fef9f06436839327547e03f22de43c6cc0a7df09ad261fbdc94fc8dc3d98400080230ec0d5d8f4ee54701e828a8dfc8e687eb9a4
7
- data.tar.gz: 48ae621a9460d013c0654b9f1774b3718984b8407495011689d156c7fe7fbab337b717d333ec8c0a55f328323497c4ae5ca658ee06cae77ddd98c76d99deedec
6
+ metadata.gz: 1b8d31c3464051ff7abb879b11a4051d9b79b776a9a312a43a8a6add8438577a0466c72906d845fedef52c456c0295bbe790bcb601050685c6d258feb18a95a1
7
+ data.tar.gz: a0fcbe2c2a11355eb290151541c99a97cc106b632986310c13ace530ba3411953692b9ea4253904e3aaa78640683a5870f4302d77cdd1fab766761c2e02c0308
data/Rakefile CHANGED
@@ -1,27 +1,2 @@
1
1
  # frozen_string_literal: true
2
-
3
2
  require "decidim/common_rake"
4
- require "rdoc/task"
5
-
6
- RDoc::Task.new(:rdoc) do |rdoc|
7
- rdoc.rdoc_dir = "rdoc"
8
- rdoc.title = "Decidim::System"
9
- rdoc.options << "--line-numbers"
10
- rdoc.rdoc_files.include("README.md")
11
- rdoc.rdoc_files.include("lib/**/*.rb")
12
- end
13
-
14
- load "rails/tasks/statistics.rake"
15
-
16
- require "bundler/gem_tasks"
17
-
18
- begin
19
- require "rspec/core/rake_task"
20
- RSpec::Core::RakeTask.new(:spec)
21
- ENV["ENGINE_PATH"] = File.dirname(__FILE__)
22
-
23
- task default: :spec
24
-
25
- Rake::Task["spec"].enhance ["common:test_app"]
26
- rescue LoadError
27
- end
@@ -1,8 +1,9 @@
1
- //= require jquery
2
- //= require jquery_ujs
3
- //= require foundation
4
- //= require turbolinks
5
- //= require_self
1
+ // = require jquery
2
+ // = require jquery_ujs
3
+ // = require foundation
4
+ // = require turbolinks
5
+ // = require decidim/editor
6
+ // = require_self
6
7
 
7
8
  $(document).on('turbolinks:load', () => {
8
9
  $(document).foundation();
@@ -1,8 +1,13 @@
1
- @import 'https://fonts.googleapis.com/css?family=Montserrat:400,700';
2
-
3
1
  @import "foundation_and_overrides";
4
2
  @import "layout";
5
3
  @import "login";
6
4
  @import "sidebar";
7
5
  @import "tables";
8
6
  @import "actions";
7
+
8
+ @import "decidim/editor";
9
+ @import "decidim/utils/fontface";
10
+
11
+ body {
12
+ font-family: 'Source Sans Pro', sans-serif;
13
+ }
@@ -11,7 +11,7 @@ module Decidim
11
11
  @form = form
12
12
  end
13
13
 
14
- # Executes the command. Braodcasts these events:
14
+ # Executes the command. Broadcasts these events:
15
15
  #
16
16
  # - :ok when everything is valid.
17
17
  # - :invalid if the form wasn't valid and we couldn't proceed.
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+ module Decidim
3
+ module System
4
+ # A command with all the business logic when creating a new organization in
5
+ # the system. It creates the organization and invites the admin to the
6
+ # system.
7
+ class CreateDefaultPages < Rectify::Command
8
+ # Public: Initializes the command.
9
+ #
10
+ # form - A form object with the params.
11
+ def initialize(organization)
12
+ @organization = organization
13
+ end
14
+
15
+ # Executes the command.
16
+ #
17
+ # Returns nothing.
18
+ def call
19
+ Decidim::StaticPage::DEFAULT_PAGES.map do |slug|
20
+ Decidim::StaticPage.find_or_create_by!(slug: slug) do |page|
21
+ page.organization = organization
22
+ page.title = localized_attribute(slug, :title)
23
+ page.content = localized_attribute(slug, :content)
24
+ end
25
+ end
26
+ end
27
+
28
+ private
29
+
30
+ attr_reader :organization
31
+
32
+ def localized_attribute(slug, attribute)
33
+ I18n.available_locales.inject({}) do |result, locale|
34
+ text = I18n.with_locale(locale) do
35
+ I18n.t(attribute, scope: "decidim.system.default_pages.placeholders", page: slug)
36
+ end
37
+
38
+ result.update(locale => text)
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -12,7 +12,7 @@ module Decidim
12
12
  @form = form
13
13
  end
14
14
 
15
- # Executes the command. Braodcasts these events:
15
+ # Executes the command. Broadcasts these events:
16
16
  #
17
17
  # - :ok when everything is valid.
18
18
  # - :invalid if the form wasn't valid and we couldn't proceed.
@@ -24,6 +24,7 @@ module Decidim
24
24
  transaction do
25
25
  organization = create_organization
26
26
  invite_admin(organization)
27
+ CreateDefaultPages.call(organization)
27
28
  end
28
29
 
29
30
  broadcast(:ok)
@@ -39,7 +40,8 @@ module Decidim
39
40
  Decidim::Organization.create!(
40
41
  name: form.name,
41
42
  host: form.host,
42
- description: form.description
43
+ available_locales: form.available_locales,
44
+ default_locale: form.default_locale
43
45
  )
44
46
  end
45
47
 
@@ -12,7 +12,7 @@ module Decidim
12
12
  @form = form
13
13
  end
14
14
 
15
- # Executes the command. Braodcasts these events:
15
+ # Executes the command. Broadcasts these events:
16
16
  #
17
17
  # - :ok when everything is valid.
18
18
  # - :invalid if the form wasn't valid and we couldn't proceed.
@@ -13,7 +13,7 @@ module Decidim
13
13
  @form = form
14
14
  end
15
15
 
16
- # Executes the command. Braodcasts these events:
16
+ # Executes the command. Broadcasts these events:
17
17
  #
18
18
  # - :ok when everything is valid.
19
19
  # - :invalid if the form wasn't valid and we couldn't proceed.
@@ -42,7 +42,6 @@ module Decidim
42
42
  def save_organization
43
43
  organization.name = form.name
44
44
  organization.host = form.host
45
- organization.description = form.description
46
45
 
47
46
  organization.save!
48
47
  end
@@ -11,11 +11,11 @@ module Decidim
11
11
  end
12
12
 
13
13
  def new
14
- @form = AdminForm.new
14
+ @form = form(AdminForm).instance
15
15
  end
16
16
 
17
17
  def create
18
- @form = AdminForm.from_params(params)
18
+ @form = form(AdminForm).from_params(params)
19
19
 
20
20
  CreateAdmin.call(@form) do
21
21
  on(:ok) do
@@ -32,12 +32,12 @@ module Decidim
32
32
 
33
33
  def edit
34
34
  @admin = Admin.find(params[:id])
35
- @form = AdminForm.from_model(@admin)
35
+ @form = form(AdminForm).from_model(@admin)
36
36
  end
37
37
 
38
38
  def update
39
39
  @admin = Admin.find(params[:id])
40
- @form = AdminForm.from_params(params)
40
+ @form = form(AdminForm).from_params(params)
41
41
 
42
42
  UpdateAdmin.call(@admin, @form) do
43
43
  on(:ok) do
@@ -3,6 +3,7 @@ module Decidim
3
3
  module System
4
4
  # The main application controller that inherits from Rails.
5
5
  class ApplicationController < ActionController::Base
6
+ include FormFactory
6
7
  protect_from_forgery with: :exception, prepend: true
7
8
 
8
9
  helper Decidim::TranslationsHelper
@@ -7,11 +7,11 @@ module Decidim
7
7
  #
8
8
  class OrganizationsController < ApplicationController
9
9
  def new
10
- @form = RegisterOrganizationForm.new
10
+ @form = form(RegisterOrganizationForm).instance
11
11
  end
12
12
 
13
13
  def create
14
- @form = RegisterOrganizationForm.from_params(params)
14
+ @form = form(RegisterOrganizationForm).from_params(params)
15
15
 
16
16
  RegisterOrganization.call(@form) do
17
17
  on(:ok) do
@@ -36,11 +36,11 @@ module Decidim
36
36
 
37
37
  def edit
38
38
  organization = Organization.find(params[:id])
39
- @form = UpdateOrganizationForm.from_model(organization)
39
+ @form = form(UpdateOrganizationForm).from_model(organization)
40
40
  end
41
41
 
42
42
  def update
43
- @form = UpdateOrganizationForm.from_params(params)
43
+ @form = form(UpdateOrganizationForm).from_params(params)
44
44
 
45
45
  UpdateOrganization.call(params[:id], @form) do
46
46
  on(:ok) do
@@ -3,7 +3,7 @@ module Decidim
3
3
  module System
4
4
  # A form object used to create organizations from the system dashboard.
5
5
  #
6
- class AdminForm < Rectify::Form
6
+ class AdminForm < Form
7
7
  mimic :admin
8
8
 
9
9
  attribute :email, String
@@ -6,16 +6,17 @@ module Decidim
6
6
  # A form object used to create organizations from the system dashboard.
7
7
  #
8
8
  class RegisterOrganizationForm < UpdateOrganizationForm
9
- include TranslatableAttributes
10
-
11
9
  mimic :organization
12
10
 
13
11
  attribute :organization_admin_email, String
14
12
  attribute :organization_admin_name, String
13
+ attribute :available_locales, Array
14
+ attribute :default_locale, String
15
15
 
16
- validates :organization_admin_email, :organization_admin_name, presence: true
17
-
18
- translatable_attribute :description, String
16
+ validates :organization_admin_email, :organization_admin_name, :name, :host, presence: true
17
+ validates :available_locales, presence: true
18
+ validates :default_locale, presence: true
19
+ validates :default_locale, inclusion: { in: :available_locales }
19
20
  end
20
21
  end
21
22
  end
@@ -5,7 +5,7 @@ module Decidim
5
5
  module System
6
6
  # A form object used to update organizations from the system dashboard.
7
7
  #
8
- class UpdateOrganizationForm < Rectify::Form
8
+ class UpdateOrganizationForm < Form
9
9
  include TranslatableAttributes
10
10
 
11
11
  mimic :organization
@@ -13,8 +13,6 @@ module Decidim
13
13
  attribute :name, String
14
14
  attribute :host, String
15
15
 
16
- translatable_attribute :description, String
17
-
18
16
  validate :validate_organization_uniqueness
19
17
 
20
18
  private
@@ -4,6 +4,8 @@ module Decidim
4
4
  # Custom helpers, scoped to the system panel.
5
5
  #
6
6
  module ApplicationHelper
7
+ include Decidim::LocalizedLocalesHelper
8
+
7
9
  def title
8
10
  "Decidim"
9
11
  end
@@ -7,10 +7,6 @@
7
7
  <%= f.text_field :host %>
8
8
  </div>
9
9
 
10
- <div class="field">
11
- <%= f.translated :text_area, :description %>
12
- </div>
13
-
14
10
  <div class="actions">
15
11
  <%= f.submit t("decidim.system.actions.save") %>
16
12
  </div>
@@ -12,16 +12,36 @@
12
12
  </div>
13
13
 
14
14
  <div class="field">
15
- <%= f.translated :text_area, :description %>
15
+ <%= f.text_field :organization_admin_name %>
16
16
  </div>
17
17
 
18
18
  <div class="field">
19
- <%= f.text_field :organization_admin_name %>
19
+ <%= f.email_field :organization_admin_email %>
20
20
  </div>
21
21
 
22
+ <%= f.fields_for :locales do |fields| %>
22
23
  <div class="field">
23
- <%= f.email_field :organization_admin_email %>
24
+ <%= f.label :organization_locales, '', class: @form.respond_to?(:errors) && @form.errors[:default_locale].present? ? "is-invalid-label" : "" %>
25
+ <table>
26
+ <thead>
27
+ <tr>
28
+ <td>Locale</td>
29
+ <td>Enabled <%= f.error_for(:available_locales) %></td>
30
+ <td>Default? <%= f.error_for(:default_locale) %></td>
31
+ </tr>
32
+ </thead>
33
+ <tbody>
34
+ <% localized_locales.each do |locale| %>
35
+ <tr>
36
+ <td><%= locale.name %></td>
37
+ <td><%= check_box_tag "organization[available_locales][#{locale.id}]", locale.id, @form.available_locales.include?(locale.id) %></td>
38
+ <td><%= radio_button_tag "organization[default_locale]", locale.id, @form.default_locale == locale.id %></td>
39
+ </tr>
40
+ <% end %>
41
+ </tbody>
42
+ </table>
24
43
  </div>
44
+ <% end %>
25
45
 
26
46
  <div class="actions">
27
47
  <%= f.submit t("decidim.system.models.organization.actions.save_and_invite") %>
@@ -88,7 +88,9 @@ search:
88
88
  # - '{devise,simple_form}.*'
89
89
 
90
90
  ## Consider these keys used:
91
- # ignore_unused:
91
+ ignore_unused:
92
+ - decidim.system.default_pages.placeholders.*
93
+ - decidim.system.models.page.name
92
94
  # - 'activerecord.attributes.*'
93
95
  # - '{devise,kaminari,will_paginate}.*'
94
96
  # - 'simple_form.{yes,no}'
@@ -1,4 +1,3 @@
1
- ---
2
1
  ca:
3
2
  decidim:
4
3
  system:
@@ -14,9 +13,9 @@ ca:
14
13
  error: S'ha produït un error en crear un nou administrador.
15
14
  success: Administrador creat correctament
16
15
  destroy:
17
- success: Administrador eliminat correctament.
16
+ success: L'administrador s'ha eliminat correctament
18
17
  edit:
19
- title: Edita administrador
18
+ title: Editar administrador
20
19
  update: Actualitzar administrador
21
20
  index:
22
21
  title: Administradors
@@ -24,8 +23,12 @@ ca:
24
23
  create: Crear administrador
25
24
  title: Nou administrador
26
25
  update:
27
- error: S'ha produït un error en actualitzar aquest administrador..
28
- success: Administrador actualitzat correctament
26
+ error: S'ha produït un error en actualitzar aquest administrador.
27
+ success: L'administrador s'ha actualitzat correctament
28
+ default_pages:
29
+ placeholders:
30
+ content: Si us plau, afegeix contingut significatiu a aquesta pàgina des del tauler de control.
31
+ title: Títol predeterminat per %{page}
29
32
  menu:
30
33
  admins: Administradors
31
34
  dashboard: Tauler de control
@@ -37,24 +40,26 @@ ca:
37
40
  email: Correu electrònic
38
41
  name: Administrador
39
42
  validations:
40
- email_uniqueness: Ja existeix un altre administrador amb aquest correu electrònic.
43
+ email_uniqueness: ja existeix un altre administrador amb aquest correu electrònic
41
44
  organization:
42
45
  actions:
43
- save_and_invite: Crear organització i convidar a administrador
46
+ save_and_invite: Crear organització i convidar l'administrador
44
47
  fields:
45
48
  created_at: Data de creació
46
49
  name: Nom
47
50
  name: Organització
51
+ page:
52
+ name: pàgina
48
53
  organizations:
49
54
  create:
50
55
  error: S'ha produït un error en crear una nova organització.
51
- success: Organització creada correctament.
56
+ success: L'organització s'ha creat correctament.
52
57
  index:
53
58
  title: Organitzacions
54
59
  new:
55
60
  title: Nova organització
56
61
  update:
57
62
  error: S'ha produït un error en actualitzar aquesta organització.
58
- success: Organització actualitzada correctament.
63
+ success: L'organització s'ha actualitzat correctament.
59
64
  titles:
60
- dashboard: Tauler de control
65
+ dashboard: Tauler de control
@@ -26,6 +26,10 @@ en:
26
26
  update:
27
27
  error: There was an error when updating this admin.
28
28
  success: Admin updated successfully
29
+ default_pages:
30
+ placeholders:
31
+ content: Please add meaningful content to this page on the admin dashboard.
32
+ title: Default title for %{page}
29
33
  menu:
30
34
  admins: Admins
31
35
  dashboard: Dashboard
@@ -45,6 +49,8 @@ en:
45
49
  created_at: Created at
46
50
  name: Name
47
51
  name: Organization
52
+ page:
53
+ name: Page
48
54
  organizations:
49
55
  create:
50
56
  error: There was an error when creating a new organization.