Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adx 1021 using a flash message to inform users of ape update #285

2 changes: 2 additions & 0 deletions ckanext/unaids/blueprints/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
from ckanext.unaids.blueprints.user_info_blueprint import user_info_blueprint
from ckanext.unaids.blueprints.unaids_dataset_releases import unaids_dataset_releases
from ckanext.unaids.blueprints.login_register_catch import login_register_catch
from ckanext.unaids.blueprints.ape_data_receiver import ape_data_receiver

blueprints = [
unaids_dataset_transfer,
user_info_blueprint,
unaids_dataset_releases,
svg_map_options,
login_register_catch,
ape_data_receiver
]
16 changes: 16 additions & 0 deletions ckanext/unaids/blueprints/ape_data_receiver.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from flask import Blueprint, redirect, request, flash
from ckan.common import _, g
from ckan.lib.helpers import url_for
from ckan.plugins import toolkit

ape_data_receiver = Blueprint("ape_data_receiver", __name__)

@ape_data_receiver.route('/ape_data_receiver', methods=['GET'])
def receive():
if not g.user:
return toolkit.abort(403, _('You must be logged in to access this page'))
else:
toolkit.h.flash_success(_('User profile successfully saved, you need to log in again to see the changes.'))
return redirect(url_for('user.edit', id=g.user))


41 changes: 33 additions & 8 deletions ckanext/unaids/helpers.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
# encoding: utf-8
from ckan.lib.helpers import url_for_static_or_external, check_access
from ckan.plugins.toolkit import get_action, request
from ckan.plugins import toolkit
from ckan.common import _, g
import logging
import os
import json
import re

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.lib.helpers import build_nav_main as core_build_nav_main

try:
from html import escape as html_escape
except ImportError:
from cgi import escape as html_escape

from urllib.parse import quote

from urllib.parse import quote, urlencode

log = logging.getLogger()
BULK_FILE_UPLOADER_DEFAULT_FIELDS = 'ckanext.bulk_file_uploader_default_fields'
Expand Down Expand Up @@ -77,6 +80,28 @@ def get_bulk_file_uploader_default_fields():
return toolkit.config.get(BULK_FILE_UPLOADER_DEFAULT_FIELDS, {})


def get_ape_url():
query_params = {
"return_url": full_current_url(),
"lang": get_lang()
}
domain_part = config.get("ckanext.unaids.ape_url", "")
encoded_query_params = urlencode(query_params)

return f"{domain_part}?{encoded_query_params}"


def user_is_editing_his_page():
current_url = full_current_url()
username = toolkit.g.userobj.name
log.error(f"User3: {username}")
return url_is_edit_url_for_username(current_url, username)


def url_is_edit_url_for_username(current_url, username):
return re.search(f"/user/edit/{username}($|/|\\?)", current_url) is not None


def get_current_dataset_release(dataset_id, activity_id=None):
"""Return version linked to either the most recent activity_id
of the dataset or the one explicitly requested
Expand Down Expand Up @@ -139,8 +164,8 @@ def build_pages_nav_main(*args):
is_current_page = toolkit.get_endpoint() in (('pages', 'show'), ('pages', 'blog_show'))
else:
is_current_page = (
hasattr(toolkit.c, 'action') and toolkit.c.action in ('pages_show', 'blog_show')
and toolkit.c.controller == 'ckanext.pages.controller:PagesController')
hasattr(toolkit.c, 'action') and toolkit.c.action in ('pages_show', 'blog_show')
and toolkit.c.controller == 'ckanext.pages.controller:PagesController')
if is_current_page:
page_name = toolkit.request.path.split('/')[-1]

Expand Down
Binary file modified ckanext/unaids/i18n/fr/LC_MESSAGES/ckanext-unaids.mo
Binary file not shown.
38 changes: 23 additions & 15 deletions ckanext/unaids/i18n/fr/LC_MESSAGES/ckanext-unaids.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2023-04-24 09:22+0000\n"
"POT-Creation-Date: 2023-07-03 09:16+0000\n"
"PO-Revision-Date: 2020-12-14 12:15+0300\n"
"Last-Translator: \n"
"Language: fr\n"
Expand All @@ -27,7 +27,7 @@ msgstr "Ressource introuvable."
msgid "TaskStatus was not found."
msgstr "L'état actuel de la tâche est introuvable."

#: ckanext/unaids/helpers.py:149
#: ckanext/unaids/helpers.py:159
msgid "title"
msgstr "Titre"

Expand All @@ -37,28 +37,28 @@ msgstr ""
"Licence Creative Commons Attribution pour les organisations "
"intergouvernementales"

#: ckanext/unaids/plugin.py:122
#: ckanext/unaids/plugin.py:126
#: ckanext/unaids/theme/templates/request/show.html:10
msgid "Organization"
msgstr "Organisation"

#: ckanext/unaids/plugin.py:123
#: ckanext/unaids/plugin.py:127
msgid "Data Type"
msgstr "Type de données"

#: ckanext/unaids/plugin.py:124
#: ckanext/unaids/plugin.py:128
msgid "Tags"
msgstr "Mots clés"

#: ckanext/unaids/plugin.py:125
#: ckanext/unaids/plugin.py:129
msgid "Year"
msgstr "Année"

#: ckanext/unaids/plugin.py:126
#: ckanext/unaids/plugin.py:130
msgid "Location"
msgstr "Lieu"

#: ckanext/unaids/plugin.py:247
#: ckanext/unaids/plugin.py:272
msgid "Data Explorer"
msgstr "Explorateur de données"

Expand Down Expand Up @@ -888,19 +888,19 @@ msgstr ""
msgid "Add Release"
msgstr "Ajouter une publication"

#: ckanext/unaids/theme/templates/package/resource_read.html:15
#: ckanext/unaids/theme/templates/package/resource_read.html:18
msgid "Resource ID:"
msgstr "ID de la ressource :"

#: ckanext/unaids/theme/templates/package/resource_read.html:19
#: ckanext/unaids/theme/templates/package/resource_read.html:21
#: ckanext/unaids/theme/templates/package/resource_read.html:25
#: ckanext/unaids/theme/templates/package/resource_read.html:27
#: ckanext/unaids/theme/templates/package/resource_read.html:22
#: ckanext/unaids/theme/templates/package/resource_read.html:24
#: ckanext/unaids/theme/templates/package/resource_read.html:28
#: ckanext/unaids/theme/templates/package/resource_read.html:30
msgid "URL:"
msgstr "URL :"

#: ckanext/unaids/theme/templates/package/resource_read.html:35
#: ckanext/unaids/theme/templates/package/resource_read.html:42
#: ckanext/unaids/theme/templates/package/resource_read.html:38
#: ckanext/unaids/theme/templates/package/resource_read.html:45
msgid "Imported from:"
msgstr "Importé à partir de:"

Expand Down Expand Up @@ -1209,6 +1209,14 @@ msgstr "Mes organisations"
msgid "Change details"
msgstr "Changer les détails"

#: ckanext/unaids/theme/templates/user/edit_user_form.html:9
msgid "To change your profile settings, please "
msgstr "Pour changer les paramètres de votre profil, veuillez "

#: ckanext/unaids/theme/templates/user/edit_user_form.html:9
msgid "click here"
msgstr "cliquer ici"

#: ckanext/unaids/theme/templates/user/edit_user_form.html:13
msgid "Full name"
msgstr "Nom complet"
Expand Down
Binary file modified ckanext/unaids/i18n/pt_PT/LC_MESSAGES/ckanext-unaids.mo
Binary file not shown.
Loading
Loading