Skip to content
This repository has been archived by the owner on Nov 7, 2018. It is now read-only.

Commit

Permalink
Merge 0ee3f61 into 8182614
Browse files Browse the repository at this point in the history
  • Loading branch information
RAMIREZG committed Jun 19, 2015
2 parents 8182614 + 0ee3f61 commit 1fc6794
Show file tree
Hide file tree
Showing 12 changed files with 186 additions and 161 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ language: python
python:
- "3.4"
install:
- pip install -r requirements.txt
- pip install -r requirements-dev.txt
- travis_retry pip install -r requirements.txt
- travis_retry pip install -r requirements-dev.txt
script:
- coverage run --source=foia_hub manage.py test --settings=foia_hub.settings.test

Expand Down
39 changes: 31 additions & 8 deletions contact_updater/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,24 +35,29 @@ class AgencyForm(forms.Form):
public_liaison_email = forms.EmailField(
label='Email',
required=False,
widget=forms.EmailInput(attrs={'class': 'public_liaison_email'}))
widget=forms.EmailInput(attrs={
'class': 'public_liaison_email',
'data-parsley-type-message': 'Please enter a valid email.'
}))
public_liaison_phone = forms.RegexField(
label='Phone Number',
required=False,
regex=PHONE_RE,
error_message=('Must contain a valid phone number'),
widget=forms.TextInput(attrs={
'class': 'public_liaison_phone',
'data-parsley-pattern-message':
'Please enter a valid phone number.',
'pattern': PHONE_PATTERN}))

# Request Center
phone = forms.RegexField(
label='Phone Number',
required=False,
regex=PHONE_RE,
error_message=('Must contain a valid phone number'),
widget=forms.TextInput(attrs={
'class': 'phone',
'data-parsley-pattern-message':
'Please enter a valid phone number.',
'pattern': PHONE_PATTERN}))

# FOIA Request Submission
Expand All @@ -75,15 +80,22 @@ class AgencyForm(forms.Form):
required=False,
widget=forms.TextInput(attrs={
'class': 'zip_code',
'data-parsley-pattern-message': 'Please enter a valid zip code.',
'pattern': '\d{5,5}(-\d{4,4})?'}))
office_url = forms.URLField(
label="Website URL",
required=False,
widget=forms.URLInput(attrs={'class': 'office_url'}))
widget=forms.URLInput(attrs={
'class': 'office_url',
'data-parsley-type-message': 'Please enter a valid url.',
}))
emails = forms.EmailField(
label='Email',
required=False,
widget=forms.EmailInput(attrs={'class': 'email'}))
widget=forms.EmailInput(attrs={
'class': 'email',
'data-parsley-type-message': 'Please enter a valid email.',
}))

fax = forms.RegexField(
label='Fax Number',
Expand All @@ -92,19 +104,30 @@ class AgencyForm(forms.Form):
error_message=('Must contain a valid phone number'),
widget=forms.TextInput(attrs={
'class': 'fax',
'data-parsley-pattern-message': 'Please enter a valid fax number.',
'pattern': PHONE_PATTERN}))

# Other
component_url = forms.URLField(
label="Agency/component website",
required=False,
widget=forms.URLInput(attrs={'class': 'component_url'}))
widget=forms.URLInput(attrs={
'class': 'component_url',
'data-parsley-type-message': 'Please enter a valid url.',
}))
foia_libraries = forms.URLField(
label="Reading room website",
required=False,
widget=forms.URLInput(attrs={'class': 'foia_libraries'}))
widget=forms.URLInput(attrs={
'class': 'foia_libraries',
'data-parsley-type-message': 'Please enter a valid url.',
}))
regulations_website = forms.URLField(
label="Regulations Website", required=False)
label="Regulations Website",
required=False,
widget=forms.URLInput(attrs={
'data-parsley-type-message': 'Please enter a valid url.'
}))
common_requests = forms.CharField(
label='Commonly requested topics',
required=False,
Expand Down
14 changes: 11 additions & 3 deletions contact_updater/templates/agency_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
{% else %}
<!-- Centralized Form -->
{% if forms|length == 1 %}
<h1>{{agency_names.0}}</h1>
<h1 class="agency-name">{{agency_names.0}}</h1>
{% for form in forms %}
{% include 'centralized.html' %}
{% endfor %}
Expand All @@ -32,11 +32,19 @@ <h1>{{agency_names.0}}</h1>
<br>
<!-- Buttons when validated -->
{% if validated %}
<input type="submit" name="download" value="Download" />
<input type="submit" id="download-button" name="download" value="Download" />
<input type="submit" name="return" value="Return" />
{# A tiny script that downloads the data when it gets to the validated
page. #}
<script>
document.getElementById("download-button").click();
</script>
{% else %}
<!-- Buttons when not validated -->
<input type="submit" value="Submit" />
<div class="submission-errors">
<ul id="error-list"></ul>
</div>
<input type="submit" id='submit-agency' value="Submit"/>
{% endif %}
</form>
</div>
Expand Down
3 changes: 2 additions & 1 deletion contact_updater/templates/centralized.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{# The slug is an invisible field for ID purposes #}
{{form.slug.as_hidden()}}
{% if loop %}<h1 class="agency-name">{{agency_names[loop.index]}}</h1>{% endif %}
<section class="description">
<div class="field">
<label for="description">{{form.description.label}}</label>
<label for="description" class="required">{{form.description.label}}</label>
{{form.description}}
<div id="charNum"></div>
</div>
Expand Down
9 changes: 9 additions & 0 deletions contact_updater/templates/contact-updater-base.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,14 @@

<footer>
{% block footer %}
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', '{{ ANALYTICS_ID }}', 'auto');
ga('set', 'anonymizeIp', true);
ga('send', 'pageview');
</script>
{% endblock %}
</footer>
2 changes: 1 addition & 1 deletion contact_updater/templates/decentralized.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ <h1>{{agency_names[0]}}</h1>

<section class="description">
<div class="field">
<label for="description">{{forms[0].description.label}}</label>
<label for="description" class="required">{{forms[0].description.label}}</label>
{{forms[0].description}}
<div id="charNum"></div>
</div>
Expand Down
11 changes: 7 additions & 4 deletions contact_updater/templates/form_index.html
Original file line number Diff line number Diff line change
@@ -1,25 +1,28 @@
{% extends "contact-updater-base.html" %}

{% block body %}
{# Pass data to JS #}
<script>
var agencies = {{agencies|safe}};
</script>

<div class="container contactUpdater">
<h1>openFOIA Contact Updater</h1>
<p>Update your agency's contact information on openFOIA.</p>
<div class="search--box scrollable-dropdown-menu">
<div class="search-icon"><span class="fa fa-search"></span></div>
{% set search_placeholder = 'Search for an agency' %}
<input id="contact" class="typeahead agency" type="search"
<input id="contact-typeahead" class="typeahead agency" type="search"
placeholder="{{ search_placeholder }}"
aria-label="{{ search_placeholder }}"
search-type="contactSearch">
<input class="submit" type="submit" value="Search">
</div>
</div>
{% endblock %}

{% block footer %}
{{ super() }}
<!-- JS scripts needed for search -->
<script src="{{ static("js/typeahead.bundle.js") }}"></script>
<script src="{{ static("js/handlebars-v1.2.0.js") }}"></script>
<script src="{{ static("js/contact-updater/typeahead.min.js") }}"></script>
<script src="{{ static("js/contact-updater/contact-search.js") }}"></script>
{% endblock %}
4 changes: 2 additions & 2 deletions contact_updater/templates/validated.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ <h3>Instructions</h3>
<li>Agency web managers will need to place the contact_data.json file in the <code>/foia/quarterly/</code> directory of the agency's website. For example, the Department of Justice will place its file at <code>www.justice.gov/foia/quarterly/contact_data.json</code>. In some cases, the <code>/foia/quarterly/</code> directory may not yet exist, and web managers will first need to create it.</li>
<li>Within 2 days your updates should appear on your agency’s page. Please double-check to make sure your changes have been implemented. If not, please email us at <a href="mailto:18f-foia@gsa.gov">18f-foia@gsa.gov</a></li>
</ol>
<!-- Invisible form to store data while validated this allows the user to
not have data deleted -->
{# Invisible form to store data while validated this allows the user to
not have data deleted #}
{% for form in forms %}
{% for field in form %}
{{field.as_hidden()}}
Expand Down
5 changes: 4 additions & 1 deletion contact_updater/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ def form_index(request):
"""
agencies = Agency.objects.filter(parent__isnull=True).values()
return render(
request, "form_index.html", {'agencies': agencies})
request,
"form_index.html",
{'agencies': {agency['name']: agency['slug'] for agency in agencies}}
)


def download_data(request):
Expand Down

0 comments on commit 1fc6794

Please sign in to comment.