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

Commit

Permalink
Reversing parity for is_searchable
Browse files Browse the repository at this point in the history
  • Loading branch information
clone1018 committed Jan 8, 2015
1 parent 21dbec1 commit 61c3db2
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 27 deletions.
2 changes: 1 addition & 1 deletion branch.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
BEGIN;
ALTER TABLE participants ADD COLUMN is_searchable bool NOT NULL DEFAULT FALSE;
ALTER TABLE participants ADD COLUMN is_searchable bool NOT NULL DEFAULT TRUE;
END;
2 changes: 1 addition & 1 deletion js/gratipay/account.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ Gratipay.account.init = function() {
, data: {toggle: 'is_searchable'}
, dataType: 'json'
, success: function(data) {
$('.is-searchable input').attr('checked', data.is_searchable);
$('.is-searchable input').attr('checked', !data.is_searchable);
}
, error: function() {
Gratipay.notification("Failed to change your search opt out settings. Please try again.", 'error');
Expand Down
21 changes: 2 additions & 19 deletions templates/profile.html
Original file line number Diff line number Diff line change
@@ -1,28 +1,11 @@
{% extends "templates/participant.html" %}

{% block head %}
<link rel="payment" type="text/html" title="Give weekly gift on Gratipay"
href="https://gratipay.com/{{ username }}/" />
<meta name="twitter:card" content="summary" />
<meta name="og:url" content="https://gratipay.com/{{ username }}/" />
<meta name="og:type" content="profile" />
<meta name="og:title" content="{{ participant.get_og_title() }}" />
{% if statement %}
<meta name="og:description" content="{{ excerpt_intro(statement)|e }}" />
{% else %}
<meta name="og:description" content="Gratipay is a weekly gift exchange" />
{% endif %}
{% if participant.avatar_url %}
<meta name="og:image" content="{{ participant.avatar_url|e }}" />
{% endif %}
<meta name="og:image" content="{{ website.asset('gratipay.opengraph.png') }}" />

{% if participant.is_searchable %}
{% block head_early %}
{% if not participant.is_searchable %}
<meta name="robots" content="noindex,nofollow" />
{% endif %}
{% endblock %}


{% block scripts %}
{% if user.ADMIN %}<script src="{{ website.asset('admin.js') }}"></script>{% endif %}
<script>$(document).ready(Gratipay.tips.init)</script>
Expand Down
6 changes: 3 additions & 3 deletions tests/py/test_privacy_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@ def hit_privacy(self, method='GET', expected_code=200, **kw):
def test_participant_can_get_their_privacy_settings(self):
response = self.hit_privacy('GET')
actual = json.loads(response.body)
assert actual == {'is_searchable': False}
assert actual == {'is_searchable': True}

def test_participant_can_toggle_is_searchable(self):
response = self.hit_privacy('POST', data={'toggle': 'is_searchable'})
actual = json.loads(response.body)
assert actual['is_searchable'] is True
assert actual['is_searchable'] is False

def test_participant_can_toggle_is_searchable_back(self):
response = self.hit_privacy('POST', data={'toggle': 'is_searchable'})
response = self.hit_privacy('POST', data={'toggle': 'is_searchable'})
actual = json.loads(response.body)
assert actual['is_searchable'] is False
assert actual['is_searchable'] is True

def test_meta_robots_tag_added_on_opt_out(self):
self.hit_privacy('POST', data={'toggle': 'is_searchable'})
Expand Down
2 changes: 1 addition & 1 deletion www/%username/account/index.html.spt
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ emails = participant.get_emails()
<br />
<label class="is-searchable">
<input type="checkbox"
{% if participant.is_searchable %}checked="true"{% endif %} />
{% if not participant.is_searchable %}checked="true"{% endif %} />
{{ _("Hide myself from search results.") }}
</label>
</p>
Expand Down
18 changes: 18 additions & 0 deletions www/%username/index.html.spt
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,24 @@ def with_others(obj):
[-----------------------------------------------------------------------------]
{% extends "templates/profile.html" %}

{% block head %}
<link rel="payment" type="text/html" title="Give weekly gift on Gratipay"
href="https://gratipay.com/{{ username }}/" />
<meta name="twitter:card" content="summary" />
<meta name="og:url" content="https://gratipay.com/{{ username }}/" />
<meta name="og:type" content="profile" />
<meta name="og:title" content="{{ participant.get_og_title() }}" />
{% if statement %}
<meta name="og:description" content="{{ excerpt_intro(statement)|e }}" />
{% else %}
<meta name="og:description" content="Gratipay is a weekly gift exchange" />
{% endif %}
{% if participant.avatar_url %}
<meta name="og:image" content="{{ participant.avatar_url|e }}" />
{% endif %}
<meta name="og:image" content="{{ website.asset('gratipay.opengraph.png') }}" />
{% endblock %}

{% block content %}
{% if user.participant == participant %}
<div id="profile-edit">
Expand Down
4 changes: 2 additions & 2 deletions www/search.spt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ if query:
FROM participants
WHERE username %% %(q)s
AND claimed_time IS NOT NULL
AND NOT is_searchable
AND is_searchable
AND NOT is_closed
ORDER BY rank DESC, username
LIMIT 10
Expand Down Expand Up @@ -54,7 +54,7 @@ if query:
) s
JOIN participants p ON p.id = s.participant
WHERE p.claimed_time IS NOT NULL
AND NOT p.is_searchable
AND p.is_searchable
AND NOT p.is_closed
GROUP BY username
ORDER BY max_rank DESC
Expand Down

0 comments on commit 61c3db2

Please sign in to comment.