Skip to content

Commit

Permalink
Add data download homepage CTA
Browse files Browse the repository at this point in the history
  • Loading branch information
symroe committed May 24, 2024
1 parent 8be343b commit abf735e
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 9 deletions.
12 changes: 6 additions & 6 deletions deploy/webapp_settings/production.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
}
]


# **** Other settings that might be useful to change locally

INTERNAL_IPS = [
Expand All @@ -55,19 +54,18 @@
},
}


# **** Settings that might be useful in production
SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https")
ACCOUNT_DEFAULT_HTTP_PROTOCOL = "https"
RAVEN_CONFIG = {"dsn": os.environ.get("RAVEN_DSN")}

RUNNING_TESTS = False


# This should be one of:
# ELECTION_STATS
# SOPN_TRACKER
# RESULTS_PROGRESS
# DATA_DOWNLOAD
# BY_ELECTIONS
FRONT_PAGE_CTA = "None"
SOPN_TRACKER_INFO = {
Expand All @@ -81,10 +79,14 @@
# ("Northern Ireland", date(year=2023, month=4, day=24)),
]

DATA_DOWNLOAD_INFO = {
"election_date": "2024-07-04",
"election_name": "2024 general election",
"election_regex": "parl.2024-07-04",
}

SCHEDULED_ELECTION_DATES = ["2024-05-02", "2024-05-18"]


STATICFILES_STORAGE = "ynr.storages.StaticStorage"
DEFAULT_FILE_STORAGE = "ynr.storages.MediaStorage"
AWS_STORAGE_BUCKET_NAME = "static-candidates.democracyclub.org.uk"
Expand All @@ -95,7 +97,6 @@
AWS_BUCKET_ACL = AWS_DEFAULT_ACL
AWS_QUERYSTRING_AUTH = False


CSRF_TRUSTED_ORIGINS = [
f"https://{os.environ.get('FQDN')}",
]
Expand All @@ -109,7 +110,6 @@
EMAIL_HOST_USER = os.environ.get("SMTP_USERNAME")
EMAIL_HOST_PASSWORD = os.environ.get("SMTP_PASSWORD")


SLACK_TOKEN = os.environ.get("SLACK_TOKEN")

CELERY_IMPORTS = [
Expand Down
4 changes: 1 addition & 3 deletions ynr/apps/elections/uk/templates/candidates/finder.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ <h1>Open candidate information for UK elections</h1>
{% sopn_import_progress %}
{% current_election_stats %}
{% results_progress %}
{% data_download %}
</div>
</div>
{% endif %}
Expand Down Expand Up @@ -97,9 +98,6 @@ <h1>Open candidate information for UK elections</h1>
{{ postcode_form.as_p }}
<input type="submit" class="button" value="Help add information!"/>
</form>
<h4>or</h4>
<h3>Get the data</h3>
<p><a href="/help/api" class="button secondary">Via our API or CSV download</a></p>
</div>
{% if front_page_cta == "BY_ELECTIONS" %}
<div class="finder__forms__container" style="margin-top:3em">
Expand Down
9 changes: 9 additions & 0 deletions ynr/apps/elections/uk/templates/includes/data_download.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{% if DATA_DOWNLOAD %}
<h2>Get the data</h2>
<p>Download the CSV of all candidates standing for the {{ election_name }}:</p>
<p><a class="button" href="{% url "data_export" %}?election_id={{ election_regex }}">Download CSV</a></p>
<p>Or for more advance filters and more fields, try the
<a href="{% url "data_home" %}?election_id={{ election_regex }}">custom CSV builder</a>.</p>
<p>You can also use our <a href="{% url "api-home" %}">candidates API</a> or <a
href="https://developers.democracyclub.org.uk/">postcode lookup API</a>.</p>
{% endif %}
15 changes: 15 additions & 0 deletions ynr/apps/elections/uk/templatetags/home_page_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,3 +250,18 @@ def by_election_ctas(context):
ballot for ballot in all_ballots if ballot.election.in_past
]
return context


@register.inclusion_tag("includes/data_download.html", takes_context=True)
def data_download(context):
context["DATA_DOWNLOAD"] = (
getattr(settings, "FRONT_PAGE_CTA", False) == "DATA_DOWNLOAD"
)

if context["DATA_DOWNLOAD"]:
context["election_date"] = settings.DATA_DOWNLOAD_INFO["election_date"]
context["election_regex"] = settings.DATA_DOWNLOAD_INFO[
"election_regex"
]
context["election_name"] = settings.DATA_DOWNLOAD_INFO["election_name"]
return context

0 comments on commit abf735e

Please sign in to comment.