Skip to content

Commit

Permalink
Account privacy settings view
Browse files Browse the repository at this point in the history
  • Loading branch information
JoonasAapro committed May 20, 2024
1 parent 813ffae commit 82f8d8f
Show file tree
Hide file tree
Showing 19 changed files with 396 additions and 458 deletions.
92 changes: 0 additions & 92 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,94 +1,2 @@
inherit_gem:
decidim-dev: rubocop-decidim.yml

inherit_mode:
merge:
- Exclude

AllCops:
Exclude:
- "decidim-initiatives/lib/gem_overrides/origami/date.rb"

Naming/FileName:
Exclude:
- "decidim-dev/lib/decidim-dev.rb"

Metrics/CyclomaticComplexity:
Exclude:
- "decidim-admin/app/queries/decidim/admin/newsletter_recipients.rb"

Metrics/ParameterLists:
Exclude:
- "decidim-core/lib/decidim/filter_form_builder.rb"

Metrics/PerceivedComplexity:
Exclude:
- "decidim-admin/app/queries/decidim/admin/newsletter_recipients.rb"

RSpec/DescribeClass:
Exclude:
- decidim-core/spec/lib/global_engines_spec.rb

RSpec/EmptyExampleGroup:
Exclude:
- decidim-core/spec/lib/participatory_space_manifest_spec.rb

RSpec/MultipleMemoizedHelpers:
Exclude:
- decidim-assemblies/spec/forms/assembly_form_spec.rb

Rails/Output:
Exclude:
- lib/decidim/git_backport_manager.rb
- lib/decidim/github_manager/poster.rb
- decidim-core/lib/decidim/core.rb
- decidim-core/lib/decidim/component_manifest.rb
- decidim-core/lib/decidim/participatory_space_manifest.rb

Rails/Exit:
Exclude:
- lib/decidim/git_backport_manager.rb

RSpec/NoExpectationExample:
Exclude:
- decidim-admin/spec/system/participatory_space_private_user_spec.rb
- decidim-comments/spec/services/decidim/comments/comment_creation_spec.rb
- decidim-conferences/spec/cells/decidim/conferences/conference_speaker_cell_spec.rb
- decidim-core/spec/cells/decidim/date_range_cell_spec.rb
- decidim-core/spec/commands/decidim/unsubscribe_settings_spec.rb
- decidim-core/spec/controllers/registrations_controller_spec.rb
- decidim-core/spec/lib/importers/import_manifest_spec.rb
- decidim-core/spec/lib/map/geocoding_spec.rb
- decidim-core/spec/lib/participatory_space_manifest_spec.rb
- decidim-core/spec/services/decidim/events_manager_spec.rb
- decidim-core/spec/services/decidim/settings_change_spec.rb
- decidim-core/spec/services/decidim/zip_stream/zip_stream_writer_spec.rb
- decidim-core/spec/tasks/decidim_tasks_right_to_be_forgotten_spec.rb
- decidim-elections/spec/lib/tasks/decidim_election_generate_identification_keys_spec.rb
- decidim-elections/spec/lib/tasks/decidim_election_scheduled_tasks_spec.rb
- decidim-elections/spec/shared/vote_examples.rb
- decidim-elections/spec/system/key_ceremony_spec.rb
- decidim-elections/spec/system/vote_online_inside_a_voting_spec.rb
- decidim-initiatives/spec/system/admin/update_initiative_spec.rb
- decidim-initiatives/spec/system/initiative_signing_spec.rb
- decidim-meetings/spec/commands/admin/export_meeting_registrations_spec.rb
- decidim-meetings/spec/system/explore_meeting_directory_spec.rb
- decidim-meetings/spec/system/explore_meetings_spec.rb
- decidim-proposals/spec/lib/decidim/proposals/markdown_to_proposals_spec.rb
- decidim-proposals/spec/shared/import_proposals_examples.rb
- decidim-proposals/spec/shared/proposals_wizards_examples.rb
- decidim-proposals/spec/system/admin/admin_manages_participatory_texts_spec.rb
- decidim-proposals/spec/system/participatory_texts_spec.rb
- decidim-participatory_processes/spec/system/participatory_processes_spec.rb

# fix these rules later
Capybara/SpecificFinders:
Enabled: false

RSpec/IndexedLet:
Enabled: false

Rails/HelperInstanceVariable:
Enabled: false

# EOF fix these rules later

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,10 @@ module ApplicationControllerExtensions

def privacy_modal_snippets
return unless respond_to?(:snippets)
return if current_user && current_user.public?

snippets.add(:foot, helpers.javascript_pack_tag("decidim_account_publish_handler"))
return unless user_signed_in?

snippets.add(:foot, helpers.cell("decidim/privacy/publish_account_modal", current_user))
if current_user && !current_user.public? && user_signed_in?
snippets.add(:foot, helpers.cell("decidim/privacy/publish_account_modal", current_user))
end
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ module ProfilesControllerExtensions
before_action :add_nofollow_meta_tag

def show
return redirect_to profile_timeline_path(nickname: params[:nickname]) if profile_holder == current_user
return redirect_to profile_members_path if profile_holder.is_a?(Decidim::UserGroup)
raise ActionController::RoutingError, "Not Found" if profile_holder.published_at.nil?

Expand Down
10 changes: 0 additions & 10 deletions app/views/decidim/account/_old_password_field.html.erb

This file was deleted.

9 changes: 0 additions & 9 deletions app/views/decidim/account/_password_fields.html.erb

This file was deleted.

76 changes: 45 additions & 31 deletions app/views/decidim/account/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,26 +1,30 @@
<%= alert_box("", "account-notification hide", true) %>
<% add_decidim_page_title(t("profile", scope: "layouts.decidim.user_menu")) %>
<% content_for(:subtitle) { t("profile", scope: "layouts.decidim.user_menu") } %>

<div class="row">
<%= decidim_form_for(@account, url: account_path, method: :put, html: { autocomplete: "on" }) do |f| %>
<div class="columns large-4">
<%= f.upload :avatar %>
<%= render layout: "layouts/decidim/shared/layout_user_profile" do %>
<% if current_user.unconfirmed_email.present? %>
<%# NOTE: announcement cell clean_body method will purge the button %>
<div id="email-change-pending" class="flash warning" data-announcement>
<div class="flash__message flex-none block leading-relaxed">
<p>
<strong><%= t("decidim.account.email_change.title") %></strong>
</p>
<p>
<%= t("decidim.account.email_change.body1", unconfirmed_email: current_user.unconfirmed_email) %>
</p>
<p>
<%== t(
"decidim.account.email_change.body2",
resend_link: link_to(t("decidim.account.email_change.send_again"), resend_confirmation_instructions_account_path, role: :button, method: :post, remote: true),
cancel_link: link_to(t("decidim.account.email_change.cancel"), cancel_email_change_account_path, role: :button, method: :post, remote: true)) %>
</p>
</div>
</div>
<% end %>

<div class="columns large-8 end">
<% if current_user.unconfirmed_email.present? %>
<div id="email-change-pending" class="callout secondary">
<p><strong><%= t("decidim.account.email_change.title") %></strong></p>
<p><%= t("decidim.account.email_change.body1", unconfirmed_email: current_user.unconfirmed_email) %></p>
<p>
<%== t(
"decidim.account.email_change.body2",
resend_link: link_to(t("decidim.account.email_change.send_again"), resend_confirmation_instructions_account_path, role: :button, method: :post, remote: true),
cancel_link: link_to(t("decidim.account.email_change.cancel"), cancel_email_change_account_path, role: :button, method: :post, remote: true)) %>
</p>
</div>
<% end %>
<%= decidim_form_for(@account, url: account_path, method: :put, html: { autocomplete: "on", class: "form-defaults edit_user" }) do |f| %>
<div class="form__wrapper pt-0">
<%= f.upload :avatar, button_class: "button button__lg button__transparent-secondary w-full" %>

<%= form_required_explanation %>

Expand All @@ -34,27 +38,37 @@
:locale,
@account.organization.available_locales,
:to_s,
->(locale) {locale_name(locale) }
->(locale) { locale_name(locale) },
help_text: t("available_locales_helper", scope:"decidim.account.show")
) %>
<p class="help-text"><%= t(".available_locales_helper") %></p>

<% if @account.errors[:password].any? || @account.errors[:password_confirmation].any? || @account.errors[:old_password].any?%>
<% if @account.password.present? %>
<%= render partial: "password_fields", locals: { form: f, user: current_user } %>
<%= render partial: "old_password_field", locals: { form: f, show_help_text: true, unhide: false } %>
<% else %>
<% if current_organization.sign_in_enabled? %>
<p>
<button type="button" data-toggle="passwordChange" class="link change-password"><%= t ".change_password" %></button>
</p>
<div id="passwordChange" class="toggle-show" data-toggler=".is-expanded">
<%= render partial: "old_password_field", locals: { form: f, show_help_text: true } %>
<% elsif current_organization.sign_in_enabled? %>
<div data-component="accordion" id="accordion-password">
<%= button_tag(
class: "text-lg font-semibold text-secondary underline block cursor-pointer",
id: "accordion-trigger-panel-password",
type: "button",
data: { controls: "panel-password" }
) do %>
<%= t("change_password", scope:"decidim.account.show") %>
<% end %>
<div id="panel-password" class="mt-6">
<%= render partial: "password_fields", locals: { form: f, user: current_user } %>
</div>
</div>

<%= content_tag :div, id: "panel-old-password", class: @account.errors[:old_password].any? ? nil : "hidden" do %>
<%= render partial: "old_password_field", locals: { form: f, show_help_text: true } %>
<% end %>
<% end %>

<%= f.submit t(".update_account") %>
<div class="form__wrapper-block flex-col-reverse md:flex-row justify-between">
<%= f.submit t("update_account", scope:"decidim.account.show"), class: "button button__sm md:button__lg button__secondary mr-auto !ml-0" %>
</div>
</div>
<% end %>
</div>
<% end %>

<%= append_javascript_pack_tag("decidim_privacy_user_form")%>
Loading

0 comments on commit 82f8d8f

Please sign in to comment.