Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Maják
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
Container registry
Model registry
Operate
Environments
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TO
Maják
Commits
1c7f1bc0
Commit
1c7f1bc0
authored
4 years ago
by
jan.bednarik
Browse files
Options
Downloads
Patches
Plain Diff
donate: Fix portal API calls for non existing project IDs
parent
f2feaa2e
Branches
Branches containing commit
No related tags found
2 merge requests
!78
donate: Fix portal API calls for non existing project IDs
,
!77
donate: Fix portal API calls for non existing project IDs
Pipeline
#1075
passed
4 years ago
Stage: build
Changes
1
Pipelines
3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
donate/models.py
+16
-9
16 additions, 9 deletions
donate/models.py
with
16 additions
and
9 deletions
donate/models.py
+
16
−
9
View file @
1c7f1bc0
...
...
@@ -428,15 +428,22 @@ class DonateProjectPage(DonateFormMixin, Page, SubpageMixin, MetadataPageMixin):
return
self
.
perex
def
get_donated_amount
(
self
):
key
=
f
"
donated_amount_
{
self
.
portal_project_id
}
"
amount
=
cache
.
get
(
key
)
if
amount
is
None
:
amount
=
get_donated_amount_from_api
(
self
.
portal_project_id
)
if
amount
is
not
None
:
self
.
donated_amount
=
amount
self
.
save
()
cache
.
set
(
key
,
amount
)
return
self
.
donated_amount
if
self
.
portal_project_id
is
None
:
return
0
# instance caching for multiple method calls during one request
if
not
hasattr
(
self
,
"
_donated_amount
"
):
# cache portal API calls (defaults to 5 min)
key
=
f
"
donated_amount_
{
self
.
portal_project_id
}
"
amount
=
cache
.
get
(
key
)
if
amount
is
None
:
amount
=
get_donated_amount_from_api
(
self
.
portal_project_id
)
if
amount
is
not
None
:
# save amount into database to be used if next API calls fails
self
.
donated_amount
=
amount
self
.
save
()
cache
.
set
(
key
,
amount
)
self
.
_donated_amount
=
self
.
donated_amount
or
0
return
self
.
_donated_amount
@property
def
donated_percentage
(
self
):
...
...
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