Skip to content

Commit

Permalink
Release/uat/3.7.0 (#215)
Browse files Browse the repository at this point in the history
* Revert adding azure-monitor-opentelemetry==1.0.0b13 to resolve No module named azure.monitor issue

* updated empty value type (#141)

* Feature/160752/stages phases (#142)

* add new column - feature key phases_stages

* create a mapping between phases and stages

* updated styles to work on all browsers (#143)

* feat/Add azure-monitor-opentelemetry to requirements

* feat/Add configure_azure_monitor to settings.py

* chore/Remove configure_azure_monitor and implement older approach to identify compatibility

* chore/Remove opentelemetry from settings.py

* chore/Code cleanup

* Dev 157615 160826 162116 163295 163762 164563 (#144)

* Adding env.var applicationsightsConnectionSrting for BE

* Feature/163742/enable ootb monitoring capabilities (#135)

* feat/Add azure-monitor-opentelemetry to requirements

* feat/Add opentelemetry to application settings

* chore/Change env from dev to tst

* chore/Rollback env from tst to dev

* Feature/157615/allow retrieval of all initiatives published and unpublished from api revision (#136)

* feat/Add published query parameter to the get_queryset

- if we do not provide an additional query parameter, then the default behavior will remain the same and the endpoint will return only the published ones.
- If we provide the additional query parameter published=0, then the endpoint will return only the unpublished ones.
- If we provide the additional query parameter published=1, then the endpoint will return both the unpublished and published ones.

* feat/Change published-unpublished to match new criteria

- Change get_queryset method to its original status, but removing the unpublished.
- Add logic to support published/unpublished parameters.

* chore/Refactor publised-unpublished cases in a more pythonic way

* Feature/163295/add swimlanes at phase board (#137)

* table with new story features

* code refactoring

* removed overflow-x from el-select-tags (#138)

* hide square logo and change menu height (#139)

* Feature/160826/group innovation portfolio solution details section (#140)

* solutions edit/create new Innovation Portfolios group, portfolios table key bug fix

* updated solution view with new Innovation portfolios card section

* Revert adding azure-monitor-opentelemetry==1.0.0b13 to resolve No module named azure.monitor issue

* updated empty value type (#141)

* Feature/160752/stages phases (#142)

* add new column - feature key phases_stages

* create a mapping between phases and stages

* updated styles to work on all browsers (#143)

* feat/Add azure-monitor-opentelemetry to requirements

* feat/Add configure_azure_monitor to settings.py

* chore/Remove configure_azure_monitor and implement older approach to identify compatibility

* chore/Remove opentelemetry from settings.py

* chore/Code cleanup

* chore/Rollback phases stages

- Rollback dbd9139 add new column - feature key phases_stages
- Rollback d665c3f create a mapping between phases and stages

Remove additions for item 160752 to move selected items to tst environment

---------

Co-authored-by: Diogenis Petropoulos <diogenis,petropoulos@sword-group.com>
Co-authored-by: ladeniva2 <122989825+ladeniva2@users.noreply.github.com>
Co-authored-by: Alexa-Laf <131444412+Alexa-Laf@users.noreply.github.com>

* Feature/163742/enable ootb monitoring capabilities (#146)

* feat/Add azure-monitor-opentelemetry to requirements

* feat/Add opentelemetry to application settings

* chore/Change env from dev to tst

* chore/Rollback env from tst to dev

* feat/Add internal_ips to fetch the pod internal ip

* chore/Rename azure folder to azure_services

* chore/Remove reduntant import from settings

* chore/Change configure_azure_monitor signature to include named argument

* feat/Change userprofile list to autocomplete field (#145)

- Add list with autocomplete search bar in the edit technology platform admin page.
- Add name as the search bar option.

* rename stage_name and phase_name to stage_label and phase_label (#147)

* feature/161336/initiatives-by-stage-board  added stage table and table switch (#148)

* feat/Switch nextLink to deltaLink mechanism

* feat/Add get and save last delta link mechanism

* chore/Refactor delta link generation and store method

- Add new DeltaLink model to let Django handle the table creation/update mechanism.
- Change get_last_delta_link and save_delta_link to follow the same pattern.

* Feature/refactor aad user fetch and update mechanism (#149)

* feat/Switch nextLink to deltaLink mechanism

* feat/Add get and save last delta link mechanism

* chore/Refactor delta link generation and store method

- Add new DeltaLink model to let Django handle the table creation/update mechanism.
- Change get_last_delta_link and save_delta_link to follow the same pattern.

* chore/Add migration file for deltalink

* chore/Add log statements to debug deltalink response

* chore/Remove redundant log statements

* chore/Refactor deltalinks and logger

- Refactor delta links to accept more than one page.
- Change azure logger from info to warning level to unclutter the django logs

* Revert commits 2ed8b75 to 46a5dcf

* Bugfix/163402/dashboarding system error (#150)

* problem_statements and portfolios are now lists containing only unique ids

* created a django management command to update the problematic solution logs (may and june 2023)

* fixed error in comment

* custom management command will now be run on deployment

* updated to fix problematic entries in all solution log rows

* Merge dev to tst (#152)

* Adding env.var applicationsightsConnectionSrting for BE

* Feature/163742/enable ootb monitoring capabilities (#135)

* feat/Add azure-monitor-opentelemetry to requirements

* feat/Add opentelemetry to application settings

* chore/Change env from dev to tst

* chore/Rollback env from tst to dev

* Feature/157615/allow retrieval of all initiatives published and unpublished from api revision (#136)

* feat/Add published query parameter to the get_queryset

- if we do not provide an additional query parameter, then the default behavior will remain the same and the endpoint will return only the published ones.
- If we provide the additional query parameter published=0, then the endpoint will return only the unpublished ones.
- If we provide the additional query parameter published=1, then the endpoint will return both the unpublished and published ones.

* feat/Change published-unpublished to match new criteria

- Change get_queryset method to its original status, but removing the unpublished.
- Add logic to support published/unpublished parameters.

* chore/Refactor publised-unpublished cases in a more pythonic way

* Feature/163295/add swimlanes at phase board (#137)

* table with new story features

* code refactoring

* removed overflow-x from el-select-tags (#138)

* hide square logo and change menu height (#139)

* Feature/160826/group innovation portfolio solution details section (#140)

* solutions edit/create new Innovation Portfolios group, portfolios table key bug fix

* updated solution view with new Innovation portfolios card section

* Revert adding azure-monitor-opentelemetry==1.0.0b13 to resolve No module named azure.monitor issue

* updated empty value type (#141)

* Feature/160752/stages phases (#142)

* add new column - feature key phases_stages

* create a mapping between phases and stages

* updated styles to work on all browsers (#143)

* feat/Add azure-monitor-opentelemetry to requirements

* feat/Add configure_azure_monitor to settings.py

* chore/Remove configure_azure_monitor and implement older approach to identify compatibility

* chore/Remove opentelemetry from settings.py

* chore/Code cleanup

* Feature/163742/enable ootb monitoring capabilities (#146)

* feat/Add azure-monitor-opentelemetry to requirements

* feat/Add opentelemetry to application settings

* chore/Change env from dev to tst

* chore/Rollback env from tst to dev

* feat/Add internal_ips to fetch the pod internal ip

* chore/Rename azure folder to azure_services

* chore/Remove reduntant import from settings

* chore/Change configure_azure_monitor signature to include named argument

* feat/Change userprofile list to autocomplete field (#145)

- Add list with autocomplete search bar in the edit technology platform admin page.
- Add name as the search bar option.

* rename stage_name and phase_name to stage_label and phase_label (#147)

* feature/161336/initiatives-by-stage-board  added stage table and table switch (#148)

* feat/Switch nextLink to deltaLink mechanism

* feat/Add get and save last delta link mechanism

* chore/Refactor delta link generation and store method

- Add new DeltaLink model to let Django handle the table creation/update mechanism.
- Change get_last_delta_link and save_delta_link to follow the same pattern.

* Feature/refactor aad user fetch and update mechanism (#149)

* feat/Switch nextLink to deltaLink mechanism

* feat/Add get and save last delta link mechanism

* chore/Refactor delta link generation and store method

- Add new DeltaLink model to let Django handle the table creation/update mechanism.
- Change get_last_delta_link and save_delta_link to follow the same pattern.

* chore/Add migration file for deltalink

* chore/Add log statements to debug deltalink response

* chore/Remove redundant log statements

* chore/Refactor deltalinks and logger

- Refactor delta links to accept more than one page.
- Change azure logger from info to warning level to unclutter the django logs

* Revert commits 2ed8b75 to 46a5dcf

---------

Co-authored-by: Diogenis Petropoulos <diogenis,petropoulos@sword-group.com>
Co-authored-by: ladeniva2 <122989825+ladeniva2@users.noreply.github.com>
Co-authored-by: Alexa-Laf <131444412+Alexa-Laf@users.noreply.github.com>

* feat/Add delta to graph url

* chore/Remove redundant logging statements

* Rollback to pre-deltaLink mechanism

* chore/Remove redundant files

* Merge dev to tst (#154)

* Adding env.var applicationsightsConnectionSrting for BE

* Feature/163742/enable ootb monitoring capabilities (#135)

* feat/Add azure-monitor-opentelemetry to requirements

* feat/Add opentelemetry to application settings

* chore/Change env from dev to tst

* chore/Rollback env from tst to dev

* Feature/157615/allow retrieval of all initiatives published and unpublished from api revision (#136)

* feat/Add published query parameter to the get_queryset

- if we do not provide an additional query parameter, then the default behavior will remain the same and the endpoint will return only the published ones.
- If we provide the additional query parameter published=0, then the endpoint will return only the unpublished ones.
- If we provide the additional query parameter published=1, then the endpoint will return both the unpublished and published ones.

* feat/Change published-unpublished to match new criteria

- Change get_queryset method to its original status, but removing the unpublished.
- Add logic to support published/unpublished parameters.

* chore/Refactor publised-unpublished cases in a more pythonic way

* Feature/163295/add swimlanes at phase board (#137)

* table with new story features

* code refactoring

* removed overflow-x from el-select-tags (#138)

* hide square logo and change menu height (#139)

* Feature/160826/group innovation portfolio solution details section (#140)

* solutions edit/create new Innovation Portfolios group, portfolios table key bug fix

* updated solution view with new Innovation portfolios card section

* Revert adding azure-monitor-opentelemetry==1.0.0b13 to resolve No module named azure.monitor issue

* updated empty value type (#141)

* Feature/160752/stages phases (#142)

* add new column - feature key phases_stages

* create a mapping between phases and stages

* updated styles to work on all browsers (#143)

* feat/Add azure-monitor-opentelemetry to requirements

* feat/Add configure_azure_monitor to settings.py

* chore/Remove configure_azure_monitor and implement older approach to identify compatibility

* chore/Remove opentelemetry from settings.py

* chore/Code cleanup

* Feature/163742/enable ootb monitoring capabilities (#146)

* feat/Add azure-monitor-opentelemetry to requirements

* feat/Add opentelemetry to application settings

* chore/Change env from dev to tst

* chore/Rollback env from tst to dev

* feat/Add internal_ips to fetch the pod internal ip

* chore/Rename azure folder to azure_services

* chore/Remove reduntant import from settings

* chore/Change configure_azure_monitor signature to include named argument

* feat/Change userprofile list to autocomplete field (#145)

- Add list with autocomplete search bar in the edit technology platform admin page.
- Add name as the search bar option.

* rename stage_name and phase_name to stage_label and phase_label (#147)

* feature/161336/initiatives-by-stage-board  added stage table and table switch (#148)

* feat/Switch nextLink to deltaLink mechanism

* feat/Add get and save last delta link mechanism

* chore/Refactor delta link generation and store method

- Add new DeltaLink model to let Django handle the table creation/update mechanism.
- Change get_last_delta_link and save_delta_link to follow the same pattern.

* Feature/refactor aad user fetch and update mechanism (#149)

* feat/Switch nextLink to deltaLink mechanism

* feat/Add get and save last delta link mechanism

* chore/Refactor delta link generation and store method

- Add new DeltaLink model to let Django handle the table creation/update mechanism.
- Change get_last_delta_link and save_delta_link to follow the same pattern.

* chore/Add migration file for deltalink

* chore/Add log statements to debug deltalink response

* chore/Remove redundant log statements

* chore/Refactor deltalinks and logger

- Refactor delta links to accept more than one page.
- Change azure logger from info to warning level to unclutter the django logs

* Revert commits 2ed8b75 to 46a5dcf

* Bugfix/163402/dashboarding system error (#150)

* problem_statements and portfolios are now lists containing only unique ids

* created a django management command to update the problematic solution logs (may and june 2023)

* fixed error in comment

* custom management command will now be run on deployment

* updated to fix problematic entries in all solution log rows

* feat/Add delta to graph url

* chore/Remove redundant logging statements

* Rollback to pre-deltaLink mechanism

* chore/Remove redundant files

---------

Co-authored-by: Diogenis Petropoulos <diogenis,petropoulos@sword-group.com>
Co-authored-by: ladeniva2 <122989825+ladeniva2@users.noreply.github.com>
Co-authored-by: Alexa-Laf <131444412+Alexa-Laf@users.noreply.github.com>
Co-authored-by: mgaliatsatou <122973661+mgaliatsatou@users.noreply.github.com>

* Performance optimization (#156)

* load users optimization

* performance improvements for inventory list page

* inventory load fix

* performance improvement by reordering api calls and asyncronicity

* removed sentry lib, removed unused unicef logo

* update node 12 to 14 in containers and fron 10 to 14 as compilation in babel

* lazy loading images

---------

Co-authored-by: ladeniva2 <122989825+ladeniva2@users.noreply.github.com>

* Merge dev to tst (#157)

* Revert adding azure-monitor-opentelemetry==1.0.0b13 to resolve No module named azure.monitor issue

* updated empty value type (#141)

* Feature/160752/stages phases (#142)

* add new column - feature key phases_stages

* create a mapping between phases and stages

* updated styles to work on all browsers (#143)

* feat/Add azure-monitor-opentelemetry to requirements

* feat/Add configure_azure_monitor to settings.py

* chore/Remove configure_azure_monitor and implement older approach to identify compatibility

* chore/Remove opentelemetry from settings.py

* chore/Code cleanup

* Feature/163742/enable ootb monitoring capabilities (#146)

* feat/Add azure-monitor-opentelemetry to requirements

* feat/Add opentelemetry to application settings

* chore/Change env from dev to tst

* chore/Rollback env from tst to dev

* feat/Add internal_ips to fetch the pod internal ip

* chore/Rename azure folder to azure_services

* chore/Remove reduntant import from settings

* chore/Change configure_azure_monitor signature to include named argument

* feat/Change userprofile list to autocomplete field (#145)

- Add list with autocomplete search bar in the edit technology platform admin page.
- Add name as the search bar option.

* rename stage_name and phase_name to stage_label and phase_label (#147)

* feature/161336/initiatives-by-stage-board  added stage table and table switch (#148)

* feat/Switch nextLink to deltaLink mechanism

* feat/Add get and save last delta link mechanism

* chore/Refactor delta link generation and store method

- Add new DeltaLink model to let Django handle the table creation/update mechanism.
- Change get_last_delta_link and save_delta_link to follow the same pattern.

* Feature/refactor aad user fetch and update mechanism (#149)

* feat/Switch nextLink to deltaLink mechanism

* feat/Add get and save last delta link mechanism

* chore/Refactor delta link generation and store method

- Add new DeltaLink model to let Django handle the table creation/update mechanism.
- Change get_last_delta_link and save_delta_link to follow the same pattern.

* chore/Add migration file for deltalink

* chore/Add log statements to debug deltalink response

* chore/Remove redundant log statements

* chore/Refactor deltalinks and logger

- Refactor delta links to accept more than one page.
- Change azure logger from info to warning level to unclutter the django logs

* Revert commits 2ed8b75 to 46a5dcf

* Bugfix/163402/dashboarding system error (#150)

* problem_statements and portfolios are now lists containing only unique ids

* created a django management command to update the problematic solution logs (may and june 2023)

* fixed error in comment

* custom management command will now be run on deployment

* updated to fix problematic entries in all solution log rows

* feat/Add delta to graph url

* chore/Remove redundant logging statements

* Rollback to pre-deltaLink mechanism

* chore/Remove redundant files

* Performance optimization (#156)

* load users optimization

* performance improvements for inventory list page

* inventory load fix

* performance improvement by reordering api calls and asyncronicity

* removed sentry lib, removed unused unicef logo

* update node 12 to 14 in containers and fron 10 to 14 as compilation in babel

* lazy loading images

---------

Co-authored-by: ladeniva2 <122989825+ladeniva2@users.noreply.github.com>

---------

Co-authored-by: ladeniva2 <122989825+ladeniva2@users.noreply.github.com>
Co-authored-by: Alexa-Laf <131444412+Alexa-Laf@users.noreply.github.com>
Co-authored-by: mgaliatsatou <122973661+mgaliatsatou@users.noreply.github.com>

* add autocomplete field managers (#159)

* add autocomplete field managers (#159) (#160)

* chore/Remove DeltaLink model

* Merge dev to tst (#163)

* add autocomplete field managers (#159)

* chore/Remove DeltaLink model

---------

Co-authored-by: Alexa-Laf <131444412+Alexa-Laf@users.noreply.github.com>

* Added country inventory link button on homepage (#164)

* added height select switch, made table height expandable (#165)

* add job title and section to export files (#162)

* Bugfix/163755/country link inventory (#166)

* added dynamic country id to link, added data-test id

* removed 's country ending as it may be not appropriate for some countries

* Feature/165200/select sectors appear phase stage board (#167)

* added selection dropdown for sectors

* dropdown count fix

* replace section name to department (#168)

* link changed from button to link (#169)

* changed project data fallback for projectBar and breadcrumps (#170)

* id correction (#171)

* users list timing loading fix and data refresh for initiatives (#172)

* users list timing loading fix and data refresh for initiatives

* added data reset on loadProject if no data exist

* updated button ui and added text to link (#177)

* Merge dev to tst (#179)

* add autocomplete field managers (#159)

* chore/Remove DeltaLink model

* Added country inventory link button on homepage (#164)

* added height select switch, made table height expandable (#165)

* add job title and section to export files (#162)

* Bugfix/163755/country link inventory (#166)

* added dynamic country id to link, added data-test id

* removed 's country ending as it may be not appropriate for some countries

* Feature/165200/select sectors appear phase stage board (#167)

* added selection dropdown for sectors

* dropdown count fix

* replace section name to department (#168)

* link changed from button to link (#169)

* changed project data fallback for projectBar and breadcrumps (#170)

* id correction (#171)

* users list timing loading fix and data refresh for initiatives (#172)

* users list timing loading fix and data refresh for initiatives

* added data reset on loadProject if no data exist

* updated button ui and added text to link (#177)

---------

Co-authored-by: Alexa-Laf <131444412+Alexa-Laf@users.noreply.github.com>
Co-authored-by: ladeniva2 <122989825+ladeniva2@users.noreply.github.com>

* UI changes

* UI changes (#182)

* Updated breadcrumbs My Initiatives to Initiatives link to inventory list (#183)

* Bugfix/130138/admin export users fails (#184)

* added background export action for auth users table

* patching the export_resource_classes to the User model

* added comment

* chore/Remove unnecessary commands from startup_actions

* chore/Silence opentelemetry logs in dev

* chore/Remove unnecessary log statements

* Feature/160750/make end phases config (#186)

* add_checkbox_end_phase_update_current_stage

* dynamically get end phases and hide them in phases board

* remove cache structire

---------

Co-authored-by: ladeniva2 <122989825+ladeniva2@users.noreply.github.com>

* Count last phase always as end phase (#187)

* Bugfix/increase dev test coverage (#190)

* feat/Add new attribute completion_marks_an_initiative_as_inactive to test files

* chore/Add custom migration files

* chore/Add print statements to add_taxonomies

* chore/Refactor code

- Move add_taxonomies functionality to a new migration file
- Revert add taxonomies to the previous state

* fix/Minor fix to add_taxonomies.py

- Add check to return first if it finds more than one

* increase coverage version 2

* remove return from def fill_named_model -initial form

---------

Co-authored-by: gkalomalos <georgios.kalomalos@sword-group.com>

* Revert "Count last phase always as end phase"

This reverts commit 9d7e5a4.

* Revert "dynamically get end phases and hide them in phases board"

This reverts commit d5671db.

* remove tests for discontinued and remove duplicate class (#193)

* Deployment to test environment (#194)

* UI changes (#182)

* Updated breadcrumbs My Initiatives to Initiatives link to inventory list (#183)

* Bugfix/130138/admin export users fails (#184)

* added background export action for auth users table

* patching the export_resource_classes to the User model

* added comment

* chore/Remove unnecessary commands from startup_actions

* chore/Silence opentelemetry logs in dev

* chore/Remove unnecessary log statements

* Feature/160750/make end phases config (#186)

* add_checkbox_end_phase_update_current_stage

* dynamically get end phases and hide them in phases board

* remove cache structire

---------

Co-authored-by: ladeniva2 <122989825+ladeniva2@users.noreply.github.com>

* Count last phase always as end phase (#187)

* Bugfix/increase dev test coverage (#190)

* feat/Add new attribute completion_marks_an_initiative_as_inactive to test files

* chore/Add custom migration files

* chore/Add print statements to add_taxonomies

* chore/Refactor code

- Move add_taxonomies functionality to a new migration file
- Revert add taxonomies to the previous state

* fix/Minor fix to add_taxonomies.py

- Add check to return first if it finds more than one

* increase coverage version 2

* remove return from def fill_named_model -initial form

---------

Co-authored-by: gkalomalos <georgios.kalomalos@sword-group.com>

* Revert "Count last phase always as end phase"

This reverts commit 9d7e5a4.

* Revert "dynamically get end phases and hide them in phases board"

This reverts commit d5671db.

* remove tests for discontinued and remove duplicate class (#193)

---------

Co-authored-by: ladeniva2 <122989825+ladeniva2@users.noreply.github.com>
Co-authored-by: mgaliatsatou <122973661+mgaliatsatou@users.noreply.github.com>
Co-authored-by: gkalomalos <georgios.kalomalos@sword-group.com>

* added link to country in initiatives published view

* updated data test id, added link to inventory countries column

* hide initiatives that have completed an end phase (#196)

* Feature/168436/add links from country to co pages (#195)

* added link to country in initiatives published view

* updated data test id, added link to inventory countries column

* remove last phase, hide some comments

* remove last phase, hide some comments (#197)

* updated column count when sectors filtered

---------

Co-authored-by: gkalomalos <georgios.kalomalos@sword-group.com>
Co-authored-by: Alexa-Laf <131444412+Alexa-Laf@users.noreply.github.com>
Co-authored-by: gkalomalos <123368636+gkalomalos@users.noreply.github.com>
Co-authored-by: Diogenis Petropoulos <diogenis,petropoulos@sword-group.com>
Co-authored-by: mgaliatsatou <122973661+mgaliatsatou@users.noreply.github.com>
  • Loading branch information
6 people authored Aug 10, 2023
1 parent e6eb411 commit f938d1f
Show file tree
Hide file tree
Showing 18 changed files with 407 additions and 181 deletions.
3 changes: 3 additions & 0 deletions django/core/admin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ class UserProfileInline(admin.StackedInline):


class CustomUserAdmin(ExportActionMixin, UserAdmin):
from import_export_celery.admin_actions import create_export_job_action
create_export_job_action.short_description = "Generate export in the background"
actions = (create_export_job_action,)
list_display = ('userprofile', 'country', 'type', 'organisation', 'is_staff', 'is_superuser')
search_fields = ('userprofile__name', 'email', 'userprofile__country__name', 'userprofile__organisation__name')
inlines = (UserProfileInline,)
Expand Down
6 changes: 4 additions & 2 deletions django/project/management/commands/add_taxonomies.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,12 @@ def handle(self, *args, **options):

for block_name in data:
if block_name in self.data_model_map:
self.fill_named_model(data[block_name], self.data_model_map[block_name])
self.fill_named_model(
data[block_name], self.data_model_map[block_name])
elif block_name == 'Currency':
self.fill_currencies(data[block_name])
elif block_name in self.nonmodel_blocks:
pp.pprint(f"Warning: need to check {block_name} by hand as it's non-model")
pp.pprint(
f"Warning: need to check {block_name} by hand as it's non-model")
else: # pragma: no cover
pp.pprint(f"Warning: unhandled block name: {block_name}")
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ def update_translation_fields(apps, schema_editor):
call_command('update_translation_fields')


def add_taxonomies(apps, schema_editor):
call_command('add_taxonomies', '--verbosity', 0)


def rebuild_search(apps, schema_editor):
call_command('rebuild_search')

Expand All @@ -31,8 +27,8 @@ class Migration(migrations.Migration):
]

operations = [
migrations.RunPython(update_translation_fields, reverse_code=migrations.RunPython.noop),
migrations.RunPython(add_taxonomies, reverse_code=migrations.RunPython.noop),
# migrations.RunPython(rebuild_search, reverse_code=migrations.RunPython.noop),
migrations.RunPython(reorder_stages, reverse_code=migrations.RunPython.noop),
migrations.RunPython(update_translation_fields,
reverse_code=migrations.RunPython.noop),
migrations.RunPython(
reorder_stages, reverse_code=migrations.RunPython.noop),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 2.1 on 2023-07-20 18:43

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('project', '0105_delete_deltalink'),
]

operations = [
migrations.AddField(
model_name='stage',
name='completion_marks_an_initiative_as_inactive',
field=models.BooleanField(default=False, help_text='When this phase is marked as completed (with an end date) it means that the initiative is no longer active.<br>It will not move automatically to a following phase, but will stay in this phase.'),
),
]
18 changes: 18 additions & 0 deletions django/project/migrations/0107_reorder_stages.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 2.1 on 2023-07-20 18:43
from django.core.management import call_command
from django.db import migrations


def add_taxonomies(apps, schema_editor):
call_command('add_taxonomies', '--verbosity', 0)


class Migration(migrations.Migration):
dependencies = [
('project', '0106_stage_completion_marks_an_initiative_as_inactive'),
]

operations = [
migrations.RunPython(
add_taxonomies, reverse_code=migrations.RunPython.noop),
]
39 changes: 20 additions & 19 deletions django/project/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1013,6 +1013,8 @@ class Stage(InvalidateCacheMixin, ExtendedNameOrderedSoftDeletedModel):
name = models.CharField(max_length=128)
order = models.PositiveSmallIntegerField(default=0, blank=True, null=True)
tooltip = models.CharField(max_length=256, blank=True, null=True)
completion_marks_an_initiative_as_inactive = models.BooleanField(
help_text="When this phase is marked as completed (with an end date) it means that the initiative is no longer active.<br>It will not move automatically to a following phase, but will stay in this phase.", default=False)

class Meta:
ordering = ["order", "name"]
Expand All @@ -1022,37 +1024,36 @@ class Meta:
def __str__(self): # pragma: no cover
return self.name

@classmethod
def get_discontinued(cls):
"""
Hardcoded for now. Object with this name must exist in the DB to work.
"""
return cls.objects.get(name="Discontinued")

@classmethod
def calc_current_phase(cls, stages: List[Dict]):
discontinued_id = cls.get_discontinued().id
all_stages = list(cls.objects.order_by(
"order").values_list("id", flat=True))
one_before_discontinued_id = all_stages[all_stages.index(
discontinued_id) - 1]

if not stages: # when no phases are selected the current phase is the first one
return all_stages[0]

stage_ids = [stage["id"] for stage in stages]
# get the completed phases of the initiative and order them
selected_stages = cls.objects.filter(
id__in=stage_ids).order_by("order")
# get the last phase from initiative's completed phases
last_stage = selected_stages.last()

if last_stage.id == discontinued_id:
current = discontinued_id
elif last_stage.id == one_before_discontinued_id:
current = last_stage.id
elif last_stage.id == all_stages[-1]:
current = last_stage.id
else:
current = all_stages[all_stages.index(last_stage.id) + 1]
# apply the business requirements
if not last_stage.completion_marks_an_initiative_as_inactive: # selected phase's checkbox unchecked
# compute if there are already previous completed end phases (checkbox=checked)
completed_stages = selected_stages.filter(
completion_marks_an_initiative_as_inactive=True)
if completed_stages: # if there completed end phases
current = last_stage.id
else: # if there are not completed end phases
if last_stage.id != all_stages[-1]: # not the last in list
current = all_stages[all_stages.index(
last_stage.id) + 1] # get the next phase
else: # the last in list
current = last_stage.id # set this phase as current
else: # selected phase's checkbox checked
current = last_stage.id # set this phase as current

return current


Expand Down
138 changes: 70 additions & 68 deletions django/project/tests/project_stage_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

from project.models import Stage
from project.tests.setup import SetupTests
from django.test import TestCase
from project.views import ProjectPublicViewSet


class ProjectStageTests(SetupTests):
Expand All @@ -16,15 +18,19 @@ def test_project_stages(self):
data = copy.deepcopy(self.project_data)

data['project']['name'] = 'Test Project 100'
data['project']['start_date'] = str((now - timezone.timedelta(days=10)).date())
data['project']['end_date'] = str((now - timezone.timedelta(days=1)).date())
data['project']['start_date'] = str(
(now - timezone.timedelta(days=10)).date())
data['project']['end_date'] = str(
(now - timezone.timedelta(days=1)).date())
data['project']['end_date_note'] = "note for end date"
del data['project']['stages']

# create project
url = reverse("project-create", kwargs={"country_office_id": self.country_office.id})
url = reverse("project-create",
kwargs={"country_office_id": self.country_office.id})
response = self.test_user_client.post(url, data, format="json")
self.assertEqual(response.status_code, status.HTTP_201_CREATED, response.json())
self.assertEqual(response.status_code,
status.HTTP_201_CREATED, response.json())

project_id = response.json()['id']
self.assertIn("end_date_note", response.json()['draft'])
Expand All @@ -41,8 +47,10 @@ def test_project_stages(self):
url = reverse("project-draft", kwargs={"project_id": project_id,
"country_office_id": self.country_office.id})
response = self.test_user_client.put(url, data, format="json")
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST, response.json())
self.assertEqual(response.json(), {'project': {'stages': [{'date': ['This field may not be null.']}]}})
self.assertEqual(response.status_code,
status.HTTP_400_BAD_REQUEST, response.json())
self.assertEqual(response.json(), {'project': {'stages': [
{'date': ['This field may not be null.']}]}})

stages = Stage.objects.all()
# add stages
Expand All @@ -68,7 +76,8 @@ def test_project_stages(self):
url = reverse("project-draft", kwargs={"project_id": project_id,
"country_office_id": self.country_office.id})
response = self.test_user_client.put(url, data, format="json")
self.assertEqual(response.status_code, status.HTTP_200_OK, response.json())
self.assertEqual(response.status_code,
status.HTTP_200_OK, response.json())
resp_data = response.json()
self.assertIn('stages', resp_data['draft'])
self.assertEqual(len(resp_data['draft']['stages']), 3)
Expand All @@ -78,7 +87,8 @@ def test_project_stages(self):
url = reverse("project-publish", kwargs={"project_id": project_id,
"country_office_id": self.country_office.id})
response = self.test_user_client.put(url, data, format="json")
self.assertEqual(response.status_code, status.HTTP_200_OK, response.json())
self.assertEqual(response.status_code,
status.HTTP_200_OK, response.json())
resp_data = response.json()
self.assertNotIn('stages', resp_data['draft'])
self.assertIn("end_date_note", response.json()['draft'])
Expand All @@ -88,7 +98,8 @@ def test_project_stages(self):
url = reverse("project-publish", kwargs={"project_id": project_id,
"country_office_id": self.country_office.id})
response = self.test_user_client.put(url, data, format="json")
self.assertEqual(response.status_code, status.HTTP_200_OK, response.json())
self.assertEqual(response.status_code,
status.HTTP_200_OK, response.json())
resp_data = response.json()
self.assertIn('stages', resp_data['draft'])
self.assertEqual(len(resp_data['draft']['stages']), 3)
Expand All @@ -102,62 +113,13 @@ def test_stage_list(self):

url = reverse("get-project-structure")
response = self.test_user_client.get(url, format="json")
self.assertEqual(response.status_code, status.HTTP_200_OK, response.json())
self.assertEqual(response.status_code,
status.HTTP_200_OK, response.json())
data = response.json()['stages']
self.assertEqual(data[0]['id'], stage_b.id)
self.assertEqual(data[1]['id'], stage_a.id)
self.assertEqual(data[2]['id'], stage_c.id)

def test_current_phase_discontinued(self):
now = timezone.now()
data = copy.deepcopy(self.project_data)
stage_1 = Stage.objects.all()[0]
stage_discontinued = Stage.objects.get(name='Discontinued')
# add stages
data['project']['stages'] = [
{
'id': stage_1.id,
'date': str((now - timezone.timedelta(days=10)).date()),
'note': 'preparation note'
},
{
'id': stage_discontinued.id,
'date': str((now - timezone.timedelta(days=7)).date()),
'note': 'analysis note'
}
]

url = reverse("project-create", kwargs={"country_office_id": self.country_office.id})
response = self.test_user_client.post(url, data, format="json")
self.assertEqual(response.status_code, status.HTTP_201_CREATED, response.json())
self.assertEqual(response.json()['draft']['current_phase'], stage_discontinued.id)

def test_current_phase_one_before_discontinued(self):
now = timezone.now()
data = copy.deepcopy(self.project_data)
stage_1 = Stage.objects.all()[0]
discontinued_id = Stage.objects.get(name='Discontinued').id
all_stages = list(Stage.objects.order_by('order').values_list('id', flat=True))
one_before_discontinued_id = all_stages[all_stages.index(discontinued_id) - 1]
# add stages
data['project']['stages'] = [
{
'id': stage_1.id,
'date': str((now - timezone.timedelta(days=10)).date()),
'note': 'preparation note'
},
{
'id': one_before_discontinued_id,
'date': str((now - timezone.timedelta(days=7)).date()),
'note': 'analysis note'
}
]

url = reverse("project-create", kwargs={"country_office_id": self.country_office.id})
response = self.test_user_client.post(url, data, format="json")
self.assertEqual(response.status_code, status.HTTP_201_CREATED, response.json())
self.assertEqual(response.json()['draft']['current_phase'], one_before_discontinued_id)

def test_current_phase_normal_case(self):
now = timezone.now()
data = copy.deepcopy(self.project_data)
Expand All @@ -176,19 +138,24 @@ def test_current_phase_normal_case(self):
}
]

url = reverse("project-create", kwargs={"country_office_id": self.country_office.id})
url = reverse("project-create",
kwargs={"country_office_id": self.country_office.id})
response = self.test_user_client.post(url, data, format="json")
self.assertEqual(response.status_code, status.HTTP_201_CREATED, response.json())
self.assertEqual(response.json()['draft']['current_phase'], stages[2].id)
self.assertEqual(response.status_code,
status.HTTP_201_CREATED, response.json())
self.assertEqual(response.json()['draft']
['current_phase'], stages[2].id)

def test_current_phase_no_phase_selected(self):
data = copy.deepcopy(self.project_data)
stage_1 = Stage.objects.order_by('order').first()
data['project']['stages'] = []

url = reverse("project-create", kwargs={"country_office_id": self.country_office.id})
url = reverse("project-create",
kwargs={"country_office_id": self.country_office.id})
response = self.test_user_client.post(url, data, format="json")
self.assertEqual(response.status_code, status.HTTP_201_CREATED, response.json())
self.assertEqual(response.status_code,
status.HTTP_201_CREATED, response.json())
self.assertEqual(response.json()['draft']['current_phase'], stage_1.id)

def test_current_phase_is_last_phase(self):
Expand All @@ -208,7 +175,42 @@ def test_current_phase_is_last_phase(self):
}
]

url = reverse("project-create", kwargs={"country_office_id": self.country_office.id})
url = reverse("project-create",
kwargs={"country_office_id": self.country_office.id})
response = self.test_user_client.post(url, data, format="json")
self.assertEqual(response.status_code, status.HTTP_201_CREATED, response.json())
self.assertEqual(response.json()['draft']['current_phase'], stages.last().id)
self.assertEqual(response.status_code,
status.HTTP_201_CREATED, response.json())
self.assertEqual(response.json()['draft']
['current_phase'], stages.last().id)


class StageTestCase(TestCase):
def setUp(self):
self.stage_data = {
'name': 'Test Stage',
# Set the value accordingly for your test
'completion_marks_an_initiative_as_inactive': True
}

def test_completion_marks_an_initiative_as_inactive(self):
# Create a stage
stage = Stage.objects.create(**self.stage_data)

# Retrieve the created stage from the database
created_stage = Stage.objects.get(id=stage.id)

# Assert the field value matches the expected value
self.assertEqual(created_stage.completion_marks_an_initiative_as_inactive,
self.stage_data['completion_marks_an_initiative_as_inactive'])

# Update the field value
new_value = False # Set the new value accordingly for your test
created_stage.completion_marks_an_initiative_as_inactive = new_value
created_stage.save()

# Retrieve the updated stage from the database
updated_stage = Stage.objects.get(id=stage.id)

# Assert the field value has been updated
self.assertEqual(
updated_stage.completion_marks_an_initiative_as_inactive, new_value)
Loading

0 comments on commit f938d1f

Please sign in to comment.