Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
ckanext-odsh
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Open-Data
ckanext-odsh
Commits
ca0ce19b
Commit
ca0ce19b
authored
5 years ago
by
anonymous
Browse files
Options
Downloads
Patches
Plain Diff
adds bugfixes for label NEW
parent
ede21adf
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
ckanext/odsh/plugin.py
+9
-7
9 additions, 7 deletions
ckanext/odsh/plugin.py
with
9 additions
and
7 deletions
ckanext/odsh/plugin.py
+
9
−
7
View file @
ca0ce19b
...
...
@@ -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
=
pk
g
_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
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment