generated from OpenSourcePolitics/decidim-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #52 from OpenSourcePolitics/develop
Release develop > master
- Loading branch information
Showing
33 changed files
with
5,432 additions
and
3,484 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
app/commands/concerns/decidim/extra_user_fields/create_registrations_commands_overrides.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
# frozen_string_literal: true | ||
|
||
require "active_support/concern" | ||
|
||
module Decidim | ||
module ExtraUserFields | ||
# Changes in methods to store extra fields in user profile | ||
module CreateRegistrationsCommandsOverrides | ||
extend ActiveSupport::Concern | ||
|
||
def call | ||
return broadcast(:invalid) if same_email_representative? | ||
|
||
if form.invalid? | ||
|
||
user = User.has_pending_invitations?(form.current_organization.id, form.email) | ||
user.invite!(user.invited_by) if user | ||
return broadcast(:invalid) | ||
end | ||
|
||
create_user | ||
send_email_to_statutory_representative | ||
|
||
broadcast(:ok, @user) | ||
rescue ActiveRecord::RecordInvalid | ||
broadcast(:invalid) | ||
end | ||
|
||
private | ||
|
||
def create_user | ||
@user = User.create!( | ||
email: form.email, | ||
name: form.name, | ||
nickname: form.nickname, | ||
password: form.password, | ||
password_confirmation: form.password_confirmation, | ||
password_updated_at: Time.current, | ||
organization: form.current_organization, | ||
tos_agreement: form.tos_agreement, | ||
newsletter_notifications_at: form.newsletter_at, | ||
accepted_tos_version: form.current_organization.tos_version, | ||
locale: form.current_locale, | ||
extended_data: extended_data | ||
) | ||
end | ||
|
||
def extended_data | ||
@extended_data ||= (@user&.extended_data || {}).merge( | ||
country: form.country, | ||
postal_code: form.postal_code, | ||
date_of_birth: form.date_of_birth, | ||
gender: form.gender, | ||
phone_number: form.phone_number, | ||
location: form.location, | ||
underage: form.underage, | ||
statutory_representative_email: form.statutory_representative_email | ||
) | ||
end | ||
|
||
def send_email_to_statutory_representative | ||
return if form.statutory_representative_email.blank? || !form.underage | ||
|
||
Decidim::ExtraUserFields::StatutoryRepresentativeMailer.inform(@user).deliver_now | ||
end | ||
|
||
def same_email_representative? | ||
return false if form.statutory_representative_email.blank? | ||
|
||
form.statutory_representative_email == form.email | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
<% | ||
add_decidim_meta_tags({ | ||
description: present(@proposal).body, | ||
title: present(@proposal).title, | ||
url: proposal_url(@proposal.id) | ||
}) | ||
%> | ||
<% | ||
edit_link( | ||
resource_locator(@proposal).edit, | ||
:edit, | ||
:proposal, | ||
proposal: @proposal | ||
) | ||
%> | ||
<% | ||
extra_admin_link( | ||
resource_locator(@proposal).show(anchor: "proposal-answer"), | ||
:create, | ||
:proposal_answer, | ||
{ proposal: @proposal }, | ||
{ name: t(".answer"), icon: "comment-square" } | ||
) | ||
%> | ||
<%= render partial: "voting_rules" %> | ||
<% if component_settings.participatory_texts_enabled? %> | ||
<div class="row column"> | ||
<div class="section text-medium"> | ||
<%= t(".back_to") %> <u><%= link_to translated_attribute(@participatory_text.title), main_component_path(current_component) %></u> | ||
</div> | ||
</div> | ||
<% end %> | ||
<%= emendation_announcement_for @proposal %> | ||
<div class="row column view-header"> | ||
|
||
<div class="m-bottom"> | ||
<%= link_to proposals_path, class: "small hollow js-back-to-list" do %> | ||
<%= icon "chevron-left", class: "icon--small", role: "img", "aria-hidden": true %> | ||
<%= t(".back_to_list") %> | ||
<% end %> | ||
</div> | ||
|
||
<% if @proposal.emendation? %> | ||
<h2 class="heading3"><%= t(".changes_at_title", title: present(@proposal.amendable).title(links: true, html_escape: true)) %></h2> | ||
<% else %> | ||
<h2 class="heading3"><%= present(@proposal).title(links: true, html_escape: true) %></h2> | ||
<% end %> | ||
<% unless component_settings.participatory_texts_enabled? %> | ||
<%= cell("decidim/coauthorships", @proposal, has_actions: true, size: 3, context: { current_user: current_user }) %> | ||
<% end %> | ||
</div> | ||
<div class="row"> | ||
<div class="columns mediumlarge-8 large-9"> | ||
<div class="section"> | ||
<% if @proposal.emendation? %> | ||
<%= cell("decidim/diff", proposal_presenter.versions.last) %> | ||
<% elsif not ["section","subsection"].include? @proposal.participatory_text_level %> | ||
<%== cell("decidim/proposals/proposal_m", @proposal, full_badge: true).badge %> | ||
<%= render_proposal_body(@proposal) %> | ||
<% end %> | ||
<% if component_settings.geocoding_enabled? %> | ||
<%= render partial: "decidim/shared/static_map", locals: { icon_name: "proposals", geolocalizable: @proposal } %> | ||
<% end %> | ||
<% if proposal_has_costs? && current_settings.answers_with_costs? %> | ||
<%= cell("decidim/proposals/cost_report", @proposal) %> | ||
<% end %> | ||
</div> | ||
|
||
<%= cell("decidim/announcement", proposal_reason_callout_announcement, callout_class: proposal_reason_callout_class) if @proposal.answered? && @proposal.published_state? %> | ||
<%= linked_resources_for @proposal, :results, "included_proposals" %> | ||
<%= linked_resources_for @proposal, :projects, "included_proposals" %> | ||
<%= linked_resources_for @proposal, :meetings, "proposals_from_meeting" %> | ||
<%= linked_resources_for @proposal, :proposals, "copied_from_component" %> | ||
<%= amendments_for @proposal %> | ||
</div> | ||
<div class="columns section view-side mediumlarge-4 large-3"> | ||
<% if @proposal.amendable? && allowed_to?(:edit, :proposal, proposal: @proposal) %> | ||
<%= link_to t(".edit_proposal"), edit_proposal_path(@proposal), class: "button hollow expanded button--sc" %> | ||
<% else %> | ||
<%= amend_button_for @proposal %> | ||
<% end %> | ||
<%= emendation_actions_for @proposal %> | ||
<% if current_settings.votes_enabled? || show_endorsements_card? || current_user %> | ||
<% if @proposal.withdrawn? %> | ||
<div class="card"> | ||
<div class="card__content"> | ||
<% if current_settings.votes_enabled? %> | ||
<%= render partial: "votes_count", locals: { proposal: @proposal, from_proposals_list: false } %> | ||
<% end %> | ||
</div> | ||
</div> | ||
<% else %> | ||
<div class="card"> | ||
<div class="card__content"> | ||
<% if current_settings.votes_enabled? %> | ||
<%= render partial: "votes_count", locals: { proposal: @proposal, from_proposals_list: false } %> | ||
<%= render partial: "vote_button", locals: { proposal: @proposal, from_proposals_list: false } %> | ||
<% end %> | ||
<div class="row collapse buttons__row"> | ||
<% if endorsements_enabled? %> | ||
<div class="column small-9 collapse"> | ||
<%= endorsement_buttons_cell(@proposal) %> | ||
</div> | ||
<% end %> | ||
<div class="column collapse <%= endorsements_enabled? ? "small-3" : "" %>"> | ||
<%= link_to "#comments", class: "button small compact hollow secondary button--nomargin expanded" do %> | ||
<span class="show-for-sr"><%= present(@proposal).title(html_escape: true) %></span> | ||
<%= icon "comment-square", class: "icon--small", aria_label: t(".comments"), role: "img" %> <%= @proposal.comments_count %> | ||
<% end %> | ||
</div> | ||
</div> | ||
<br> | ||
<%= follow_button_for(@proposal) %> | ||
</div> | ||
</div> | ||
<% end %> | ||
<% end %> | ||
<%= amenders_list_for(@proposal) %> | ||
<%= resource_reference(@proposal) %> | ||
<%= resource_version(proposal_presenter, versions_path: proposal_versions_path(@proposal)) %> | ||
<%= cell("decidim/fingerprint", @proposal) %> | ||
<%= render partial: "decidim/shared/share_modal", locals: { resource: @proposal } %> | ||
<%= embed_modal_for proposal_widget_url(@proposal, format: :js) %> | ||
<%= cell "decidim/proposals/proposal_link_to_collaborative_draft", @proposal %> | ||
<%= cell "decidim/proposals/proposal_link_to_rejected_emendation", @proposal %> | ||
</div> | ||
</div> | ||
<%= attachments_for @proposal %> | ||
<%= comments_for @proposal %> | ||
<%= cell("decidim/flag_modal", @proposal) %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.