Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #871 from WikipediaLibrary/jason-T294919
Create a URL which initiates a library search
- Loading branch information
Showing
12 changed files
with
219 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
from crispy_forms.helper import FormHelper | ||
from crispy_forms.layout import Hidden, Submit, Layout | ||
|
||
from django.conf import settings | ||
from django.contrib.auth.models import User | ||
|
||
from django import forms | ||
from django.utils.translation import get_language, gettext as _ | ||
|
||
|
||
class EdsSearchForm(forms.Form): | ||
""" """ | ||
|
||
lang = forms.ChoiceField(choices=settings.LANGUAGES) | ||
schemaId = forms.CharField() | ||
custid = forms.CharField() | ||
groupid = forms.CharField() | ||
profid = forms.CharField() | ||
scope = forms.CharField() | ||
site = forms.CharField() | ||
direct = forms.CharField() | ||
authtype = forms.CharField() | ||
bquery = forms.CharField() | ||
|
||
def __init__(self, *args, **kwargs): | ||
language_code = get_language() | ||
lang = language_code | ||
bquery = kwargs.pop("bquery", None) | ||
|
||
super().__init__(*args, **kwargs) | ||
if language_code == "pt": | ||
lang = "pt-pt" | ||
elif language_code == "zh-hans": | ||
lang = "zh-cn" | ||
elif language_code == "zh-hant": | ||
lang = "zh-tw" | ||
self.helper = FormHelper() | ||
self.helper.form_id = "search" | ||
self.helper.form_action = "https://searchbox.ebsco.com/search/" | ||
self.helper.form_method = "GET" | ||
self.helper.label_class = "sr-only" | ||
self.helper.layout = Layout( | ||
Hidden("bquery", bquery), | ||
Hidden("lang", lang), | ||
Hidden("schemaId", "search"), | ||
Hidden("custid", "ns253359"), | ||
Hidden("groupid", "main"), | ||
Hidden("profid", "eds"), | ||
Hidden("scope", "site"), | ||
Hidden("site", "eds-live"), | ||
Hidden("direct", "true"), | ||
Hidden("authtype", "url"), | ||
Submit( | ||
"submit", | ||
# Translators: Shown in the search button. | ||
_("Search"), | ||
css_class="btn eds-search-button", | ||
), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{% extends "new_base.html" %} | ||
{% load i18n %} | ||
{% load crispy_forms_tags %} | ||
{% load twlight_perms %} | ||
{% block content %} | ||
{% comment %}Translators: On a special 'link to search' page, this message is shown if JavaScript is disabled.{% endcomment %} | ||
<p id="noscript">{% trans "JavaScript is disabled; use the button below to continue." %}</p> | ||
{% crispy form %} | ||
{% endblock %} | ||
|
||
{% block javascript %} | ||
<script> | ||
// On page load | ||
document.addEventListener("DOMContentLoaded", function(event) { | ||
// Delete noscript element. | ||
// <noscript> text was not showing up in testing with the noscript extension. | ||
var noscript = document.getElementById("noscript"); | ||
noscript.parentNode.removeChild(noscript); | ||
// Submit the form. | ||
document.createElement('form').submit.call(document.getElementById('search')); | ||
}); | ||
</script> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters