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

Added alert in manual study entry page #819

Merged
merged 7 commits into from
May 19, 2023
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
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