Skip to content

Commit

Permalink
Bump to Python 3.10
Browse files Browse the repository at this point in the history
  • Loading branch information
open-risk committed Sep 14, 2023
1 parent c1dc067 commit d422488
Show file tree
Hide file tree
Showing 91 changed files with 1,951 additions and 1,714 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/django.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
strategy:
max-parallel: 4
matrix:
python-version: [3.9]
python-version: [3.10]

steps:
- uses: actions/checkout@v2
Expand Down
12 changes: 8 additions & 4 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@ v0.8 (Upcoming)
-----------------
* Scripts for deleting user data from database

v0.7.1 (14-09-2023)
-------------------
* Update to Python 3.10

v0.7 (09-06-2023)
-----------------
-------------------
* Enhancements: New models supporting Scope 2 reporting
* Fixtures for various use cases
* Adopt pytest and basic coverage of all models
Expand All @@ -30,12 +34,12 @@ v0.4 (22-04-2022)
* Earth Day 2022 Release
* Major enhancements include procurement data framework and portfolio policy framework

v0.32 (31-03-2022)
v0.3.2 (31-03-2022)
-------------------
* Integration of Procurement data models / workflows

v0.314 (14-03-2022)
-------------------
v0.3.14 (14-03-2022)
--------------------
* Pi Day pre-release
* PCAF for Mortgages

Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM python:3.9-slim
FROM python:3.10-slim
LABEL author="Open Risk <www.openriskmanagement.com>"
LABEL version="0.4"
LABEL version="0.7.1"
LABEL description="Equinox: Open Source Sustainable Porfolio Management"
LABEL maintainer="[email protected]"
EXPOSE 8080
Expand Down
7 changes: 2 additions & 5 deletions SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

## Supported Versions

Use this section to tell people about which versions of your project are
currently being supported with security updates.
Use this section to tell people about which versions of your project are currently being supported with security updates.

| Version | Supported |
| ------- | ------------------ |
Expand All @@ -16,6 +15,4 @@ currently being supported with security updates.

Use this section to tell people how to report a vulnerability.

Tell them where to go, how often they can expect to get an update on a
reported vulnerability, what to expect if the vulnerability is accepted or
declined, etc.
Tell them where to go, how often they can expect to get an update on a reported vulnerability, what to expect if the vulnerability is accepted or declined, etc.
1 change: 1 addition & 0 deletions createadmin.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
# !/usr/bin/env python

import os

import django

os.environ['DJANGO_SETTINGS_MODULE'] = 'equinox.settings'
Expand Down
3 changes: 1 addition & 2 deletions createcategories.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

# !/usr/bin/env python
import os

import django

os.environ['DJANGO_SETTINGS_MODULE'] = 'equinox.settings'
Expand Down Expand Up @@ -47,5 +48,3 @@
node = get(ted_node.pk).add_child(name='WORKS')
get(node.pk).add_sibling(name='SERVICES')
get(node.pk).add_sibling(name='SUPPLIES')


3 changes: 2 additions & 1 deletion createsectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

#!/usr/bin/env python
# !/usr/bin/env python
import os

import django

os.environ['DJANGO_SETTINGS_MODULE'] = 'equinox.settings'
Expand Down
4 changes: 2 additions & 2 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

django.setup()

__version__ = '0.7'
__version__ = '0.7.1'

# -- Project information -----------------------------------------------------

Expand Down Expand Up @@ -182,7 +182,7 @@
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'equinox', 'Equinox Documentation',
author, 'Open Risk', 'Sustainable Finance Reporting Platform.',
author, 'Open Risk', 'Sustainable Finance Reporting Platform',
'Miscellaneous'),
]

Expand Down
Binary file modified docs/source/equinox-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions docs/source/setup.rst
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,12 @@ Step 1: Download the github sources to your preferred directory
cd equinox
Step 2: Create a virtualenv for Python >= 3.9.
Step 2: Create a virtualenv for Python >= 3.10.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

It is advisable to run the equinox platform via a Python *virtualenv* so as not to interfere with your system's own Python distribution.

.. note:: If you do not have Python 3.9 please install it first into your system (either as a replacement of your previous 3.X version or as an alternative).
.. note:: If you do not have Python 3.10 please install it first into your system (either as a replacement of your previous 3.X version or as an alternative).

.. code:: bash
Expand All @@ -88,7 +88,7 @@ It is advisable to run the equinox platform via a Python *virtualenv* so as not
Step 3: Install the required python dependencies
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The core dependency of Equinox is *Django* (and its own dependencies). In addition it uses the *Jazzmin* skin as the admin interface and various Python libraries such as *Numpy* and *Pandas* are also required for calculations. You install all dependencies issuing the following:
The core dependency of Equinox is *Django* (and its own dependencies). In addition Equinox uses the *Jazzmin* skin as the admin interface and various Python libraries such as *Numpy* and *Pandas* are also required for calculations. You install all dependencies issuing the following:

.. code:: bash
Expand Down Expand Up @@ -133,7 +133,7 @@ In the next step we create an Equinox superuser (administrator).

.. code:: bash
python3 createadmin
python3 createadmin.py
Step 7: Collect static files
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down
9 changes: 4 additions & 5 deletions equinox/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,16 @@
from rest_framework import status
from rest_framework.decorators import api_view, permission_classes
from rest_framework.response import Response
from rest_framework.parsers import JSONParser
from rest_framework.reverse import reverse

from risk.Scorecard import Scorecard
from equinox.serializers import ScorecardSerializer, ScorecardDetailSerializer
from portfolio.Revenue import Revenue
from portfolio.Sponsor import Sponsor
from portfolio.Contractor import Contractor
from portfolio.Loan import Loan
from portfolio.Operator import Operator
from portfolio.Revenue import Revenue
from portfolio.Sponsor import Sponsor
from portfolio.Stakeholders import Stakeholders
from portfolio.Loan import Loan
from risk.Scorecard import Scorecard


@api_view(['GET'])
Expand Down
3 changes: 2 additions & 1 deletion manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

#!/usr/bin/env python
# !/usr/bin/env python
"""Django's command-line utility for administrative tasks."""

import os
import sys

Expand Down
1 change: 1 addition & 0 deletions policy/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def export2xml(self, request, queryset):
serializers.serialize("xml", queryset, stream=response)
return response


class DataSeriesAdmin(admin.ModelAdmin):
formfield_overrides = {
JSONField: {'widget': PrettyJSONWidget(attrs={'initiaĺ': 'parsed'})},
Expand Down
4 changes: 2 additions & 2 deletions policy/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@


class DashBoardParams(models.Model):

# key value store for policy dashboard parameters
# dataseries statistics etc

Expand Down Expand Up @@ -112,7 +111,8 @@ class DataSeries(models.Model):
status = models.CharField(null=True, blank=True, max_length=50)

# last observation date tracked separately for filtering purposes
last_observation_date = models.DateTimeField(null=True, blank=True, default=datetime(1916, 9, 25, 17, 22, 22, 90879))
last_observation_date = models.DateTimeField(null=True, blank=True,
default=datetime(1916, 9, 25, 17, 22, 22, 90879))

# nature of field (categorical, ordinal, numerical)
field_type = models.CharField(null=True, blank=True, default="numerical", max_length=50)
Expand Down
3 changes: 1 addition & 2 deletions policy/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,9 @@
DATA_PATH = os.path.join(EQUINOX_DIR, 'policy/fixtures/policy_data/')
ROOT_DIR = DATA_PATH


# Output files:
dataseries_file = ROOT_DIR + "dataseries.latest.json"
dimensions_file = ROOT_DIR + "dimensions.latest.json"
dimensions_file = ROOT_DIR + "dimensions.latest.json"
dataseries_update_file = ROOT_DIR + "dataseries.update.json"
metadata_file = ROOT_DIR + 'wikidata_extract_19_05_2020.json'

Expand Down
20 changes: 20 additions & 0 deletions policy/tests.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
# Copyright (c) 2020 - 2023 Open Risk (https://www.openriskmanagement.com)
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

from django.test import TestCase

from django.test import Client
Expand Down
11 changes: 3 additions & 8 deletions portfolio/Asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,15 +445,14 @@ class PowerPlant(models.Model):
# IDENTIFICATION & CATEGORIZATION

production_device_number = models.CharField(max_length=80, blank=True, null=True,
help_text='Production Device Number (GSRN)')
help_text='Production Device Number (GSRN)')

production_device_name = models.CharField(max_length=80, blank=True, null=True,
help_text='Name of Production Device')
help_text='Name of Production Device')

description = models.TextField(blank=True, null=True,
help_text='Additional information about the Asset')


#
# GHG Data
#
Expand All @@ -463,12 +462,8 @@ class PowerPlant(models.Model):

# OTHER


date_of_commisioning = models.DateField(blank=True, null=True,
help_text='Commissioning date of the power plant. <a class="risk_manual_url" href="https://www.openriskmanual.org/wiki">Documentation</a>')



help_text='Commissioning date of the power plant. <a class="risk_manual_url" href="https://www.openriskmanual.org/wiki">Documentation</a>')

#
# BOOKKEEPING FIELDS
Expand Down
7 changes: 3 additions & 4 deletions portfolio/Borrower.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ class Borrower(models.Model):
"""


#
# IDENTIFICATION FIELDS
#
Expand Down Expand Up @@ -118,13 +117,13 @@ class Borrower(models.Model):
help_text='Insolvency Practitioner Reference" href="https://www.openriskmanual.org/wiki/EBA_NPL.Counterparty.Insolvency_Practitioner_Reference">Documentation</a>')

proof_of_claim_filed_by_the_seller = models.BooleanField(blank=True, null=True,
help_text='Proof of Claim Filed by the seller. <a class="risk_manual_url" href="https://www.openriskmanual.org/wiki/EBA_NPL.Counterparty.Proof_of_Claim_Filed_by_the_seller">Documentation</a>')
help_text='Proof of Claim Filed by the seller. <a class="risk_manual_url" href="https://www.openriskmanual.org/wiki/EBA_NPL.Counterparty.Proof_of_Claim_Filed_by_the_seller">Documentation</a>')

distribution_made_to_the_seller = models.BooleanField(blank=True, null=True,
help_text='https://www.openriskmanual.org/wiki/EBA_NPL.Counterparty.Distribution_made_to_the_Seller. <a class="risk_manual_url" href="https://www.openriskmanual.org/wiki/EBA_NPL.Counterparty.Country_of_Registered_Location">Documentation</a>')
help_text='https://www.openriskmanual.org/wiki/EBA_NPL.Counterparty.Distribution_made_to_the_Seller. <a class="risk_manual_url" href="https://www.openriskmanual.org/wiki/EBA_NPL.Counterparty.Country_of_Registered_Location">Documentation</a>')

notice_for_procedure_termination = models.BooleanField(blank=True, null=True,
help_text='Indicator as to whether the notice of the end of the procedure has been given to the seller. <a class="risk_manual_url" href="https://www.openriskmanual.org/wiki/EBA_NPL.Counterparty.Notice_for_Procedure_Termination">Documentation</a>')
help_text='Indicator as to whether the notice of the end of the procedure has been given to the seller. <a class="risk_manual_url" href="https://www.openriskmanual.org/wiki/EBA_NPL.Counterparty.Notice_for_Procedure_Termination">Documentation</a>')

cross_collateralisation_for_counterparty = models.IntegerField(blank=True, null=True,
choices=CROSS_COLLATERALISATION_FOR_COUNTERPARTY_CHOICES,
Expand Down
39 changes: 20 additions & 19 deletions portfolio/Certificate.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@

from django.db import models
from django.urls import reverse
from portfolio.Counterparty import Counterparty
from portfolio.Asset import PowerPlant


class Certificate(models.Model):
"""
Expand All @@ -32,32 +31,38 @@ class Certificate(models.Model):

# IDENTIFICATION
certificate_identifier = models.CharField(max_length=80, blank=True, null=True,
help_text='Unique EECS Certificate Number.<a class="risk_manual_url" href="https://www.openriskmanual.org/wiki/EECS_Certficate_Number">Documentation</a>')
help_text='Unique EECS Certificate Number.<a class="risk_manual_url" href="https://www.openriskmanual.org/wiki/EECS_Certficate_Number">Documentation</a>')

# LINKS
seller = models.ForeignKey('Counterparty', blank=True, null=True, on_delete=models.CASCADE, related_name='Seller', help_text='EECS Account Holder (Certificate Seller). <a class="risk_manual_url" href="https://www.openriskmanual.org/wiki/EECS_Account_Holder">Documentation</a>')
seller = models.ForeignKey('Counterparty', blank=True, null=True, on_delete=models.CASCADE, related_name='Seller',
help_text='EECS Account Holder (Certificate Seller). <a class="risk_manual_url" href="https://www.openriskmanual.org/wiki/EECS_Account_Holder">Documentation</a>')

buyer = models.ForeignKey('Counterparty', blank=True, null=True, on_delete=models.CASCADE, related_name='Buyer', help_text='EECS Account Holder (Certificate Buyer). <a class="risk_manual_url" href="https://www.openriskmanual.org/wiki/EECS_Account_Holder">Documentation</a>')
buyer = models.ForeignKey('Counterparty', blank=True, null=True, on_delete=models.CASCADE, related_name='Buyer',
help_text='EECS Account Holder (Certificate Buyer). <a class="risk_manual_url" href="https://www.openriskmanual.org/wiki/EECS_Account_Holder">Documentation</a>')

production_device = models.ForeignKey('PowerPlant', blank=True, null=True, on_delete=models.CASCADE, help_text='EECS Production Device. <a class="risk_manual_url" href="https://www.openriskmanual.org/wiki/EECS_Production_Device">Documentation</a>')
production_device = models.ForeignKey('PowerPlant', blank=True, null=True, on_delete=models.CASCADE,
help_text='EECS Production Device. <a class="risk_manual_url" href="https://www.openriskmanual.org/wiki/EECS_Production_Device">Documentation</a>')

# CERTIFICATE DATA

# production period
production_start = models.DateField(blank=True, null=True, help_text='EECS Production Period Start. <a class="risk_manual_url" href="https://www.openriskmanual.org/wiki/EECS_Production_Period">Documentation</a>')
production_start = models.DateField(blank=True, null=True,
help_text='EECS Production Period Start. <a class="risk_manual_url" href="https://www.openriskmanual.org/wiki/EECS_Production_Period">Documentation</a>')

production_end = models.DateField(blank=True, null=True, help_text='EECS Production Period End. <a class="risk_manual_url" href="https://www.openriskmanual.org/wiki/EECS_Production_Period">Documentation</a>')
production_end = models.DateField(blank=True, null=True,
help_text='EECS Production Period End. <a class="risk_manual_url" href="https://www.openriskmanual.org/wiki/EECS_Production_Period">Documentation</a>')

# technology
technology_code = models.CharField(max_length=80, blank=True, null=True,
help_text='EECS Technology Code. <a class="risk_manual_url" href="https://www.openriskmanual.org/wiki/EECS_Technology_Code">Documentation</a>')

# delivery date
delivery_date = models.DateField(blank=True, null=True, help_text='EECS Delivery Date. <a class="risk_manual_url" href="https://www.openriskmanual.org/wiki/EECS_Delivery_Date">Documentation</a>')
delivery_date = models.DateField(blank=True, null=True,
help_text='EECS Delivery Date. <a class="risk_manual_url" href="https://www.openriskmanual.org/wiki/EECS_Delivery_Date">Documentation</a>')

# quantity
contract_quantity = models.IntegerField(default=1, blank=True, null=True,
help_text='EECS Contract Quantity. <a class="risk_manual_url" href="https://www.openriskmanual.org/wiki/EECS_Contract_Quantity">Documentation</a>')
help_text='EECS Contract Quantity. <a class="risk_manual_url" href="https://www.openriskmanual.org/wiki/EECS_Contract_Quantity">Documentation</a>')

# contract price

Expand All @@ -67,28 +72,24 @@ class Certificate(models.Model):
# EECS DOMAIN

production_country = models.CharField(max_length=80, blank=True, null=True,
help_text='Country / Countries of Production. <a class="risk_manual_url" href="https://www.openriskmanual.org/wiki/EECS_Production_Country">Documentation</a>')
help_text='Country / Countries of Production. <a class="risk_manual_url" href="https://www.openriskmanual.org/wiki/EECS_Production_Country">Documentation</a>')

production_issuing_body = models.CharField(max_length=80, blank=True, null=True,
help_text='Authorised Issuing Body of the Country / Countries of Production. <a class="risk_manual_url" href="https://www.openriskmanual.org/wiki/EECS_Issuing_Body">Documentation</a>')
help_text='Authorised Issuing Body of the Country / Countries of Production. <a class="risk_manual_url" href="https://www.openriskmanual.org/wiki/EECS_Issuing_Body">Documentation</a>')

delivery_country = models.CharField(max_length=80, blank=True, null=True,
help_text='Country of Delivery')

deliver_issuing_body = models.CharField(max_length=80, blank=True, null=True,
help_text='Authorised Issuing Body of Country of Delivery. <a class="risk_manual_url" href="https://www.openriskmanual.org/wiki/EECS_Issuing_Body">Documentation</a>')

help_text='Authorised Issuing Body of Country of Delivery. <a class="risk_manual_url" href="https://www.openriskmanual.org/wiki/EECS_Issuing_Body">Documentation</a>')

# OTHER


support_type = models.CharField(max_length=40, blank=True, null=True,
help_text='Type of support (no support, production support, etc.)')

help_text='Type of support (no support, production support, etc.)')

ics = models.CharField(max_length=40, blank=True, null=True,
help_text='Independent Criteria Scheme')

help_text='Independent Criteria Scheme')

#
# BOOKKEEPING FIELDS
Expand Down
Loading

0 comments on commit d422488

Please sign in to comment.