Skip to content

Commit

Permalink
Placeholder for defining the default permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
rossjones committed Aug 23, 2012
1 parent d67f5fd commit c8e4a81
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions ckan/migration/versions/061_add_default_permissions.py
@@ -0,0 +1,28 @@
from sqlalchemy import *
from migrate import *

def upgrade(migrate_engine):
metadata = MetaData()
metadata.bind = migrate_engine
migrate_engine.execute('''
BEGIN;
CREATE OR REPLACE FUNCTION CREATE_UUID()
RETURNS uuid AS
$BODY$
SELECT CAST(md5(current_database()|| user ||current_timestamp ||random()) as uuid)
$BODY$
LANGUAGE 'sql' VOLATILE;
INSERT INTO permission (id, name, description)
VALUES (CREATE_UUID(), 'package.view', 'View a dataset');
INSERT INTO permission (id, name, description)
VALUES (CREATE_UUID(), 'package.edit', 'Edit a dataset');
INSERT INTO permission (id, name, description)
VALUES (CREATE_UUID(), 'package.create', 'Create a dataset');
COMMIT;
'''
)

0 comments on commit c8e4a81

Please sign in to comment.