Skip to content
Snippets Groups Projects
Commit efb12652 authored by Benjamin Becker's avatar Benjamin Becker
Browse files

adds bugfixes for label NEW

parent 2caee74e
No related branches found
No related tags found
No related merge requests found
......@@ -566,25 +566,27 @@ class OdshPlugin(plugins.SingletonPlugin, DefaultTranslation, DefaultDatasetForm
is_new = False
else:
date_package_created = self._get_date_from_string(date_package_created_as_str)
if date_package_created == None:
is_new = False
else:
is_new = odsh_helpers.is_within_last_month(date_package_created)
return is_new
def _get_date_of_package_creation_from_pkg_dict(self, pkg_dict):
if 'extras' in pkg_dict:
extras = pk_dict['extras']
extras = pkg_dict['extras']
issued = odsh_helpers.odsh_extract_value_from_extras(extras=extras, key='issued') # is None if issued not in extras
return issued
else:
return None
def _get_date_from_string(self, date_time_str):
# todo: update this function if used in different context
date_time_format = '%Y-%m-%dT%H:%M:%S.%f' #e.g. u'2019-06-12T11:56:25.059563'
date_time_format = '%Y-%m-%dT%H:%M:%S' #e.g. u'2019-06-12T11:56:25'
try:
date_time = datetime.datetime.strptime(date_time_str, date_time_format)
except ValueError:
# if date cannot be converted from string fall back to 1.1.2000
date = datetime.date(2000, 1, 1)
date = date_time.date()
except ValueError:
# if date cannot be converted from string return None
date = None
return date
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment