diff create_or_update_organism.py @ 5:950fb2bf116d draft

planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/apollo commit 85194fa009ead2c34720faab61a4143fc29d17c2
author gga
date Fri, 31 Aug 2018 09:33:38 -0400
parents 236155b4e5f9
children db216690cbbf
line wrap: on
line diff
--- a/create_or_update_organism.py	Mon Mar 12 06:31:27 2018 -0400
+++ b/create_or_update_organism.py	Fri Aug 31 09:33:38 2018 -0400
@@ -8,11 +8,10 @@
 import sys
 import time
 
-from webapollo import AssertUser, GuessOrg, OrgOrGuess, WAAuth, WebApolloInstance
+from webapollo import GuessOrg, OrgOrGuess, PermissionCheck, WAAuth, WebApolloInstance
 logging.basicConfig(level=logging.INFO)
 log = logging.getLogger(__name__)
 
-
 if __name__ == '__main__':
     parser = argparse.ArgumentParser(description='Create or update an organism in an Apollo instance')
     WAAuth(parser)
@@ -33,8 +32,8 @@
     if isinstance(org_cn, list):
         org_cn = org_cn[0]
 
-    # User must have an account
-    gx_user = AssertUser(wa.users.loadUsers(email=args.email))
+    # User must have an account, if not, create it
+    gx_user = wa.users.assertOrCreateUser(args.email)
 
     log.info("Determining if add or update required")
     try:
@@ -43,14 +42,9 @@
         org = None
 
     if org:
-        has_perms = False
         old_directory = org['directory']
-        for user_owned_organism in gx_user.organismPermissions:
-            if 'WRITE' in user_owned_organism['permissions']:
-                has_perms = True
-                break
 
-        if not has_perms:
+        if not PermissionCheck(gx_user, org_cn, "WRITE"):
             print("Naming Conflict. You do not have permissions to access this organism. Either request permission from the owner, or choose a different name for your organism.")
             sys.exit(2)