Skip to content

Commit

Permalink
Merge branch 'release-v0.28.1' into 'master'
Browse files Browse the repository at this point in the history
Release v0.28.1

See merge request Scientific-IT-Systems/SampleDB!1110
  • Loading branch information
danielkaiser committed Jun 18, 2024
2 parents 8c619af + 81798e5 commit 8981fc8
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ docker run \
--restart=always \
--name sampledb \
-p 8000:8000 \
sciapp/sampledb:0.28.0
sciapp/sampledb:0.28.1
```

### Once it's started
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ version: '3'

services:
web:
image: sciapp/sampledb:0.28.0
image: sciapp/sampledb:0.28.1
restart: always
container_name: sampledb
# Note: this config option works with docker-compose version >1.27
Expand Down
2 changes: 1 addition & 1 deletion docs/administrator_guide/getting_started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Next, start the SampleDB container:
--restart=always \
--name sampledb \
-p 8000:8000 \
sciapp/sampledb:0.28.0
sciapp/sampledb:0.28.1
This will start a minimal SampleDB installation at ``http://localhost:8000`` and allow you to sign in with the username ``admin`` and the password ``password``.

Expand Down
8 changes: 8 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
Changelog
=========

Version 0.28.1
--------------

Released on June 18th, 2024.

- Fixed use of timezones for ``date`` style ``datetime`` properties
- Fixed validation of ORCID iDs

Version 0.28
------------

Expand Down
2 changes: 1 addition & 1 deletion sampledb/frontend/templates/eln_files/import_eln_file.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ <h1 class="text-center">{{ _('Import Data') }}</h1>
{% for user_info in parsed_eln_file_data.users | sort(attribute='id') %}
<div class="row">
<li>
<span class="col-sm-10">{{ user_info.id }}: {{ user_info.name or '—' }} {% if user_info.url %}({{ user_info.url }}){% endif %}</span><span class="col-sm-2" style="float: left;"><input type="checkbox" class="checkboxes-fed-identities" name="{{ user_info.id }}" data-eln-user-id="{{ user_info.id }}"></span>
<span class="col-sm-10" style="word-break: break-all">{{ user_info.id }}: {{ user_info.name or '—' }} {% if user_info.url %}({{ user_info.url }}){% endif %}</span><span class="col-sm-2" style="float: left;"><input type="checkbox" class="checkboxes-fed-identities" name="{{ user_info.id }}" data-eln-user-id="{{ user_info.id }}"></span>
</li>
</div>
{% endfor %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{% set style_variant = get_style_variant(schema.style, template_mode) %}
<span data-utc-datetime="{{ data.utc_datetime | generic_format_datetime }}" {%- if style_variant == 'date' -%}data-sampledb-date-only="true"{%- elif style_variant == 'time' -%}data-sampledb-time-only="true"{%- endif -%}>
{%- if style_variant == 'date' -%}
{{ data.utc_datetime.split(' ')[0] | babel_format_date }}
{{ data.utc_datetime | babel_format_date }}
{%- elif style_variant == 'time' -%}
{{ data.utc_datetime | babel_format_time }}
{%- else -%}
Expand Down
15 changes: 13 additions & 2 deletions sampledb/frontend/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,11 @@ def custom_format_date(
if isinstance(date, datetime):
datetime_obj = date
else:
datetime_obj = datetime.strptime(date, format)
if ' ' in date:
utc_datetime = datetime.strptime(date, '%Y-%m-%d %H:%M:%S').replace(tzinfo=timezone.utc)
datetime_obj = utc_datetime.astimezone(pytz.timezone(current_user.timezone or 'UTC'))
else:
datetime_obj = datetime.strptime(date, format)
return format_date(datetime_obj)


Expand Down Expand Up @@ -1030,7 +1034,14 @@ def validate_orcid(orcid: str) -> typing.Tuple[bool, typing.Optional[str]]:
if orcid.startswith(orcid_prefix):
orcid = orcid[len(orcid_prefix):]
# check ORCID iD syntax
if not re.fullmatch(r'\d{4}-\d{4}-\d{4}-\d{4}', orcid, flags=re.ASCII):
if not re.fullmatch(r'\d{4}-\d{4}-\d{4}-\d{3}[\dX]', orcid, flags=re.ASCII):
return False, None
# check ISO 7064 Mod 11, 2 checksum
checksum = '0123456789X'[(12 - sum(
int(digit) << index
for index, digit in enumerate(reversed(orcid.replace('-', '')[:-1]), start=1)
) % 11) % 11]
if checksum != orcid[-1]:
return False, None
# return sanitized ORCID iD on success
return True, orcid
Expand Down
2 changes: 1 addition & 1 deletion sampledb/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@

import os

__version__ = os.environ.get('SAMPLEDB_VERSION') or '0.28.0'
__version__ = os.environ.get('SAMPLEDB_VERSION') or '0.28.1'
15 changes: 15 additions & 0 deletions tests/frontend/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -762,3 +762,18 @@ def test_get_search_paths():
for action_type in all_action_types
}
)

def test_validate_orcid():
for orcid in [
'0000-0001-2345-6789',
'0000-0001-2345-672X',
]:
assert sampledb.frontend.utils.validate_orcid(orcid) == (True, orcid)
for orcid in [
'0000-0001-2345-6780',
'0000-0000-0000-000',
'0000-0000-0000-00000',
'0000-0000-0000-00X0',
'0000-0000-0000-000a',
]:
assert sampledb.frontend.utils.validate_orcid(orcid) == (False, None)

0 comments on commit 8981fc8

Please sign in to comment.