Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#3012] Add authorized field to user model
- Loading branch information
Showing
2 changed files
with
25 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from migrate import * | ||
|
||
def upgrade(migrate_engine): | ||
|
||
update_schema = ''' | ||
BEGIN; | ||
ALTER TABLE "user" | ||
ADD COLUMN authorized boolean DEFAULT FALSE; | ||
COMMIT; | ||
''' | ||
migrate_engine.execute(update_schema) | ||
|
||
|
||
# authorize any sysadmins | ||
import ckan.model as model | ||
sysadmins = model.Session.query(model.SystemRole).filter_by(role=model.Role.ADMIN) | ||
for sysadmin in sysadmins: | ||
|
||
user = model.User.get(sysadmin.user.id) | ||
user.authorized = True | ||
model.Session.commit() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters