Use SQLAlchemy Relationships
replace 'type' by 'action'
fix permission manager