Minor improvements and bugfixes

This commit is contained in:
Aitor Magán 2014-07-10 13:21:28 +02:00
parent 1c8340a089
commit f8d66dc400
2 changed files with 21 additions and 30 deletions

View File

@ -5,24 +5,14 @@ import db
def is_adquired(pkg_dict): def is_adquired(pkg_dict):
adquired = False
if db.package_allowed_users_table is None: if db.package_allowed_users_table is None:
db.init_db(model) db.init_db(model)
if db.AllowedUser.get(package_id=pkg_dict['id'], user_name=tk.c.user): return len(db.AllowedUser.get(package_id=pkg_dict['id'], user_name=tk.c.user)) > 0
adquired = True
return adquired
def is_owner(pkg_dict): def is_owner(pkg_dict):
return tk.c.userobj.id == pkg_dict['creator_user_id']
owner = False
if tk.c.userobj.id == pkg_dict['creator_user_id']:
owner = True
return owner
def get_allowed_users_str(users): def get_allowed_users_str(users):

View File

@ -151,6 +151,7 @@ class PrivateDatasets(p.SingletonPlugin, tk.DefaultDatasetForm):
db.init_db(context['model']) db.init_db(context['model'])
# Get the users and the package ID # Get the users and the package ID
if 'allowed_users' in pkg_dict:
received_users = [allowed_user for allowed_user in pkg_dict['allowed_users']] received_users = [allowed_user for allowed_user in pkg_dict['allowed_users']]
package_id = pkg_dict['id'] package_id = pkg_dict['id']