decidim-elections 0.28.1 → 0.28.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 14abed66a6404a8b45709150cb399c942d45aa91e67c2142a562cbe62f77e4ff
4
- data.tar.gz: 06b0ad232cfdbfaafe6753c97735bd1f1584c5b0dc7a289dddc88849b575c6bb
3
+ metadata.gz: c2a9ebfe2cd9d6b54273994020cfecf7f9eb24e2a3be2198b116eec548451655
4
+ data.tar.gz: f5663bc3c6473caa335d4f99c028e84eda1ed2ef819eac72ae6f30ae46ca9eaa
5
5
  SHA512:
6
- metadata.gz: 361878a51aa94cce6d7548ab5079c47d72e9efb7a02f2ce5033788d69523418768627c8104630ef3583ba1bb0fdad89c2688b284cbdf541046f28d6d8258c1d5
7
- data.tar.gz: 26cceea1a3ce9f80ebbb5912b901a7139ec34f55797cf5d826a18332b2d3c456d176b79fbf152084a5e65e9e2b01d74ef51d8b39ab46ddd8c0dd12388413eeae
6
+ metadata.gz: 1793f8447b4c2ddbedd782f39f7d52046fe6f4677cf34405f9cb4248126582fcb081c8adeb681fc2e91ffdcff27bdc51c1dd4e17d1d6d8735f108157d80cc327
7
+ data.tar.gz: 4b7c05ae8c79ba24769d3f0a67f561605b6f40e300491779fc7bb2874fc864f8c0c7d7b5dfbd9f8f6b5cb0ac5144aff77848f28e71fd6c0f38ce58d6c91b69c4
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "seven_zip_ruby"
4
- require "zip"
3
+ require "decidim/seven_zip_wrapper"
5
4
 
6
5
  module Decidim
7
6
  module Votings
@@ -29,18 +28,21 @@ module Decidim
29
28
  end
30
29
 
31
30
  def export
32
- dirname = File.dirname(@path)
33
- FileUtils.mkdir_p(dirname) unless File.directory?(dirname)
34
- File.open(@path, "wb") do |file|
35
- SevenZipRuby::Writer.open(file, password:) do |szw|
36
- szw.header_encryption = true
37
- szw.add_data(csv_data.read, format(FILE_NAME_PATTERN, voting_name: translated_attribute(dataset.voting.title).parameterize))
38
- end
39
- end
31
+ tmpdir = Dir.mktmpdir("votings-access-code-exporter")
32
+ save_voting_access_code_data(tmpdir)
33
+ SevenZipWrapper.compress_and_encrypt(filename: @path, password: @password, input_directory: tmpdir)
40
34
  end
41
35
 
42
36
  private
43
37
 
38
+ def save_voting_access_code_data(tmpdir)
39
+ file_name = File.join(
40
+ tmpdir,
41
+ format(FILE_NAME_PATTERN, voting_name: translated_attribute(dataset.voting.title).parameterize)
42
+ )
43
+ File.write(file_name, csv_data.read)
44
+ end
45
+
44
46
  def csv_data
45
47
  Decidim::Exporters::CSV.new(dataset.data, Decidim::Votings::Census::DatumSerializer).export
46
48
  end