Skip to content

Commit

Permalink
Merge branch 'release/19.30.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
brianjgeiger committed Oct 16, 2019
2 parents d22b269 + 5804d52 commit 3c8e752
Show file tree
Hide file tree
Showing 186 changed files with 1,606 additions and 441 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

We follow the CalVer (https://calver.org/) versioning scheme: YY.MINOR.MICRO.

19.30.0 (2019-10-16)
===================
- Fix weirdness around deleted nodes by not deleing OSF Storage
- Make deleted fields on models and addons into date fields
- API v2: Chronos users can have more name options
- Python 3 backwards compatibility changes

19.29.0 (2019-10-02)
===================
- Use new pagecounter fields for increased query efficiency
Expand Down
13 changes: 8 additions & 5 deletions PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,14 @@

## QA Notes

<!-- Does this change need QA? If so, this section is required.
- Is cross-browser testing required/recommended?
- Is API testing required/recommended?
- What pages on the OSF should be tested?
- What edge cases should QA be aware of?
- Does this change require a data migration? If so, what data will we migrate?
- What is the level of risk?
- Any permissions code touched?
- Is this an additive or subtractive change, other?
- How can QA verify? (Through UI, API, AdminApp or AdminAdminApp?)
- If verifying through API, what's the new version? Please include the endpoints in PR notes or Dev docs.
- What features or workflows might this change impact?
- How will this impact performance?
-->

## Documentation
Expand Down
2 changes: 1 addition & 1 deletion addons/base/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def addon_short_name(self):
pass

def _log_params(self):
node_settings = self.node.get_addon(self.addon_short_name, deleted=True)
node_settings = self.node.get_addon(self.addon_short_name, is_deleted=True)
return {
'project': self.node.parent_id,
'node': self.node._primary_key,
Expand Down
13 changes: 9 additions & 4 deletions addons/base/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import markupsafe
import requests
from django.db import models
from django.utils import timezone
from framework.auth import Auth
from framework.auth.decorators import must_be_logged_in
from framework.exceptions import HTTPError, PermissionsError
Expand All @@ -14,6 +15,7 @@
from osf.models.node import AbstractNode
from osf.models.user import OSFUser
from osf.utils.datetime_aware_jsonfield import DateTimeAwareJSONField
from osf.utils.fields import NonNaiveDateTimeField
from website import settings
from addons.base import logger, serializer
from website.oauth.signals import oauth_complete
Expand All @@ -38,7 +40,8 @@


class BaseAddonSettings(ObjectIDMixin, BaseModel):
deleted = models.BooleanField(default=False)
is_deleted = models.BooleanField(default=False)
deleted = NonNaiveDateTimeField(null=True, blank=True)

class Meta:
abstract = True
Expand All @@ -52,13 +55,15 @@ def short_name(self):
return self.config.short_name

def delete(self, save=True):
self.deleted = True
self.is_deleted = True
self.deleted = timezone.now()
self.on_delete()
if save:
self.save()

def undelete(self, save=True):
self.deleted = False
self.is_deleted = False
self.deleted = None
self.on_add()
if save:
self.save()
Expand Down Expand Up @@ -215,7 +220,7 @@ def revoke_oauth_access(self, external_account, auth, save=True):
"""
for node in self.get_nodes_with_oauth_grants(external_account):
try:
node.get_addon(external_account.provider, deleted=True).deauthorize(auth=auth)
node.get_addon(external_account.provider, is_deleted=True).deauthorize(auth=auth)
except AttributeError:
# No associated addon settings despite oauth grant
pass
Expand Down
9 changes: 7 additions & 2 deletions addons/base/tests/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import mock
import pytest
import pytz
import datetime
from addons.base.tests.utils import MockFolder
from django.utils import timezone
from framework.auth import Auth
Expand Down Expand Up @@ -304,11 +306,14 @@ def test_delete(self):
assert_true(self.node_settings.user_settings)
assert_true(self.node_settings.folder_id)
old_logs = list(self.node.logs.all())
self.node_settings.delete()
mock_now = datetime.datetime(2017, 3, 16, 11, 00, tzinfo=pytz.utc)
with mock.patch.object(timezone, 'now', return_value=mock_now):
self.node_settings.delete()
self.node_settings.save()
assert_is(self.node_settings.user_settings, None)
assert_is(self.node_settings.folder_id, None)
assert_true(self.node_settings.deleted)
assert_true(self.node_settings.is_deleted)
assert_equal(self.node_settings.deleted, mock_now)
assert_equal(list(self.node.logs.all()), list(old_logs))

def test_on_delete(self):
Expand Down
10 changes: 7 additions & 3 deletions addons/base/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,9 @@ def get_auth(auth, **kwargs):
raise HTTPError(http_status.HTTP_400_BAD_REQUEST)

node = AbstractNode.load(node_id) or Preprint.load(node_id)
if not node:
if node and node.is_deleted:
raise HTTPError(http_status.HTTP_410_GONE)
elif not node:
raise HTTPError(http_status.HTTP_404_NOT_FOUND)

check_access(node, auth, action, cas_resp)
Expand Down Expand Up @@ -603,11 +605,12 @@ def addon_deleted_file(auth, target, error_type='BLAME_PROVIDER', **kwargs):
# Allow file_node to be passed in so other views can delegate to this one
file_node = kwargs.get('file_node') or TrashedFileNode.load(kwargs.get('trashed_id'))

deleted_by, deleted_on = None, None
deleted_by, deleted_on, deleted = None, None, None
if isinstance(file_node, TrashedFileNode):
deleted_by = file_node.deleted_by
deleted_by_guid = file_node.deleted_by._id if deleted_by else None
deleted_on = file_node.deleted_on.strftime('%c') + ' UTC'
deleted = deleted_on
if getattr(file_node, 'suspended', False):
error_type = 'FILE_SUSPENDED'
elif file_node.deleted_by is None or (auth.private_key and auth.private_link.anonymous):
Expand All @@ -633,7 +636,8 @@ def addon_deleted_file(auth, target, error_type='BLAME_PROVIDER', **kwargs):
file_name=markupsafe.escape(file_name),
deleted_by=markupsafe.escape(getattr(deleted_by, 'fullname', None)),
deleted_on=markupsafe.escape(deleted_on),
provider=markupsafe.escape(provider_full)
provider=markupsafe.escape(provider_full),
deleted=markupsafe.escape(deleted)
)
if deleted_by:
format_params['deleted_by_guid'] = markupsafe.escape(deleted_by_guid)
Expand Down
36 changes: 36 additions & 0 deletions addons/bitbucket/migrations/0003_rename_deleted_field.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.15 on 2019-06-27 20:29
from __future__ import unicode_literals

from django.db import migrations
import osf.utils.fields


class Migration(migrations.Migration):

dependencies = [
('addons_bitbucket', '0002_auto_20170808_1140'),
]

operations = [
migrations.RenameField(
model_name='nodesettings',
new_name='is_deleted',
old_name='deleted',
),
migrations.RenameField(
model_name='usersettings',
new_name='is_deleted',
old_name='deleted',
),
migrations.AddField(
model_name='nodesettings',
name='deleted',
field=osf.utils.fields.NonNaiveDateTimeField(blank=True, null=True),
),
migrations.AddField(
model_name='usersettings',
name='deleted',
field=osf.utils.fields.NonNaiveDateTimeField(blank=True, null=True),
),
]
2 changes: 1 addition & 1 deletion addons/bitbucket/settings/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@

try:
from .local import * # noqa
except ImportError as error:
except ImportError:
logger.warn('No local.py settings file found')
36 changes: 36 additions & 0 deletions addons/box/migrations/0004_rename_deleted_field.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.15 on 2019-06-27 20:29
from __future__ import unicode_literals

from django.db import migrations
import osf.utils.fields


class Migration(migrations.Migration):

dependencies = [
('addons_box', '0003_auto_20170713_1125'),
]

operations = [
migrations.RenameField(
model_name='nodesettings',
new_name='is_deleted',
old_name='deleted',
),
migrations.RenameField(
model_name='usersettings',
new_name='is_deleted',
old_name='deleted',
),
migrations.AddField(
model_name='nodesettings',
name='deleted',
field=osf.utils.fields.NonNaiveDateTimeField(blank=True, null=True),
),
migrations.AddField(
model_name='usersettings',
name='deleted',
field=osf.utils.fields.NonNaiveDateTimeField(blank=True, null=True),
),
]
2 changes: 1 addition & 1 deletion addons/box/settings/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@

try:
from .local import * # noqa
except ImportError as error:
except ImportError:
logger.warn('No local.py settings file found')
36 changes: 36 additions & 0 deletions addons/dataverse/migrations/0004_rename_deleted_field.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.15 on 2019-06-27 20:29
from __future__ import unicode_literals

from django.db import migrations
import osf.utils.fields


class Migration(migrations.Migration):

dependencies = [
('addons_dataverse', '0003_auto_20170713_1125'),
]

operations = [
migrations.RenameField(
model_name='nodesettings',
new_name='is_deleted',
old_name='deleted',
),
migrations.RenameField(
model_name='usersettings',
new_name='is_deleted',
old_name='deleted',
),
migrations.AddField(
model_name='nodesettings',
name='deleted',
field=osf.utils.fields.NonNaiveDateTimeField(blank=True, null=True),
),
migrations.AddField(
model_name='usersettings',
name='deleted',
field=osf.utils.fields.NonNaiveDateTimeField(blank=True, null=True),
),
]
2 changes: 1 addition & 1 deletion addons/dataverse/settings/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@

try:
from .local import * # noqa
except ImportError as error:
except ImportError:
logger.warn('No local.py settings file found')
2 changes: 1 addition & 1 deletion addons/dataverse/tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def test_get_dataset_calls_patched_timeout_method(self, mock_requests):
with assert_raises(Exception) as e:
get_dataset(dataverse, 'My hdl')
assert_is(mock_requests.get.assert_called_once_with('123', auth='me', timeout=settings.REQUEST_TIMEOUT), None)
assert_equal(e.exception.message, 'Done Testing')
assert_equal(str(e.exception), 'Done Testing')

def test_get_deaccessioned_dataset(self):
self.mock_dataset.get_state.return_value = 'DEACCESSIONED'
Expand Down
36 changes: 36 additions & 0 deletions addons/dropbox/migrations/0004_rename_deleted_field.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.15 on 2019-06-27 20:29
from __future__ import unicode_literals

from django.db import migrations
import osf.utils.fields


class Migration(migrations.Migration):

dependencies = [
('addons_dropbox', '0003_auto_20170713_1125'),
]

operations = [
migrations.RenameField(
model_name='nodesettings',
new_name='is_deleted',
old_name='deleted',
),
migrations.RenameField(
model_name='usersettings',
new_name='is_deleted',
old_name='deleted',
),
migrations.AddField(
model_name='nodesettings',
name='deleted',
field=osf.utils.fields.NonNaiveDateTimeField(blank=True, null=True),
),
migrations.AddField(
model_name='usersettings',
name='deleted',
field=osf.utils.fields.NonNaiveDateTimeField(blank=True, null=True),
),
]
2 changes: 1 addition & 1 deletion addons/dropbox/settings/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@

try:
from .local import * # noqa
except ImportError as error:
except ImportError:
logger.warn('No local.py settings file found')
36 changes: 36 additions & 0 deletions addons/figshare/migrations/0004_rename_deleted_field.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.15 on 2019-06-27 20:29
from __future__ import unicode_literals

from django.db import migrations
import osf.utils.fields


class Migration(migrations.Migration):

dependencies = [
('addons_figshare', '0003_auto_20170713_1125'),
]

operations = [
migrations.RenameField(
model_name='nodesettings',
new_name='is_deleted',
old_name='deleted',
),
migrations.RenameField(
model_name='usersettings',
new_name='is_deleted',
old_name='deleted',
),
migrations.AddField(
model_name='nodesettings',
name='deleted',
field=osf.utils.fields.NonNaiveDateTimeField(blank=True, null=True),
),
migrations.AddField(
model_name='usersettings',
name='deleted',
field=osf.utils.fields.NonNaiveDateTimeField(blank=True, null=True),
),
]
2 changes: 1 addition & 1 deletion addons/figshare/settings/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@

try:
from .local import * # noqa
except ImportError as error:
except ImportError:
logger.warn('No local.py settings file found')
Loading

0 comments on commit 3c8e752

Please sign in to comment.