decidim-system 0.0.1.alpha3

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.

Potentially problematic release.


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

Files changed (61) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +28 -0
  3. data/Rakefile +32 -0
  4. data/app/assets/config/decidim_system_manifest.js +2 -0
  5. data/app/assets/javascripts/decidim/system.js +21 -0
  6. data/app/assets/stylesheets/decidim/system/_actions.scss +8 -0
  7. data/app/assets/stylesheets/decidim/system/_foundation_and_overrides.scss +52 -0
  8. data/app/assets/stylesheets/decidim/system/_layout.scss +16 -0
  9. data/app/assets/stylesheets/decidim/system/_login.scss +36 -0
  10. data/app/assets/stylesheets/decidim/system/_settings.scss +566 -0
  11. data/app/assets/stylesheets/decidim/system/_sidebar.scss +73 -0
  12. data/app/assets/stylesheets/decidim/system/_tables.scss +5 -0
  13. data/app/assets/stylesheets/decidim/system.scss +8 -0
  14. data/app/commands/decidim/system/create_admin.rb +40 -0
  15. data/app/commands/decidim/system/register_organization.rb +59 -0
  16. data/app/commands/decidim/system/update_admin.rb +52 -0
  17. data/app/commands/decidim/system/update_organization.rb +51 -0
  18. data/app/controllers/decidim/system/admins_controller.rb +67 -0
  19. data/app/controllers/decidim/system/application_controller.rb +11 -0
  20. data/app/controllers/decidim/system/dashboard_controller.rb +9 -0
  21. data/app/controllers/decidim/system/devise/passwords_controller.rb +12 -0
  22. data/app/controllers/decidim/system/devise/sessions_controller.rb +12 -0
  23. data/app/controllers/decidim/system/organizations_controller.rb +59 -0
  24. data/app/forms/decidim/system/admin_form.rb +33 -0
  25. data/app/forms/decidim/system/register_organization_form.rb +20 -0
  26. data/app/forms/decidim/system/update_organization_form.rb +28 -0
  27. data/app/helpers/decidim/system/application_helper.rb +12 -0
  28. data/app/jobs/decidim/system/application_job.rb +9 -0
  29. data/app/mailers/decidim/system/application_mailer.rb +11 -0
  30. data/app/models/decidim/system/admin.rb +18 -0
  31. data/app/models/decidim/system/application_record.rb +10 -0
  32. data/app/views/decidim/system/admins/_form.html.erb +11 -0
  33. data/app/views/decidim/system/admins/edit.html.erb +11 -0
  34. data/app/views/decidim/system/admins/index.html.erb +33 -0
  35. data/app/views/decidim/system/admins/new.html.erb +11 -0
  36. data/app/views/decidim/system/admins/show.html.erb +9 -0
  37. data/app/views/decidim/system/dashboard/show.html.erb +3 -0
  38. data/app/views/decidim/system/devise/mailers/password_change.html.erb +3 -0
  39. data/app/views/decidim/system/devise/mailers/reset_password_instructions.html.erb +8 -0
  40. data/app/views/decidim/system/devise/passwords/edit.html.erb +23 -0
  41. data/app/views/decidim/system/devise/passwords/new.html.erb +15 -0
  42. data/app/views/decidim/system/devise/sessions/new.html.erb +23 -0
  43. data/app/views/decidim/system/devise/shared/_links.html.erb +25 -0
  44. data/app/views/decidim/system/organizations/edit.html.erb +17 -0
  45. data/app/views/decidim/system/organizations/index.html.erb +34 -0
  46. data/app/views/decidim/system/organizations/new.html.erb +25 -0
  47. data/app/views/decidim/system/organizations/show.html.erb +11 -0
  48. data/app/views/layouts/decidim/system/_header.html.erb +4 -0
  49. data/app/views/layouts/decidim/system/_login_items.html.erb +8 -0
  50. data/app/views/layouts/decidim/system/_sidebar.html.erb +15 -0
  51. data/app/views/layouts/decidim/system/application.html.erb +40 -0
  52. data/app/views/layouts/decidim/system/login.html.erb +19 -0
  53. data/config/i18n-tasks.yml +120 -0
  54. data/config/locales/en.yml +60 -0
  55. data/config/routes.rb +17 -0
  56. data/db/migrate/20160919105637_devise_create_decidim_admins.rb +26 -0
  57. data/db/seeds.rb +9 -0
  58. data/lib/decidim/system/engine.rb +31 -0
  59. data/lib/decidim/system.rb +12 -0
  60. data/lib/tasks/decidim/system_tasks.rake +5 -0
  61. metadata +317 -0
@@ -0,0 +1,25 @@
1
+ <%- if controller_name != 'sessions' %>
2
+ <%= link_to "Log in", new_session_path(resource_name) %><br />
3
+ <% end -%>
4
+
5
+ <%- if devise_mapping.registerable? && controller_name != 'registrations' %>
6
+ <%= link_to "Sign up", new_registration_path(resource_name) %><br />
7
+ <% end -%>
8
+
9
+ <%- if devise_mapping.recoverable? && controller_name != 'passwords' && controller_name != 'registrations' %>
10
+ <%= link_to "Forgot your password?", new_password_path(resource_name) %><br />
11
+ <% end -%>
12
+
13
+ <%- if devise_mapping.confirmable? && controller_name != 'confirmations' %>
14
+ <%= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) %><br />
15
+ <% end -%>
16
+
17
+ <%- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' %>
18
+ <%= link_to "Didn't receive unlock instructions?", new_unlock_path(resource_name) %><br />
19
+ <% end -%>
20
+
21
+ <%- if devise_mapping.omniauthable? %>
22
+ <%- resource_class.omniauth_providers.each do |provider| %>
23
+ <%= link_to "Sign in with #{OmniAuth::Utils.camelize(provider)}", omniauth_authorize_path(resource_name, provider) %><br />
24
+ <% end -%>
25
+ <% end -%>
@@ -0,0 +1,17 @@
1
+ <%= form_for(@form) do |f| %>
2
+ <div class="field">
3
+ <%= f.text_field :name, autofocus: true %>
4
+ </div>
5
+
6
+ <div class="field">
7
+ <%= f.text_field :host %>
8
+ </div>
9
+
10
+ <div class="field">
11
+ <%= f.translated :text_area, :description %>
12
+ </div>
13
+
14
+ <div class="actions">
15
+ <%= f.submit t("decidim.system.actions.save") %>
16
+ </div>
17
+ <% end %>
@@ -0,0 +1,34 @@
1
+ <% content_for :title do %>
2
+ <h2><%= t ".title" %></h2>
3
+ <% end %>
4
+
5
+ <div class="actions title">
6
+ <%= link_to t("actions.new", scope: "decidim.system", name: t("models.organization.name", scope: "decidim.system")), ['new', 'organization'], class: 'new' %>
7
+ </div>
8
+
9
+ <table class="stack">
10
+ <thead>
11
+ <tr>
12
+ <th><%= t("models.organization.fields.name", scope: "decidim.system") %></th>
13
+ <th><%= t("models.organization.fields.created_at", scope: "decidim.system") %></th>
14
+ <th class="actions"><%= t("actions.title", scope: "decidim.system") %></th>
15
+ </tr>
16
+ </thead>
17
+ <tbody>
18
+ <% @organizations.each do |organization| %>
19
+ <tr>
20
+ <td>
21
+ <%= link_to organization.name, organization %><br />
22
+ <%= organization.host %>
23
+ </td>
24
+ <td>
25
+ <%= l organization.created_at, format: :short %>
26
+ </td>
27
+ <td class="actions">
28
+ <%= link_to t("actions.edit", scope: "decidim.system"), ['edit', organization] %>
29
+ <%= link_to t("actions.destroy", scope: "decidim.system"), organization, method: :delete, class: "small alert button", data: { confirm: t("actions.confirm_destroy", scope: "decidim.system") } %>
30
+ </td>
31
+ </tr>
32
+ <% end %>
33
+ </tbody>
34
+ </table>
@@ -0,0 +1,25 @@
1
+ <% content_for :title do %>
2
+ <h2><%= t ".title" %></h2>
3
+ <% end %>
4
+
5
+ <%= form_for(@form) do |f| %>
6
+ <div class="field">
7
+ <%= f.text_field :name, autofocus: true %>
8
+ </div>
9
+
10
+ <div class="field">
11
+ <%= f.text_field :host %>
12
+ </div>
13
+
14
+ <div class="field">
15
+ <%= f.translated :text_area, :description %>
16
+ </div>
17
+
18
+ <div class="field">
19
+ <%= f.email_field :organization_admin_email %>
20
+ </div>
21
+
22
+ <div class="actions">
23
+ <%= f.submit t("decidim.system.models.organization.actions.save_and_invite") %>
24
+ </div>
25
+ <% end %>
@@ -0,0 +1,11 @@
1
+ <% content_for :title do %>
2
+ <h2><%= link_to @organization.name, @organization %></h2>
3
+ <h3 class="subheader"><%= @organization.host %></h3>
4
+ <p><%= translated_attribute @organization.description %></p>
5
+ <% end %>
6
+
7
+ <div class="actions">
8
+ <hr />
9
+ <%= link_to t("decidim.system.actions.edit"), ['edit', @organization] %>
10
+ <%= link_to t("decidim.system.actions.destroy"), @organization, method: :delete, class: "alert button", data: { confirm: t("decidim.system.actions.confirm_destroy") } %>
11
+ </div>
@@ -0,0 +1,4 @@
1
+ <meta name="viewport" content="width=device-width, initial-scale=1">
2
+ <%= csrf_meta_tags %>
3
+ <%= stylesheet_link_tag 'decidim/system', media: 'all', 'data-turbolinks-track': 'reload' %>
4
+ <%= javascript_include_tag 'decidim/system', 'data-turbolinks-track': 'reload' %>
@@ -0,0 +1,8 @@
1
+ <div class="session-box">
2
+ <div class="admin-email">
3
+ <%= current_admin.email %>
4
+ </div>
5
+ <div class="sign-out">
6
+ <%= link_to('Logout', destroy_admin_session_path, :method => :delete) %>
7
+ </div>
8
+ </div>
@@ -0,0 +1,15 @@
1
+ <div class="title">
2
+ <h1>
3
+ <%= link_to root_path do %>
4
+ <%= title %>
5
+ <% end %>
6
+ </h1>
7
+ </div>
8
+
9
+ <nav class="main-menu">
10
+ <%= active_link_to t("menu.dashboard", scope: "decidim.system"), root_path, active: :exact %>
11
+ <%= active_link_to t("menu.organizations", scope: "decidim.system"), organizations_path, active: :inclusive %>
12
+ <%= active_link_to t("menu.admins", scope: "decidim.system"), admins_path, active: :inclusive %>
13
+ </nav>
14
+
15
+ <%= render partial: 'layouts/decidim/system/login_items' %>
@@ -0,0 +1,40 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Decidim - System</title>
5
+ <%= render partial: 'layouts/decidim/system/header' %>
6
+ </head>
7
+
8
+ <body>
9
+ <div class="off-canvas-wrapper">
10
+ <div class="off-canvas-wrapper-inner" data-off-canvas-wrapper>
11
+ <div class="off-canvas position-left reveal-for-large" id="my-info" data-off-canvas data-position="left">
12
+ <div class="sidebar">
13
+ <%= render partial: 'layouts/decidim/system/sidebar' %>
14
+ </div>
15
+ </div>
16
+
17
+ <div class="off-canvas-content" data-off-canvas-content>
18
+ <div class="title-bar hide-for-large">
19
+ <div class="title-bar-left">
20
+ <button class="menu-icon" type="button" data-open="my-info"></button>
21
+ <span class="title-bar-title"><%= title %></span>
22
+ </div>
23
+ </div>
24
+ <div class="row main-content">
25
+ <div class="small-12 column">
26
+ <% if content_for?(:title) %>
27
+ <section class="page-title">
28
+ <%= content_for :title %>
29
+ </section>
30
+ <% end %>
31
+
32
+ <%= display_flash_messages %>
33
+ <%= yield %>
34
+ </div>
35
+ </div>
36
+ </div>
37
+ </div>
38
+ </div>
39
+ </body>
40
+ </html>
@@ -0,0 +1,19 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Decidim - Login</title>
5
+ <%= render partial: 'layouts/decidim/system/header' %>
6
+ </head>
7
+
8
+ <body class="login">
9
+ <div class="login-form-wrapper">
10
+ <div class="login-form">
11
+ <h1>Decidim</h1>
12
+ <%= display_flash_messages %>
13
+ <div class="login-form-inner">
14
+ <%= yield %>
15
+ </div>
16
+ </div>
17
+ </div>
18
+ </body>
19
+ </html>
@@ -0,0 +1,120 @@
1
+ # i18n-tasks finds and manages missing and unused translations: https://github.com/glebm/i18n-tasks
2
+
3
+ # The "main" locale.
4
+ base_locale: en
5
+ ## All available locales are inferred from the data by default. Alternatively, specify them explicitly:
6
+ # locales: [es, fr]
7
+ ## Reporting locale, default: en. Available: en, ru.
8
+ # internal_locale: en
9
+
10
+ # Read and write translations.
11
+ data:
12
+ ## Translations are read from the file system. Supported format: YAML, JSON.
13
+ ## Provide a custom adapter:
14
+ # adapter: I18n::Tasks::Data::FileSystem
15
+
16
+ # Locale files or `File.find` patterns where translations are read from:
17
+ read:
18
+ ## Default:
19
+ # - config/locales/%{locale}.yml
20
+ ## More files:
21
+ # - config/locales/**/*.%{locale}.yml
22
+ ## Another gem (replace %#= with %=):
23
+ # - "<%#= %x[bundle show vagrant].chomp %>/templates/locales/%{locale}.yml"
24
+
25
+ # Locale files to write new keys to, based on a list of key pattern => file rules. Matched from top to bottom:
26
+ # `i18n-tasks normalize -p` will force move the keys according to these rules
27
+ write:
28
+ ## For example, write devise and simple form keys to their respective files:
29
+ # - ['{devise, simple_form}.*', 'config/locales/\1.%{locale}.yml']
30
+ ## Catch-all default:
31
+ # - config/locales/%{locale}.yml
32
+
33
+ ## Specify the router (see Readme for details). Valid values: conservative_router, pattern_router, or a custom class.
34
+ # router: convervative_router
35
+
36
+ yaml:
37
+ write:
38
+ # do not wrap lines at 80 characters
39
+ line_width: -1
40
+
41
+ ## Pretty-print JSON:
42
+ # json:
43
+ # write:
44
+ # indent: ' '
45
+ # space: ' '
46
+ # object_nl: "\n"
47
+ # array_nl: "\n"
48
+
49
+ # Find translate calls
50
+ search:
51
+ ## Paths or `File.find` patterns to search in:
52
+ # paths:
53
+ # - app/
54
+
55
+ ## Root directories for relative keys resolution.
56
+ # relative_roots:
57
+ # - app/controllers
58
+ # - app/helpers
59
+ # - app/mailers
60
+ # - app/presenters
61
+ # - app/views
62
+
63
+ ## Files or `File.fnmatch` patterns to exclude from search. Some files are always excluded regardless of this setting:
64
+ ## %w(*.jpg *.png *.gif *.svg *.ico *.eot *.otf *.ttf *.woff *.woff2 *.pdf *.css *.sass *.scss *.less *.yml *.json)
65
+ exclude:
66
+ - app/assets/images
67
+ - app/assets/fonts
68
+
69
+ ## Alternatively, the only files or `File.fnmatch patterns` to search in `paths`:
70
+ ## If specified, this settings takes priority over `exclude`, but `exclude` still applies.
71
+ # only: ["*.rb", "*.html.slim"]
72
+
73
+ ## If `strict` is `false`, guess usages such as t("categories.#{category}.title"). The default is `true`.
74
+ # strict: true
75
+
76
+ ## Multiple scanners can be used. Their results are merged.
77
+ ## The options specified above are passed down to each scanner. Per-scanner options can be specified as well.
78
+ ## See this example of a custom scanner: https://github.com/glebm/i18n-tasks/wiki/A-custom-scanner-example
79
+
80
+ ## Google Translate
81
+ # translation:
82
+ # # Get an API key and set billing info at https://code.google.com/apis/console to use Google Translate
83
+ # api_key: "AbC-dEf5"
84
+
85
+ ## Do not consider these keys missing:
86
+ # ignore_missing:
87
+ # - 'errors.messages.{accepted,blank,invalid,too_short,too_long}'
88
+ # - '{devise,simple_form}.*'
89
+
90
+ ## Consider these keys used:
91
+ # ignore_unused:
92
+ # - 'activerecord.attributes.*'
93
+ # - '{devise,kaminari,will_paginate}.*'
94
+ # - 'simple_form.{yes,no}'
95
+ # - 'simple_form.{placeholders,hints,labels}.*'
96
+ # - 'simple_form.{error_notification,required}.:'
97
+
98
+ ## Exclude these keys from the `i18n-tasks eq-base' report:
99
+ # ignore_eq_base:
100
+ # all:
101
+ # - common.ok
102
+ # fr,es:
103
+ # - common.brand
104
+
105
+ ## Ignore these keys completely:
106
+ # ignore:
107
+ # - kaminari.*
108
+
109
+ ## Sometimes, it isn't possible for i18n-tasks to match the key correctly,
110
+ ## e.g. in case of a relative key defined in a helper method.
111
+ ## In these cases you can use the built-in PatternMapper to map patterns to keys, e.g.:
112
+ #
113
+ # <%#= I18n::Tasks.add_scanner 'I18n::Tasks::Scanners::PatternMapper',
114
+ # only: %w(*.html.haml *.html.slim),
115
+ # patterns: [['= title\b', '.page_title']] %>
116
+ #
117
+ # The PatternMapper can also match key literals via a special %{key} interpolation, e.g.:
118
+ #
119
+ # <%#= I18n::Tasks.add_scanner 'I18n::Tasks::Scanners::PatternMapper',
120
+ # patterns: [['\bSpree\.t[( ]\s*%{key}', 'spree.%{key}']] %>
@@ -0,0 +1,60 @@
1
+ ---
2
+ en:
3
+ decidim:
4
+ system:
5
+ actions:
6
+ confirm_destroy: Are you sure you want to delete this?
7
+ destroy: Destroy
8
+ edit: Edit
9
+ new: New %{name}
10
+ save: Save
11
+ title: Actions
12
+ admins:
13
+ create:
14
+ error: There was an error when creating a new admin.
15
+ success: Admin created successfully
16
+ destroy:
17
+ success: Admin successfully destroyed
18
+ edit:
19
+ title: Edit admin
20
+ update: Update admin
21
+ index:
22
+ title: Admins
23
+ new:
24
+ create: Create admin
25
+ title: New admin
26
+ update:
27
+ error: There was an error when updating this admin.
28
+ success: Admin updated successfully
29
+ menu:
30
+ admins: Admins
31
+ dashboard: Dashboard
32
+ organizations: Organizations
33
+ models:
34
+ admin:
35
+ fields:
36
+ created_at: Created at
37
+ email: Email
38
+ name: Admin
39
+ validations:
40
+ email_uniqueness: another admin with the same email already exists
41
+ organization:
42
+ actions:
43
+ save_and_invite: Create organization & invite admin
44
+ fields:
45
+ created_at: Created at
46
+ name: Name
47
+ name: Organization
48
+ organizations:
49
+ create:
50
+ error: There was an error when creating a new organization.
51
+ success: Organization created successfully.
52
+ index:
53
+ title: Organizations
54
+ new:
55
+ title: New organization
56
+ update:
57
+ error: There was an error when updating this organization.
58
+ success: Organization updated successfully.
59
+ titles:
60
+ dashboard: Dashboard
data/config/routes.rb ADDED
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+ Decidim::System::Engine.routes.draw do
3
+ devise_for :admins,
4
+ class_name: "Decidim::System::Admin",
5
+ module: :devise,
6
+ router_name: :decidim_system,
7
+ controllers: {
8
+ sessions: "decidim/system/devise/sessions",
9
+ passwords: "decidim/system/devise/passwords"
10
+ }
11
+
12
+ authenticate(:admin) do
13
+ resources :organizations
14
+ resources :admins
15
+ root to: "dashboard#show"
16
+ end
17
+ end
@@ -0,0 +1,26 @@
1
+ class DeviseCreateDecidimAdmins < ActiveRecord::Migration[5.0]
2
+ def change
3
+ create_table :decidim_system_admins do |t|
4
+ ## Database authenticatable
5
+ t.string :email, null: false, default: ""
6
+ t.string :encrypted_password, null: false, default: ""
7
+
8
+ ## Recoverable
9
+ t.string :reset_password_token
10
+ t.datetime :reset_password_sent_at
11
+
12
+ ## Rememberable
13
+ t.datetime :remember_created_at
14
+
15
+ ## Lockable
16
+ t.integer :failed_attempts, default: 0, null: false # Only if lock strategy is :failed_attempts
17
+ t.string :unlock_token # Only if unlock strategy is :email or :both
18
+ t.datetime :locked_at
19
+
20
+ t.timestamps null: false
21
+ end
22
+
23
+ add_index :decidim_system_admins, :email, unique: true
24
+ add_index :decidim_system_admins, :reset_password_token, unique: true
25
+ end
26
+ end
data/db/seeds.rb ADDED
@@ -0,0 +1,9 @@
1
+ if !Rails.env.production? || ENV["SEED"]
2
+ puts "Creating Decidim::System seeds..."
3
+
4
+ Decidim::System::Admin.create!(
5
+ email: "system@decidim.org",
6
+ password: "decidim123456",
7
+ password_confirmation: "decidim123456"
8
+ )
9
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+ require "rails"
3
+ require "active_support/all"
4
+
5
+ require "devise"
6
+ require "devise-i18n"
7
+ require "decidim/core"
8
+ require "jquery-rails"
9
+ require "sass-rails"
10
+ require "turbolinks"
11
+ require "jquery-turbolinks"
12
+ require "foundation-rails"
13
+ require "foundation_rails_helper"
14
+ require "jbuilder"
15
+ require "rectify"
16
+
17
+ module Decidim
18
+ module System
19
+ # Decidim's core Rails Engine.
20
+ class Engine < ::Rails::Engine
21
+ isolate_namespace Decidim::System
22
+
23
+ config.to_prepare do
24
+ Rails.application.config.assets.precompile += %w(
25
+ decidim/system.js
26
+ decidim/system.css
27
+ )
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+ require "decidim/system/engine"
3
+
4
+ module Decidim
5
+ # This module contains all the logic related to a system-wide
6
+ # administration panel. The scope of the domain is to be able
7
+ # to manage Organizations (tenants), as well as have a bird's
8
+ # eye view of the whole system.
9
+ #
10
+ module System
11
+ end
12
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+ # desc "Explaining what the task does"
3
+ # task :decidim_system do
4
+ # # Task goes here
5
+ # end