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

Fix publisher name and dataset in email #25

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions ckanext/iati/logic/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
from datetime import datetime
from email_validator import validate_email
import re
import requests
import os
from sqlalchemy import and_
from ckan.logic import get_action
from ckan import authz as new_authz
Expand All @@ -26,15 +28,22 @@ def iati_resource_count(key, data, errors, context):

def send_url_invalid_email(context, is_url_error=True):
user = context['auth_user_obj']
package = context['package']
host = os.environ.get('HOST')

res = requests.post('https://{0}/api/3/action/package_show?id={1}'.format(host, package.name)).json()
publisher_name = res['result']['publisher_iati_id']
dataset_link = 'https://{0}/dataset/{1}'.format(host, package.name)

if is_url_error:
body = emailer.data_has_url_errors.format(
user_name=context['user'], publisher_name='publisher_name',
publisher_registry_dataset_link='publisher_registry_dataset_link'
user_name=context['user'], publisher_name=publisher_name,
publisher_registry_dataset_link=dataset_link
)
else:
body = emailer.data_not_xml_email_body.format(
user_name=context['user'], publisher_name='publisher_name',
publisher_registry_dataset_link='publisher_registry_dataset_link'
user_name=context['user'], publisher_name=publisher_name,
publisher_registry_dataset_link=dataset_link
)

subject = "Invalid dataset upload format"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,4 @@
<span> <a href="https://validator.iatistandard.org/report/{{ pkg_dict.name }}">Check validation report</a></span>
</td>
</tr>

{% endblock %}
4 changes: 2 additions & 2 deletions ckanext/iati/theme/templates/snippets/package_item.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ <h3 class="dataset-heading">
<a href="{{ package_url }}">View Metadata</a>
&middot;
{% snippet 'snippets/resource_links.html', resource=resource, package=package %}
<span>Validation URL:</span><span> <a href="https://validator.iatistandard.org/report/{{ package.name }}">Check validation report</a></span>
</p>
<span>Validation URL:</span><span> <a href="https://validator.iatistandard.org/report/{{ package.name }}">Check validation report</a></span>
</p>
{% endfor %}
{% endif %}

Expand Down