Skip to content

Commit

Permalink
Rename data portability to download your data (decidim#9196)
Browse files Browse the repository at this point in the history
  • Loading branch information
Eero Lahdenperä authored May 4, 2022
1 parent 2fe472a commit 45c74ca
Show file tree
Hide file tree
Showing 92 changed files with 240 additions and 228 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,18 @@ PR [\#8645](https://github.com/decidim/decidim/pull/8645) we now only allow PNG

### Changed

### Rename data portability to download your data

"Data portability" has been renamed to "Download you data" at [\#9196](https://github.com/decidim/decidim/pull/9196), you should update your cron job via crontab -e.
```
0 0 * * * cd /home/user/decidim_application && RAILS_ENV=production bundle exec rake decidim:delete_data_portability_files
```
Changes to:
```
0 0 * * * cd /home/user/decidim_application && RAILS_ENV=production bundle exec rake decidim:delete_download_your_data_files
```


- **decidim-core**: The `Decidim::ActivitySearch` class has been rewritten as `Decidim::PublicActivities` which is now a `Rectify::Query` class instead of `Searchlight::Search` class due to the removal of Searchlight at [\#8748](https://github.com/decidim/decidim/pull/8748).
- **decidim-core**: The `Decidim::ResourceSearch` class now inherits from `Ransack::Search` instead of `Searchlight::Search` as of [\#8748](https://github.com/decidim/decidim/pull/8748). The new `ResourceSearch` class provides extra search functionality for contextual searches that require context information in addition to the search parameters, such as current user or current component. It has barely anything to do with the `ResourceSearch` class in the previous versions which contained much more logic. Please review all your search classes that were inheriting from this class. You should migrate your search filtering to Ransack.
- **decidim-debates**, **decidim-initiatives**, **decidim-meetings**: The resource search classes `Decidim::Debates::DebateSearch`, `Decidim::Intitatives::InitiativeSearch` and `Decidim::Meetings::MeetingSearch` are rewritten for the Ransack searches due to Searchlight removal at [\#8748](https://github.com/decidim/decidim/pull/8748). The role of these classes is now to pass contextual information to the searches, such as the current user. All other search filtering should happen directly through Ransack.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Result < Accountability::ApplicationRecord
include Decidim::Comments::CommentableWithComponent
include Decidim::Traceable
include Decidim::Loggable
include Decidim::DataPortability
include Decidim::DownloadYourData
include Decidim::Randomable
include Decidim::Searchable
include Decidim::TranslatableResource
Expand Down
4 changes: 2 additions & 2 deletions decidim-budgets/app/models/decidim/budgets/order.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module Budgets
# The data store for a Order in the Decidim::Budgets component. It is unique for each
# user and component and contains a collection of projects
class Order < Budgets::ApplicationRecord
include Decidim::DataPortability
include Decidim::DownloadYourData
include Decidim::NewsletterParticipant

belongs_to :user, class_name: "Decidim::User", foreign_key: "decidim_user_id"
Expand Down Expand Up @@ -171,7 +171,7 @@ def self.user_collection(user)
end

def self.export_serializer
Decidim::Budgets::DataPortabilityBudgetsOrderSerializer
Decidim::Budgets::DownloadYourDataBudgetsOrderSerializer
end

def self.newsletter_participant_ids(component)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

module Decidim
module Budgets
class DataPortabilityBudgetsOrderSerializer < Decidim::Exporters::Serializer
class DownloadYourDataBudgetsOrderSerializer < Decidim::Exporters::Serializer
# Public: Initializes the serializer with a conversation.
def initialize(order)
@order = order
end

# Serializes a Debate for data portability
# Serializes a Debate for download your data
def serialize
{
id: order.id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require "spec_helper"

module Decidim::Budgets
describe DataPortabilityBudgetsOrderSerializer do
describe DownloadYourDataBudgetsOrderSerializer do
let(:resource) { create(:order) }
let!(:projects) { create_list(:project, 2, budget: resource.budget, budget_amount: 25_000_000) }

Expand Down
2 changes: 1 addition & 1 deletion decidim-comments/app/models/decidim/comments/comment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Comment < ApplicationRecord
include Decidim::Authorable
include Decidim::Comments::Commentable
include Decidim::FriendlyDates
include Decidim::DataPortability
include Decidim::DownloadYourData
include Decidim::Traceable
include Decidim::Loggable
include Decidim::Searchable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module Comments
# A comment can include user votes. A user should be able to upVote, votes with
# weight 1 and downVote, votes with weight -1.
class CommentVote < ApplicationRecord
include Decidim::DataPortability
include Decidim::DownloadYourData

belongs_to :comment, foreign_key: "decidim_comment_id", class_name: "Comment"
belongs_to :author, foreign_key: "decidim_author_id", foreign_type: "decidim_author_type", polymorphic: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def serialize

def root_commentable_url
@root_commentable_url ||= if resource.root_commentable&.respond_to?(:polymorphic_resource_url)
resource.root_commentable.polymorphic_resource_url
resource.root_commentable.polymorphic_resource_url({})
else
ResourceLocatorPresenter.new(resource.root_commentable).url
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module Conferences
class ConferenceInvite < ApplicationRecord
include Decidim::Traceable
include Decidim::Loggable
include Decidim::DataPortability
include Decidim::DownloadYourData

belongs_to :conference, foreign_key: "decidim_conference_id", class_name: "Decidim::Conference"
belongs_to :user, foreign_key: "decidim_user_id", class_name: "Decidim::User"
Expand All @@ -15,7 +15,7 @@ class ConferenceInvite < ApplicationRecord
validates :user, uniqueness: { scope: :conference }

def self.export_serializer
Decidim::Conferences::DataPortabilityConferenceInviteSerializer
Decidim::Conferences::DownloadYourDataConferenceInviteSerializer
end

def self.log_presenter_class_for(_log)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module Decidim
module Conferences
# The data store for a Registration in the Decidim::Conferences component.
class ConferenceRegistration < ApplicationRecord
include Decidim::DataPortability
include Decidim::DownloadYourData

belongs_to :conference, foreign_key: "decidim_conference_id", class_name: "Decidim::Conference"
belongs_to :user, foreign_key: "decidim_user_id", class_name: "Decidim::User"
Expand All @@ -19,7 +19,7 @@ def self.user_collection(user)
end

def self.export_serializer
Decidim::Conferences::DataPortabilityConferenceRegistrationSerializer
Decidim::Conferences::DownloadYourDataConferenceRegistrationSerializer
end

def confirmed?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

module Decidim
module Conferences
class DataPortabilityConferenceInviteSerializer < Decidim::Exporters::Serializer
# Serializes a conference invite for data portability
class DownloadYourDataConferenceInviteSerializer < Decidim::Exporters::Serializer
# Serializes a conference invite for download your data
def serialize
{
id: resource.id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

module Decidim
module Conferences
class DataPortabilityConferenceRegistrationSerializer < Decidim::Exporters::Serializer
# Serializes a registration for data portability
class DownloadYourDataConferenceRegistrationSerializer < Decidim::Exporters::Serializer
# Serializes a registration for download your data
def serialize
{
id: resource.id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require "spec_helper"

module Decidim::Conferences
describe DataPortabilityConferenceInviteSerializer do
describe DownloadYourDataConferenceInviteSerializer do
let(:resource) { build_stubbed(:conference_invite) }
let(:subject) { described_class.new(resource) }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require "spec_helper"

module Decidim::Conferences
describe DataPortabilityConferenceRegistrationSerializer do
describe DownloadYourDataConferenceRegistrationSerializer do
let(:resource) { create(:conference_registration) }
let(:subject) { described_class.new(resource) }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

<div class="row">
<p>
<%= t("refuse.modal_body", scope: "decidim.pages.terms_and_conditions", data_portability_path: decidim.data_portability_path, delete_path: decidim.delete_account_path) %>
<%= t("refuse.modal_body", scope: "decidim.pages.terms_and_conditions", download_your_data_path: decidim.download_your_data_path, delete_path: decidim.delete_account_path) %>
</p>
</div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ def permitted_paths?
permitted_paths = [tos_path,
decidim.delete_account_path,
decidim.accept_tos_path,
decidim.data_portability_path,
decidim.export_data_portability_path,
decidim.download_file_data_portability_path]
decidim.download_your_data_path,
decidim.export_download_your_data_path,
decidim.download_file_download_your_data_path]
# ensure that path with or without query string pass
permitted_paths.find { |el| el.split("?").first == request.path }
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

module Decidim
# The controller to handle the user's download_my_data page.
class DataPortabilityController < Decidim::ApplicationController
class DownloadYourDataController < Decidim::ApplicationController
include Decidim::UserProfile

def show
Expand All @@ -16,20 +16,20 @@ def show
def export
enforce_permission_to :export, :user, current_user: current_user

DataPortabilityExportJob.perform_later(current_user)
DownloadYourDataExportJob.perform_later(current_user)

flash[:notice] = t("decidim.account.data_portability_export.notice")
redirect_back(fallback_location: data_portability_path)
flash[:notice] = t("decidim.account.download_your_data_export.notice")
redirect_back(fallback_location: download_your_data_path)
end

def download_file
enforce_permission_to :download, :user, current_user: current_user

if current_user.data_portability_file.attached?
redirect_to Rails.application.routes.url_helpers.rails_blob_url(current_user.data_portability_file.blob, only_path: true)
if current_user.download_your_data_file.attached?
redirect_to Rails.application.routes.url_helpers.rails_blob_url(current_user.download_your_data_file.blob, only_path: true)
else
flash[:error] = t("decidim.account.data_portability_export.file_no_exists")
redirect_to data_portability_path
flash[:error] = t("decidim.account.download_your_data_export.file_no_exists")
redirect_to download_your_data_path
end
end
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
# frozen_string_literal: true

module Decidim
class DataPortabilityExportJob < ApplicationJob
class DownloadYourDataExportJob < ApplicationJob
queue_as :default

def perform(user, export_format = ::Decidim::DataPortabilityExporter::DEFAULT_EXPORT_FORMAT)
def perform(user, export_format = ::Decidim::DownloadYourDataExporter::DEFAULT_EXPORT_FORMAT)
filename = "#{SecureRandom.urlsafe_base64}.zip"
path = Rails.root.join("tmp/#{filename}")
password = SecureRandom.urlsafe_base64

generate_zip_file(user, path, password, export_format)
save_or_upload_file(user, path)

ExportMailer.data_portability_export(user, filename, password).deliver_later
ExportMailer.download_your_data_export(user, filename, password).deliver_later
end

private

def generate_zip_file(user, path, password, export_format)
DataPortabilityExporter.new(user, path, password, export_format).export
DownloadYourDataExporter.new(user, path, password, export_format).export
end

def save_or_upload_file(user, path)
user.data_portability_file.attach(io: File.open(path, "rb"), filename: File.basename(path))
user.download_your_data_file.attach(io: File.open(path, "rb"), filename: File.basename(path))
end
end
end
4 changes: 2 additions & 2 deletions decidim-core/app/mailers/decidim/export_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ def export(user, export_name, export_data)
end

# Public: Sends a notification email with a link to retrieve
# the result of a data_portability export in a zipped file.
# the result of a download_your_data export in a zipped file.
#
# user - The user to be notified.
#
# Returns nothing.
def data_portability_export(user, filename, password)
def download_your_data_export(user, filename, password)
@user = user
@organization = user.organization
@filename = filename
Expand Down
4 changes: 2 additions & 2 deletions decidim-core/app/models/decidim/follow.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module Decidim
class Follow < ApplicationRecord
include Decidim::DataPortability
include Decidim::DownloadYourData

belongs_to :followable, foreign_key: "decidim_followable_id", foreign_type: "decidim_followable_type", polymorphic: true, counter_cache: true
belongs_to :user, foreign_key: "decidim_user_id", class_name: "Decidim::User"
Expand All @@ -20,7 +20,7 @@ def self.user_collection(user)
end

def self.export_serializer
Decidim::DataPortabilitySerializers::DataPortabilityFollowSerializer
Decidim::DownloadYourDataSerializers::DownloadYourDataFollowSerializer
end

def self.user_follower_ids_for_participatory_spaces(spaces)
Expand Down
4 changes: 2 additions & 2 deletions decidim-core/app/models/decidim/identity.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Decidim
# Store user's social identities
class Identity < ApplicationRecord
include Decidim::DataPortability
include Decidim::DownloadYourData

belongs_to :user, foreign_key: :decidim_user_id, class_name: "Decidim::User"
belongs_to :organization, foreign_key: :decidim_organization_id, class_name: "Decidim::Organization"
Expand All @@ -18,7 +18,7 @@ def self.user_collection(user)
end

def self.export_serializer
Decidim::DataPortabilitySerializers::DataPortabilityIdentitySerializer
Decidim::DownloadYourDataSerializers::DownloadYourDataIdentitySerializer
end

private
Expand Down
4 changes: 2 additions & 2 deletions decidim-core/app/models/decidim/messaging/conversation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module Messaging
class Conversation < ApplicationRecord
self.table_name = "decidim_messaging_conversations"

include Decidim::DataPortability
include Decidim::DownloadYourData

has_many :participations, foreign_key: :decidim_conversation_id,
class_name: "Decidim::Messaging::Participation",
Expand Down Expand Up @@ -173,7 +173,7 @@ def self.user_collection(user)
end

def self.export_serializer
Decidim::DataPortabilitySerializers::DataPortabilityConversationSerializer
Decidim::DownloadYourDataSerializers::DownloadYourDataConversationSerializer
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions decidim-core/app/models/decidim/notification.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module Decidim
class Notification < ApplicationRecord
include Decidim::DataPortability
include Decidim::DownloadYourData

belongs_to :resource, foreign_key: "decidim_resource_id", foreign_type: "decidim_resource_type", polymorphic: true
belongs_to :user, foreign_key: "decidim_user_id", class_name: "Decidim::User"
Expand All @@ -26,7 +26,7 @@ def self.user_collection(user)
end

def self.export_serializer
Decidim::DataPortabilitySerializers::DataPortabilityNotificationSerializer
Decidim::DownloadYourDataSerializers::DownloadYourDataNotificationSerializer
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Decidim
# This class gives a given User access to a given private ParticipatorySpacePrivateUser
class ParticipatorySpacePrivateUser < ApplicationRecord
include Decidim::DataPortability
include Decidim::DownloadYourData

belongs_to :user, class_name: "Decidim::User", foreign_key: :decidim_user_id
belongs_to :privatable_to, polymorphic: true
Expand All @@ -17,7 +17,7 @@ def self.user_collection(user)
end

def self.export_serializer
Decidim::DataPortabilitySerializers::DataPortabilityParticipatorySpacePrivateUserSerializer
Decidim::DownloadYourDataSerializers::DownloadYourDataParticipatorySpacePrivateUserSerializer
end

def self.log_presenter_class_for(_log)
Expand Down
4 changes: 2 additions & 2 deletions decidim-core/app/models/decidim/report.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Decidim
# A reportable can be reported one time for each user.
class Report < ApplicationRecord
include Decidim::DataPortability
include Decidim::DownloadYourData

REASONS = %w(spam offensive does_not_belong).freeze

Expand All @@ -20,7 +20,7 @@ def self.user_collection(user)
end

def self.export_serializer
Decidim::DataPortabilitySerializers::DataPortabilityReportSerializer
Decidim::DownloadYourDataSerializers::DownloadYourDataReportSerializer
end

private
Expand Down
Loading

0 comments on commit 45c74ca

Please sign in to comment.