From 98cd4301a6e8f95510e5ef76f8e89717a677e4ae Mon Sep 17 00:00:00 2001 From: Emanuel Schuetze Date: Wed, 30 Dec 2015 21:56:03 +0100 Subject: [PATCH] Generate example csv import files (Fixes #1761) - agenda csv file - motions csv file - users csv file --- openslides/agenda/static/js/agenda/site.js | 16 ++++++++++++++++ .../static/templates/agenda/item-import.html | 4 +--- openslides/motions/static/js/motions/site.js | 17 +++++++++++++++++ .../static/templates/motions/motion-import.html | 4 +--- openslides/users/static/js/users/site.js | 17 +++++++++++++++++ .../static/templates/users/user-import.html | 4 +--- 6 files changed, 53 insertions(+), 9 deletions(-) diff --git a/openslides/agenda/static/js/agenda/site.js b/openslides/agenda/static/js/agenda/site.js index 050756058..9452d97fc 100644 --- a/openslides/agenda/static/js/agenda/site.js +++ b/openslides/agenda/static/js/agenda/site.js @@ -342,6 +342,22 @@ angular.module('OpenSlidesApp.agenda.site', ['OpenSlidesApp.agenda']) $scope.clear = function () { $scope.csv.result = null; }; + // download CSV example file + $scope.downloadCSVExample = function () { + var element = document.getElementById('downloadLink'); + var csvRows = [ + // column header line + ['title', 'text'], + // example entries + ['Demo 1', 'Demo text 1'], + ['Demo 2', 'Demo text 2'] + + ]; + var csvString = csvRows.join("%0A"); + element.href = 'data:text/csv;charset=utf-8,' + csvString; + element.download = 'agenda-example.csv'; + element.target = '_blank'; + } } ]); diff --git a/openslides/agenda/static/templates/agenda/item-import.html b/openslides/agenda/static/templates/agenda/item-import.html index 2d08fa05c..4fba723ee 100644 --- a/openslides/agenda/static/templates/agenda/item-import.html +++ b/openslides/agenda/static/templates/agenda/item-import.html @@ -69,9 +69,7 @@ Keep each item in a single line.

'title, text'
  • Text is optional and may be empty.
  • Only double quotes are accepted as text delimiter (no single quotes). -
  • - Use the CSV example file from OpenSlides Wiki. - +
  • Download CSV example file
    diff --git a/openslides/motions/static/js/motions/site.js b/openslides/motions/static/js/motions/site.js index fa31363dd..08e14f313 100644 --- a/openslides/motions/static/js/motions/site.js +++ b/openslides/motions/static/js/motions/site.js @@ -720,6 +720,23 @@ angular.module('OpenSlidesApp.motions.site', ['OpenSlidesApp.motions']) $scope.clear = function () { $scope.csv.result = null; }; + // download CSV example file + $scope.downloadCSVExample = function () { + var element = document.getElementById('downloadLink'); + var csvRows = [ + // column header line + ['identifier', 'title', 'text', 'reason', 'submitter', 'category'], + // example entries + ['A1', 'title 1', 'text 1', 'reason 1', 'Submitter A', 'Category A'], + ['B1', 'title 2', 'text 2', 'reason 2', 'Submitter B', 'Category B'], + ['' , 'title 3', 'text 3', '', '', ''] + + ]; + var csvString = csvRows.join("%0A"); + element.href = 'data:text/csv;charset=utf-8,' + csvString; + element.download = 'motions-example.csv'; + element.target = '_blank'; + } } ]) diff --git a/openslides/motions/static/templates/motions/motion-import.html b/openslides/motions/static/templates/motions/motion-import.html index c6bc8c50e..14a8f5607 100644 --- a/openslides/motions/static/templates/motions/motion-import.html +++ b/openslides/motions/static/templates/motions/motion-import.html @@ -41,9 +41,7 @@ 'identifier, title, text, reason, submitter, category'
  • Identifier, reason, submitter and category are optional and may be empty.
  • Only double quotes are accepted as text delimiter (no single quotes). -
  • - Use the CSV example file from OpenSlides Wiki. - +
  • Download CSV example file
    diff --git a/openslides/users/static/js/users/site.js b/openslides/users/static/js/users/site.js index d54200919..c353f1c28 100644 --- a/openslides/users/static/js/users/site.js +++ b/openslides/users/static/js/users/site.js @@ -712,6 +712,23 @@ angular.module('OpenSlidesApp.users.site', ['OpenSlidesApp.users']) $scope.clear = function () { $scope.csv.result = null; }; + // download CSV example file + $scope.downloadCSVExample = function () { + var element = document.getElementById('downloadLink'); + var csvRows = [ + // column header line + ['title', 'first_name', 'last_name', 'structure_level', 'groups', 'comment', 'is_active'], + // example entries + ['Dr.', 'Max', 'Mustermann', 'Berlin', '"3,4"', 'xyz', '1'], + ['', 'John', 'Doe', 'Washington', '3', 'abc', '1'], + ['', 'Fred', 'Bloggs', 'London', '', '', ''], + + ]; + var csvString = csvRows.join("%0A"); + element.href = 'data:text/csv;charset=utf-8,' + csvString; + element.download = 'users-example.csv'; + element.target = '_blank'; + } } ]) diff --git a/openslides/users/static/templates/users/user-import.html b/openslides/users/static/templates/users/user-import.html index 575eaad0b..8e316453f 100644 --- a/openslides/users/static/templates/users/user-import.html +++ b/openslides/users/static/templates/users/user-import.html @@ -74,9 +74,7 @@
  • At least first name or last name have to be filled in. All other fields are optional and may be empty.
  • Only double quotes are accepted as text delimiter (no single quotes). -
  • - Use the CSV example file from OpenSlides Wiki. - +
  • Download CSV example file