Skip to content

Commit

Permalink
Release 0.5. Includes test fixtures for usecase-1 (city wide procurem…
Browse files Browse the repository at this point in the history
…ent portfolio and associated emissions)
  • Loading branch information
open-risk committed May 26, 2022
1 parent 7c33a8e commit 1db6686
Show file tree
Hide file tree
Showing 16 changed files with 42,274 additions and 15 deletions.
20 changes: 20 additions & 0 deletions dumpfixtures-usecase-1.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash
source ./venv/bin/activate

python3 manage.py dumpdata --format=json --indent 2 portfolio.PortfolioManager -o portfolio/fixtures/usecase-1/PortfolioManager.json

python3 manage.py dumpdata --format=json --indent 2 portfolio.ProjectPortfolio -o portfolio/fixtures/usecase-1/ProjectPortfolio.json

python3 manage.py dumpdata --format=json --indent 2 portfolio.Project -o portfolio/fixtures/usecase-1/Project.json

python3 manage.py dumpdata --format=json --indent 2 portfolio.Contractor -o portfolio/fixtures/usecase-1/Contractor.json

python3 manage.py dumpdata --format=json --indent 2 portfolio.ProjectActivity -o portfolio/fixtures/usecase-1/ProjectActivity.json

python3 manage.py dumpdata --format=json --indent 2 portfolio.ProjectEvent -o portfolio/fixtures/usecase-1/ProjectEvent.json

python3 manage.py dumpdata --format=json --indent 2 portfolio.ProjectAsset -o portfolio/fixtures/usecase-1/ProjectAsset.json

python3 manage.py dumpdata --format=json --indent 2 portfolio.GPPEmissionsSource -o portfolio/fixtures/usecase-1/GPPEmissionsSource.json

python3 manage.py dumpdata --format=json --indent 2 portfolio.MultiAreaSource -o portfolio/fixtures/usecase-1/MultiAreaSource.json
12 changes: 12 additions & 0 deletions loadfixtures-usecase-1.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash
source ./venv/bin/activate

python3 manage.py loaddata portfolio/fixtures/usecase-1/PortfolioManager.json
python3 manage.py loaddata portfolio/fixtures/usecase-1/ProjectPortfolio.json
python3 manage.py loaddata portfolio/fixtures/usecase-1/Project.json
python3 manage.py loaddata portfolio/fixtures/usecase-1/Contractor.json
python3 manage.py loaddata portfolio/fixtures/usecase-1/ProjectActivity.json
python3 manage.py loaddata portfolio/fixtures/usecase-1/ProjectAsset.json
python3 manage.py loaddata portfolio/fixtures/usecase-1/ProjectEvent.json
python3 manage.py loaddata portfolio/fixtures/usecase-1/GPPEmissionsSource.json
python3 manage.py loaddata portfolio/fixtures/usecase-1/MultiAreaSource.json
6 changes: 3 additions & 3 deletions portfolio/Asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

class ProjectAsset(models.Model):
"""
The Project Asset model holds asset specific data for each real asset, facility (plant, infrastructure etc) that
The Project Asset model holds asset specific data for each real asset, facility (plant, infrastructure etc.) that
is part of a Portfolio or Inventory or a Project - which may or may not be financed.
A Project Asset will in general be associated with one or more emissions sources.
Expand Down Expand Up @@ -68,7 +68,7 @@ class ProjectAsset(models.Model):

# LINKS / RELATIONS

project = models.ForeignKey('Project', blank=True, null=True, on_delete=models.CASCADE)
project = models.ForeignKey('Project', blank=True, null=True, on_delete=models.CASCADE, help_text="The project to which this asset belongs")

legal_owner = models.TextField(blank=True, null=True,
help_text='Standard Description. <a class="risk_manual_url" href="https://www.openriskmanual.org/wiki">Documentation</a>')
Expand All @@ -78,7 +78,7 @@ class ProjectAsset(models.Model):
#

asset_ghg_emissions = models.FloatField(blank=True, null=True,
help_text='This stores the aggregate current annualized emissions of an asset in GO2 equivalents')
help_text='This field stores the aggregate current annualized emissions of an asset in CO2 equivalents')

#
# Geographic Information (Geometries stored separately)
Expand Down
19 changes: 11 additions & 8 deletions portfolio/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ class ProjectAssetAdmin(admin.ModelAdmin):
view_on_site = False
save_as = True
search_fields = ['name']
list_display = ('asset_identifier', 'asset_class', 'asset_ghg_emissions', 'project')
list_filter = ('asset_class', 'project')
date_hierarchy = ('creation_date')

fieldsets = (
('Identification', {
Expand Down Expand Up @@ -195,13 +195,7 @@ def project__budget(self, obj):
return obj.project.project_budget


@admin.register(Project)
class ProjectAdmin(admin.ModelAdmin):
"""Project admin"""
view_on_site = False
save_as = True
list_display = ('pk', 'project_title', 'cpv_code', 'project_budget', 'project_category')
date_hierarchy = ('creation_date')



@admin.register(ProjectEvent)
Expand Down Expand Up @@ -229,6 +223,15 @@ class SecondaryEffectAdmin(admin.ModelAdmin):
date_hierarchy = ('creation_date')


@admin.register(Project)
class ProjectAdmin(admin.ModelAdmin):
"""Project admin"""
view_on_site = False
save_as = True
search_fields = ['project_title']
list_display = ('pk', 'project_title', 'cpv_code', 'project_budget', 'project_category')
list_filter = ('project_category',)

@admin.register(ProjectActivity)
class ProjectActivityAdmin(admin.ModelAdmin):
"""Project Activity admin"""
Expand Down
Loading

0 comments on commit 1db6686

Please sign in to comment.