Skip to content

Commit

Permalink
Added alert in manual study entry page (#819)
Browse files Browse the repository at this point in the history
* added alert on create study page

* added link to new literature import in alert

* reworded alert

* changed "from" back to "on"

* updates

---------

Co-authored-by: Andy Shapiro <shapiromatron@gmail.com>
  • Loading branch information
dannypeterson and shapiromatron authored May 19, 2023
1 parent 5bfc6bc commit 5075e0f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
17 changes: 15 additions & 2 deletions hawc/apps/study/templates/study/study_form.html
Original file line number Diff line number Diff line change
@@ -1,14 +1,27 @@
{% extends 'assessment-rooted.html' %}

{% load crispy_forms_tags %}
{% load bs4 %}

{% block content %}
{% crispy form %}
{% if manual_entry_warning %}
{% alert warning %}
<p>You can continue to manually enter a study if you wish. However, instead of manually
entering reference information, we recommend importing the reference from PubMed or HERO
using one of these approaches instead:</p>
<ul>
<li><a href="{% url 'study:create_from_identifier' assessment.pk %}" class="alert-link">Create Study From Identifier</a> - for a single reference</li>
<li><a href="{% url 'lit:import_new' assessment.pk %}" class="alert-link">New Literature Import</a> - for multiple references simultaneously</li>
</ul>
<p>This requires less work, and ensures that we have links to the reference throughout your assessment.</p>
{% endalert %}
{% endif %}
{% crispy form %}
{% endblock %}

{% block extrajs %}
<script type="text/javascript">
$(document).ready(function(){
$(document).ready(function () {
document.getElementById("id_short_citation").focus()
});
</script>
Expand Down
10 changes: 10 additions & 0 deletions hawc/apps/study/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ class ReferenceStudyCreate(EnsurePreparationStartedMixin, BaseCreate):
model = models.Study
form_class = forms.ReferenceStudyForm

def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context["manual_entry_warning"] = True
return context

def post_object_save(self, form):
search = apps.get_model("lit", "Search").objects.get_manually_added(self.assessment)
self.object.searches.add(search)
Expand All @@ -90,6 +95,11 @@ class IdentifierStudyCreate(ReferenceStudyCreate):
def get_success_url(self):
return reverse_lazy("study:update", args=(self.object.id,))

def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context["manual_entry_warning"] = False
return context


class StudyDetail(BaseDetail):
model = models.Study
Expand Down

0 comments on commit 5075e0f

Please sign in to comment.