Skip to content

Commit

Permalink
pentabarf import updated
Browse files Browse the repository at this point in the history
* more documentation on importing from pentabarf
* improved event rating import speed
* carefully import long links
* fix user role import
* redirect deleted users
* respect conference timezone on event import
* sorted Gemfile
  • Loading branch information
manno committed Jan 14, 2013
1 parent 99f6b50 commit d16f927
Show file tree
Hide file tree
Showing 4 changed files with 148 additions and 70 deletions.
40 changes: 20 additions & 20 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,34 @@ ruby "1.9.3"

gem 'rails', '3.2.11'

gem 'sqlite3'
gem 'pg'
gem 'mysql2'
gem 'pg'
gem 'sqlite3'

gem 'acts_as_commentable'
gem 'acts_as_indexed'
gem 'barista'
gem 'bcrypt-ruby'
gem 'cancan'
gem 'haml'
gem 'acts_as_commentable'
gem 'will_paginate'
gem 'paperclip', '< 3.0'
gem 'gravatar-ultimate'
gem 'cocoon'
gem 'formtastic', '~> 2.1.0'
gem 'formtastic-bootstrap', :git => "git://github.com/katastrophie/formtastic-bootstrap.git"
gem 'gravatar-ultimate'
gem 'haml'
gem 'jquery-rails', '~> 1.0.19'
gem 'acts_as_indexed'
gem 'cocoon'
gem 'paper_trail', '2.3.3'
gem 'json'
gem 'localized_language_select', '0.2.0', :git => "git://github.com/oneiros/localized_language_select.git"
gem 'nokogiri'
gem 'paperclip', '< 3.0'
gem 'paper_trail', '2.3.3'
gem 'prawn'
gem 'prawn_rails'
gem 'ransack'
gem 'transitions', :require => ["transitions", "active_record/transitions"]
gem 'json'
gem 'barista'
gem 'ri_cal'
gem 'nokogiri'
gem 'settingslogic'
gem 'transitions', :require => ["transitions", "active_record/transitions"]
gem 'twitter-bootstrap-rails', :git => "git://github.com/seyhunak/twitter-bootstrap-rails.git", :ref => "5e62b21c8f258010af7f5bc858b89a24f16936a9"
gem 'formtastic-bootstrap', :git => "git://github.com/katastrophie/formtastic-bootstrap.git"
gem 'prawn'
gem 'prawn_rails'
gem 'will_paginate'

group :development, :test do
gem 'bullet'
Expand All @@ -40,19 +40,19 @@ group :development, :test do
end

group :test do
gem 'minitest'
gem 'factory_girl_rails', '~> 1.2.0'
gem 'minitest'
gem 'turn', :require => false
end

group :development do
gem 'hpricot'
gem 'yaml_db'
gem 'shotgun'
gem 'yaml_db'
end

group :assets do
gem 'sass-rails', " ~> 3.2.0"
gem 'coffee-rails', " ~> 3.2.0"
gem 'sass-rails', " ~> 3.2.0"
gem 'uglifier'
end
37 changes: 31 additions & 6 deletions README.pentabarf.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ These notes may help to import data from a pentabarf postgresql database.
Using postgresql as a database for frab is still somewhat untested. The pentabarf
import is however likely to fail, as pentabarf uses text fields instead of char(255)

Imagemagick needs to be installed as we will convert pjpeg and tiff to png.

## postgresql installation

install postgresql
Install postgresql

## postgresql setup

* Make it listen on localhost
* make it listen on localhost
* create a psql user and grant some access on relations
* add a pentabarf entry for the postgresql database to your rails db environment

Expand All @@ -27,26 +29,49 @@ Make a copy of your postgresql database, as we need to do some changes

Grant all permissions on the database copy to the import user account:

psql cccv
select 'grant all on '||schemaname||'.'||tablename||' to bar;' from pg_tables
psql NEWNAME
-- generate the grant statements
select 'grant all on '||schemaname||'.'||tablename||' to frab;' from pg_tables
order by schemaname, tablename;
-- copy&paste the generated statements into psql

-- in case you re-created the NEWNAME copy, re-grant permissions to the user
REVOKE ALL ON SCHEMA public FROM frab;
GRANT ALL ON SCHEMA public TO frab;
REVOKE ALL ON SCHEMA auth FROM frab;
GRANT ALL ON SCHEMA auth TO frab;

## data migration

I had to delete some images, too.
Conference acronyms need to be within /^[a-zA-Z0-9_-]*$/
Whitespaces are removed automatically, but you need to replace unicode characters manually.

-- conference acronyms appear in URLs, they may not contain whitespace in frab:
UPDATE conference SET acronym = replace(acronym, ' ', '');
UPDATE conference SET acronym = 'mrmcdX' where conference_id=86; -- mrmcdⅩ

## import


Delete any old mappings from previous imports. Maybe delete the old filess, too.

rm tmp/*mappings.yml
rm -fr public/system
RAILS_ENV=production rake db:reset
RAILS_ENV=production rake pentabarf:import:all

## testing

You can check on the barf data like this:

RAILS_ENV="development" rails console
@p = PentabarfImportHelper.new
@barf = @p.instance_variable_get('@barf')
@barf.select_all("SELECT * FROM conference")

## privileges

You maybe want to drop all users to the coordinator role, to start fresh.

User.all.select { |u| u.role == "admin" or u.role == "orga" }.each { |u| puts "dropping ${u.email}"; u.role = "coordinator"; u.save }


8 changes: 7 additions & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,13 @@ def default_url_options
end

def current_user
@current_user ||= User.find(session[:user_id]) if session[:user_id]
user = nil
# maybe the user got deleted, so lets wrap this in a rescue block
begin
user = User.find(session[:user_id]) if session[:user_id]
rescue
end
@current_user ||= user
end

def authenticate_user!
Expand Down
Loading

0 comments on commit d16f927

Please sign in to comment.