diff --git a/app/assets/javascripts/projects/index.js b/app/assets/javascripts/projects/index.js index 78f226c91..15a6e8a2f 100644 --- a/app/assets/javascripts/projects/index.js +++ b/app/assets/javascripts/projects/index.js @@ -30,6 +30,7 @@ var exportProjectsModal = null; var exportProjectsModalHeader = null; var exportProjectsModalBody = null; + var exportProjectsBtn = null; var projectsViewMode = 'cards'; var projectsViewFilter = $('.projects-view-filter.active').data('filter'); @@ -218,11 +219,10 @@ * Initialize the JS for export projects modal to work. */ function initExportProjectsModal() { - var $exportProjectsBtn = $('#export-projects-button'); - $exportProjectsBtn.click(function() { + exportProjectsBtn.click(function() { // Load HTML to refresh users list $.ajax({ - url: $exportProjectsBtn.data('export-projects-url'), + url: exportProjectsBtn.data('export-projects-url'), type: 'POST', dataType: 'json', data: { @@ -339,6 +339,8 @@ exportProjectsModal = $('#export-projects-modal'); exportProjectsModalHeader = exportProjectsModal.find('.modal-title'); exportProjectsModalBody = exportProjectsModal.find('.modal-body'); + exportProjectsBtn = $('#export-projects-button'); + exportProjectsBtn.addClass('disabled'); updateSelectedCards(); initNewProjectModal(); @@ -361,10 +363,14 @@ if (this.checked && index === -1) { $(this).closest('.panel-project').addClass('selected'); selectedProjects.push(projectId); + exportProjectsBtn.removeClass('disabled'); // Otherwise, if checkbox is not checked and ID is in list of selected IDs } else if (!this.checked && index !== -1) { $(this).closest('.panel-project').removeClass('selected'); selectedProjects.splice(index, 1); + + if (selectedProjects.length == 0) + exportProjectsBtn.addClass('disabled'); } }); @@ -530,9 +536,13 @@ // If checkbox is checked and row ID is not in list of selected project IDs if (this.checked && index === -1) { selectedProjects.push(rowId); + exportProjectsBtn.removeClass('disabled'); // Otherwise, if checkbox is not checked and ID is in list of selected IDs } else if (!this.checked && index !== -1) { selectedProjects.splice(index, 1); + + if (selectedProjects.length == 0) + exportProjectsBtn.addClass('disabled'); } updateDataTableSelectAllCtrl(); diff --git a/app/models/team_zip_export.rb b/app/models/team_zip_export.rb index 35be60fe7..af5a89a69 100644 --- a/app/models/team_zip_export.rb +++ b/app/models/team_zip_export.rb @@ -7,11 +7,14 @@ require 'csv' class TeamZipExport < ZipExport include StringUtility - has_attached_file :zip_file, - path: '/zip_exports/:attachment/:id_partition/' \ - ':hash/:style/:filename' - validates_attachment :zip_file, - content_type: { content_type: 'application/zip' } + # Override path only for S3 + if ENV['PAPERCLIP_STORAGE'] == 's3' + has_attached_file :zip_file, + path: '/zip_exports/:attachment/:id_partition/' \ + ':hash/:style/:filename' + validates_attachment :zip_file, + content_type: { content_type: 'application/zip' } + end def generate_exportable_zip(user, data, type, options = {}) @user = user diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 63524da50..167dabb5a 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -37,6 +37,7 @@ describe User, type: :model do it { should have_db_column :invited_by_type } it { should have_db_column :invitations_count } it { should have_db_column :settings } + it { should have_db_column :variables } it { should have_db_column :current_team_id } it { should have_db_column :authentication_token } end @@ -179,6 +180,10 @@ describe User, type: :model do it { is_expected.to respond_to(:system_message_email_notification) } end + describe 'user variables' do + it { is_expected.to respond_to(:export_vars) } + end + describe '#last_activities' do let!(:user) { create :user } let!(:project) { create :project }