-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6326 from OCHA-DAP/dev
dev into prod for onboarding phase 2
- Loading branch information
Showing
70 changed files
with
1,858 additions
and
278 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
ckanext-hdx_org_group/ckanext/hdx_org_group/controller_logic/organization_join_logic.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import logging | ||
from typing import cast | ||
|
||
import ckan.model as model | ||
import ckan.plugins.toolkit as tk | ||
from ckan.common import current_user | ||
from ckan.types import Context | ||
|
||
get_action = tk.get_action | ||
check_access = tk.check_access | ||
config = tk.config | ||
h = tk.h | ||
NotAuthorized = tk.NotAuthorized | ||
|
||
log = logging.getLogger(__name__) | ||
|
||
|
||
class OrgJoinLogic(object): | ||
def __init__(self, context: Context): | ||
self.active_org_dict = {} | ||
self.inactive_org_dict = {} | ||
self.all_org_list = [] | ||
self.context = context | ||
|
||
|
||
def read(self): | ||
self._fetch_org_list_metadata() | ||
return self | ||
|
||
def _fetch_org_list_metadata(self): | ||
''' | ||
:returns: populated self object | ||
:rtype: | ||
''' | ||
|
||
self.all_org_list = get_action(u'cached_organization_list')(self.context, {}) | ||
|
||
if len(self.all_org_list) > 0: | ||
for o in self.all_org_list: | ||
if not o.get('closed_organization'): | ||
self.active_org_dict[o.get('id')] = o.get('display_name') | ||
else: | ||
self.inactive_org_dict[o.get('id')] = o.get('display_name') | ||
|
51 changes: 51 additions & 0 deletions
51
ckanext-hdx_org_group/ckanext/hdx_org_group/controller_logic/organization_request_logic.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import logging | ||
|
||
import ckan.lib.navl.dictization_functions as dictization_functions | ||
import ckan.logic as logic | ||
import ckan.plugins.toolkit as tk | ||
from ckan.types import Context | ||
from ckan.logic.schema import validator_args | ||
from ckan.lib.navl.dictization_functions import validate | ||
|
||
get_action = tk.get_action | ||
check_access = tk.check_access | ||
config = tk.config | ||
h = tk.h | ||
NotAuthorized = tk.NotAuthorized | ||
unicode_safe = tk.get_validator('unicode_safe') | ||
log = logging.getLogger(__name__) | ||
|
||
|
||
@validator_args | ||
def request_new_organization_schema(not_empty, ignore_missing, hdx_url_validator): | ||
schema = { | ||
'name': [not_empty, unicode_safe], | ||
'description': [not_empty, unicode_safe], | ||
'website': [ignore_missing, unicode_safe, hdx_url_validator], | ||
'role': [not_empty, unicode_safe], | ||
'data_type': [not_empty, unicode_safe], | ||
'data_already_available': [not_empty, unicode_safe], | ||
'data_already_available_link': [ignore_missing, unicode_safe, hdx_url_validator], | ||
} | ||
return schema | ||
|
||
|
||
class OrgRequestLogic(object): | ||
def __init__(self, context: Context, request): | ||
self.request = request | ||
self.context = context | ||
self.form = request.form | ||
self.schema = request_new_organization_schema() | ||
|
||
def read(self): | ||
data_dict = logic.clean_dict( | ||
dictization_functions.unflatten( | ||
logic.tuplize_dict(logic.parse_params(self.form)))) | ||
return data_dict | ||
|
||
def validate(self, data_dict): | ||
try: | ||
validated_response = validate(data_dict, self.schema, self.context) | ||
except Exception as ex: | ||
log.error(ex) | ||
return validated_response |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.