decidim-core 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/decidim.js.es6 +2 -4
- data/app/assets/javascripts/decidim/append_elements.js.es6 +1 -1
- data/app/assets/javascripts/decidim/editor.js.es6 +33 -35
- data/app/assets/javascripts/decidim/filters.js.es6 +9 -15
- data/app/assets/javascripts/decidim/form_filter.component.js.es6 +5 -5
- data/app/assets/javascripts/decidim/form_filter.component.test.js +1 -1
- data/app/assets/javascripts/decidim/foundation.js.es6 +17 -0
- data/app/assets/javascripts/decidim/user_registrations.js.es6 +2 -3
- data/app/assets/stylesheets/decidim/_decidim.scss +9 -0
- data/app/assets/stylesheets/decidim/_variables.scss +5 -11
- data/app/assets/stylesheets/decidim/application.scss.erb +6 -0
- data/app/assets/stylesheets/decidim/extras/_leaflet.scss +13 -0
- data/app/assets/stylesheets/decidim/modules/_buttons.scss +8 -2
- data/app/assets/stylesheets/decidim/modules/_cards.scss +0 -2
- data/app/assets/stylesheets/decidim/modules/_comments.scss +33 -8
- data/app/assets/stylesheets/decidim/modules/{_defintion-data.scss → _definition-data.scss} +0 -0
- data/app/assets/stylesheets/decidim/modules/_filter-tags.scss +24 -0
- data/app/assets/stylesheets/decidim/modules/_layout.scss +1 -9
- data/app/assets/stylesheets/decidim/modules/_list-docs.scss +1 -1
- data/app/assets/stylesheets/decidim/modules/_margins.scss +15 -0
- data/app/assets/stylesheets/decidim/modules/_modules.scss +56 -0
- data/app/assets/stylesheets/decidim/modules/_opinion-toggle.scss +25 -5
- data/app/assets/stylesheets/decidim/modules/_order-by.scss +1 -0
- data/app/assets/stylesheets/decidim/modules/_process-header.scss +2 -1
- data/app/assets/stylesheets/decidim/modules/_process-phase.scss +0 -4
- data/app/assets/stylesheets/decidim/modules/_status-labels.scss +7 -1
- data/app/assets/stylesheets/decidim/modules/_typography.scss +17 -0
- data/app/assets/stylesheets/decidim/utils/_fontface.scss +3 -3
- data/app/assets/stylesheets/decidim/utils/_settings.scss +10 -7
- data/app/commands/decidim/invite_user.rb +2 -2
- data/app/commands/decidim/update_account.rb +48 -0
- data/app/controllers/concerns/decidim/form_factory.rb +1 -1
- data/app/controllers/concerns/decidim/needs_authorization.rb +12 -1
- data/app/controllers/concerns/decidim/user_profile.rb +30 -0
- data/app/controllers/decidim/account_controller.rb +28 -10
- data/app/controllers/decidim/authorizations_controller.rb +21 -8
- data/app/controllers/decidim/devise/invitations_controller.rb +2 -0
- data/app/controllers/decidim/devise/sessions_controller.rb +1 -1
- data/app/controllers/decidim/own_user_groups_controller.rb +14 -0
- data/app/controllers/decidim/participatory_processes_controller.rb +1 -1
- data/app/forms/decidim/account_form.rb +41 -0
- data/app/helpers/decidim/aria_selected_link_to_helper.rb +26 -0
- data/app/helpers/decidim/attachments_helper.rb +15 -0
- data/app/helpers/decidim/filters_helper.rb +2 -3
- data/app/helpers/decidim/layout_helper.rb +29 -6
- data/app/helpers/decidim/resource_helper.rb +64 -0
- data/app/helpers/decidim/user_profile_helper.rb +23 -0
- data/app/mailers/decidim/decidim_devise_mailer.rb +1 -0
- data/app/models/decidim/abilities/everyone.rb +5 -1
- data/app/models/decidim/ability.rb +3 -4
- data/app/models/decidim/{participatory_process_attachment.rb → attachment.rb} +5 -5
- data/app/models/decidim/feature.rb +2 -0
- data/app/models/decidim/organization.rb +1 -0
- data/app/models/decidim/participatory_process.rb +2 -5
- data/app/models/decidim/resource_link.rb +28 -0
- data/app/models/decidim/user.rb +6 -0
- data/app/models/decidim/user_group.rb +10 -1
- data/app/services/decidim/resource_search.rb +1 -4
- data/app/types/decidim/session_type.rb +16 -0
- data/app/types/decidim/user_group_type.rb +20 -0
- data/app/types/decidim/user_type.rb +5 -1
- data/app/uploaders/decidim/attachment_uploader.rb +4 -1
- data/app/uploaders/decidim/avatar_uploader.rb +8 -0
- data/app/uploaders/decidim/banner_image_uploader.rb +1 -0
- data/app/uploaders/decidim/hero_image_uploader.rb +1 -0
- data/app/uploaders/decidim/homepage_image_uploader.rb +5 -1
- data/app/uploaders/decidim/image_uploader.rb +1 -1
- data/app/uploaders/decidim/organization_favicon_uploader.rb +17 -0
- data/app/uploaders/decidim/organization_logo_uploader.rb +2 -2
- data/app/validators/feature_validator.rb +23 -0
- data/app/views/decidim/account/_password_fields.html.erb +2 -0
- data/app/views/decidim/account/_user_groups.html.erb +0 -0
- data/app/views/decidim/account/show.html.erb +24 -29
- data/app/views/decidim/application/_attachments.html.erb +8 -0
- data/app/views/decidim/{participatory_processes → application}/_documents.html.erb +0 -0
- data/app/views/decidim/{participatory_processes → application}/_photos.html.erb +0 -0
- data/app/views/decidim/authorizations/first_login.html.erb +22 -0
- data/app/views/decidim/authorizations/index.html.erb +46 -19
- data/app/views/decidim/devise/omniauth_registrations/new.html.erb +1 -1
- data/app/views/decidim/devise/registrations/new.html.erb +1 -1
- data/app/views/decidim/own_user_groups/index.html.erb +24 -0
- data/app/views/decidim/participatory_process_steps/_participatory_process_step.html.erb +1 -1
- data/app/views/decidim/participatory_process_steps/index.html.erb +3 -1
- data/app/views/decidim/participatory_processes/_participatory_process.html.erb +2 -2
- data/app/views/decidim/participatory_processes/_promoted_process.html.erb +1 -1
- data/app/views/decidim/participatory_processes/index.html.erb +2 -0
- data/app/views/decidim/participatory_processes/show.html.erb +37 -8
- data/app/views/decidim/shared/_comments.html.erb +0 -0
- data/app/views/layouts/decidim/_application.html.erb +5 -3
- data/app/views/layouts/decidim/_header.html.erb +4 -4
- data/app/views/layouts/decidim/_logo.html.erb +29 -17
- data/app/views/layouts/decidim/_process_header.html.erb +15 -3
- data/app/views/layouts/decidim/_process_header_steps.html.erb +1 -1
- data/app/views/layouts/decidim/_user_menu.html.erb +3 -0
- data/app/views/layouts/decidim/mailer.html.erb +1 -1
- data/app/views/layouts/decidim/user_profile.html.erb +35 -0
- data/app/views/pages/home.html.erb +5 -139
- data/app/views/pages/home/_extended.html.erb +48 -0
- data/app/views/pages/home/_hero.html.erb +20 -0
- data/app/views/pages/home/_highlighted_processes.html.erb +37 -0
- data/app/views/pages/home/_statistics.html.erb +22 -0
- data/app/views/pages/home/_sub_hero.html.erb +11 -0
- data/config/i18n-tasks.yml +1 -0
- data/config/initializers/foundation_rails_helper.rb +2 -0
- data/config/locales/ca.yml +69 -33
- data/config/locales/en.yml +86 -29
- data/config/locales/es.yml +68 -32
- data/config/routes.rb +8 -3
- data/db/migrate/20161116115156_create_attachments.rb +0 -2
- data/db/migrate/20170113150627_create_resource_links.rb +10 -0
- data/db/migrate/20170123134023_make_attachments_polymorphic.rb +18 -0
- data/db/migrate/20170123140857_add_avatar_to_user_groups.rb +5 -0
- data/db/migrate/20170125135937_rename_attachable_to_attached_to.rb +11 -0
- data/db/migrate/20170125152026_add_weight_to_features.rb +5 -0
- data/db/migrate/20170126151123_add_extra_info_to_processes.rb +8 -0
- data/db/migrate/20170128140553_add_timestamps_to_identities.rb +5 -0
- data/db/migrate/20170130132833_add_favicon_to_decidim_organizations.rb +5 -0
- data/db/seeds.rb +38 -6
- data/lib/decidim/authorable.rb +32 -0
- data/lib/decidim/core.rb +37 -0
- data/lib/decidim/core/engine.rb +2 -3
- data/lib/decidim/core/test.rb +6 -0
- data/lib/decidim/core/test/factories.rb +24 -3
- data/lib/decidim/core/test/shared_examples/authorable.rb +31 -0
- data/lib/decidim/core/test/shared_examples/has_attachments.rb +29 -0
- data/lib/decidim/core/test/shared_examples/has_category.rb +10 -0
- data/lib/decidim/core/test/shared_examples/has_feature.rb +20 -0
- data/lib/decidim/core/test/shared_examples/has_scope.rb +10 -0
- data/lib/decidim/core/version.rb +1 -1
- data/lib/decidim/feature_manifest.rb +31 -1
- data/lib/decidim/features/base_controller.rb +10 -0
- data/lib/decidim/features/settings_manifest.rb +1 -0
- data/lib/decidim/has_attachment.rb +32 -0
- data/lib/decidim/has_attachments.rb +32 -0
- data/lib/decidim/has_category.rb +21 -0
- data/lib/decidim/has_feature.rb +20 -0
- data/lib/decidim/has_scope.rb +21 -0
- data/lib/decidim/query_extensions.rb +2 -2
- data/lib/decidim/resource_manifest.rb +80 -0
- data/lib/decidim/resourceable.rb +85 -0
- metadata +67 -40
- data/app/assets/javascripts/decidim/inline_svg.js.es6 +0 -12
- data/app/assets/stylesheets/decidim/application.sass +0 -12
- data/app/assets/stylesheets/decidim/extras/_turbolinks.scss +0 -3
- data/app/assets/stylesheets/decidim/modules/_popularity.scss +0 -74
- data/app/assets/stylesheets/decidim/utils/_variables.scss +0 -22
- data/app/views/decidim/account/_authorizations.html.erb +0 -52
- data/vendor/assets/javascripts/owl.carousel.min.js +0 -47
- data/vendor/assets/javascripts/svg-injector.js +0 -464
@@ -7,19 +7,22 @@ module Decidim
|
|
7
7
|
class AuthorizationsController < ApplicationController
|
8
8
|
helper_method :handler, :handlers
|
9
9
|
before_action :valid_handler, only: [:new, :create]
|
10
|
-
before_action :only_one_handler?, only: [:index]
|
11
10
|
|
12
|
-
|
13
|
-
|
14
|
-
|
11
|
+
include Decidim::UserProfile
|
12
|
+
|
13
|
+
layout "layouts/decidim/user_profile", only: [:index]
|
14
|
+
|
15
|
+
def new; end
|
15
16
|
|
16
17
|
def index
|
17
|
-
|
18
|
+
@authorizations = current_user.authorizations
|
18
19
|
end
|
19
20
|
|
20
|
-
def
|
21
|
-
|
21
|
+
def first_login
|
22
|
+
redirect_to(action: :new, handler: handlers.first.handler_name) if handlers.length == 1
|
23
|
+
end
|
22
24
|
|
25
|
+
def create
|
23
26
|
AuthorizeUser.call(handler) do
|
24
27
|
on(:ok) do
|
25
28
|
flash[:notice] = t("authorizations.create.success", scope: "decidim")
|
@@ -35,7 +38,7 @@ module Decidim
|
|
35
38
|
|
36
39
|
def destroy
|
37
40
|
@authorization = current_user.authorizations.find(params[:id])
|
38
|
-
authorize!
|
41
|
+
authorize! :destroy, @authorization
|
39
42
|
|
40
43
|
@authorization.destroy
|
41
44
|
flash[:notice] = t("authorizations.destroy.success", scope: "decidim")
|
@@ -72,5 +75,15 @@ module Decidim
|
|
72
75
|
def only_one_handler?
|
73
76
|
redirect_to(action: :new, handler: handlers.first.handler_name) && return if handlers.length == 1
|
74
77
|
end
|
78
|
+
|
79
|
+
def handlers
|
80
|
+
@handlers ||= available_authorization_handlers.reject do |handler|
|
81
|
+
authorized_handlers.include?(handler.handler_name)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def authorized_handlers
|
86
|
+
current_user.authorizations.map(&:name)
|
87
|
+
end
|
75
88
|
end
|
76
89
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require_dependency "decidim/application_controller"
|
3
|
+
|
4
|
+
module Decidim
|
5
|
+
# The controller to handle managing the current user's
|
6
|
+
# UserGroups.
|
7
|
+
class OwnUserGroupsController < ApplicationController
|
8
|
+
include Decidim::UserProfile
|
9
|
+
|
10
|
+
def index
|
11
|
+
@user_groups = current_user.user_groups
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -11,7 +11,7 @@ module Decidim
|
|
11
11
|
|
12
12
|
helper_method :participatory_processes, :promoted_processes
|
13
13
|
|
14
|
-
skip_after_action :verify_participatory_process
|
14
|
+
skip_after_action :verify_participatory_process, only: [:index]
|
15
15
|
|
16
16
|
def index
|
17
17
|
authorize! :read, ParticipatoryProcess
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
# The form object that handles the data behind updating a user's
|
5
|
+
# account in her profile page.
|
6
|
+
class AccountForm < Form
|
7
|
+
mimic :user
|
8
|
+
|
9
|
+
attribute :name
|
10
|
+
attribute :email
|
11
|
+
attribute :password
|
12
|
+
attribute :password_confirmation
|
13
|
+
attribute :avatar
|
14
|
+
attribute :remove_avatar
|
15
|
+
|
16
|
+
validates :name, presence: true
|
17
|
+
validates :email, presence: true
|
18
|
+
|
19
|
+
validates :password, confirmation: true
|
20
|
+
validates :password, length: { in: Decidim::User.password_length, allow_blank: true }
|
21
|
+
validates :password_confirmation, presence: true, if: :password_present
|
22
|
+
|
23
|
+
validate :unique_email
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def password_present
|
28
|
+
!password.blank?
|
29
|
+
end
|
30
|
+
|
31
|
+
def unique_email
|
32
|
+
return true if Decidim::User.where(
|
33
|
+
organization: context.current_organization,
|
34
|
+
email: email
|
35
|
+
).where.not(id: context.current_user.id).empty?
|
36
|
+
|
37
|
+
errors.add :email, :taken
|
38
|
+
false
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Decidim
|
3
|
+
# Module to add the attribute `aria-selected` to links when they are
|
4
|
+
# pointing to the current path. Uses the `active_link_to` gem to calculate
|
5
|
+
# this.
|
6
|
+
#
|
7
|
+
module AriaSelectedLinkToHelper
|
8
|
+
# Adds the `aria-selected` attribute to a link when it's pointing to the
|
9
|
+
# current path. The API is the same than the `link_to` one, and uses this
|
10
|
+
# helper internally.
|
11
|
+
#
|
12
|
+
# text - a String with the link text
|
13
|
+
# link - Where the link should point to. Accepts the same value than
|
14
|
+
# `link_to` helper.
|
15
|
+
# options - An options Hash that will be passed to `link_to`.
|
16
|
+
def aria_selected_link_to(text, link, options = {})
|
17
|
+
link_to(
|
18
|
+
text,
|
19
|
+
link,
|
20
|
+
options.merge(
|
21
|
+
"aria-selected": is_active_link?(link, options[:aria_link_type] || :inclusive)
|
22
|
+
)
|
23
|
+
)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Decidim
|
3
|
+
# A Helper to render and link to resources.
|
4
|
+
module AttachmentsHelper
|
5
|
+
# Renders a the attachments of a model that includes the
|
6
|
+
# HasAttachments concern.
|
7
|
+
#
|
8
|
+
# attached_to - The model to render the attachments from.
|
9
|
+
#
|
10
|
+
# Returns nothing.
|
11
|
+
def attachments_for(attached_to)
|
12
|
+
render partial: "attachments", locals: { attached_to: attached_to }
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -10,12 +10,11 @@ module Decidim
|
|
10
10
|
#
|
11
11
|
# Returns the filter resource form wrapped in a div
|
12
12
|
def filter_form_for(filter)
|
13
|
-
|
14
|
-
form_for filter, builder: FilterFormBuilder, url: url_for, as: :filter, method: :get, remote: true do |form|
|
13
|
+
content_tag :div, class: "filters" do
|
14
|
+
form_for filter, builder: FilterFormBuilder, url: url_for, as: :filter, method: :get, remote: true, html: { id: nil } do |form|
|
15
15
|
yield form
|
16
16
|
end
|
17
17
|
end
|
18
|
-
filters_container + javascript_include_tag("decidim/filters")
|
19
18
|
end
|
20
19
|
end
|
21
20
|
end
|
@@ -3,10 +3,22 @@ module Decidim
|
|
3
3
|
# View helpers related to the layout.
|
4
4
|
module LayoutHelper
|
5
5
|
def decidim_page_title
|
6
|
-
title = content_for(:
|
6
|
+
title = content_for(:meta_title)
|
7
7
|
title ? "#{title} - #{current_organization.name}" : current_organization.name
|
8
8
|
end
|
9
9
|
|
10
|
+
# Public: Generates a set of meta tags that generate the different favicon
|
11
|
+
# versions for an organization.
|
12
|
+
#
|
13
|
+
# Returns a safe String with the versions.
|
14
|
+
def favicon
|
15
|
+
return unless current_organization.favicon.present?
|
16
|
+
|
17
|
+
safe_join(Decidim::OrganizationFaviconUploader::SIZES.map do |version, size|
|
18
|
+
favicon_link_tag(current_organization.favicon.send(version).url, sizes: "#{size}x#{size}")
|
19
|
+
end)
|
20
|
+
end
|
21
|
+
|
10
22
|
# Outputs an SVG-based icon.
|
11
23
|
#
|
12
24
|
# name - The String with the icon name.
|
@@ -34,8 +46,7 @@ module Decidim
|
|
34
46
|
html_properties["role"] = options[:role]
|
35
47
|
html_properties["aria-hidden"] = options[:aria_hidden]
|
36
48
|
|
37
|
-
|
38
|
-
html_properties["class"] = "icon--#{name} #{icon_class} #{options[:class]}"
|
49
|
+
html_properties["class"] = (["icon--#{name}"] + _icon_classes(options)).join(" ")
|
39
50
|
|
40
51
|
content_tag :svg, html_properties do
|
41
52
|
content_tag :use, nil, "xlink:href" => "#{asset_url("decidim/icons.svg")}#icon-#{name}"
|
@@ -49,11 +60,23 @@ module Decidim
|
|
49
60
|
# path - The asset's path
|
50
61
|
#
|
51
62
|
# Returns an <img /> tag with the SVG icon.
|
52
|
-
def external_icon(path)
|
63
|
+
def external_icon(path, options = {})
|
53
64
|
# Ugly hack to prevent PhantomJS from freaking out with SVGs.
|
54
|
-
|
65
|
+
classes = _icon_classes(options) + ["external-icon"]
|
66
|
+
return content_tag(:span, "?", class: classes.join(" "), "data-src" => path) if Rails.env.test?
|
67
|
+
|
68
|
+
if path.split(".").last == "svg"
|
69
|
+
asset = Rails.application.assets_manifest.find_sources(path).first
|
70
|
+
asset.gsub("<svg ", "<svg class=\"#{classes.join(" ")}\" ").html_safe
|
71
|
+
else
|
72
|
+
image_tag(path, class: classes.join(" "), style: "display: none")
|
73
|
+
end
|
74
|
+
end
|
55
75
|
|
56
|
-
|
76
|
+
def _icon_classes(options = {})
|
77
|
+
classes = options[:remove_icon_class] ? [] : ["icon"]
|
78
|
+
classes += [options[:class]]
|
79
|
+
classes.compact
|
57
80
|
end
|
58
81
|
end
|
59
82
|
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Decidim
|
3
|
+
# A Helper to render and link to resources.
|
4
|
+
module ResourceHelper
|
5
|
+
# Builds the path to a resource. Useful when linking to a resource from
|
6
|
+
# another engine.
|
7
|
+
#
|
8
|
+
# resource - An object that is a valid resource exposed by some feature.
|
9
|
+
#
|
10
|
+
# Returns a String.
|
11
|
+
def decidim_resource_path(resource)
|
12
|
+
_decidim_resource_route(resource, "path")
|
13
|
+
end
|
14
|
+
|
15
|
+
# Builds the url to a resource. Useful when linking to a resource from
|
16
|
+
# another engine.
|
17
|
+
#
|
18
|
+
# resource - An object that is a valid resource exposed by some feature.
|
19
|
+
#
|
20
|
+
# Returns a String.
|
21
|
+
def decidim_resource_url(resource)
|
22
|
+
_decidim_resource_route(resource, "url")
|
23
|
+
end
|
24
|
+
|
25
|
+
# Renders a collection of linked resources for a resource.
|
26
|
+
#
|
27
|
+
# resource - The resource to get the links from.
|
28
|
+
# type - The String type fo the resources we want to render.
|
29
|
+
# link_name - The String name of the link between the resources.
|
30
|
+
#
|
31
|
+
# Example to render the proposals in a meeting view:
|
32
|
+
#
|
33
|
+
# linked_resources_for(:meeting, :proposals, "proposals_from_meeting")
|
34
|
+
#
|
35
|
+
# Returns nothing.
|
36
|
+
def linked_resources_for(resource, type, link_name)
|
37
|
+
linked_resources = resource.linked_resources(type, link_name).group_by { |linked_resource| linked_resource.class.name }
|
38
|
+
|
39
|
+
safe_join(linked_resources.map do |klass, resources|
|
40
|
+
resource_manifest = klass.constantize.resource_manifest
|
41
|
+
content_tag(:div, class: "section") do
|
42
|
+
content_tag(:h3, I18n.t(resource_manifest.name, scope: "decidim.resource_links.#{link_name}"), class: "section-heading") +
|
43
|
+
render(partial: resource_manifest.template, locals: { resources: resources })
|
44
|
+
end
|
45
|
+
end)
|
46
|
+
end
|
47
|
+
|
48
|
+
# Private: Build the route to a given resource.
|
49
|
+
#
|
50
|
+
# Returns a String.
|
51
|
+
def _decidim_resource_route(resource, route_type)
|
52
|
+
manifest = resource.class.resource_manifest
|
53
|
+
engine = send(manifest.mounted_engine_name)
|
54
|
+
|
55
|
+
url_params = {
|
56
|
+
id: resource.id,
|
57
|
+
feature_id: resource.feature.id,
|
58
|
+
participatory_process_id: resource.feature.participatory_process.id
|
59
|
+
}
|
60
|
+
|
61
|
+
engine.send("#{manifest.route_name}_#{route_type}", url_params)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Decidim
|
3
|
+
# Helpers used in controllers implementing the `Decidim::UserProfile` concern.
|
4
|
+
module UserProfileHelper
|
5
|
+
# Public: Shows a menu tab with a section. It highlights automatically bye
|
6
|
+
# detecting if the current path is a subset of the provided route.
|
7
|
+
#
|
8
|
+
# text - The text to show in the tab.
|
9
|
+
# link - The path to link to.
|
10
|
+
# options - Extra options.
|
11
|
+
# aria_link_type - :inclusive or :exact, depending on the type of
|
12
|
+
# highlighting desired.
|
13
|
+
#
|
14
|
+
# Returns a String with the menu tab.
|
15
|
+
def user_profile_tab(text, link, options = {})
|
16
|
+
active = is_active_link?(link, (options[:aria_link_type] || :inclusive))
|
17
|
+
|
18
|
+
content_tag(:li, class: "tabs-title#{active ? " is-active" : nil}") do
|
19
|
+
aria_selected_link_to(text, link, options)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -16,6 +16,7 @@ module Decidim
|
|
16
16
|
def invitation_instructions(user, token, opts = {})
|
17
17
|
with_user(user) do
|
18
18
|
@token = token
|
19
|
+
@organization = user.organization
|
19
20
|
|
20
21
|
if opts[:invitation_instructions]
|
21
22
|
opts[:subject] = I18n.t("devise.mailer.#{opts[:invitation_instructions]}.subject", organization: user.organization.name)
|
@@ -6,10 +6,14 @@ module Decidim
|
|
6
6
|
class Everyone
|
7
7
|
include CanCan::Ability
|
8
8
|
|
9
|
-
def initialize(
|
9
|
+
def initialize(user, _context)
|
10
10
|
can :read, ParticipatoryProcess, &:published?
|
11
11
|
can :read, :public_pages
|
12
12
|
can :manage, :locales
|
13
|
+
|
14
|
+
can :manage, User do |other|
|
15
|
+
other == user
|
16
|
+
end
|
13
17
|
end
|
14
18
|
end
|
15
19
|
end
|
@@ -17,16 +17,15 @@ module Decidim
|
|
17
17
|
# every time you change things in your ability classes.
|
18
18
|
#
|
19
19
|
# user - the User that needs its abilities checked.
|
20
|
-
|
20
|
+
# context - a Hash with some context related to the current request.
|
21
|
+
def initialize(user, context = {})
|
21
22
|
Decidim.abilities.each do |ability|
|
22
|
-
merge ability.new(user)
|
23
|
+
merge ability.constantize.new(user, context)
|
23
24
|
end
|
24
25
|
|
25
26
|
can :manage, Authorization do |authorization|
|
26
27
|
authorization.user == user
|
27
28
|
end
|
28
|
-
|
29
|
-
can :read, :user_account if user
|
30
29
|
end
|
31
30
|
end
|
32
31
|
end
|
@@ -2,11 +2,11 @@
|
|
2
2
|
module Decidim
|
3
3
|
# Attachment can be any type of document or images related to a partcipatory
|
4
4
|
# process.
|
5
|
-
class
|
6
|
-
belongs_to :
|
5
|
+
class Attachment < ApplicationRecord
|
6
|
+
belongs_to :attached_to, polymorphic: true
|
7
7
|
|
8
|
-
validates :file, :
|
9
|
-
validates :file, file_size: { less_than_or_equal_to:
|
8
|
+
validates :file, :attached_to, :content_type, presence: true
|
9
|
+
validates :file, file_size: { less_than_or_equal_to: ->(_attachment) { Decidim.maximum_attachment_size } }
|
10
10
|
mount_uploader :file, Decidim::AttachmentUploader
|
11
11
|
|
12
12
|
# Whether this attachment is a photo or not.
|
@@ -27,7 +27,7 @@ module Decidim
|
|
27
27
|
#
|
28
28
|
# Returns String.
|
29
29
|
def file_type
|
30
|
-
file.
|
30
|
+
file.url&.split(".")&.last&.downcase
|
31
31
|
end
|
32
32
|
|
33
33
|
# The URL to download the file.
|