decidim-admin 0.0.1.alpha3

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

Potentially problematic release.


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

Files changed (37) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +28 -0
  3. data/Rakefile +32 -0
  4. data/app/assets/config/decidim_admin_manifest.js +2 -0
  5. data/app/assets/javascripts/decidim/admin.js +21 -0
  6. data/app/assets/stylesheets/decidim/admin.scss +8 -0
  7. data/app/assets/stylesheets/decidim/admin/_actions.scss +8 -0
  8. data/app/assets/stylesheets/decidim/admin/_foundation_and_overrides.scss +52 -0
  9. data/app/assets/stylesheets/decidim/admin/_layout.scss +16 -0
  10. data/app/assets/stylesheets/decidim/admin/_login.scss +36 -0
  11. data/app/assets/stylesheets/decidim/admin/_settings.scss +566 -0
  12. data/app/assets/stylesheets/decidim/admin/_sidebar.scss +73 -0
  13. data/app/assets/stylesheets/decidim/admin/_tables.scss +5 -0
  14. data/app/constraints/decidim/admin/organization_dashboard_constraint.rb +36 -0
  15. data/app/controllers/decidim/admin/application_controller.rb +10 -0
  16. data/app/controllers/decidim/admin/dashboard_controller.rb +9 -0
  17. data/app/helpers/decidim/admin/application_helper.rb +12 -0
  18. data/app/jobs/decidim/admin/application_job.rb +9 -0
  19. data/app/mailers/decidim/admin/application_mailer.rb +11 -0
  20. data/app/models/decidim/admin/application_record.rb +10 -0
  21. data/app/policies/decidim/admin/application_policy.rb +20 -0
  22. data/app/policies/decidim/admin/organization_policy.rb +15 -0
  23. data/app/views/decidim/admin/dashboard/show.html.erb +3 -0
  24. data/app/views/decidim/admin/devise/mailers/password_change.html.erb +3 -0
  25. data/app/views/decidim/admin/devise/mailers/reset_password_instructions.html.erb +8 -0
  26. data/app/views/layouts/decidim/admin/_header.html.erb +4 -0
  27. data/app/views/layouts/decidim/admin/_login_items.html.erb +8 -0
  28. data/app/views/layouts/decidim/admin/_sidebar.html.erb +13 -0
  29. data/app/views/layouts/decidim/admin/application.html.erb +40 -0
  30. data/app/views/layouts/decidim/admin/login.html.erb +19 -0
  31. data/config/i18n-tasks.yml +120 -0
  32. data/config/locales/en.yml +8 -0
  33. data/config/routes.rb +4 -0
  34. data/lib/decidim/admin.rb +12 -0
  35. data/lib/decidim/admin/engine.rb +31 -0
  36. data/lib/tasks/decidim/admin_tasks.rake +5 -0
  37. metadata +321 -0
@@ -0,0 +1,73 @@
1
+ @mixin menu-title{
2
+ text-transform: uppercase;
3
+ letter-spacing: 5px;
4
+ }
5
+
6
+ .title-bar-title{
7
+ @include menu-title;
8
+ }
9
+
10
+ .sidebar{
11
+ color: $light-gray;
12
+
13
+ .title{
14
+ background-color: black;
15
+ background-color: map-get($foundation-palette, primary);
16
+
17
+ h1{
18
+ margin: 0;
19
+ padding: 0;
20
+ font-size: rem-calc(18);
21
+ font-weight: bold;
22
+ }
23
+
24
+ a{
25
+ display: block;
26
+ color: inherit;
27
+ padding: rem-calc(20) $global-padding;
28
+ @include menu-title;
29
+ }
30
+
31
+ @include show-for(large);
32
+ }
33
+
34
+ .main-menu{
35
+ border-top: 1px solid black;
36
+ border-bottom: 1px solid black;
37
+ a{
38
+ padding: $global-padding;
39
+ display: block;
40
+ color: $light-gray;
41
+ text-transform: uppercase;
42
+ font-weight: bold;
43
+ font-size: 0.9em;
44
+ border-left: 2px solid transparent;
45
+
46
+ transition: all 0.3s;
47
+
48
+ &.active {
49
+ border-color: map-get($foundation-palette, primary);
50
+ &, &:hover{
51
+ background-color: #101010;
52
+ }
53
+ }
54
+
55
+ &:hover {
56
+ background-color: #1a1a1a;
57
+ }
58
+ }
59
+ }
60
+
61
+ .session-box {
62
+ padding: $global-padding 0;
63
+
64
+ @include grid-row;
65
+
66
+ .admin-email {
67
+ @include grid-column(8);
68
+ text-overflow: ellipsis;
69
+ overflow: hidden;
70
+ }
71
+ .sign-out{ @include grid-column(4); }
72
+ }
73
+ }
@@ -0,0 +1,5 @@
1
+ table{
2
+ td.actions, th.actions{
3
+ text-align: right;
4
+ }
5
+ }
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+ module Decidim
3
+ module Admin
4
+ # A Rails routes constraint to only allow access to an Organization admin to
5
+ # the organization dashboard.
6
+ class OrganizationDashboardConstraint
7
+ # Initializes the contraint.
8
+ #
9
+ # request [Rack::Request]
10
+ def initialize(request)
11
+ @request = request
12
+ end
13
+
14
+ # Checks if the user can access the organization dashboard.
15
+ #
16
+ # Returns boolean.
17
+ def matches?
18
+ OrganizationPolicy.new(user, organization).update?
19
+ end
20
+
21
+ private
22
+
23
+ attr_reader :request
24
+
25
+ def organization
26
+ request.env["decidim.current_organization"]
27
+ end
28
+
29
+ def user
30
+ return unless request.env["warden"].authenticate!(scope: :user)
31
+
32
+ @user ||= request.env["warden"].user("user")
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+ module Decidim
3
+ module Admin
4
+ # The main application controller that inherits from Rails.
5
+ class ApplicationController < ActionController::Base
6
+ include NeedsOrganization
7
+ protect_from_forgery with: :exception, prepend: true
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+ require_dependency "decidim/admin/application_controller"
3
+
4
+ module Decidim
5
+ module Admin
6
+ class DashboardController < ApplicationController
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+ module Decidim
3
+ module Admin
4
+ # Custom helpers, scoped to the admin panel.
5
+ #
6
+ module ApplicationHelper
7
+ def title
8
+ current_organization.name
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+ module Decidim
3
+ module Admin
4
+ # Custom ApplicationJob scoped to the admin panel.
5
+ #
6
+ class ApplicationJob < ActiveJob::Base
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+ module Decidim
3
+ module Admin
4
+ # Custom application mailer, scoped to the admin mailer.
5
+ #
6
+ class ApplicationMailer < ActionMailer::Base
7
+ default from: "from@example.com"
8
+ layout "mailer"
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+ module Decidim
3
+ module Admin
4
+ # Custom ApplicationRecord scoped to the Admin panel.
5
+ #
6
+ class ApplicationRecord < ActiveRecord::Base
7
+ self.abstract_class = true
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+ module Decidim
3
+ module Admin
4
+ # Main application policy so we don't ahve to repeat the initialization
5
+ # code in each Policy. To be used with Pundit.
6
+ class ApplicationPolicy
7
+ attr_reader :user, :record
8
+
9
+ # Initializes a Policy.
10
+ #
11
+ # user - The User that we want to authorize.
12
+ # record - The record on which to perform the authorizations.
13
+ #
14
+ def initialize(user, record)
15
+ @user = user
16
+ @record = record
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+ module Decidim
3
+ module Admin
4
+ # A policy to define all the authorizations regarding an Organization, to
5
+ # be used with Pundit.
6
+ class OrganizationPolicy < ApplicationPolicy
7
+ # Checks if the user can update an organization.
8
+ #
9
+ # Returns a Boolean.
10
+ def update?
11
+ user.roles.include?("admin") && user.organization == record
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,3 @@
1
+ <% content_for :title do %>
2
+ <h2><%= t("decidim.admin.titles.dashboard") %></h2>
3
+ <% end %>
@@ -0,0 +1,3 @@
1
+ <p>Hello <%= @resource.email %>!</p>
2
+
3
+ <p>We're contacting you to notify you that your password has been changed.</p>
@@ -0,0 +1,8 @@
1
+ <p>Hello <%= @resource.email %>!</p>
2
+
3
+ <p>Someone has requested a link to change your password. You can do this through the link below.</p>
4
+
5
+ <p><%= link_to 'Change my password', edit_password_url(@resource, reset_password_token: @token) %></p>
6
+
7
+ <p>If you didn't request this, please ignore this email.</p>
8
+ <p>Your password won't change until you access the link above and create a new one.</p>
@@ -0,0 +1,4 @@
1
+ <meta name="viewport" content="width=device-width, initial-scale=1">
2
+ <%= csrf_meta_tags %>
3
+ <%= stylesheet_link_tag 'decidim/admin', media: 'all', 'data-turbolinks-track': 'reload' %>
4
+ <%= javascript_include_tag 'decidim/admin', 'data-turbolinks-track': 'reload' %>
@@ -0,0 +1,8 @@
1
+ <div class="session-box">
2
+ <div class="admin-email">
3
+ <%= current_user.email %>
4
+ </div>
5
+ <div class="sign-out">
6
+ <%= link_to('Logout', decidim.destroy_user_session_path, method: :delete) %>
7
+ </div>
8
+ </div>
@@ -0,0 +1,13 @@
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.admin"), root_path, active: :exact %>
11
+ </nav>
12
+
13
+ <%= render partial: 'layouts/decidim/admin/login_items' %>
@@ -0,0 +1,40 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Decidim - admin</title>
5
+ <%= render partial: 'layouts/decidim/admin/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/admin/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/admin/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}']] %>