Skip to content

Commit

Permalink
Merge branch 'master' into prevent-oom-on-home-page-load
Browse files Browse the repository at this point in the history
  • Loading branch information
georgeteo committed Jan 11, 2016
2 parents 5dd4172 + 4fd5a00 commit ecd9ff9
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 18 deletions.
5 changes: 3 additions & 2 deletions caravel/model/listing.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class _Listing(CategoriesMixin, PhotosMixin, PrincipalMixin, TimeOrderMixin,
SchemaMixin, PriceMixin, RateLimitMixin, ModeratedMixin,
ndb.Model):

SCHEMA_VERSION = 11
SCHEMA_VERSION = 12

title = ndb.StringProperty()
body = ndb.TextProperty()
Expand All @@ -48,7 +48,8 @@ def _keywords(self):
keywords = (
self._tokenize("title", self.title) +
self._tokenize("body", self.body) +
self._tokenize("category", " ".join(self.categories))
self._tokenize("category", " ".join(self.categories)) +
self._tokenize("seller", self.principal.email)
)
if self.price == 0:
keywords.append("price:free")
Expand Down
5 changes: 5 additions & 0 deletions caravel/static/default.css
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ body {
color: white;
}

p.help {
font-size: 0.85em;
color: #222;
}

/* For search results */
.float-to-inline-block {
display:inline-block;
Expand Down
3 changes: 3 additions & 0 deletions caravel/templates/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ <h1 class="branding">
</button>
</span>
</div>
<p class="help">
tip: search for "seller:yourname@uchicago.edu" to see your listings
</p>
</form>
<div class="user-button-container">
{% if not is_from_tor() %}
Expand Down
3 changes: 2 additions & 1 deletion caravel/templates/listings/fullpage.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ <h2>{{ listing.title }}</h2>
</p>
<p>Posted <strong>{{ listing.posted_at|as_duration }}</strong>
by {% if current_user %}
<a href="mailto:{{ listing.principal.email }}">
<a href="{{ url_for('search_listings',
q=listing.principal.email) }}">
{{ listing.principal.email }}</a>
{%- else -%}
[address hidden] (<a href="{{ login_url() }}">sign in</a> to view)
Expand Down
6 changes: 2 additions & 4 deletions caravel/templates/search_fail.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<div class="search-fail">
<img src="/static/images/search_fail.gif" alt="No results matching this query" class="img-rounded center-block">
<h4> We were unable to find any listings matching "{{ query }}".
<br>
Please try a different search term.</h4>
<h4>We were unable to find any listings matching "{{ query }}".</h4>
<p>Please try a different search term.
</div>
1 change: 1 addition & 0 deletions caravel/tests/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ def clean(self, markup):
markup = re.sub(r'Marketplace is.*lists.uchicago.edu\. ', '', markup)
markup = re.sub(r'(^.*UChicago Marketplace)|(&#169;.*$)', '', markup)
markup = re.sub(r'Please .* Update to Marketplace \. ', '', markup)
markup = re.sub(r'tip: .*? listings ', '', markup)
return markup.strip()

def extract_photos(self, markup):
Expand Down
23 changes: 12 additions & 11 deletions caravel/tests/test_migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,31 +46,32 @@ def test_migrate_from_old(self):
# Verify that gets now receive the correct version.
listing = model.Listing.get_by_id("my-listing-name")
self.assertEquals(listing.key.id(), "my-listing-name")
self.assertEquals(repr(listing.principal),
"Principal("
"email='jarcher@uchicago.edu', "
"device=Device(nonce='autogen', user_agent='(unknown)',"
" ip_address='0.0.0.0'), "
"auth_method='LEGACY')")
self.assertEquals(
repr(
listing.principal), "Principal("
"email='jarcher@uchicago.edu', "
"device=Device(nonce='autogen', user_agent='(unknown)',"
" ip_address='0.0.0.0'), "
"auth_method='LEGACY')")

self.assertEquals(listing.title, u"Legacy \xe2\x98\x86")
self.assertEquals(listing.body, u"Body of Legacy \xe2\x98\x86")
self.assertEquals(listing.price, 42.24)
self.assertEquals(int((
listing.posted_at -
datetime.datetime.fromtimestamp(1450075938)
).total_seconds()), 0)
listing.posted_at -
datetime.datetime.fromtimestamp(1450075938)
).total_seconds()), 0)
self.assertEquals(listing.categories, ["furniture", "bikes"])
self.assertEquals(listing.photos[0].path, "aa-bb")
self.assertEquals(listing.photos[1].path, "cc-dd")
self.assertEquals(listing.version, 11)
self.assertEquals(listing.version, 12)

# Trigger an update cronjob.
self.get("/_internal/migrate_schema")

# Verify that we have now changed on disk.
listing = Listing.get_by_key_name("my-listing-name")
self.assertEquals(listing.version, 11)
self.assertEquals(listing.version, 12)

# Verify that no emails were sent.
self.assertEquals(self.emails, [])
Expand Down

0 comments on commit ecd9ff9

Please sign in to comment.