Skip to content

Commit

Permalink
Merge branch 'dev' into 'master'
Browse files Browse the repository at this point in the history
merge v0.6.1 release

See merge request CUBI_Engineering/CUBI_Data_Mgmt/sodar_core!64
  • Loading branch information
mikkonie committed Jun 5, 2019
2 parents c798dd9 + b5b1144 commit 5c0b106
Show file tree
Hide file tree
Showing 33 changed files with 421 additions and 154 deletions.
9 changes: 7 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ language: python
python:
- "3.6"

env:
- CHROME_DRIVER_VERSION="74.0.3729.6"

before_install:
- sudo apt-get update -qq
- sudo apt-get install -qq build-essential zlib1g-dev libtiff5-dev libjpeg8-dev libfreetype6-dev
Expand All @@ -17,7 +20,6 @@ addons:
packages:
- python3.6
- python3.6-dev
- chromium-chromedriver
postgresql: "9.6"
chrome: stable

Expand All @@ -29,7 +31,10 @@ before_script:
- psql -c "CREATE USER sodar_core WITH PASSWORD 'sodar_core';" -U postgres
- psql -c "GRANT ALL PRIVILEGES ON DATABASE sodar_core to sodar_core;" -U postgres
- psql -c "ALTER USER sodar_core CREATEDB;" -U postgres
- ln -s /usr/lib/chromium-browser/chromedriver ~/bin/chromedriver
- wget -N http://chromedriver.storage.googleapis.com/$CHROME_DRIVER_VERSION/chromedriver_linux64.zip -P ~/
- unzip ~/chromedriver_linux64.zip -d ~/
- sudo mv -f ~/chromedriver /usr/bin/chromedriver
- sudo chmod ugo+rx /usr/bin/chromedriver

script:
- python manage.py collectstatic --noinput
Expand Down
49 changes: 47 additions & 2 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,51 @@ Changelog for the **SODAR Core** Django app package. Loosely follows the
Note that the issue IDs here refer to ones in the private CUBI GitLab.


v0.6.1 (2019-06-05)
===================

Added
-----

- **Filesfolders**
- Example project list columns (#265)
- Setting ``FILESFOLDERS_SHOW_LIST_COLUMNS`` to manage example project list columns (#265)
- **Projectroles**
- Optional project list columns for project apps (#265)
- **Sodarcache**
- ``delete_cache()`` API function (#257)

Changed
-------

- **Projectroles**
- Refactor ``RemoteProject.get_project()`` (#262)
- Use ``get_info_link()`` in remote site list (#264)
- Define ``SYSTEM_USER_GROUP`` in ``SODAR_CONSTANTS`` (#251)
- Make pagedown textarea element resizeable and increase minimum height (#273)
- **Sodarcache**
- Handle and log raised exceptions in ``synccache`` management command (#272)
- **Userprofile**
- Disable user settings link if no settings are available (#260)

Fixed
-----

- **General**
- Chrome and Chromedriver version mismatch in Travis-CI config (#254)
- **Projectroles**
- Remove redundant ``get_project_list()`` call from ``project_detail.html``

Removed
-------

- **Projectroles**
- Unused project statistics in the home view (#269)
- App settings deprecation protection (#245)
- **Sodarcache**
- Unused ``TaskflowCacheUpdateAPIView`` (#205)


v0.6.0 (2019-05-10)
===================

Expand All @@ -20,7 +65,7 @@ Added
- ``user_settings`` field in project plugins (#16)
- Optional ``label`` key for settings
- Optional "wait for element" args in UI test helpers to ease Javascript testing (#230)
- ``get_info_link()``template tag (#239)
- ``get_info_link()`` template tag (#239)
- ``get_setting_defs()`` API function for retrieving project and user setting definitions (#225)
- ``get_all_defaults()`` API function for retrieving all default setting values (#225)
- Human readable labels for app settings (#9)
Expand All @@ -39,7 +84,7 @@ Changed
- **General**
- Upgrade to ChromeDriver v74 (#221)
- **Bgjobs**
- Ordering of background job for homgenization with downstream Varfish
- Job order to match downstream Varfish
- **Filesfolders**
- Update app settings (#246)
- **Projectroles**
Expand Down
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
SODAR Core
^^^^^^^^^^

.. image:: https://travis-ci.com/bihealth/sodar_core.svg?branch=master
:target: https://travis-ci.com/bihealth/sodar_core
.. image:: https://travis-ci.org/bihealth/sodar_core.svg?branch=master
:target: https://travis-ci.org/bihealth/sodar_core

.. image:: https://api.codacy.com/project/badge/Grade/404e8515825548b1aa5a44dbe3d45ece
:target: https://www.codacy.com/app/bihealth/sodar_core
Expand Down
2 changes: 1 addition & 1 deletion config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ def set_logging(debug):
)
FILESFOLDERS_SERVE_AS_ATTACHMENT = False
FILESFOLDERS_LINK_BAD_REQUEST_MSG = 'Invalid request'

FILESFOLDERS_SHOW_LIST_COLUMNS = True # Custom project list column example

# Adminalerts app settings
ADMINALERTS_PAGINATION = 15
Expand Down
11 changes: 11 additions & 0 deletions docs/source/breaking_changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,17 @@ version. For a complete list of changes in the current release, see the
be missing. Please click "display source" if you want to read this in GitLab.


v0.6.1 (2019-06-05)
===================

App Settings Deprecation Protection Removed
-------------------------------------------

The deprecation protection set up in the previous release has been removed.
Project app plugins are now expected to declare ``app_settings`` in the format
introduced in v0.6.0.


v0.6.0 (2019-05-10)
===================

Expand Down
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
# The short X.Y version
version = '0.6'
# The full version, including alpha/beta/rc tags
release = '0.6.0'
release = '0.6.1'


# -- General configuration ---------------------------------------------------
Expand Down
7 changes: 6 additions & 1 deletion docs/source/dev_project_app.rst
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,8 @@ Implementing the following is **optional**:
are needed. See the plugin point definition for an example.
- ``search_types``: Implement if searching the data of the app is enabled
- ``search_template``: Implement if searching the data of the app is enabled
- ``project_list_columns``: Optional custom columns do be shown in the project
list. See the plugin point definition for an example.
- ``get_taskflow_sync_data()``: Applicable only if working with
``sodar_taskflow`` and iRODS
- ``get_object_link()``: If Django models are associated with the app. Used e.g.
Expand All @@ -217,6 +219,9 @@ Implementing the following is **optional**:
search is enabled
- ``get_statistics()``: Return statistics for the siteinfo app. See details in
:ref:`the siteinfo documentation <app_siteinfo>`.
- ``get_project_list_value()``: A function which **must** be implemented if
``project_list_columns`` are defined, to retrieve a column cell value for a
specific project.

Once you have implemented the ``rules.py`` and ``plugins.py`` files and added
the app and its URL patterns to the Django site configuration, you can create
Expand Down Expand Up @@ -630,7 +635,7 @@ the result:
}
Search Template
----------------
---------------

Projectroles will provide your template context the ``search_results`` object,
which corresponds to the result dict of the aforementioned function. There are
Expand Down
2 changes: 2 additions & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ which wants to make use of the following features:
- Advanced project activity logging
- Small file uploading and browsing
- Managing server-side background jobs
- Caching and aggregation of data from external services
- Tracking site information and statistics

Basics of Django site setup and instructions for third party packages used are
considered out of scope for this documentation. Please refer instead to official
Expand Down
50 changes: 50 additions & 0 deletions filesfolders/plugins.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from django.conf import settings
from django.urls import reverse

# Projectroles dependency
Expand All @@ -11,6 +12,13 @@
# SODAR Constants
APP_SETTING_SCOPE_PROJECT = SODAR_CONSTANTS['APP_SETTING_SCOPE_PROJECT']

# Local constants
SHOW_LIST_COLUMNS = (
settings.FILESFOLDERS_SHOW_LIST_COLUMNS
if hasattr(settings, 'FILESFOLDERS_SHOW_LIST_COLUMNS')
else False
)


class ProjectAppPlugin(ProjectAppPluginPoint):
"""Plugin for registering app with Projectroles"""
Expand Down Expand Up @@ -71,6 +79,23 @@ class ProjectAppPlugin(ProjectAppPluginPoint):
#: Position in plugin ordering
plugin_ordering = 30

project_list_columns = {
'files': {
'title': 'Files',
'width': 75,
'description': 'Small files stored for the project',
'active': SHOW_LIST_COLUMNS,
'align': 'right',
},
'links': {
'title': 'Links',
'width': 75,
'description': 'Hyperlinks defined in the small files app',
'active': SHOW_LIST_COLUMNS,
'align': 'right',
},
}

def get_taskflow_sync_data(self):
"""
Return data for syncing taskflow operations
Expand Down Expand Up @@ -174,3 +199,28 @@ def get_statistics(self):
'value': HyperLink.objects.all().count(),
},
}

def get_project_list_value(self, column_id, project):
"""
Return a value for the optional additional project list column specific
to a project.
:param column_id: ID of the column (string)
:param project: Project object
:return: String (may contain HTML) or None
"""
if column_id == 'files':
count = File.objects.filter(project=project).count()

elif column_id == 'links':
count = HyperLink.objects.filter(project=project).count()

if count > 0:
return '<a href="{}">{}'.format(
reverse(
'filesfolders:list', kwargs={'project': project.sodar_uuid}
),
count,
)

return count
24 changes: 24 additions & 0 deletions filesfolders/tests/test_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -450,3 +450,27 @@ def test_search_type_nonexisting(self):
+ urlencode({'s': 'test type:Jaix1au'})
)
self.assert_element_count(expected, url, 'sodar-ff-search-item')


class TestHomeView(TestUIBase):
"""Tests for appearance of filesfolders specific data in the home view"""

def test_project_list(self):
"""Test custom filesfolders project list column visibility"""

users = [
self.superuser,
self.as_owner.user,
self.as_delegate.user,
self.as_contributor.user,
self.as_guest.user,
self.user_no_roles,
]
url = reverse('home')

self.assert_element_exists(
users, url, 'sodar-pr-project-list-header-filesfolders-files', True
)
self.assert_element_exists(
users, url, 'sodar-pr-project-list-header-filesfolders-links', True
)
51 changes: 9 additions & 42 deletions projectroles/app_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,6 @@


class AppSettingAPI:
@classmethod
def _get_settings_dict(cls, app_plugin):
"""
TEMPORARY DEPRECATION PROTECTION HELPER, TO BE REMOVED IN THE NEXT
RELEASE
:param app_plugin: Project app plugin object
:return: Dict
"""
if not app_plugin.app_settings and app_plugin.project_settings:
return app_plugin.project_settings

return app_plugin.app_settings

@classmethod
def _check_project_and_user(cls, project, user):
"""
Expand Down Expand Up @@ -68,11 +54,8 @@ def get_default_setting(cls, app_name, setting_name):
"""
app_plugin = get_app_plugin(app_name)

# NOTE: Deprecation protection, to be removed in the next release
settings_defs = cls._get_settings_dict(app_plugin)

if setting_name in settings_defs:
return settings_defs[setting_name]['default']
if setting_name in app_plugin.app_settings:
return app_plugin.app_settings[setting_name]['default']

raise KeyError(
'Setting "{}" not found in app plugin "{}"'.format(
Expand Down Expand Up @@ -202,17 +185,15 @@ def set_app_setting(

except AppSetting.DoesNotExist:
app_plugin = get_app_plugin(app_name)
# NOTE: Deprecation protection, to be removed in the next release
settings_defs = cls._get_settings_dict(app_plugin)

if setting_name not in settings_defs:
if setting_name not in app_plugin.app_settings:
raise KeyError(
'Setting "{}" not found in app plugin "{}"'.format(
setting_name, app_name
)
)

s_type = settings_defs[setting_name]['type']
s_type = app_plugin.app_settings[setting_name]['type']

if validate:
cls.validate_setting(s_type, value)
Expand Down Expand Up @@ -267,22 +248,8 @@ def get_setting_defs(cls, plugin, scope):
"""
cls._check_scope(scope)

# NOTE: Deprecation protection, to be removed in the next release
if (
not plugin.app_settings
and plugin.project_settings
and scope == APP_SETTING_SCOPE_PROJECT
):
ret = plugin.project_settings

elif plugin.app_settings:
ret = {
k: v
for k, v in plugin.app_settings.items()
if 'scope' in v and v['scope'] == scope
}

else:
ret = {}

return ret
return {
k: v
for k, v in plugin.app_settings.items()
if 'scope' in v and v['scope'] == scope
}
2 changes: 2 additions & 0 deletions projectroles/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
'CATEGORY': {'default': 'category', 'plural': 'categories'},
'PROJECT': {'default': 'project', 'plural': 'projects'},
},
# System user group
'SYSTEM_USER_GROUP': 'system',
}


Expand Down
9 changes: 4 additions & 5 deletions projectroles/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -902,11 +902,10 @@ def __repr__(self):

def get_project(self):
"""Get the related Project object"""
try:
return Project.objects.get(sodar_uuid=self.project_uuid)

except Project.DoesNotExist:
return None
return (
self.project
or Project.objects.filter(sodar_uuid=self.project_uuid).first()
)


# Abstract User Model ----------------------------------------------------------
Expand Down
Loading

0 comments on commit 5c0b106

Please sign in to comment.