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

Issues notes #60

Merged
merged 4 commits into from
Jun 6, 2024
Merged
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
6 changes: 6 additions & 0 deletions config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@
'LOGOUT_URL',
'CACHE_MIDDLEWARE_SECONDS',
'CAVEATS_MAX_DATASETS',
'CAVEATS_LIST_SUBSCRIBE_URL',
'CAVEATS_LIST_ARCHIVE_URL',
'METADATA_RESOURCE_MAX_DATASETS',
]

Expand Down Expand Up @@ -193,6 +195,10 @@
CAVEATS_DEFAULT_RECIPIENTS = (
'[email protected]',
)

CAVEATS_LIST_SUBSCRIBE_URL = 'https://www.listserv.dfn.de/sympa/subscribe/isimip-data_updates'
CAVEATS_LIST_ARCHIVE_URL = 'https://www.listserv.dfn.de/sympa/arc/isimip-data_updates'

CAVEATS_MAX_DATASETS = 100

PROXY = None
Expand Down
19 changes: 16 additions & 3 deletions config/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,23 @@
class StaticSitemap(Sitemap):

def items(self):
return ['metadata', 'resources', 'search', 'download', 'caveats', 'home']
return [
'metadata',
'resources',
'search',
'download',
'issues-and-notes',
'caveats', # legacy
'home'
]

def location(self, item):
return reverse(item)


sitemaps = {
'static': StaticSitemap,
'issues-and-notes': CaveatSitemap,
'caveats': CaveatSitemap,
'datasets': DatasetSitemap,
'files': FileSitemap,
Expand Down Expand Up @@ -91,8 +100,12 @@ def location(self, item):
path('download/', download, name='download'),
path('download/<str:job_id>/', download, name='download'),

path('caveats/', caveats, name='caveats'),
path('caveats/<int:pk>/', caveat, name='caveat'),
path('issues-and-notes/', caveats, name='issues_and_notes'),
path('caveats/', caveats, name='caveats'), # legacy

path('issues/<int:pk>/', caveat, name='issue'),
path('notes/<int:pk>/', caveat, name='note'),
path('caveats/<int:pk>/', caveat, name='caveat'), # legacy

path('', TemplateView.as_view(template_name='home/home.html'), name='home'),
path('robots.txt', TemplateView.as_view(template_name='core/robots.txt'), name='robots.txt'),
Expand Down
8 changes: 4 additions & 4 deletions isimip_data/caveats/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class Caveat(models.Model):
MESSAGE_REPLACED = 'replaced'
MESSAGE_CHOICES = (
(MESSAGE_CAN_BE_USED, _('Affected datasets can still be used for simulations or research.')),
(MESSAGE_DO_NOT_USE, _('Affected datasets should not be used until this caveat is resolved.')),
(MESSAGE_DO_NOT_USE, _('Affected datasets should not be used until this issue is resolved.')),
(MESSAGE_REPLACED, _('Please use the replaced datasets for new simulations or research.'))
)

Expand Down Expand Up @@ -159,10 +159,10 @@ def pretty_specifiers(self):
return prettify_specifiers(self.specifiers, self.specifiers.keys())

def get_absolute_url(self):
return reverse('caveat', kwargs={'pk': self.pk})
return reverse(self.category, kwargs={'pk': self.pk})

def get_reply_url(self):
return reverse('caveat', kwargs={'pk': self.pk}) + '#reply'
return reverse(self.category, kwargs={'pk': self.pk}) + '#reply'

def get_admin_url(self):
return reverse('admin:caveats_caveat_change', kwargs={'object_id': self.pk})
Expand Down Expand Up @@ -214,7 +214,7 @@ def get_creator_display(self):
return get_full_name(self.creator)

def get_absolute_url(self):
return reverse('caveat', args=[self.caveat.id]) + f'#comment-{self.id}'
return reverse(self.caveat.category, args=[self.caveat.id]) + f'#comment-{self.id}'

def get_quote(self, level):
head = f'On {self.created.strftime("%B %d, %Y")}, {self.get_creator_display()} commented:'
Expand Down
4 changes: 2 additions & 2 deletions isimip_data/caveats/templates/caveats/cards/caveats.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ <h4>
{% include 'caveats/snippets/status.html' %}
{% endif %}
</div>
<a href="{% url 'caveat' caveat.id %}">{{ caveat.title }}</a>
<a href="{{ caveat.get_absolute_url }}">{{ caveat.title }}</a>
<span class="text-muted">#{{ caveat.id }}</span>
</h4>
<div class="mb-2">
Expand All @@ -29,7 +29,7 @@ <h4>
<li class="list-inline-item">{% trans 'Affected versions' %}: {% include 'caveats/snippets/versions.html' %}</li>
</ul>
<p>
{{ caveat.get_creator_display }} opened this caveat on {{ caveat.created|date }}.
{{ caveat.get_creator_display }} created this {{ caveat.category }} on {{ caveat.created|date }}.
{% if caveat.created != caveat.updated %}It was last updated on {{ caveat.updated|date }}.{% endif %}
</p>
</li>
Expand Down
2 changes: 1 addition & 1 deletion isimip_data/caveats/templates/caveats/caveat.html
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ <h3>{% trans 'Affected datasets' %}</h3>
<div class="card mb-1">
<div class="card-body">
<p>
There are {{ count }} datasets affected by this caveat. {% if count > settings.CAVEATS_MAX_DATASETS %}Here we only display the first {{ settings.CAVEATS_MAX_DATASETS }} datasets.{% endif %} You can download a complete list of all the <a href="{% url 'caveat-detail-datasets' caveat.id %}">datasets</a>, or <a href="{% url 'caveat-detail-files' caveat.id %}">files</a> affected by this caveat as JSON. Alternatively, can also download a list the files <a href="{% url 'caveat-detail-filelist' caveat.id %}">as a flat file</a> suitable for Wget. You can use the search interface to further restrict your <a class="break-link" href="{{ search_url }}" target="_blank">query</a>.
There are {{ count }} datasets affected by this {{ caveat.category }}. {% if count > settings.CAVEATS_MAX_DATASETS %}Here we only display the first {{ settings.CAVEATS_MAX_DATASETS }} datasets.{% endif %} You can download a complete list of all the <a href="{% url 'caveat-detail-datasets' caveat.id %}">datasets</a>, or <a href="{% url 'caveat-detail-files' caveat.id %}">files</a> affected by this {{ caveat.category }} as JSON. Alternatively, can also download a list the files <a href="{% url 'caveat-detail-filelist' caveat.id %}">as a flat file</a> suitable for Wget. You can use the search interface to further restrict your <a class="break-link" href="{{ search_url }}" target="_blank">query</a>.
</p>
</div>
</div>
Expand Down
13 changes: 3 additions & 10 deletions isimip_data/caveats/templates/caveats/caveats.html
Original file line number Diff line number Diff line change
@@ -1,29 +1,22 @@
{% extends 'core/base.html' %}
{% load static %}
{% load i18n %}

{% block main %}

<div class="container">
<header>
<h1>{% trans 'Caveats and Updates' %}</h1>
<h1>Issues and notes</h1>

<p class="text-center">
{% blocktrans trimmed %}
If you want to get notified, when we find issues found in the ISIMIP input and output data, please subscribe to our <a href="https://www.listserv.dfn.de/sympa/subscribe/isimip-data_updates">caveats mailing list</a>.
{% endblocktrans %}
If you want to get notified, when we find issues found in the ISIMIP input and output data, please subscribe to our <a href="{{ settings.CAVEATS_LIST_SUBSCRIBE_URL }}">data issues and notes mailing list</a>.
</p>

<p class="text-center">
{% blocktrans trimmed %}
The archive of this mailing list can be accessed <a href="https://www.listserv.dfn.de/sympa/arc/isimip-data_updates">here</a>.
{% endblocktrans %}
The archive of this mailing list can be accessed <a href="{{ settings.CAVEATS_LIST_ARCHIVE_URL }}">here</a>.
</p>

<p class="text-center">
{% blocktrans trimmed %}
If you encounter problems with the data yourself and want to notify us, please contact <a href="mailto:[email protected]">[email protected]</a>.
{% endblocktrans %}
</p>
</header>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{% load i18n %}Dear ISIMIP data users,
Dear ISIMIP data users,

{% blocktrans %}We would like to draw your attention to the following caveat:{% endblocktrans %}
We would like to draw your attention to the following {{ caveat.category }}:

{{ caveat.title|safe }}

{{ caveat.description|safe }}

{% blocktrans %}If you have any questions or require further information, please do not hesitate to contact us.{% endblocktrans %}
If you have any questions or require further information, please do not hesitate to contact us.

{% blocktrans %}More information about the caveat can be accessed at {{ caveat_url }}.{% endblocktrans %}
More information about the {{ caveat.category }} can be accessed at {{ caveat_url }}.

{% if datasets %}The following datasets are affected:
{% for dataset in datasets %}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
{% load i18n %}Dear ISIMIP data users,

{% blocktrans trimmed with caveat_title=comment.caveat.title %}
We would like to draw your attention to the following update on the caveat:
{% endblocktrans %}
We would like to draw your attention to the following update on the {{ comment.caveat.category }}:

{{ comment.caveat.title|safe }}

{{ comment.text|safe }}

{% blocktrans %}If you have any questions or require further information, please do not hesitate to contact us.{% endblocktrans %}
If you have any questions or require further information, please do not hesitate to contact us.

{% blocktrans %}More information about the caveat can be accessed at {{ caveat_url }}.{% endblocktrans %}
More information about the {{ comment.caveat.category }} can be accessed at {{ caveat_url }}.

Best wishes,
The ISIMIP data team

{% for quote in quotes %}{{ quote }}
{% endfor %}
{% endfor %}
24 changes: 17 additions & 7 deletions isimip_data/caveats/tests/test_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,38 @@


def test_caveats(db, client):
url = reverse('caveats')
url = reverse('issues_and_notes')
response = client.get(url)
assert response.status_code == 200


def test_caveats_user(db, client):
def test_caveats_legacy(db, client):
url = reverse('caveats')
response = client.get(url)
assert response.status_code == 302
assert response.url == '/issues-and-notes/'


def test_issue_user(db, client):
client.login(username='user', password='user')

url = reverse('caveats')
url = reverse('issue', args=[1])
response = client.get(url)
assert response.status_code == 200


def test_caveats_admin(db, client):
def test_issue_admin(db, client):
client.login(username='admin', password='admin')

url = reverse('caveats')
url = reverse('issue', args=[1])
response = client.get(url)
assert response.status_code == 200


def test_caveat(db, client):
def test_caveat_legacy(db, client):
client.login(username='user', password='user')

url = reverse('caveat', args=[1])
response = client.get(url)
assert response.status_code == 200
assert response.status_code == 302
assert response.url == '/issues/1/'
9 changes: 8 additions & 1 deletion isimip_data/caveats/views.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
from django.conf import settings
from django.shortcuts import get_object_or_404, render
from django.shortcuts import get_object_or_404, redirect, render

from isimip_data.metadata.models import Dataset

from .models import Caveat


def caveats(request):
if request.resolver_match.url_name != 'issues_and_notes':
return redirect('issues_and_notes')

caveats = Caveat.objects.public(request.user) \
.select_related('creator')

Expand All @@ -19,6 +22,10 @@ def caveats(request):
def caveat(request, pk=None):
queryset = Caveat.objects.public(request.user)
caveat = get_object_or_404(queryset, id=pk)

if request.path != caveat.get_absolute_url():
return redirect(caveat)

comments = caveat.comments.public(request.user)
datasets = Dataset.objects.using('metadata') \
.filter(target=None, id__in=caveat.datasets[:settings.CAVEATS_MAX_DATASETS]) \
Expand Down
3 changes: 2 additions & 1 deletion isimip_data/core/templates/core/base_footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
</p>
<p>
If you want to get notified, when we find issues in the ISIMIP input and output data, please
<a href="https://www.listserv.dfn.de/sympa/info/isimip-data_updates">subscribe to our caveats and updates mailing list</a>.
<a href="{{ settings.CAVEATS_LIST_SUBSCRIBE_URL }}">subscribe to our data
issues and notes mailing list</a>.
</p>
<p>
The ISIMIP repository is a service by the <a href="https://www.pik-potsdam.de">Potsdam Institute for Climate Impact Research (PIK)</a>.
Expand Down
2 changes: 1 addition & 1 deletion isimip_data/core/templates/core/base_nav.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<a class="nav-link" href="{% url 'metadata' %}">Metadata</a>
</li>
<li class="nav-item {% if request.resolver_match.url_name in 'caveats,caveat' %}active{% endif %}">
<a class="nav-link" href="{% url 'caveats' %}">Caveats & Updates</a>
<a class="nav-link" href="{% url 'issues_and_notes' %}">Issues & Notes</a>
</li>
</ul>
<ul class="navbar-nav">
Expand Down
2 changes: 1 addition & 1 deletion isimip_data/home/templates/home/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ <h1 class="mb-5">
</p>

<p class="text-center">
By downloading data, you agree to our <a href="http://www.isimip.org/protocol/terms-of-use">Terms of Use</a>. Documentation of the impact models that provided impact simulations for this archive can be found in the <a href="https://www.isimip.org/impactmodels/">ISIMIP Impact Model Database</a>. If you want to get notified, when we find issues in the ISIMIP input and output data, please <a href="https://www.listserv.dfn.de/sympa/info/isimip-data_updates">subscribe to our caveats and updates mailing list</a>. The archive of this mailing list can be accessed <a href="https://www.listserv.dfn.de/sympa/arc/isimip-data_updates">here</a>.
By downloading data, you agree to our <a href="http://www.isimip.org/protocol/terms-of-use">Terms of Use</a>. Documentation of the impact models that provided impact simulations for this archive can be found in the <a href="https://www.isimip.org/impactmodels/">ISIMIP Impact Model Database</a>. If you want to get notified, when we find issues in the ISIMIP input and output data, please <a href="{{ settings.CAVEATS_LIST_SUBSCRIBE_URL }}">subscribe to our data issues and notes mailing list</a>. The archive of this mailing list can be accessed <a href="{{ settings.CAVEATS_LIST_ARCHIVE_URL }}">here</a>.
</p>
</header>
</div>
Expand Down
5 changes: 1 addition & 4 deletions isimip_data/metadata/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class Meta:

class DatasetCaveatSerializer(serializers.ModelSerializer):

url = serializers.SerializerMethodField()
url = serializers.CharField(source='get_absolute_url')
category_display = serializers.CharField(source='get_category_display')
severity_display = serializers.CharField(source='get_severity_display')
status_display = serializers.CharField(source='get_status_display')
Expand Down Expand Up @@ -83,9 +83,6 @@ class Meta:
'message_color'
)

def get_url(self, obj):
return reverse('caveat', args=[obj.id])


class DatasetAnnotationFigureSerializer(serializers.ModelSerializer):

Expand Down
4 changes: 2 additions & 2 deletions isimip_data/metadata/templates/metadata/dataset.html
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,12 @@ <h3 id="references">{% trans 'References' %}</h3>
{% endif %}

{% if caveats %}
<h3>{% trans 'Caveats for this dataset' %}</h3>
<h3>{% trans 'Issues and notes for this dataset' %}</h3>
{% include 'caveats/cards/caveats.html' %}
{% endif %}

{% if caveats_versions %}
<h3>{% trans 'Caveats for other versions of this dataset' %}</h3>
<h3>{% trans 'Issues and notes for other versions of this dataset' %}</h3>
{% include 'caveats/cards/caveats.html' with caveats=caveats_versions %}
{% endif %}

Expand Down
4 changes: 2 additions & 2 deletions isimip_data/metadata/templates/metadata/file.html
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,12 @@ <h3>{% trans 'Part of the dataset' %}</h3>
{% include 'metadata/cards/datasets.html' with datasets=parents %}

{% if caveats %}
<h3>{% trans 'Caveats for the dataset' %}</h3>
<h3>{% trans 'Issues and notes for the dataset' %}</h3>
{% include 'caveats/cards/caveats.html' %}
{% endif %}

{% if caveats_versions %}
<h3>{% trans 'Caveats for other versions of the dataset' %}</h3>
<h3>{% trans 'Issues and notes for other versions of the dataset' %}</h3>
{% include 'caveats/cards/caveats.html' with caveats=caveats_versions %}
{% endif %}

Expand Down
2 changes: 1 addition & 1 deletion isimip_data/metadata/templates/metadata/resource.html
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ <h3>{% trans 'GCMD Keywords' %}</h3>
{% endif %}

{% if caveats %}
<h3>{% trans 'Caveats for datasets for this DOI' %}</h3>
<h3>{% trans 'Issues and notes for datasets for this DOI' %}</h3>
{% include 'caveats/cards/caveats.html' %}
{% endif %}

Expand Down
6 changes: 3 additions & 3 deletions isimip_data/metadata/templatetags/metadata_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def restricted_message(obj):

@register.filter
def replace_caveats(value):
# replaces, e.g. <a ...>https://data.isimip.org/caveats/8/</a>
# replaces, e.g. <a ...>https://data.isimip.org/issues/8/</a>
# with <a ...>#8</a>
return mark_safe(re.sub(r'(<a.*?>)(https://data\.isimip\.org/caveats/.*?)(\d+)([/]*)(</a>)',
r'\1#\3\5', value))
return mark_safe(re.sub(r'(<a.*?>)(https://data\.isimip\.org/(caveats|issues|notes)/.*?)(\d+)([/]*)(</a>)',
r'\1#\4\6', value))
4 changes: 2 additions & 2 deletions isimip_data/search/assets/js/components/Caveats.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Caveats extends Component {
<div className="float-right">
<button className={`btn btn-link text-${color}`}>
<span className="material-symbols-rounded symbols-caveat"
title="There are caveats for this dataset."
title="There are issues or notes for this dataset."
onClick={toggleCaveats}>{symbol}</span>
</button>
</div>
Expand All @@ -36,7 +36,7 @@ class Caveats extends Component {
<div className="float-right">
<button className="btn btn-link text-muted">
<span className="material-symbols-rounded symbols-caveat"
title="There are caveats for other versions of this dataset."
title="There are issues or notes for other versions of this dataset."
onClick={toggleCaveats}>{symbol}</span>
</button>
</div>
Expand Down
4 changes: 2 additions & 2 deletions isimip_data/search/assets/js/components/Result.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,11 @@ class Result extends Component {
<div className="d-inline">
<button className="btn btn-link" onClick={this.toggleCaveats}>
{showCaveats && <span>
Caveats
Issues & Notes
<span className="material-symbols-rounded symbols-expand">expand_less</span>
</span>}
{!showCaveats && <span>
Caveats
Issues & Notes
<span className="material-symbols-rounded symbols-expand">expand_more</span>
</span>}
</button>
Expand Down
Loading