2014-07-10 12:26:31 +02:00
|
|
|
import ckan.model as model
|
|
|
|
import ckan.plugins.toolkit as tk
|
|
|
|
import db
|
|
|
|
|
|
|
|
|
|
|
|
def is_adquired(pkg_dict):
|
|
|
|
|
|
|
|
if db.package_allowed_users_table is None:
|
|
|
|
db.init_db(model)
|
|
|
|
|
2014-07-10 13:21:28 +02:00
|
|
|
return len(db.AllowedUser.get(package_id=pkg_dict['id'], user_name=tk.c.user)) > 0
|
2014-07-10 12:26:31 +02:00
|
|
|
|
|
|
|
|
|
|
|
def is_owner(pkg_dict):
|
2014-07-11 13:55:23 +02:00
|
|
|
if tk.c.userobj:
|
|
|
|
return tk.c.userobj.id == pkg_dict['creator_user_id']
|
|
|
|
else:
|
|
|
|
return False
|
2014-07-10 12:26:31 +02:00
|
|
|
|
|
|
|
|
|
|
|
def get_allowed_users_str(users):
|
2014-07-11 13:55:23 +02:00
|
|
|
if users:
|
|
|
|
return ','.join([user for user in users])
|