Skip to content

Commit

Permalink
Merge pull request #3022 from unicef/staging
Browse files Browse the repository at this point in the history
Staging
  • Loading branch information
robertavram authored Jul 8, 2021
2 parents 04ec0b8 + 4d1c604 commit 4a0f45f
Show file tree
Hide file tree
Showing 50 changed files with 693 additions and 330 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
PGHOST: 127.0.0.1
DATABASE_URL: "postgis://postgres:postgres@localhost:5432/circle_test"
DEPLOY_BRANCHES: "develop|staging|master|ci-updates2"
- image: circleci/postgres:9.5-alpine-postgis
- image: circleci/postgres:12-alpine-postgis
environment:
POSTGRES_USER: postgres
PGUSER: postgres
Expand Down
73 changes: 0 additions & 73 deletions docker-compose.yml

This file was deleted.

76 changes: 0 additions & 76 deletions docker-compose_v2.yml

This file was deleted.

11 changes: 11 additions & 0 deletions src/etools/applications/core/data/attachments_file_types.json
Original file line number Diff line number Diff line change
Expand Up @@ -520,5 +520,16 @@
"code": "psea_answer",
"group": ["psea_answer"]
}
},
{
"model": "unicef_attachments.filetype",
"pk": 62,
"fields": {
"order": 0,
"label": "PSEA NFR Attachment",
"name": "psea_nfr_attachment",
"code": "psea_nfr_attachment",
"group": ["psea"]
}
}
]
6 changes: 6 additions & 0 deletions src/etools/applications/core/templatetags/etools.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,9 @@ def tenant_model_filter(context, app):
def tenant_app_filter(app):
tenant_app_labels = [tenant_app.split('.')[-1] for tenant_app in settings.TENANT_APPS]
return app['app_label'] in tenant_app_labels


@register.simple_tag
def call_method(obj, method_name, *args):
method = getattr(obj, method_name)
return method(*args)
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from django.urls import reverse

from etools_offline import OfflineCollect
from sentry_sdk import capture_exception
from simplejson import JSONDecodeError

from etools.applications.environment.helpers import tenant_switch_is_active
Expand All @@ -31,7 +32,7 @@ def __init__(self, activity: 'MonitoringActivity'):
self.enabled = not tenant_switch_is_active('fm_offline_sync_disabled') and settings.ETOOLS_OFFLINE_API

def _get_data_collectors(self) -> List[str]:
data_collectors = [self.activity.person_responsible.email]
data_collectors = [self.activity.visit_lead.email]
data_collectors += list(self.activity.team_members.values_list('email', flat=True))
return data_collectors

Expand All @@ -46,33 +47,39 @@ def initialize_blueprints(self) -> None:

for method in self.activity.methods:
blueprint = get_blueprint_for_activity_and_method(self.activity, method)
OfflineCollect().add(data={
"is_active": True,
"code": blueprint.code,
"form_title": blueprint.title,
"form_instructions": json.dumps(blueprint.to_dict(), indent=2),
"accessible_by": self._get_data_collectors(),
"api_response_url": urljoin(
host,
'{}?workspace={}'.format(
reverse(
'field_monitoring_data_collection:activities-offline',
args=[self.activity.id, method.id]
),
connection.tenant.schema_name or ''
try:
OfflineCollect().add(data={
"is_active": True,
"code": blueprint.code,
"form_title": blueprint.title,
"form_instructions": json.dumps(blueprint.to_dict(), indent=2),
"accessible_by": self._get_data_collectors(),
"api_response_url": urljoin(
host,
'{}?workspace={}'.format(
reverse(
'field_monitoring_data_collection:activities-offline',
args=[self.activity.id, method.id]
),
connection.tenant.schema_name or ''
)
)
)
})
})
except JSONDecodeError:
capture_exception()

def update_data_collectors_list(self) -> None:
if not self.enabled:
return

for method in self.activity.methods:
OfflineCollect().update(
get_blueprint_code(self.activity, method),
accessible_by=self._get_data_collectors()
)
try:
OfflineCollect().update(
get_blueprint_code(self.activity, method),
accessible_by=self._get_data_collectors()
)
except JSONDecodeError:
capture_exception()

def close_blueprints(self) -> None:
if not self.enabled:
Expand All @@ -85,4 +92,4 @@ def close_blueprints(self) -> None:
try:
OfflineCollect().delete(code)
except JSONDecodeError:
pass
capture_exception()
Loading

0 comments on commit 4a0f45f

Please sign in to comment.