Skip to content

Commit

Permalink
chore: Use constants, not literal strings
Browse files Browse the repository at this point in the history
  • Loading branch information
jpmckinney committed Aug 30, 2023
1 parent 4ea5245 commit b6ceb03
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
6 changes: 3 additions & 3 deletions data_registry/process_manager/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from django.utils import timezone

from data_registry.exceptions import RecoverableException
from data_registry.models import Job, Task
from data_registry.models import Collection, Job, Task
from data_registry.process_manager.task.factory import TaskFactory
from data_registry.process_manager.util import request

Expand Down Expand Up @@ -141,9 +141,9 @@ def should_be_planned(collection):
return True

delta = timedelta(days=30) # MONTHLY
if collection.retrieval_frequency == "HALF_YEARLY":
if collection.retrieval_frequency == Collection.RetrievalFrequency.HALF_YEARLY:
delta = timedelta(days=180)
elif collection.retrieval_frequency == "ANNUALLY":
elif collection.retrieval_frequency == Collection.RetrievalFrequency.ANNUALLY:
delta = timedelta(days=365)

return date.today() >= (last_job.start + delta).date()
Expand Down
4 changes: 2 additions & 2 deletions data_registry/templates/detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ <h2 class="h4 mb-3">{% translate "Overview" %}</h2>
<dl class="mb-n2 list-desc-grid">
<dt>{% translate "Data date range:" %}</dt>
<dd>{{ job.date_from|date:"M Y" }} - {{ job.date_to|date:"M Y" }}
{% if collection.retrieval_frequency == "NEVER" %}
{% if collection.retrieval_frequency == never %}
({{ collection.get_retrieval_frequency_display }})
{% endif %}
</dd>
Expand All @@ -128,7 +128,7 @@ <h2 class="h4 mb-3">{% translate "Overview" %}</h2>
<dt>{% translate "Last retrieved:" %}</dt>
<dd>
{{ collection.last_retrieved|date:"M Y" }}
{% if collection.retrieval_frequency != "NEVER" %}
{% if collection.retrieval_frequency != never %}
({% blocktranslate with retrieval_frequency=collection.get_retrieval_frequency_display.lower %}retrieved {{ retrieval_frequency }}{% endblocktranslate %})
{% endif %}
</dd>
Expand Down
4 changes: 2 additions & 2 deletions data_registry/templates/search.html
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ <h2>{{ collection.country }}: {{ collection.title }}</h2>
<dt>{% translate "Data date range:" %}</dt>
<dd>
{{ collection.date_from|date:"M Y" }} - {{ collection.date_to|date:"M Y" }}
{% if collection.retrieval_frequency == "NEVER" %}
{% if collection.retrieval_frequency == never %}
({{ collection.get_retrieval_frequency_display }})
{% endif %}
</dd>
Expand All @@ -156,7 +156,7 @@ <h2>{{ collection.country }}: {{ collection.title }}</h2>
<dt>{% translate "Last retrieved:" %}</dt>
<dd>
{{ collection.last_retrieved|date:"M Y" }}
{% if collection.retrieval_frequency != "NEVER" %}
{% if collection.retrieval_frequency != never %}
({% blocktranslate with retrieval_frequency=collection.get_retrieval_frequency_display.lower %}retrieved {{ retrieval_frequency }}{% endblocktranslate %})
{% endif %}
</dd>
Expand Down
7 changes: 6 additions & 1 deletion data_registry/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ def facet_counts(qs, key):
"date_ranges": date_ranges,
"frequencies": Collection.UpdateFrequency.choices,
"counts": counts,
"never": Collection.RetrievalFrequency.NEVER,
}
return render(request, "search.html", context)

Expand All @@ -152,7 +153,11 @@ def detail(request, id):
job = collection.job.filter(active=True).first()
files = Export.get_files(job and job.id)

return render(request, "detail.html", {"collection": collection, "job": job, "files": files})
return render(
request,
"detail.html",
{"collection": collection, "job": job, "files": files, "never": Collection.RetrievalFrequency.NEVER},
)


@login_required
Expand Down

0 comments on commit b6ceb03

Please sign in to comment.