Exemple #1
0
 def get_config(self, *args, **kwargs):
     user = kwargs["user"]
     try:
         client = self.get_client(user)
     except PluginIdentityRequired as e:
         raise self.raise_error(e)
     try:
         workspaces = client.get_workspaces()
     except HTTPError as e:
         if (e.response.status_code == 400 and e.response.url
                 == "https://app.asana.com/-/oauth_token"):
             raise PluginIdentityRequired(ERR_BEARER_EXPIRED)
         raise
     workspace_choices = self.get_workspace_choices(workspaces)
     workspace = self.get_option("workspace", kwargs["project"])
     # check to make sure the current user has access to the workspace
     helptext = None
     if workspace and not self.has_workspace_access(workspace,
                                                    workspace_choices):
         workspace_choices.append((workspace, workspace))
         helptext = (
             "This plugin has been configured for an Asana workspace "
             "that either you don't have access to or doesn't "
             "exist. You can edit the configuration, but you will not "
             "be able to change it back to the current configuration "
             "unless a teammate grants you access to the workspace in Asana."
         )
     return [{
         "name": "workspace",
         "label": "Workspace",
         "type": "select",
         "choices": workspace_choices,
         "default": workspace or workspaces["data"][0]["gid"],
         "help": helptext,
     }]
    def get_client(self, user):
        """Try and setup an API client"""
        auth = self.get_auth_for_user(user=user)
        if auth is None:
            raise PluginIdentityRequired(ERR_AUTH_NOT_CONFIGURED)

        return AssemblaClient(auth=auth)
Exemple #3
0
 def get_client(self, user):
     auth = self.get_auth_for_user(user=user)
     if auth is None:
         raise PluginIdentityRequired(ERR_AUTH_NOT_CONFIGURED)
     return AsanaClient(auth=auth)