Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Add replication for new inquiries and listings" #240

Merged
merged 1 commit into from
Apr 1, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 1 addition & 24 deletions caravel/model/inquiry.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,38 +8,15 @@
from caravel.model.principal import PrincipalMixin
from caravel.model.side_effects import SideEffectsMixin
from caravel.model.rate_limits import RateLimitMixin
from caravel.model.replication import ReplicationMixin


from flask import render_template


class _Inquiry(TimeOrderMixin, PrincipalMixin, ModeratedMixin,
ReplicationMixin, ndb.Model):

REPLICATION_URL = "https://go-marketplace.appspot.com/inquiries"

ndb.Model):
message = ndb.StringProperty()
listing = ndb.KeyProperty(kind=listing.Listing)

def encode_for_replication(self):
"""Flattens this Listing into a JSON dict."""

data = self.to_dict()
data["listing"] = self.listing.id()
data["sender"] = {
"email": self.principal.email,
"validated": (self.principal.auth_method == "GOOGLE_APPS")
}
data["moderated"] = (bool(self.principal.validated_by) or
(self.principal.auth_method == "GOOGLE_APPS"))
del data["principal"]
del data["posted_at"]
if "run_trigger" in data:
del data["run_trigger"]

return data


class Inquiry(SideEffectsMixin, _Inquiry):

Expand Down
30 changes: 1 addition & 29 deletions caravel/model/listing.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from caravel.model.full_text import FullTextMixin
from caravel.model.rate_limits import RateLimitMixin
from caravel.model.sellable import SellableMixin
from caravel.model.replication import ReplicationMixin

from caravel import utils

Expand All @@ -22,11 +21,10 @@

class _Listing(CategoriesMixin, PhotosMixin, PrincipalMixin, TimeOrderMixin,
SchemaMixin, PriceMixin, RateLimitMixin, ModeratedMixin,
SellableMixin, FullTextMixin, ReplicationMixin, ndb.Model):
SellableMixin, FullTextMixin, ndb.Model):

SCHEMA_VERSION = 12
MARK_AS_OLD_AFTER = datetime.timedelta(days=30)
REPLICATION_URL = "https://go-marketplace.appspot.com/listings"

title = ndb.StringProperty()
body = ndb.TextProperty()
Expand All @@ -35,32 +33,6 @@ class _Listing(CategoriesMixin, PhotosMixin, PrincipalMixin, TimeOrderMixin,
def can_bump(self):
return self.age >= datetime.timedelta(days=7)

def encode_for_replication(self):
"""Flattens this Listing into a JSON dict."""

data = self.to_dict()
data["posted_at"] = data["posted_at"].isoformat()
data["photos"] = [{"small": photo.public_url("small"),
"large": photo.public_url("large")}
for photo in data["photos"]]
data["price"] = float(data["price"])
if "run_trigger" in data:
del data["run_trigger"]
del data["version"]
del data["burst_count"]
del data["daily_count"]
del data["keywords"]
del data["principal"]

data["seller"] = {
"email": self.principal.email,
"validated": (self.principal.auth_method == "GOOGLE_APPS")
}
data["moderated"] = (bool(self.principal.validated_by) or
(self.principal.auth_method == "GOOGLE_APPS"))

return data


class Listing(SideEffectsMixin, _Listing):

Expand Down
31 changes: 0 additions & 31 deletions caravel/model/replication.py

This file was deleted.

1 change: 0 additions & 1 deletion caravel/storage/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,5 @@ def get_tor_addresses():
"recaptcha_private_key",
"6LeIxAcTAAAAAGG-vFI1TnRWxMZNFuojJ4WifJWe")
app.config["RECAPTCHA_DATA_ATTRS"] = {"size": "compact"}
replication_key = lookup("replication_key", "~key~")

Bootstrap(app)
5 changes: 0 additions & 5 deletions caravel/templates/listings/map.html

This file was deleted.

11 changes: 5 additions & 6 deletions caravel/tests/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import uuid
import time
import sys
import urllib2
import os
from contextlib import contextmanager

Expand Down Expand Up @@ -95,10 +94,10 @@ def setUp(self):
sendgrid = config.send_grid_client
self._send, sendgrid.send = sendgrid.send, self.emails.append

# Capture outgoing webhooks.
self.webhooks = []
self._urlopen = urllib2.urlopen
urllib2.urlopen = lambda url, body: self.webhooks.append((url, body))
# Capture outgoing Slack messages.
# self.chats = []
# self._send_chat = slack.send_chat
# slack.send_chat = lambda **kw: self.chats.append(kw)

# Ensure that UUIDs are deterministic.
self._uuid4 = uuid.uuid4
Expand Down Expand Up @@ -157,7 +156,7 @@ def tearDown(self):
# Un-stub mocks.
uuid.uuid4 = self._uuid4
config.send_grid_client.send = self._send
urllib2.urlopen = self._urlopen
# slack.send_chat = self._send_chat

super(CaravelTestCase, self).tearDown()

Expand Down
67 changes: 0 additions & 67 deletions caravel/tests/test_replication.py

This file was deleted.

Empty file.
Empty file.