diff --git a/ckanext/unaids/actions.py b/ckanext/unaids/actions.py index 362a0fb9..50cfc453 100644 --- a/ckanext/unaids/actions.py +++ b/ckanext/unaids/actions.py @@ -6,11 +6,11 @@ import ckan.lib.dictization.model_save as model_save import ckan.lib.dictization.model_dictize as model_dictize import ckan.plugins.toolkit as t -import ckanext.validation.helpers as validation_helpers import ckanext.unaids.custom_user_profile as custom_user_profile from ckan.common import _ from ckanext.versions.logic.dataset_version_action import get_activity_id_from_dataset_version_name, activity_dataset_show from ckanext.unaids.logic import populate_data_dictionary_from_schema +from ckanext.unaids.helpers import validation_load_json_schema NotFound = logic.NotFound NotAuthorized = logic.NotAuthorized @@ -41,7 +41,7 @@ def get_table_schema(context, data_dict): schema_name = resource.get('schema') schema = False if schema_name: - schema = validation_helpers.validation_load_json_schema(schema_name) + schema = validation_load_json_schema(schema_name) if not schema: schema = {} return schema diff --git a/ckanext/unaids/assets/css/validation.css b/ckanext/unaids/assets/css/validation.css new file mode 100644 index 00000000..606cfb2b --- /dev/null +++ b/ckanext/unaids/assets/css/validation.css @@ -0,0 +1,23 @@ +.validation-badge{ + display: inline-block; + margin: 0 0 20px 0; +} + + +.resource-list .validation-badge{ + float: right; + margin: 0 150px 0 0; + text-align: right; +} + +@media (max-width: 991px) { + .resource-list .validation-badge{ + margin: 0px; + } +} + +.validation-badge p.badge-link{ + text-align: center; + margin: 5px 0 0 0 ; + font-size: 14px; +} diff --git a/ckanext/unaids/assets/validation-badge.js b/ckanext/unaids/assets/validation-badge.js new file mode 100644 index 00000000..fe903b2b --- /dev/null +++ b/ckanext/unaids/assets/validation-badge.js @@ -0,0 +1,55 @@ +this.ckan.module('validation-badge', function (jQuery) { + return{ + options: { + resource: null, + status: 'created', + url: null + }, + initialize: function () { + $.proxyAll(this, /_on/); + this._poll(); + this.options.url = $(this.el).attr('href'); + $(this.el).removeAttr('href'); + }, + _poll: function() { + var module = this; + $.ajax({ + url: "/api/3/action/resource_validation_show?resource_id=" + this.options.resource, + type: "GET", + success: function(data){module._success(data);}, + error: function(XMLHttpRequest, textStatus, errorThrown){module._error(XMLHttpRequest, textStatus, errorThrown);}, + dataType: "json", + complete: setTimeout(function(){module._complete();}, 5000), + timeout: 2000 + }); + }, + _success: function(data) { + this.options.status = data.result.status; + if(this.options.status != 'running' && this.options.status != 'created'){ + this._update_badge(); + $(this.el).attr('href', this.options.url); + if( this.options.status == 'failure' || this.options.status == 'error' ){ + $(this.el).find('.badge-link').removeClass('hidden'); + } + } + }, + _error: function(XMLHttpRequest, textStatus, errorThrown) { + this.options.status = 'error'; + this._update_badge(); + var message = 'No server connection. Please refresh your page.'; + $(this.el).attr('title', message ); + $(this.el).find('img').attr('title', message ); + }, + _complete: function() { + if(this.options.status == 'running' || this.options.status == 'created'){ + this._poll(); + } + }, + _update_badge: function(){ + var src = $('a.validation-badge').find('img').attr('src'); + var src = src.split('-')[0] + "-" + this.options.status + '.gif'; + $(this.el).find('img').attr('src', src); + } + + } +}); diff --git a/ckanext/unaids/assets/webassets.yml b/ckanext/unaids/assets/webassets.yml index 85bedd1d..808f1362 100644 --- a/ckanext/unaids/assets/webassets.yml +++ b/ckanext/unaids/assets/webassets.yml @@ -7,6 +7,7 @@ main: - text_template.js - bootstrap_table.js - format_update.js + - validation-badge.js extra: preload: - base/main @@ -64,3 +65,9 @@ MapSelectorCSS: filters: cssmin output: unaids/%(version)s_MapSelector.css +ValidationBadgeCSS: + filters: cssmin + output: unaids/%(version)s_ValidationBadge.css + contents: + - css/validation.css + diff --git a/ckanext/unaids/helpers.py b/ckanext/unaids/helpers.py index 3497e109..96798f79 100644 --- a/ckanext/unaids/helpers.py +++ b/ckanext/unaids/helpers.py @@ -2,14 +2,16 @@ import logging import os import json +import requests import six from ckan.lib.helpers import url_for_static_or_external, check_access, full_current_url from ckan.lib.i18n import get_lang from ckan.plugins.toolkit import get_action, request from ckan.plugins import toolkit -from ckan.common import _, g, config +from ckan.common import _, g, asbool, config from ckan.lib.helpers import build_nav_main as core_build_nav_main + try: from html import escape as html_escape except ImportError: @@ -20,6 +22,48 @@ log = logging.getLogger() BULK_FILE_UPLOADER_DEFAULT_FIELDS = 'ckanext.bulk_file_uploader_default_fields' +log = logging.getLogger(__name__) + + +def _files_from_directory(path, extension=".json"): + listed_files = {} + for root, dirs, files in os.walk(path): + for file in files: + if extension in file: + name = file.split(".json")[0] + listed_files[name] = os.path.join(root, file) + return listed_files + + +def get_schema_filepath(schema): + schema_directory = toolkit.config["ckanext.unaids.schema_directory"] + schemas = _files_from_directory(schema_directory) + return schemas.get(schema) + + +def validation_load_json_schema(schema): + try: + # When updating a resource there's already an existing JSON schema + # attached to the resource + if isinstance(schema, dict): + return schema + + if schema.startswith("http"): + r = requests.get(schema) + return r.json() + + schema_filepath = get_schema_filepath(schema) + if schema_filepath: + with open(schema_filepath, "rb") as schema_file: + return json.load(schema_file) + + return json.loads(schema) + + except json.JSONDecodeError as e: + log.error("Error loading schema: " + schema) + log.exception(e) + return None + def get_all_package_downloads(pkg_dict): """ @@ -185,3 +229,60 @@ def is_an_estimates_dataset(dataset_type_name): def url_encode(url): return quote(url, safe='/:?=&') + + +def unaids_get_validation_badge(resource, in_listing=False): + + if in_listing and not asbool( + toolkit.config.get('ckanext.validation.show_badges_in_listings', True)): + return '' + + if not resource.get('validation_status'): + return '' + + messages = { + 'success': _('Valid data'), + 'failure': _('Invalid data'), + 'error': _('Error during validation'), + 'unknown': _('Data validation unknown'), + } + + if resource['validation_status'] in ['success', 'failure', 'error']: + status = resource['validation_status'] + else: + status = 'unknown' + + validation_url = toolkit.url_for( + 'validation_read', + id=resource['package_id'], + resource_id=resource['id'] + ) + + tags = "" + if status == 'unknown': + tags += "data-module='validation-badge' data-module-resource='{}'".format( + resource['id'] + ) + + badge_url = url_for_static_or_external( + '/images/badges/{}-{}.gif'.format(toolkit.h.lang(), status)) + + link_visibility = "" + if status in ['success', 'unknown']: + link_visibility = 'hidden' + + badge_html = ''' + + {alt} + +'''.format( + validation_url=validation_url, + tags=tags, + badge_url=badge_url, + alt=messages[status], + title=resource.get('validation_timestamp', ''), + link_visibility=link_visibility, + badge_link=_('View Error Report') + ) + + return badge_html diff --git a/ckanext/unaids/i18n/fr/LC_MESSAGES/ckanext-unaids.mo b/ckanext/unaids/i18n/fr/LC_MESSAGES/ckanext-unaids.mo index 1a220012..109029cf 100755 Binary files a/ckanext/unaids/i18n/fr/LC_MESSAGES/ckanext-unaids.mo and b/ckanext/unaids/i18n/fr/LC_MESSAGES/ckanext-unaids.mo differ diff --git a/ckanext/unaids/i18n/fr/LC_MESSAGES/ckanext-unaids.po b/ckanext/unaids/i18n/fr/LC_MESSAGES/ckanext-unaids.po index 67da667f..c1086b78 100755 --- a/ckanext/unaids/i18n/fr/LC_MESSAGES/ckanext-unaids.po +++ b/ckanext/unaids/i18n/fr/LC_MESSAGES/ckanext-unaids.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PROJECT VERSION\n" "Report-Msgid-Bugs-To: info@fjelltopp.org\n" -"POT-Creation-Date: 2023-07-27 11:48+0000\n" +"POT-Creation-Date: 2023-08-01 17:46+0000\n" "PO-Revision-Date: 2020-12-14 12:15+0300\n" "Last-Translator: Toavina A. \n" "Language: fr\n" @@ -27,10 +27,30 @@ msgstr "Ressource introuvable." msgid "TaskStatus was not found." msgstr "L'état actuel de la tâche est introuvable." -#: ckanext/unaids/helpers.py:166 +#: ckanext/unaids/helpers.py:197 msgid "title" msgstr "Titre" +#: ckanext/unaids/helpers.py:233 +msgid "Valid data" +msgstr "Données valides" + +#: ckanext/unaids/helpers.py:234 +msgid "Invalid data" +msgstr "Données invalides" + +#: ckanext/unaids/helpers.py:235 +msgid "Error during validation" +msgstr "Erreur durant la validation" + +#: ckanext/unaids/helpers.py:236 +msgid "Data validation unknown" +msgstr "Validation de données inconnue" + +#: ckanext/unaids/helpers.py:250 +msgid "en" +msgstr "fr" + #: ckanext/unaids/licenses.py:13 msgid "Creative Commons Attribution for Intergovernmental Organisations" msgstr "" @@ -58,7 +78,7 @@ msgstr "Année" msgid "Location" msgstr "Lieu" -#: ckanext/unaids/plugin.py:272 +#: ckanext/unaids/plugin.py:288 msgid "Data Explorer" msgstr "Explorateur de données" @@ -93,18 +113,6 @@ msgstr "iframe" msgid ",m[42]=" msgstr ",m[42]=" -#: ckanext/unaids/blueprints/ape_data_receiver.py:13 -msgid "You must be logged in to access this page" -msgstr "Vous devez être connecté pour accéder à cette page" - -#: ckanext/unaids/blueprints/ape_data_receiver.py:15 -msgid "" -"User profile successfully saved, you need to log in again to see the " -"changes." -msgstr "" -"Le profil utilisateur a été enregistré avec succès. Vous devez vous " -"connecter à nouveau pour voir les modifications." - #: ckanext/unaids/blueprints/unaids_dataset_releases.py:16 msgid "Something went wrong. Please try again." msgstr "Une erreur est survenue. Veuillez réessayer." @@ -186,7 +194,7 @@ msgstr "Entrées et sorties pour le modèle Naomi" #: ckanext/unaids/i18n/extra_translations.py:12 #: ckanext/unaids/theme/templates/footer.html:10 #: ckanext/unaids/theme/templates/organization/read_base.html:12 -#: ckanext/unaids/theme/templates/user/edit_user_form.html:32 +#: ckanext/unaids/theme/templates/user/edit_user_form.html:21 msgid "About" msgstr "À propos" @@ -291,6 +299,7 @@ msgid "URL" msgstr "URL" #: ckanext/unaids/i18n/extra_translations.py:37 +#: ckanext/unaids/theme/templates/user/edit_user_form.html:15 #: ckanext/unaids/theme/templates/user/new_user_form.html:22 msgid "Email" msgstr "e-mail" @@ -453,7 +462,7 @@ msgstr "" #: ckanext/unaids/react/components/FileInputComponent/src/DisplayUploadedFile.js:14 #: ckanext/unaids/react/components/FileInputComponent/src/UrlUploader.js:26 #: ckanext/unaids/theme/templates/scheming/form_snippets/upload.html:46 -#: ckanext/unaids/theme/templates/snippets/search_form.html:14 +#: ckanext/unaids/theme/templates/snippets/search_form.html:17 msgid "Remove" msgstr "Supprimer" @@ -658,15 +667,15 @@ msgstr "Avec l’appui de" #: ckanext/unaids/theme/templates/organization/members.html:70 #: ckanext/unaids/theme/templates/package/collaborators/collaborator_new.html:34 #: ckanext/unaids/theme/templates/package/releases/delete.html:12 -#: ckanext/unaids/theme/templates/package/snippets/resource_item.html:63 -#: ckanext/unaids/theme/templates/user/edit_user_form.html:57 +#: ckanext/unaids/theme/templates/package/snippets/resource_item.html:65 +#: ckanext/unaids/theme/templates/user/edit_user_form.html:46 msgid "Delete" msgstr "Supprimer" #: ckanext/unaids/theme/templates/organization/bulk_process.html:42 #: ckanext/unaids/theme/templates/organization/members.html:67 #: ckanext/unaids/theme/templates/package/releases/create_or_edit.html:31 -#: ckanext/unaids/theme/templates/package/snippets/resource_item.html:55 +#: ckanext/unaids/theme/templates/package/snippets/resource_item.html:57 msgid "Edit" msgstr "Modifier" @@ -699,6 +708,7 @@ msgstr "" " descriptions de rôle." #: ckanext/unaids/theme/templates/organization/member_new.html:16 +#: ckanext/unaids/theme/templates/user/edit_user_form.html:11 #: ckanext/unaids/theme/templates/user/new_user_form.html:11 #: ckanext/unaids/theme/templates/user/new_user_form.html:14 msgid "Username" @@ -749,6 +759,7 @@ msgstr "Titre de poste" #: ckanext/unaids/theme/templates/organization/members.html:13 #: ckanext/unaids/theme/templates/organization/members.html:48 #: ckanext/unaids/theme/templates/request/show.html:32 +#: ckanext/unaids/theme/templates/user/edit_user_form.html:19 #: ckanext/unaids/theme/templates/user/new_user_form.html:20 msgid "Affiliation" msgstr "Affiliation" @@ -808,12 +819,12 @@ msgstr "Ajouter une nouvelle ressource" msgid "New resource" msgstr "Nouvelle ressource" -#: ckanext/unaids/theme/templates/package/new_resource_not_draft.html:30 +#: ckanext/unaids/theme/templates/package/new_resource_not_draft.html:32 #: ckanext/unaids/theme/templates/package/snippets/bulk_file_uploader.html:4 msgid "Bulk Upload" msgstr "Transfert groupé" -#: ckanext/unaids/theme/templates/package/new_resource_not_draft.html:31 +#: ckanext/unaids/theme/templates/package/new_resource_not_draft.html:33 msgid "Bulk upload is not possible for this resource." msgstr "Cette ressource ne permet pas le transfert groupé." @@ -1009,27 +1020,27 @@ msgstr "Restaurer" msgid "Not Set" msgstr "Non défini" -#: ckanext/unaids/theme/templates/package/snippets/resource_item.html:18 +#: ckanext/unaids/theme/templates/package/snippets/resource_item.html:20 msgid "Last modified" msgstr "Dernière modification" -#: ckanext/unaids/theme/templates/package/snippets/resource_item.html:28 +#: ckanext/unaids/theme/templates/package/snippets/resource_item.html:30 msgid "Preview" msgstr "Aperçu" -#: ckanext/unaids/theme/templates/package/snippets/resource_item.html:31 +#: ckanext/unaids/theme/templates/package/snippets/resource_item.html:33 msgid "More information" msgstr "Plus d'informations" -#: ckanext/unaids/theme/templates/package/snippets/resource_item.html:41 +#: ckanext/unaids/theme/templates/package/snippets/resource_item.html:43 msgid "Download" msgstr "Télécharger" -#: ckanext/unaids/theme/templates/package/snippets/resource_item.html:46 +#: ckanext/unaids/theme/templates/package/snippets/resource_item.html:48 msgid "Go to resource" msgstr "Aller à la ressource" -#: ckanext/unaids/theme/templates/package/snippets/resource_item.html:61 +#: ckanext/unaids/theme/templates/package/snippets/resource_item.html:63 msgid "Are you sure you want to delete this resource?" msgstr "Êtes-vous sûr de vouloir supprimer cette ressource ?" @@ -1049,15 +1060,15 @@ msgstr "Êtes-vous sûr de vouloir approuver cette requête?" msgid "Are you sure you want reject this request?" msgstr "Êtes-vous sûr de vouloir rejeter cette requête?" -#: ckanext/unaids/theme/templates/scheming/form_snippets/org_to_allow_transfer_to.html:13 +#: ckanext/unaids/theme/templates/scheming/form_snippets/org_to_allow_transfer_to.html:15 msgid "No organisation" msgstr "Aucune organisation" -#: ckanext/unaids/theme/templates/scheming/form_snippets/org_to_allow_transfer_to.html:32 +#: ckanext/unaids/theme/templates/scheming/form_snippets/org_to_allow_transfer_to.html:35 msgid "Transfer Dataset" msgstr "Transférer l'ensemble de données" -#: ckanext/unaids/theme/templates/scheming/form_snippets/org_to_allow_transfer_to.html:43 +#: ckanext/unaids/theme/templates/scheming/form_snippets/org_to_allow_transfer_to.html:46 msgid "How dataset transfers work:" msgstr "Comment fonctionnent les transferts d’ensemble de données :" @@ -1083,7 +1094,7 @@ msgstr "Données générales" msgid "Add Dataset" msgstr "Ajouter un ensemble de données" -#: ckanext/unaids/theme/templates/snippets/search_form.html:20 +#: ckanext/unaids/theme/templates/snippets/search_form.html:23 msgid "Filter Results" msgstr "Filtrer les résultats" @@ -1218,51 +1229,62 @@ msgstr "Mes organisations" msgid "Change details" msgstr "Changer les détails" -#: ckanext/unaids/theme/templates/user/edit_user_form.html:9 -msgid "HIV Tools Profile Data" -msgstr "Données de profil Outils VIH" +#: ckanext/unaids/theme/templates/user/edit_user_form.html:13 +msgid "Full name" +msgstr "Nom complet" -#: ckanext/unaids/theme/templates/user/edit_user_form.html:19 -msgid "No job title specified" -msgstr "Titre de poste non spécifié" +#: ckanext/unaids/theme/templates/user/edit_user_form.html:13 +msgid "eg. Joe Bloggs" +msgstr "par ex. Joe Bloggs" + +#: ckanext/unaids/theme/templates/user/edit_user_form.html:15 +msgid "eg. joe@example.com" +msgstr "par ex. joe@example.com" -#: ckanext/unaids/theme/templates/user/edit_user_form.html:20 -msgid "No organisation specified" -msgstr "Organisation non spécifiée" +#: ckanext/unaids/theme/templates/user/edit_user_form.html:17 +#: ckanext/unaids/theme/templates/user/new_user_form.html:18 +msgid "Job Title" +msgstr "Titre de poste" -#: ckanext/unaids/theme/templates/user/edit_user_form.html:26 -msgid "Update data" -msgstr "Mettre à jour" +#: ckanext/unaids/theme/templates/user/edit_user_form.html:17 +#: ckanext/unaids/theme/templates/user/new_user_form.html:18 +msgid "Data Scientist" +msgstr "Scientifique de Données" -#: ckanext/unaids/theme/templates/user/edit_user_form.html:32 +#: ckanext/unaids/theme/templates/user/edit_user_form.html:19 +#: ckanext/unaids/theme/templates/user/new_user_form.html:20 +msgid "WHO" +msgstr "OMS" + +#: ckanext/unaids/theme/templates/user/edit_user_form.html:21 msgid "A little information about yourself" msgstr "A propos de vous" -#: ckanext/unaids/theme/templates/user/edit_user_form.html:35 +#: ckanext/unaids/theme/templates/user/edit_user_form.html:24 msgid "Subscribe to notification emails" msgstr "S'abonner aux notifications par courriel" -#: ckanext/unaids/theme/templates/user/edit_user_form.html:44 +#: ckanext/unaids/theme/templates/user/edit_user_form.html:33 msgid "Profile picture" msgstr "Photo de profil" -#: ckanext/unaids/theme/templates/user/edit_user_form.html:44 +#: ckanext/unaids/theme/templates/user/edit_user_form.html:33 msgid "Profile picture URL" msgstr "URL de la photo de profil" -#: ckanext/unaids/theme/templates/user/edit_user_form.html:57 +#: ckanext/unaids/theme/templates/user/edit_user_form.html:46 msgid "Are you sure you want to delete this User?" msgstr "Êtes-vous sûr de vouloir supprimer cet utilisateur?" -#: ckanext/unaids/theme/templates/user/edit_user_form.html:62 +#: ckanext/unaids/theme/templates/user/edit_user_form.html:51 msgid "Are you sure you want to regenerate the API key?" msgstr "Êtes-vous sûr de vouloir régénérer la clé API?" -#: ckanext/unaids/theme/templates/user/edit_user_form.html:62 +#: ckanext/unaids/theme/templates/user/edit_user_form.html:51 msgid "Regenerate API Key" msgstr "Régénérer la clé API" -#: ckanext/unaids/theme/templates/user/edit_user_form.html:65 +#: ckanext/unaids/theme/templates/user/edit_user_form.html:54 msgid "Update Profile" msgstr "Mettre à jour le profil" @@ -1281,18 +1303,6 @@ msgstr "Joe Bloggs" msgid "username" msgstr "Nom d'utilisateur" -#: ckanext/unaids/theme/templates/user/new_user_form.html:18 -msgid "Job Title" -msgstr "Titre de poste" - -#: ckanext/unaids/theme/templates/user/new_user_form.html:18 -msgid "Data Scientist" -msgstr "Scientifique de Données" - -#: ckanext/unaids/theme/templates/user/new_user_form.html:20 -msgid "WHO" -msgstr "OMS" - #: ckanext/unaids/theme/templates/user/new_user_form.html:22 #: ckanext/unaids/theme/templates/user/new_user_form.html:24 msgid "joe@example.com" @@ -1314,6 +1324,19 @@ msgstr "Confirmer le mot de passe" msgid "Create Account" msgstr "Créer un compte" +#: ckanext/unaids/theme/templates/validation/validation_read.html:4 +msgid "Validation Report" +msgstr "Raport de validation" + +#: ckanext/unaids/theme/templates/validation/validation_read.html:27 +msgid "Validation timestamp" +msgstr "Horaire de validation" + +#: ckanext/unaids/theme/templates/validation/validation_read.html:29 +#, fuzzy +msgid "Duration" +msgstr "Lieu" + #~ msgid "Click below for more information on uploading data:" #~ msgstr "Pour plus d'informations sur le téléchargement cliquez ci-dessous:" @@ -1344,18 +1367,3 @@ msgstr "Créer un compte" #~ msgid "VMMC Data" #~ msgstr "Données VMMC" -#~ msgid "To change your profile settings, please " -#~ msgstr "Pour changer les paramètres de votre profil, veuillez " - -#~ msgid "click here" -#~ msgstr "cliquer ici" - -#~ msgid "Full name" -#~ msgstr "Nom complet" - -#~ msgid "eg. Joe Bloggs" -#~ msgstr "par ex. Joe Bloggs" - -#~ msgid "eg. joe@example.com" -#~ msgstr "par ex. joe@example.com" - diff --git a/ckanext/unaids/i18n/pt_PT/LC_MESSAGES/ckanext-unaids.mo b/ckanext/unaids/i18n/pt_PT/LC_MESSAGES/ckanext-unaids.mo index d160dc83..d17b6b43 100755 Binary files a/ckanext/unaids/i18n/pt_PT/LC_MESSAGES/ckanext-unaids.mo and b/ckanext/unaids/i18n/pt_PT/LC_MESSAGES/ckanext-unaids.mo differ diff --git a/ckanext/unaids/i18n/pt_PT/LC_MESSAGES/ckanext-unaids.po b/ckanext/unaids/i18n/pt_PT/LC_MESSAGES/ckanext-unaids.po index c24e93a3..8324ab62 100755 --- a/ckanext/unaids/i18n/pt_PT/LC_MESSAGES/ckanext-unaids.po +++ b/ckanext/unaids/i18n/pt_PT/LC_MESSAGES/ckanext-unaids.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: ckanext-unaids 0.0\n" "Report-Msgid-Bugs-To: info@fjelltopp.org\n" -"POT-Creation-Date: 2023-07-27 11:48+0000\n" +"POT-Creation-Date: 2023-08-01 17:46+0000\n" "PO-Revision-Date: 2022-01-11 08:31+0000\n" "Last-Translator: Toavina A. \n" "Language: pt_PT\n" @@ -27,9 +27,29 @@ msgstr "Recurso não encontrado." msgid "TaskStatus was not found." msgstr "O TaskStatus não foi encontrado." -#: ckanext/unaids/helpers.py:166 +#: ckanext/unaids/helpers.py:197 msgid "title" -msgstr "título" +msgstr "titulo" + +#: ckanext/unaids/helpers.py:233 +msgid "Valid data" +msgstr "Dados válidos" + +#: ckanext/unaids/helpers.py:234 +msgid "Invalid data" +msgstr "Dados inválidos" + +#: ckanext/unaids/helpers.py:235 +msgid "Error during validation" +msgstr "Erro durante a validação" + +#: ckanext/unaids/helpers.py:236 +msgid "Data validation unknown" +msgstr "Validação de dados desconhecida" + +#: ckanext/unaids/helpers.py:250 +msgid "en" +msgstr "pt_PT" #: ckanext/unaids/licenses.py:13 msgid "Creative Commons Attribution for Intergovernmental Organisations" @@ -56,7 +76,7 @@ msgstr "Ano" msgid "Location" msgstr "Localização" -#: ckanext/unaids/plugin.py:272 +#: ckanext/unaids/plugin.py:288 msgid "Data Explorer" msgstr "Explorador de dados" @@ -91,18 +111,6 @@ msgstr "iframe" msgid ",m[42]=" msgstr ",m[42]=" -#: ckanext/unaids/blueprints/ape_data_receiver.py:13 -msgid "You must be logged in to access this page" -msgstr "Você precisa estar conectado para acessar esta página" - -#: ckanext/unaids/blueprints/ape_data_receiver.py:15 -msgid "" -"User profile successfully saved, you need to log in again to see the " -"changes." -msgstr "" -"Perfil de usuário salvo com sucesso. Você precisa fazer login novamente " -"para ver as alterações." - #: ckanext/unaids/blueprints/unaids_dataset_releases.py:16 msgid "Something went wrong. Please try again." msgstr "Alguma coisa correu mal. Por favor, tente novamente." @@ -182,7 +190,7 @@ msgstr "Entradas e Saídas Naomi" #: ckanext/unaids/i18n/extra_translations.py:12 #: ckanext/unaids/theme/templates/footer.html:10 #: ckanext/unaids/theme/templates/organization/read_base.html:12 -#: ckanext/unaids/theme/templates/user/edit_user_form.html:32 +#: ckanext/unaids/theme/templates/user/edit_user_form.html:21 msgid "About" msgstr "Sobre" @@ -287,6 +295,7 @@ msgid "URL" msgstr "URL" #: ckanext/unaids/i18n/extra_translations.py:37 +#: ckanext/unaids/theme/templates/user/edit_user_form.html:15 #: ckanext/unaids/theme/templates/user/new_user_form.html:22 msgid "Email" msgstr "Email" @@ -434,20 +443,18 @@ msgstr "Carregado" #: ckanext/unaids/react/components/FileInputComponent/src/App.js:41 msgid "Unfortunately an error has occurred." -msgstr "Infelizmente, ocorreu um erro.." +msgstr "Ocorreu um erro desconhecido." #: ckanext/unaids/react/components/FileInputComponent/src/App.js:46 msgid "" "Please click here to try " "again." msgstr "" -"Clique em here para tentar" -" novamente." #: ckanext/unaids/react/components/FileInputComponent/src/DisplayUploadedFile.js:14 #: ckanext/unaids/react/components/FileInputComponent/src/UrlUploader.js:26 #: ckanext/unaids/theme/templates/scheming/form_snippets/upload.html:46 -#: ckanext/unaids/theme/templates/snippets/search_form.html:14 +#: ckanext/unaids/theme/templates/snippets/search_form.html:17 msgid "Remove" msgstr "Remover" @@ -513,7 +520,7 @@ msgstr "Carregamento" #: ckanext/unaids/react/components/FileInputComponent/src/ResourceForker.js:74 msgid "Search existing resources" -msgstr "Pesquisar recursos existentes" +msgstr "Buscar recursos existentes" #: ckanext/unaids/react/components/FileInputComponent/src/ResourceForker.js:177 #: ckanext/unaids/react/components/FileInputComponent/src/ResourceForker.js:256 @@ -526,7 +533,7 @@ msgstr "Verificando o acesso..." #: ckanext/unaids/react/components/FileInputComponent/src/ResourceForker.js:193 msgid "Request Access" -msgstr "Solicitar acesso" +msgstr "Solicitar Acesso" #: ckanext/unaids/react/components/FileInputComponent/src/ResourceForker.js:198 msgid "Circular Import" @@ -542,7 +549,7 @@ msgstr "Importar dados de outro recurso:" #: ckanext/unaids/react/components/FileInputComponent/src/ResourceForker.js:373 msgid "Import Latest Data" -msgstr "Importar dados mais recentes" +msgstr "Importar Dados Atualizados" #: ckanext/unaids/react/components/FileInputComponent/src/ResourceForker.js:379 msgid "Select Different Resource" @@ -610,6 +617,7 @@ msgid "HIV Estimates
Navigator" msgstr "Navegador
de estimativas sobre o VIH" #: ckanext/unaids/theme/templates/home/layout1.html:51 +#, fuzzy msgid "Instructions to upload your
Country Estimates 2024 Data" msgstr "Instruções para carregar os seus
dados de Estimativas do país 2024" @@ -649,15 +657,15 @@ msgstr "Com o apoio de" #: ckanext/unaids/theme/templates/organization/members.html:70 #: ckanext/unaids/theme/templates/package/collaborators/collaborator_new.html:34 #: ckanext/unaids/theme/templates/package/releases/delete.html:12 -#: ckanext/unaids/theme/templates/package/snippets/resource_item.html:63 -#: ckanext/unaids/theme/templates/user/edit_user_form.html:57 +#: ckanext/unaids/theme/templates/package/snippets/resource_item.html:65 +#: ckanext/unaids/theme/templates/user/edit_user_form.html:46 msgid "Delete" msgstr "Eliminar" #: ckanext/unaids/theme/templates/organization/bulk_process.html:42 #: ckanext/unaids/theme/templates/organization/members.html:67 #: ckanext/unaids/theme/templates/package/releases/create_or_edit.html:31 -#: ckanext/unaids/theme/templates/package/snippets/resource_item.html:55 +#: ckanext/unaids/theme/templates/package/snippets/resource_item.html:57 msgid "Edit" msgstr "Editar" @@ -690,6 +698,7 @@ msgstr "" "descrição das funções." #: ckanext/unaids/theme/templates/organization/member_new.html:16 +#: ckanext/unaids/theme/templates/user/edit_user_form.html:11 #: ckanext/unaids/theme/templates/user/new_user_form.html:11 #: ckanext/unaids/theme/templates/user/new_user_form.html:14 msgid "Username" @@ -723,23 +732,24 @@ msgstr "Adicionar Membro" #: ckanext/unaids/theme/templates/organization/members.html:6 msgid "Membership requests" -msgstr "Solicitação de associação" +msgstr "Solicitações de adesão" #: ckanext/unaids/theme/templates/organization/members.html:11 #: ckanext/unaids/theme/templates/organization/members.html:46 #: ckanext/unaids/theme/templates/request/show.html:14 msgid "User" -msgstr "Utilizador" +msgstr "Nome de utilizador" #: ckanext/unaids/theme/templates/organization/members.html:12 #: ckanext/unaids/theme/templates/organization/members.html:47 #: ckanext/unaids/theme/templates/request/show.html:27 msgid "Job title" -msgstr "Cargo" +msgstr "Título do cargo" #: ckanext/unaids/theme/templates/organization/members.html:13 #: ckanext/unaids/theme/templates/organization/members.html:48 #: ckanext/unaids/theme/templates/request/show.html:32 +#: ckanext/unaids/theme/templates/user/edit_user_form.html:19 #: ckanext/unaids/theme/templates/user/new_user_form.html:20 msgid "Affiliation" msgstr "Organização" @@ -747,7 +757,7 @@ msgstr "Organização" #: ckanext/unaids/theme/templates/organization/members.html:15 #: ckanext/unaids/theme/templates/request/show.html:37 msgid "Request date" -msgstr "Data do Pedido" +msgstr "Data da solicitação" #: ckanext/unaids/theme/templates/organization/members.html:16 msgid "Action" @@ -799,12 +809,12 @@ msgstr "Adicionar Novo Recurso" msgid "New resource" msgstr "Novo recurso" -#: ckanext/unaids/theme/templates/package/new_resource_not_draft.html:30 +#: ckanext/unaids/theme/templates/package/new_resource_not_draft.html:32 #: ckanext/unaids/theme/templates/package/snippets/bulk_file_uploader.html:4 msgid "Bulk Upload" msgstr "Upload em massa" -#: ckanext/unaids/theme/templates/package/new_resource_not_draft.html:31 +#: ckanext/unaids/theme/templates/package/new_resource_not_draft.html:33 msgid "Bulk upload is not possible for this resource." msgstr "O upload em massa não é possível para este recurso." @@ -997,33 +1007,33 @@ msgstr "Restaurar" msgid "Not Set" msgstr "Não definido" -#: ckanext/unaids/theme/templates/package/snippets/resource_item.html:18 +#: ckanext/unaids/theme/templates/package/snippets/resource_item.html:20 msgid "Last modified" msgstr "Última modificação" -#: ckanext/unaids/theme/templates/package/snippets/resource_item.html:28 +#: ckanext/unaids/theme/templates/package/snippets/resource_item.html:30 msgid "Preview" msgstr "Pré-visualização" -#: ckanext/unaids/theme/templates/package/snippets/resource_item.html:31 +#: ckanext/unaids/theme/templates/package/snippets/resource_item.html:33 msgid "More information" msgstr "Mais informações" -#: ckanext/unaids/theme/templates/package/snippets/resource_item.html:41 +#: ckanext/unaids/theme/templates/package/snippets/resource_item.html:43 msgid "Download" msgstr "Descarregar" -#: ckanext/unaids/theme/templates/package/snippets/resource_item.html:46 +#: ckanext/unaids/theme/templates/package/snippets/resource_item.html:48 msgid "Go to resource" msgstr "Ir para o recurso" -#: ckanext/unaids/theme/templates/package/snippets/resource_item.html:61 +#: ckanext/unaids/theme/templates/package/snippets/resource_item.html:63 msgid "Are you sure you want to delete this resource?" msgstr "Pretende apagar este recurso?" #: ckanext/unaids/theme/templates/request/show.html:6 msgid "Organization membership request" -msgstr "Solicitação de associação à organização" +msgstr "Pedido de associação à organização" #: ckanext/unaids/theme/templates/request/show.html:40 msgid "State" @@ -1031,21 +1041,21 @@ msgstr "Estado" #: ckanext/unaids/theme/templates/request/show.html:58 msgid "Are you sure you want approve this request?" -msgstr "Pretende aprovar esta solicitação?" +msgstr "Tem certeza de que deseja aprovar este pedido?" #: ckanext/unaids/theme/templates/request/show.html:61 msgid "Are you sure you want reject this request?" -msgstr "Pretende rejeitar esta solicitação?" +msgstr "Tem certeza de que deseja rejeitar este pedido?" -#: ckanext/unaids/theme/templates/scheming/form_snippets/org_to_allow_transfer_to.html:13 +#: ckanext/unaids/theme/templates/scheming/form_snippets/org_to_allow_transfer_to.html:15 msgid "No organisation" msgstr "Nenhuma organização" -#: ckanext/unaids/theme/templates/scheming/form_snippets/org_to_allow_transfer_to.html:32 +#: ckanext/unaids/theme/templates/scheming/form_snippets/org_to_allow_transfer_to.html:35 msgid "Transfer Dataset" msgstr "Transferir o conjunto de dados" -#: ckanext/unaids/theme/templates/scheming/form_snippets/org_to_allow_transfer_to.html:43 +#: ckanext/unaids/theme/templates/scheming/form_snippets/org_to_allow_transfer_to.html:46 msgid "How dataset transfers work:" msgstr "Como funcionam as transferências de conjuntos de dados:" @@ -1071,7 +1081,7 @@ msgstr "Dados gerais" msgid "Add Dataset" msgstr "Adicionar conjunto de dados" -#: ckanext/unaids/theme/templates/snippets/search_form.html:20 +#: ckanext/unaids/theme/templates/snippets/search_form.html:23 msgid "Filter Results" msgstr "Filtrar resultados" @@ -1084,7 +1094,7 @@ msgstr[1] "{number} {type} conjuntos de dados encontrados para \"{query}\"" #: ckanext/unaids/theme/templates/snippets/search_result_text.html:20 #: ckanext/unaids/theme/templates/snippets/search_result_text.html:25 msgid "No datasets found for \"{query}\"" -msgstr "Nenhum conjunto de dados encontrado para \"{query}\"" +msgstr "Nenhum conjunto de dados encontrado para" #: ckanext/unaids/theme/templates/snippets/search_result_text.html:21 msgid "{number} {type} dataset found" @@ -1137,7 +1147,7 @@ msgstr[1] "{number} organizações encontradas para \"{query}\"" #: ckanext/unaids/theme/templates/snippets/search_result_text.html:38 msgid "No organizations found for \"{query}\"" -msgstr "Nenhuma organização encontrada para" +msgstr "Nenhuma organização encontrada para \"{query}\"" #: ckanext/unaids/theme/templates/snippets/search_result_text.html:39 msgid "{number} organization found" @@ -1152,22 +1162,22 @@ msgstr "Nenhuma organização encontrada" #: ckanext/unaids/theme/templates/snippets/search_result_text.html:43 msgid "{number} DHIS2 source found for \"{query}\"" msgid_plural "{number} DHIS2 sources found for \"{query}\"" -msgstr[0] "{number} fonte DHIS2 encontrada para \"{query}\"" -msgstr[1] "{number} fontes DHIS2 encontradas para \"{query}\"" +msgstr[0] "{number} fonte do DHIS2 encontrada para \"{query}\"" +msgstr[1] "{number} fontes do DHIS2 encontradas para \"{query}\"" #: ckanext/unaids/theme/templates/snippets/search_result_text.html:44 msgid "Sorry no DHIS2 sources found for \"{query}\"" -msgstr "Desculpe, nenhuma fonte DHIS2 encontrada para \"{query}\"" +msgstr "Desculpe, nenhuma fonte do DHIS2 encontrada para \"{query}\"" #: ckanext/unaids/theme/templates/snippets/search_result_text.html:45 msgid "{number} DHIS2 source found" msgid_plural "{number} DHIS2 sources found" -msgstr[0] "{number} fonte DHIS2 encontrada" -msgstr[1] "{number} fontes DHIS2 encontradas" +msgstr[0] "{number} fonte do DHIS2 encontrada" +msgstr[1] "{number} fontes do DHIS2 encontradas" #: ckanext/unaids/theme/templates/snippets/search_result_text.html:46 msgid "Sorry no DHIS2 sources found" -msgstr "Desculpe, nenhuma fonte DHIS2 encontrada" +msgstr "Desculpe, nenhuma fonte do DHIS2 encontrada" #: ckanext/unaids/theme/templates/snippets/activities/changed_package.html:6 msgid "{actor} updated the dataset {dataset}" @@ -1206,53 +1216,64 @@ msgstr "As Minhas Organizações" msgid "Change details" msgstr "Alterar detalhes" -#: ckanext/unaids/theme/templates/user/edit_user_form.html:9 -msgid "HIV Tools Profile Data" -msgstr "Dados do Perfil de Ferramentas de HIV" +#: ckanext/unaids/theme/templates/user/edit_user_form.html:13 +msgid "Full name" +msgstr "Nome completo" + +#: ckanext/unaids/theme/templates/user/edit_user_form.html:13 +msgid "eg. Joe Bloggs" +msgstr "ex. Joe Bloggs" -#: ckanext/unaids/theme/templates/user/edit_user_form.html:19 -msgid "No job title specified" -msgstr "Sem título de cargo especificado" +#: ckanext/unaids/theme/templates/user/edit_user_form.html:15 +msgid "eg. joe@example.com" +msgstr "ex. joe@example.com" -#: ckanext/unaids/theme/templates/user/edit_user_form.html:20 -msgid "No organisation specified" -msgstr "Organização não especificada" +#: ckanext/unaids/theme/templates/user/edit_user_form.html:17 +#: ckanext/unaids/theme/templates/user/new_user_form.html:18 +msgid "Job Title" +msgstr "Título do cargo" -#: ckanext/unaids/theme/templates/user/edit_user_form.html:26 -msgid "Update data" -msgstr "Atualizar dados" +#: ckanext/unaids/theme/templates/user/edit_user_form.html:17 +#: ckanext/unaids/theme/templates/user/new_user_form.html:18 +msgid "Data Scientist" +msgstr "Cientista de Dados" -#: ckanext/unaids/theme/templates/user/edit_user_form.html:32 +#: ckanext/unaids/theme/templates/user/edit_user_form.html:19 +#: ckanext/unaids/theme/templates/user/new_user_form.html:20 +msgid "WHO" +msgstr "OMS" + +#: ckanext/unaids/theme/templates/user/edit_user_form.html:21 msgid "A little information about yourself" -msgstr "Um pouco de informação sobre você" +msgstr "Uma pequena informação sobre você mesmo" -#: ckanext/unaids/theme/templates/user/edit_user_form.html:35 +#: ckanext/unaids/theme/templates/user/edit_user_form.html:24 msgid "Subscribe to notification emails" -msgstr "Assinar e-mails de notificação" +msgstr "Inscrever-se para receber e-mails de notificação" -#: ckanext/unaids/theme/templates/user/edit_user_form.html:44 +#: ckanext/unaids/theme/templates/user/edit_user_form.html:33 msgid "Profile picture" -msgstr "Foto do perfil" +msgstr "Foto de perfil" -#: ckanext/unaids/theme/templates/user/edit_user_form.html:44 +#: ckanext/unaids/theme/templates/user/edit_user_form.html:33 msgid "Profile picture URL" -msgstr "URL da foto do perfil" +msgstr "URL da foto de perfil" -#: ckanext/unaids/theme/templates/user/edit_user_form.html:57 +#: ckanext/unaids/theme/templates/user/edit_user_form.html:46 msgid "Are you sure you want to delete this User?" msgstr "Pretende apagar este membro?" -#: ckanext/unaids/theme/templates/user/edit_user_form.html:62 +#: ckanext/unaids/theme/templates/user/edit_user_form.html:51 msgid "Are you sure you want to regenerate the API key?" -msgstr "Tem certeza de que deseja gerar novamente a chave de API?" +msgstr "Pretende apagar este membro?" -#: ckanext/unaids/theme/templates/user/edit_user_form.html:62 +#: ckanext/unaids/theme/templates/user/edit_user_form.html:51 msgid "Regenerate API Key" -msgstr "Gerar chave de API novamente" +msgstr "Regenerar chave de API" -#: ckanext/unaids/theme/templates/user/edit_user_form.html:65 +#: ckanext/unaids/theme/templates/user/edit_user_form.html:54 msgid "Update Profile" -msgstr "Atualizar perfil" +msgstr "Atualizar Perfil" #: ckanext/unaids/theme/templates/user/new_user_form.html:9 #: ckanext/unaids/theme/templates/user/new_user_form.html:15 @@ -1267,19 +1288,7 @@ msgstr "Joe Bloggs" #: ckanext/unaids/theme/templates/user/new_user_form.html:11 #: ckanext/unaids/theme/templates/user/new_user_form.html:14 msgid "username" -msgstr "nome de usuário" - -#: ckanext/unaids/theme/templates/user/new_user_form.html:18 -msgid "Job Title" -msgstr "Cargo" - -#: ckanext/unaids/theme/templates/user/new_user_form.html:18 -msgid "Data Scientist" -msgstr "Cientista de Dados" - -#: ckanext/unaids/theme/templates/user/new_user_form.html:20 -msgid "WHO" -msgstr "WHO" +msgstr "Nome de utilizador" #: ckanext/unaids/theme/templates/user/new_user_form.html:22 #: ckanext/unaids/theme/templates/user/new_user_form.html:24 @@ -1288,7 +1297,7 @@ msgstr "joe@example.com" #: ckanext/unaids/theme/templates/user/new_user_form.html:24 msgid "Confirm Email" -msgstr "Confirmar e-mail" +msgstr "Confirmar E-mail" #: ckanext/unaids/theme/templates/user/new_user_form.html:26 msgid "Password" @@ -1296,11 +1305,23 @@ msgstr "Senha" #: ckanext/unaids/theme/templates/user/new_user_form.html:27 msgid "Confirm Password" -msgstr "Confirme sua senha" +msgstr "Confirmar Senha" #: ckanext/unaids/theme/templates/user/new_user_form.html:37 msgid "Create Account" -msgstr "Criar uma conta" +msgstr "Criar Conta" + +#: ckanext/unaids/theme/templates/validation/validation_read.html:4 +msgid "Validation Report" +msgstr "Relatório de Validação" + +#: ckanext/unaids/theme/templates/validation/validation_read.html:27 +msgid "Validation timestamp" +msgstr "Carimbo de tempo de validação" + +#: ckanext/unaids/theme/templates/validation/validation_read.html:29 +msgid "Duration" +msgstr "Duração" #~ msgid "Naomi Geographic Data Input" #~ msgstr "Entrada de Dados Geográficos Naomi" @@ -1320,24 +1341,3 @@ msgstr "Criar uma conta" #~ msgid "VMMC Data" #~ msgstr "Dados VMMC" -#~ msgid "" -#~ "User profile successfully saved, you " -#~ "need to log in again to see " -#~ "the changes." -#~ msgstr "" - -#~ msgid "To change your profile settings, please " -#~ msgstr "Para alterar as configurações do seu perfil, " - -#~ msgid "click here" -#~ msgstr "clique aqui" - -#~ msgid "Full name" -#~ msgstr "Nome completo" - -#~ msgid "eg. Joe Bloggs" -#~ msgstr "por exemplo Joe Bloggs" - -#~ msgid "eg. joe@example.com" -#~ msgstr "por exemplo joe@example.com" - diff --git a/ckanext/unaids/logic.py b/ckanext/unaids/logic.py index 84fa68e7..2ee221c7 100644 --- a/ckanext/unaids/logic.py +++ b/ckanext/unaids/logic.py @@ -1,7 +1,7 @@ from ckan import model from ckan.lib.munge import substitute_ascii_equivalents from ckan.plugins import toolkit -from ckanext.validation.helpers import validation_load_json_schema +from ckanext.unaids.helpers import validation_load_json_schema def validate_resource_upload_fields(context, resource_dict): diff --git a/ckanext/unaids/plugin.py b/ckanext/unaids/plugin.py index 86b2b899..83619231 100644 --- a/ckanext/unaids/plugin.py +++ b/ckanext/unaids/plugin.py @@ -33,7 +33,8 @@ get_google_analytics_id, is_an_estimates_dataset, url_encode, - get_ape_url + get_ape_url, + unaids_get_validation_badge ) import ckanext.blob_storage.helpers as blobstorage_helpers import ckanext.unaids.actions as actions @@ -150,7 +151,8 @@ def get_helpers(self): "get_google_analytics_id": get_google_analytics_id, "is_an_estimates_dataset": is_an_estimates_dataset, "url_encode": url_encode, - "get_ape_url": get_ape_url + "get_ape_url": get_ape_url, + "unaids_get_validation_badge": unaids_get_validation_badge, } # IAuthFunctions @@ -163,14 +165,16 @@ def get_validators(self): "organization_id_exists": organization_id_exists_validator, } - def can_validate(self, context, data_dict): - if data_dict.get("validate_package"): + def can_validate(self, context, pkg_dict): + if pkg_dict.get("schema"): + return True + + def after_create(self, context, pkg_dict): + if pkg_dict.get("validate_package") and not context.get("_dont_validate"): logging.warning("VALIDATING ENTIRE PACKAGE") toolkit.get_action("resource_validation_run_batch")( - context, {"dataset_ids": data_dict["package_id"]} + context, {"dataset_ids": pkg_dict["package_id"]} ) - if data_dict.get("schema"): - return True # IPackageController def after_update(self, context, pkg_dict): @@ -185,21 +189,42 @@ def after_update(self, context, pkg_dict): dataset_id=pkg_dict["id"], recipient_org_id=org_to_allow_transfer_to[0], ) + if pkg_dict.get("validate_package") and not context.get("_dont_validate"): + logging.warning("VALIDATING ENTIRE PACKAGE") + toolkit.get_action("resource_validation_run_batch")( + context, {"dataset_ids": pkg_dict["package_id"]} + ) # IResourceController + def _process_schema_fields(self, data_dict): + """ + Here we overload the default schema processing (from frictionlessdata/ckanext-validation) + to allow for the fact that we just pass a schema name around rather than the schema url + or a schema JSON. + """ + + schema = data_dict.pop("schema", None) + if schema: + schema_json = logic.validation_load_json_schema(schema) + data_dict[u'schema_json'] = schema_json + + return data_dict + def before_create(self, context, resource): if _data_dict_is_resource(resource): _giftless_upload(context, resource) _update_resource_last_modified_date(resource) logic.validate_resource_upload_fields(context, resource) - return resource + context["_resource_create_call"] = True + return self._process_schema_fields(resource) def before_update(self, context, current, resource): if _data_dict_is_resource(resource): _giftless_upload(context, resource, current=current) _update_resource_last_modified_date(resource, current=current) logic.validate_resource_upload_fields(context, resource) - return resource + context["_resource_create_call"] = True + return self._process_schema_fields(resource) def before_show(self, resource): if _data_dict_is_resource(resource): @@ -299,7 +324,7 @@ def _data_dict_is_resource(data_dict): def _giftless_upload(context, resource, current=None): attached_file = resource.pop("upload", None) if attached_file: - if type(attached_file) is FlaskFileStorage: + if isinstance(attached_file, FlaskFileStorage): dataset_id = resource.get("package_id") if not dataset_id: dataset_id = current["package_id"] diff --git a/ckanext/unaids/theme/public/images/badges/ValidationBadges.odg b/ckanext/unaids/theme/public/images/badges/ValidationBadges.odg new file mode 100644 index 00000000..9d9ce774 Binary files /dev/null and b/ckanext/unaids/theme/public/images/badges/ValidationBadges.odg differ diff --git a/ckanext/unaids/theme/public/images/badges/en-error.gif b/ckanext/unaids/theme/public/images/badges/en-error.gif new file mode 100644 index 00000000..e5601584 Binary files /dev/null and b/ckanext/unaids/theme/public/images/badges/en-error.gif differ diff --git a/ckanext/unaids/theme/public/images/badges/en-failure.gif b/ckanext/unaids/theme/public/images/badges/en-failure.gif new file mode 100644 index 00000000..350f7642 Binary files /dev/null and b/ckanext/unaids/theme/public/images/badges/en-failure.gif differ diff --git a/ckanext/unaids/theme/public/images/badges/en-success.gif b/ckanext/unaids/theme/public/images/badges/en-success.gif new file mode 100644 index 00000000..29a1c5f0 Binary files /dev/null and b/ckanext/unaids/theme/public/images/badges/en-success.gif differ diff --git a/ckanext/unaids/theme/public/images/badges/en-unknown.gif b/ckanext/unaids/theme/public/images/badges/en-unknown.gif new file mode 100644 index 00000000..5485166c Binary files /dev/null and b/ckanext/unaids/theme/public/images/badges/en-unknown.gif differ diff --git a/ckanext/unaids/theme/public/images/badges/fr-error.gif b/ckanext/unaids/theme/public/images/badges/fr-error.gif new file mode 100644 index 00000000..3bbb4724 Binary files /dev/null and b/ckanext/unaids/theme/public/images/badges/fr-error.gif differ diff --git a/ckanext/unaids/theme/public/images/badges/fr-failure.gif b/ckanext/unaids/theme/public/images/badges/fr-failure.gif new file mode 100644 index 00000000..b6084de7 Binary files /dev/null and b/ckanext/unaids/theme/public/images/badges/fr-failure.gif differ diff --git a/ckanext/unaids/theme/public/images/badges/fr-success.gif b/ckanext/unaids/theme/public/images/badges/fr-success.gif new file mode 100644 index 00000000..2518798a Binary files /dev/null and b/ckanext/unaids/theme/public/images/badges/fr-success.gif differ diff --git a/ckanext/unaids/theme/public/images/badges/fr-unknown.gif b/ckanext/unaids/theme/public/images/badges/fr-unknown.gif new file mode 100644 index 00000000..87a76a72 Binary files /dev/null and b/ckanext/unaids/theme/public/images/badges/fr-unknown.gif differ diff --git a/ckanext/unaids/theme/public/images/badges/pt_PT-error.gif b/ckanext/unaids/theme/public/images/badges/pt_PT-error.gif new file mode 100644 index 00000000..167f2f2a Binary files /dev/null and b/ckanext/unaids/theme/public/images/badges/pt_PT-error.gif differ diff --git a/ckanext/unaids/theme/public/images/badges/pt_PT-failure.gif b/ckanext/unaids/theme/public/images/badges/pt_PT-failure.gif new file mode 100644 index 00000000..2bdb0968 Binary files /dev/null and b/ckanext/unaids/theme/public/images/badges/pt_PT-failure.gif differ diff --git a/ckanext/unaids/theme/public/images/badges/pt_PT-success.gif b/ckanext/unaids/theme/public/images/badges/pt_PT-success.gif new file mode 100644 index 00000000..7ed09992 Binary files /dev/null and b/ckanext/unaids/theme/public/images/badges/pt_PT-success.gif differ diff --git a/ckanext/unaids/theme/public/images/badges/pt_PT-unknown.gif b/ckanext/unaids/theme/public/images/badges/pt_PT-unknown.gif new file mode 100644 index 00000000..fd82cebc Binary files /dev/null and b/ckanext/unaids/theme/public/images/badges/pt_PT-unknown.gif differ diff --git a/ckanext/unaids/theme/templates/package/resource_read.html b/ckanext/unaids/theme/templates/package/resource_read.html index a4c7ea1a..df4a7c57 100644 --- a/ckanext/unaids/theme/templates/package/resource_read.html +++ b/ckanext/unaids/theme/templates/package/resource_read.html @@ -55,3 +55,10 @@

{{ _('URL:') }} {{ res.url }}

{{ super() }} {% endif %} {% endblock %} + +{% block resource_read_title %} +

{{ h.resource_display_name(res) | truncate(50) }} +

+ {{ h.unaids_get_validation_badge(res)|safe }} + {% asset 'ckanext-unaids/ValidationBadgeCSS' %} +{% endblock %} \ No newline at end of file diff --git a/ckanext/unaids/theme/templates/package/snippets/resource_item.html b/ckanext/unaids/theme/templates/package/snippets/resource_item.html index a01e168e..35a6e564 100644 --- a/ckanext/unaids/theme/templates/package/snippets/resource_item.html +++ b/ckanext/unaids/theme/templates/package/snippets/resource_item.html @@ -1,9 +1,11 @@ {% ckan_extends %} {% set activity_id = request.args['activity_id'] %} {% block resource_item_title %} -
- {{ super() }} -
+ + {{ h.resource_display_name(res) | truncate(50) }}{{ h.get_translated(res, 'format') }} + {{ h.popular('views', res.tracking_summary.total, min=10) if res.tracking_summary }} + + {{ h.unaids_get_validation_badge(res, in_listing=True)|safe }} {% endblock %} {% block resource_item_description %} @@ -64,4 +66,8 @@ {% endif %} + + + {% asset 'ckanext-unaids/ValidationBadgeCSS' %} {% endblock %} + diff --git a/ckanext/unaids/theme/templates/snippets/validation_asset.html b/ckanext/unaids/theme/templates/snippets/validation_asset.html new file mode 100644 index 00000000..211c76b4 --- /dev/null +++ b/ckanext/unaids/theme/templates/snippets/validation_asset.html @@ -0,0 +1 @@ +{% asset name %} diff --git a/ckanext/unaids/theme/templates/snippets/validation_resource.html b/ckanext/unaids/theme/templates/snippets/validation_resource.html new file mode 100644 index 00000000..252e6ca8 --- /dev/null +++ b/ckanext/unaids/theme/templates/snippets/validation_resource.html @@ -0,0 +1 @@ +{% resource name %} diff --git a/ckanext/unaids/theme/templates/validation/validation_read.html b/ckanext/unaids/theme/templates/validation/validation_read.html new file mode 100644 index 00000000..d6a0c5d0 --- /dev/null +++ b/ckanext/unaids/theme/templates/validation/validation_read.html @@ -0,0 +1,51 @@ +{% extends "package/base.html" %} + + +{%- block subtitle %}{{ _('Validation Report') }}{% endblock -%} + +{% block breadcrumb_content_selected %}{% endblock %} +{% block breadcrumb_content %} + {{ super() }} + +
  • {{ h.resource_display_name(resource)|truncate(30) }}
  • +
  • Validation Report
  • +{% endblock %} + +{% block pre_primary %} + +
    +
    +
    + +
    + +

    {{ h.resource_display_name(resource) | truncate(50) }} + {{ h.unaids_get_validation_badge(resource)|safe }} +

    + +
    +
    {{ _('Validation timestamp') }}: {{ h.render_datetime(resource.validation_timestamp, with_hours=True) }}
    + {% if validation.report %} +
    {{ _('Duration') }}: {{ h.validation_dict(validation.report)["stats"]["seconds"] }}s
    + {% endif %} +
    + + {% if validation.report %} +
    + {% endif %} + +
    +
    +{% if h.use_webassets() %} + {% snippet 'validation/snippets/validation_asset.html', name='ckanext-validation/report-css' %} + {% snippet 'validation/snippets/validation_asset.html', name='ckanext-validation/report-js' %} +{% else %} + {% snippet 'validation/snippets/validation_resource.html', name='ckanext-validation/report' %} +{% endif %} + +{% endblock %} + + +{% block primary %}{% endblock %} + +{% block secondary %}{% endblock %} diff --git a/test.ini b/test.ini index 677f626f..786edeb1 100644 --- a/test.ini +++ b/test.ini @@ -11,7 +11,7 @@ port = 5000 [app:main] use = config:../ckan/test-core.ini ckan.resource_formats = %(here)s/ckanext/unaids/resource_formats.json -ckanext.validation.schema_directory = /ckanext/unaids/tests/test_schemas +ckanext.unaids.schema_directory = /ckanext/unaids/tests/test_schemas scheming.presets = ckanext.unaids:presets.json ckanext.scheming:presets.json scheming.dataset_schemas = ckanext.unaids.tests.test_scheming_schemas:test_schema.json