SciPost Code Repository
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SciPost
Manage
Activity
Members
Labels
Plan
Issues
118
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
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
Code review analytics
Issue analytics
Insights
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
SciPost
SciPost
Commits
29d47168
Commit
29d47168
authored
5 months ago
by
George Katsikas
Browse files
Options
Downloads
Patches
Plain Diff
add country-level nap data
parent
08e88284
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
scipost_django/finances/templates/finances/_hx_country_level_data.html
+6
-0
6 additions, 0 deletions
...o/finances/templates/finances/_hx_country_level_data.html
scipost_django/finances/views.py
+30
-3
30 additions, 3 deletions
scipost_django/finances/views.py
with
36 additions
and
3 deletions
scipost_django/finances/templates/finances/_hx_country_level_data.html
+
6
−
0
View file @
29d47168
...
...
@@ -7,6 +7,7 @@
<thead>
<tr>
<th></th>
<th
style=
"text-align: right;"
>
NAP
</th>
<th
style=
"text-align: right;"
>
Expenditures
</th>
<th
style=
"text-align: right;"
>
Subsidy income
</th>
<th
style=
"text-align: right;"
>
Impact on reserves
</th>
...
...
@@ -15,6 +16,7 @@
<tbody>
<tr
class=
"bg-light"
>
<td>
Cumulative
</td>
<td
style=
"text-align: right;"
>
{{ cumulative.nap }}
</td>
<td
style=
"text-align: right;"
>
€
{{ cumulative.expenditures }}
</td>
<td
style=
"text-align: right;"
>
€
{{ cumulative.subsidy_income }}
</td>
<td
style=
"text-align: right;"
>
€
{{ cumulative.impact_on_reserves }}
</td>
...
...
@@ -22,6 +24,7 @@
{% for year, val in per_year.items %}
<tr>
<td>
{{ year }}
</td>
<td
style=
"text-align: right;"
>
{{ val.nap }}
</td>
<td
style=
"text-align: right;"
>
€
{{ val.expenditures }}
</td>
<td
style=
"text-align: right;"
>
€
{{ val.subsidy_income }}
</td>
<td
style=
"text-align: right;"
>
€
{{ val.impact_on_reserves }}
</td>
...
...
@@ -42,6 +45,7 @@
<tr>
<th></th>
<th></th>
<th
style=
"text-align: right;"
>
NAP
</th>
<th
style=
"text-align: right;"
>
Expenditures
</th>
<th
style=
"text-align: right;"
>
Subsidy Income
</th>
<th
style=
"text-align: right;"
>
Impact on reserves
</th>
...
...
@@ -51,6 +55,7 @@
<tr
class=
"bg-light"
>
<td>
Total
</td>
<td></td>
<td
style=
"text-align: right;"
>
{{ cumulative.nap }}
</td>
<td
style=
"text-align: right;"
>
{{ cumulative.expenditures }}
</td>
<td
style=
"text-align: right;"
>
{{ cumulative.subsidy_income }}
</td>
<td
style=
"text-align: right;"
>
{{ cumulative.impact_on_reserves }}
</td>
...
...
@@ -60,6 +65,7 @@
<tr>
<td><a
href=
"https://{{ request.get_host }}{{ organization.get_absolute_url }}"
>
{{ organization }}
</a></td>
<td>
{{ organization.get_orgtype_display }}
</td>
<td
style=
"text-align: right;"
>
{{ organization.cf_balance_info.cumulative.nap }}
</td>
<td
style=
"text-align: right;"
>
{{ organization.cf_balance_info.cumulative.expenditures }}
</td>
<td
style=
"text-align: right;"
>
{{ organization.cf_balance_info.cumulative.subsidy_income }}
</td>
<td
style=
"text-align: right;"
>
{{ organization.cf_balance_info.cumulative.impact_on_reserves }}
</td>
...
...
This diff is collapsed.
Click to expand it.
scipost_django/finances/views.py
+
30
−
3
View file @
29d47168
...
...
@@ -3,13 +3,13 @@ __license__ = "AGPL v3"
import
datetime
from
itertools
import
accumulate
from
itertools
import
accumulate
,
chain
import
mimetypes
from
dal
import
autocomplete
from
django.contrib.contenttypes.models
import
ContentType
from
django.db
import
models
from
django.db.models
import
Q
,
Count
,
OuterRef
,
Subquery
from
django.db.models
import
Q
,
Count
,
Exists
,
OuterRef
,
Subquery
from
django.db.models.functions
import
Coalesce
from
django.template.response
import
TemplateResponse
from
django.utils.html
import
format_html
...
...
@@ -17,6 +17,7 @@ import matplotlib
from
common.views
import
HXDynselAutocomplete
,
HXDynselSelectOptionView
from
finances.constants
import
SUBSIDY_TYPE_SPONSORSHIPAGREEMENT
,
SUBSIDY_PROMISED
from
journals.models.publication
import
PublicationAuthorsTable
matplotlib
.
use
(
"
Agg
"
)
import
matplotlib.pyplot
as
plt
...
...
@@ -281,14 +282,40 @@ def _hx_country_level_data(request, country):
context
=
{
"
country
"
:
country
,
"
organizations
"
:
organizations
,
"
cumulative
"
:
{
"
subsidy_income
"
:
0
,
"
expenditures
"
:
0
,
"
impact_on_reserves
"
:
0
},
"
cumulative
"
:
{
"
subsidy_income
"
:
0
,
"
expenditures
"
:
0
,
"
impact_on_reserves
"
:
0
,
"
nap
"
:
len
(
set
(
chain
.
from_iterable
([
o
.
get_publications
()
for
o
in
organizations
]))
),
},
"
per_year
"
:
{},
}
def
get_yearly_nap_of_country
(
country
:
str
)
->
dict
[
int
,
int
]:
return
dict
(
Publication
.
objects
.
annotate
(
has_author_of_country
=
Exists
(
PublicationAuthorsTable
.
objects
.
filter
(
publication
=
OuterRef
(
"
pk
"
),
affiliations__country
=
country
)
)
)
.
filter
(
has_author_of_country
=
True
)
.
values
(
"
publication_date__year
"
)
.
annotate
(
nr
=
Count
(
"
publication_date__year
"
))
.
order_by
(
"
publication_date__year
"
)
.
values_list
(
"
publication_date__year
"
,
"
nr
"
)
)
country_yearly_nap
=
get_yearly_nap_of_country
(
country
)
for
year
in
pubyears
:
context
[
"
per_year
"
][
year
]
=
{
"
subsidy_income
"
:
0
,
"
expenditures
"
:
0
,
"
impact_on_reserves
"
:
0
,
"
nap
"
:
country_yearly_nap
.
get
(
int
(
year
),
0
),
}
for
organization
in
organizations
.
all
():
for
key
in
(
"
subsidy_income
"
,
"
expenditures
"
,
"
impact_on_reserves
"
):
...
...
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