diff --git a/QOpenScienceFramework/__init__.py b/QOpenScienceFramework/__init__.py
index e9ef345..a9ed4f0 100644
--- a/QOpenScienceFramework/__init__.py
+++ b/QOpenScienceFramework/__init__.py
@@ -1,4 +1,4 @@
-__version__ = "1.2.0"
+__version__ = "1.2.1"
__author__ = "Daniel Schreij"
import os
diff --git a/QOpenScienceFramework/manager.py b/QOpenScienceFramework/manager.py
index d6f4ff1..273b256 100644
--- a/QOpenScienceFramework/manager.py
+++ b/QOpenScienceFramework/manager.py
@@ -50,10 +50,6 @@ class ConnectionManager(QtNetwork.QNetworkAccessManager):
success_message = QtCore.Signal('QString','QString')
"""PyQt signal to send a success message."""
- # Dictionary holding requests in progress, so that they can be repeated if
- # mid-request it is discovered that the OAuth2 token is no longer valid.
- pending_requests = {}
-
def __init__(self, *args, **kwargs):
""" Constructor
@@ -123,6 +119,10 @@ def __init__(self, *args, **kwargs):
# The icon to show on the progress dialog
self._progress_icon = None
+ # Dictionary holding requests in progress, so that they can be repeated if
+ # mid-request it is discovered that the OAuth2 token is no longer valid.
+ self.pending_requests = {}
+
### properties
@property
def progress_icon(self):
@@ -248,6 +248,12 @@ def func_wrapper(inst, *args, **kwargs):
return func(inst, *args, **kwargs)
return func_wrapper
+ def clear_pending_requests(self):
+ """ Resets the pending network requests that still need to be executed.
+ Network requests
+ """
+ self.pending_requests = {}
+
def add_token(self, request):
"""Adds the OAuth2 token to a HTTP request.
@@ -1043,4 +1049,5 @@ def set_logged_in_user(self, user_data):
for (user_id, request) in self.pending_requests.values():
if user_id == self.logged_in_user['data']['id']:
request()
- self.pending_requests = {}
+ # Clear the pending actions queue, just to be sure.
+ self.clear_pending_requests()
diff --git a/QOpenScienceFramework/widgets/osfexplorer.py b/QOpenScienceFramework/widgets/osfexplorer.py
index b889ed5..fb3a4fd 100644
--- a/QOpenScienceFramework/widgets/osfexplorer.py
+++ b/QOpenScienceFramework/widgets/osfexplorer.py
@@ -318,13 +318,13 @@ def __create_properties_pane(self):
labelStyle = 'font-weight: bold'
self.common_fields = ['Name','Type']
- self.file_fields = ['Size','Created','Modified','Link']
+ self.file_fields = ['Size','Created','Modified','Online']
self.properties = {}
for field in self.common_fields + self.file_fields:
label = QtWidgets.QLabel(_(field))
label.setStyleSheet(labelStyle)
- if field == "Link":
+ if field == "Online":
# Initialize label with some HTML to trigger the rich text mode
value = QtWidgets.QLabel('')
value.setOpenExternalLinks(True)
@@ -538,36 +538,22 @@ def set_file_properties(self, data):
for field in self.properties[row]:
field.show()
- # Get the link to the file on the website of OSF. This is not readily
- # available from the returned API data, but can be parsed from the
- # comments URL, of which it is the [target] filter parameter
+ # Get the link to the file on the website of OSF.
# Sadly, this is URL is not always available for all files, so hide the
- # row if parsing fails.
- try:
- comments_url = data["relationships"]["comments"]["links"]["related"]\
- ["href"]
- except KeyError as e:
- warnings.warn('Could not retrieve comments url, because of missing field {}'.format(e))
- self.properties["Link"][0].hide()
- self.properties["Link"][1].hide()
+ # row if the GUID is not provided.
+
+ guid = data["attributes"]["guid"]
+ if guid is None:
+ self.properties["Online"][0].hide()
+ self.properties["Online"][1].hide()
else:
- # Use regular expression to search for the relevant part of the url
- try:
- target = re.search('filter\[target\]\=\w+', comments_url).group(0)
- except AttributeError:
- # If this didn't work, hide the row altogether
- self.properties["Link"][0].hide()
- self.properties["Link"][1].hide()
- else:
- # Get the ID part of the filter parameter and generate the url
- web_id = target.split("=")[1]
- web_url = u"{}/{}".format(osf.settings['website_url'], web_id)
- a = u"{0}".format(web_url)
- # Set the URL in the field
- self.properties["Link"][1].setText(a)
- # Show the row
- self.properties["Link"][0].show()
- self.properties["Link"][1].show()
+ web_url = u"{}/{}".format(osf.settings['website_url'], guid)
+ a = u"{0}".format(web_url)
+ # Set the URL in the field
+ self.properties["Online"][1].setText(a)
+ # Show the row
+ self.properties["Online"][0].show()
+ self.properties["Online"][1].show()
def set_folder_properties(self, data):
"""
diff --git a/QOpenScienceFramework/widgets/projecttree.py b/QOpenScienceFramework/widgets/projecttree.py
index 1c807e5..cfe438c 100644
--- a/QOpenScienceFramework/widgets/projecttree.py
+++ b/QOpenScienceFramework/widgets/projecttree.py
@@ -427,12 +427,14 @@ def refresh_contents(self):
time depending on the number of projects that the user has, so it is
recommended to use a partial refresh (refresh_children_of_node), wherever
you can. """
+
# If tree is already refreshing, don't start again, as this will result
# in a crash
- if self.isRefreshing == True:
+ if self.isRefreshing:
return
# Set flag that tree is currently refreshing
self.isRefreshing = True
+
# Save current item selection to restore it after refresh
current_item = self.currentItem()
if current_item:
@@ -651,7 +653,8 @@ def process_repo_contents(self, logged_in_user):
def handle_login(self):
""" Callback function for EventDispatcher when a login event is detected. """
self.active_requests = []
- self.refresh_contents()
+ if not self.isRefreshing:
+ self.refresh_contents()
def handle_logout(self):
""" Callback function for EventDispatcher when a logout event is detected. """
diff --git a/setup.py b/setup.py
index 5fbb94e..428836f 100644
--- a/setup.py
+++ b/setup.py
@@ -1,7 +1,5 @@
#!/usr/bin/env python
-import os
-import glob
import QOpenScienceFramework
from setuptools import setup
@@ -32,4 +30,4 @@
],
include_package_data=True,
packages = ['QOpenScienceFramework'],
- )
+)