-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP: Fix/access request from implementation feedback (#17)
* [Refactor][xs]: Code formatting * [From][xl]: Access request form API implementation * [UI][xl]:Response list/view/delete UI implementation and other improvement * [Email][s]: Email text updated * [BugFix][xs]: checkbox selection bug fix * [Fix][xs]: Bug fix and consent required * [actions][xs]: Call to action buttons * [fix][xs]: bug fix * [fix][xs]: Explicit limit specified on upload * [improve][xs]: improve title * [captcha][xs]: captcha added for bot blocking * [Improve][xs]: label fixes * [Improve][xs]: Consent focus when it's not checked * [Email][xs]: Date format change * [update][s]: Full name, postal updated to first, surname & country respectively * [update][s]: 2 questions column removed * [update][s]: Feedbacks implemented #datopian/ubdc-clientshared-tracker#22 * [deploy][s]: Captcha Implemented, Reviews Implemented * [Fix][xs]: Checkbox not so reactive bug fix --------- Co-authored-by: Sagar Ghimire <[email protected]>
- Loading branch information
1 parent
fb295df
commit bcd907e
Showing
22 changed files
with
1,038 additions
and
61 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
ckan.module("data-service-request-form", function (jQuery) { | ||
return { | ||
initialize: function () { | ||
var message = this._('There are unsaved modifications to this form'); | ||
|
||
$.proxyAll(this, /_on/); | ||
|
||
this.el.incompleteFormWarning(message); | ||
|
||
// Disable the submit button on form submit, to prevent multiple | ||
// consecutive form submissions. | ||
|
||
this.el.on('submit', this._onSubmit); | ||
|
||
this.el.find('.checkboxes label').click(function (event) { | ||
event.stopPropagation(); | ||
var checkbox = $(this).find('input'); | ||
checkbox.prop('checked', !checkbox.prop('checked')); | ||
}); | ||
|
||
this.el.find('.checkboxes label input').click(function (event) { | ||
event.stopPropagation(); | ||
}); | ||
}, | ||
_onSubmit: function () { | ||
// The button is not disabled immediately so that its value can be sent | ||
// the first time the form is submitted, because the "save" field is | ||
// used in the backend. | ||
|
||
var consent = this.el.find('input[name="consent"]') | ||
var contactConsent = this.el.find('input[name="contactConsent"]') | ||
if (!consent.prop('checked')) { | ||
consent.focus(); | ||
this.el.preventDefault() | ||
} | ||
|
||
if (!contactConsent.prop('checked')) { | ||
contactConsent.focus(); | ||
this.el.preventDefault() | ||
} | ||
|
||
setTimeout(function () { | ||
this.el.find('button[name="save"]').attr('disabled', true); | ||
}.bind(this), 0); | ||
} | ||
}; | ||
}); |
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,35 @@ | ||
ckan.module('reCaptcha', function (jQuery) { | ||
return { | ||
options: { | ||
sitekey: null, | ||
}, | ||
initialize: function () { | ||
var recaptcha = document.createElement('script'); | ||
recaptcha.src = 'https://www.google.com/recaptcha/api.js?render=' + this.options.sitekey; | ||
recaptcha.async = true; | ||
recaptcha.defer = true; | ||
document.body.appendChild(recaptcha); | ||
$.proxyAll(this, /_on/); | ||
|
||
// onClick event | ||
this.el.on('click', this._onClick); | ||
|
||
// hidden input field with the token | ||
this.el.before('<input type="hidden" name="g-recaptcha-response" value="">'); | ||
|
||
}, | ||
_onClick: function (event) { | ||
event.preventDefault(); | ||
var module = this; | ||
grecaptcha.ready(function (module) { | ||
return function () { | ||
grecaptcha.execute(module.options.sitekey, { action: 'submit' }).then(function (token) { | ||
jQuery('input[name="g-recaptcha-response"]').val(token); | ||
jQuery('#data-service-access-request')[0].reportValidity() | ||
module.el.closest('form').submit(); | ||
}); | ||
}; | ||
}(module)); | ||
} | ||
}; | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,71 @@ | ||
|
||
from ckan import model | ||
from ckan.logic import get_action | ||
import ckan.plugins.toolkit as tk | ||
from ckanext.ubdc import view | ||
|
||
|
||
def popular_datasets(limit=3): | ||
"""Return a list of the most popular datasets.""" | ||
context = {'model': model, 'session': model.Session} | ||
data_dict = {'sort': 'views_recent desc', 'rows': limit} | ||
return get_action('package_search')(context, data_dict)['results'] | ||
context = {"model": model, "session": model.Session} | ||
data_dict = {"sort": "views_recent desc", "rows": limit} | ||
return get_action("package_search")(context, data_dict)["results"] | ||
|
||
|
||
def resources_count(): | ||
"""Return the total number of resources.""" | ||
context = {'model': model, 'session': model.Session} | ||
data_dict = {'query': 'name:'} | ||
return get_action('resource_search')(context, data_dict)['count'] | ||
context = {"model": model, "session": model.Session} | ||
data_dict = {"query": "name:"} | ||
return get_action("resource_search")(context, data_dict)["count"] | ||
|
||
|
||
def tags_count(): | ||
"""Return the total number of tags.""" | ||
context = {'model': model, 'session': model.Session} | ||
return {'count': len(get_action('tag_list')(context, {})) } | ||
context = {"model": model, "session": model.Session} | ||
return {"count": len(get_action("tag_list")(context, {}))} | ||
|
||
|
||
def get_gtm_id(): | ||
"""Return the Google Tag Manager ID.""" | ||
return tk.config.get('ls', '') | ||
return tk.config.get("ls", "") | ||
|
||
|
||
def get_cookie_control_config(): | ||
cookie_control_config = {} | ||
|
||
api_key = tk.config.get("ckanext.ubdc.cc.api_key", "") | ||
cookie_control_config["api_key"] = api_key | ||
|
||
cookie_control_config = {} | ||
license_type = tk.config.get("ckanext.ubdc.cc.license_type", "COMMUNITY") | ||
cookie_control_config["license_type"] = license_type | ||
|
||
api_key = tk.config.get( | ||
'ckanext.ubdc.cc.api_key', '') | ||
cookie_control_config['api_key'] = api_key | ||
popup_position = tk.config.get("ckanext.ubdc.cc.popup_position", "LEFT") | ||
cookie_control_config["popup_position"] = popup_position | ||
|
||
license_type = tk.config.get( | ||
'ckanext.ubdc.cc.license_type', 'COMMUNITY') | ||
cookie_control_config['license_type'] = license_type | ||
theme_color = tk.config.get("ckanext.ubdc.cc.theme_color", "DARK") | ||
cookie_control_config["theme_color"] = theme_color | ||
|
||
popup_position = tk.config.get( | ||
'ckanext.ubdc.cc.popup_position', 'LEFT') | ||
cookie_control_config['popup_position'] = popup_position | ||
initial_state = tk.config.get("ckanext.ubdc.cc.initial_state", "OPEN") | ||
cookie_control_config["initial_state"] = initial_state | ||
|
||
theme_color = tk.config.get( | ||
'ckanext.ubdc.cc.theme_color', 'DARK') | ||
cookie_control_config['theme_color'] = theme_color | ||
gtm_id = tk.config.get("googleanalytics.measurement_id", "") | ||
cookie_control_config["gtm_id"] = gtm_id.replace("G-", "_ga_") | ||
|
||
initial_state = tk.config.get( | ||
'ckanext.ubdc.cc.initial_state', 'OPEN') | ||
cookie_control_config['initial_state'] = initial_state | ||
return cookie_control_config | ||
|
||
gtm_id = tk.config.get( | ||
'googleanalytics.measurement_id', '') | ||
cookie_control_config['gtm_id'] = gtm_id.replace('G-', '_ga_') | ||
|
||
return cookie_control_config | ||
def get_field_to_question(value): | ||
get_field_to_question = { | ||
"first_name": "First Name", | ||
"surname": "Surname", | ||
"organization": "Organisation / Institution", | ||
"email": "Email Address", | ||
"telephone": "Telephone Number", | ||
"country": "Country", | ||
"summary_of_project": "Summary of your project or intended use of UBDC data and/or services", | ||
"project_funding": "The UBDC does not provide project funding itself, but our collections and services can be used in projects funded from other sources. Are you applying for funding for this project or work?", | ||
"funding_information": "If yes, please provide additional information (e.g. deadline) and/or a link to the Funding Call.", | ||
"wish_to_use_data": "Please select all data from the UBDC collections you wish to use.", | ||
"document_url": "Optional supporting documentation upload (PDF or DOC only).", | ||
"created": "Date of submission", | ||
} | ||
return get_field_to_question.get(value, value) |
Oops, something went wrong.