Skip to content

Commit

Permalink
remove dead apps: poll_and_call, predictionmarket, whipturk
Browse files Browse the repository at this point in the history
Removes the dependencies on twilio libraries. Fixes #132.
  • Loading branch information
JoshData committed Jul 31, 2017
1 parent d423b3e commit f18ab4c
Show file tree
Hide file tree
Showing 31 changed files with 0 additions and 1,670 deletions.
2 changes: 0 additions & 2 deletions .env.server.template
Original file line number Diff line number Diff line change
Expand Up @@ -83,5 +83,3 @@ FACEBOOK_APP_ID=fill this in
FACEBOOK_APP_SECRET=fill this in
FACEBOOK_AUTH_SCOPE=

TWILIO_ACCOUNT_SID=fill this in
TWILIO_AUTH_TOKEN=fill this in
111 changes: 0 additions & 111 deletions bill/management/commands/make_markets.py

This file was deleted.

24 changes: 0 additions & 24 deletions bill/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1354,30 +1354,6 @@ def date_filter(d):

return None

def get_open_market(self, user):
from django.contrib.contenttypes.models import ContentType
bill_ct = ContentType.objects.get_for_model(Bill)

import predictionmarket.models
try:
m = predictionmarket.models.Market.objects.get(owner_content_type=bill_ct, owner_object_id=self.id, isopen=True)
except predictionmarket.models.Market.DoesNotExist:
return None

for outcome in m.outcomes.all():
if outcome.owner_key == "1": # "yes"
m.yes = outcome
m.yes_price = int(round(outcome.price() * 100.0))
if user and user.is_authenticated():
account = predictionmarket.models.TradingAccount.get(user, if_exists=True)
if account:
positions, profit = account.position_in_market(m)
m.user_profit = round(profit, 1)
m.user_positions = { }
for outcome in positions:
m.user_positions[outcome.owner_key] = positions[outcome]
return m

def get_gop_summary(self):
import urllib, StringIO
try:
Expand Down
2 changes: 0 additions & 2 deletions bill/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,9 @@
url(r'^$', 'bill_docket', name='bill_docket'),
url(r'^statistics$', 'bill_statistics', name='bill_stats'),
url(r'^uscode(?:/(\d+|.*))?$', 'uscodeindex'),
url(r'^_ajax/market_test_vote', 'market_test_vote'),
url(r'^_ajax/load_text', 'bill_text_ajax'),
url(r'^_ajax/join_community', 'join_community'),
url(r'^_admin/go_to_summary_admin', 'go_to_summary_admin', name="bill_go_to_summary_admin"),
url(r'^_redirect/start-poll', 'start_poll', name="bill_start_poll"),
url(r'^(\d+)/([a-z]+)(\d+)/(thumbnail|_text_image)$', 'bill_text_image'),
)

Expand Down
113 changes: 0 additions & 113 deletions bill/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,51 +105,18 @@ def bill_details_user_view(request, congress, type_slug, number):
| <a href="/admin/bill/bill/{{bill.id}}">Edit</a>
<br/>Tracked by {{feed.tracked_in_lists.count|intcomma}} users
({{feed.tracked_in_lists_with_email.count|intcomma}} w/ email).
<br/>{{num_issuepos}} poll responses, {{num_calls}} phone calls to Congress.
</div>
"""

from poll_and_call.models import RelatedBill as IssueByBill
try:
from poll_and_call.models import *
ix = RelatedBill.objects.get(bill=bill).issue
num_issuepos = UserPosition.objects.filter(position__issue=ix).count()
num_calls = len([c for c in CallLog.objects.filter(position__position__issue=ix) if c.is_complete()])
except IssueByBill.DoesNotExist:
num_issuepos = 0
num_calls = 0

from django.template import Template, Context, RequestContext, loader
ret["admin_panel"] = Template(admin_panel).render(RequestContext(request, {
'bill': bill,
"feed": bill.get_feed(),
"num_issuepos": num_issuepos,
"num_calls": num_calls,
}))

from person.views import render_subscribe_inline
ret.update(render_subscribe_inline(request, bill.get_feed()))

# poll_and_call
if request.user.is_authenticated():
from poll_and_call.models import RelatedBill as IssueByBill, UserPosition
try:
issue = IssueByBill.objects.get(bill=bill).issue
try:
up = UserPosition.objects.get(user=request.user, position__issue=issue)
targets = up.get_current_targets()
ret["poll_and_call_position"] = {
"id": up.position.id,
"text": up.position.text,
"can_change": up.can_change_position(),
"can_call": [(t.id, t.person.name) for t in targets] if isinstance(targets, list) else [],
"call_url": issue.get_absolute_url() + "/make_call",
}
except UserPosition.DoesNotExist:
pass
except IssueByBill.DoesNotExist:
pass

# emoji reactions
import json
from website.models import Reaction
Expand Down Expand Up @@ -244,30 +211,6 @@ def bill_widget_info(request, congress, type_slug, number):
"SITE_ROOT_URL": settings.SITE_ROOT_URL,
}

@json_response
@login_required
def market_test_vote(request):
bill = get_object_or_404(Bill, id = request.POST.get("bill", "0"))
prediction = int(request.POST.get("prediction", "0"))
market = bill.get_open_market(request.user)
if not market: return { }

from predictionmarket.models import Trade, TradingAccount
account = TradingAccount.get(request.user)
if prediction != 0:
# Buy shares in one of the outcomes.
try:
t = Trade.place(account, market.outcomes.get(owner_key = 1 if prediction == 1 else 0), 10)
except ValueError as e:
return { "error": str(e) }

else:
# Sell shares.
positions, pl = account.position_in_market(market)
for outcome in positions:
Trade.place(account, outcome, -positions[outcome]["shares"])

return { "vote": prediction }

@anonymous_view
@render_to('bill/bill_text.html')
Expand Down Expand Up @@ -753,62 +696,6 @@ def uscodeindex(request, secid):
"feed": (Feed.objects.get_or_create(feedname="usc:" + str(parent.id))[0]) if parent else None,
}

@anonymous_view
def start_poll(request):
from poll_and_call.models import Issue, IssuePosition, RelatedBill as IssueByBill

# get the bill & valence
bill = get_object_or_404(Bill, id=request.GET.get("bill"))
valence = (request.GET.get("position") == "support")

# get the Issue
try:
ix = IssueByBill.objects.get(bill=bill).issue
except IssueByBill.DoesNotExist:
# no Issue yet, so create
ix = Issue.objects.create(
slug = "%d-%s-%d" % (bill.congress, bill.bill_type_slug, bill.number),
title = "PLACEHOLDER",
question = "PLACEHOLDER",
introtext = "Weigh in on %s." % bill.display_number_with_congress_number,
isopen = True,
)
IssueByBill.objects.create(issue=ix, bill=bill, valence=True)

# update the Issue since the bill title may have changed
ix.title = bill.title
ix.question = "What is your position on %s?" % bill.title
ix.save()

# how to refer to the bill in the call script
from django.template.defaultfilters import truncatewords
title = bill.title_no_number
if re.match(".* Act( of \d{4})?", title):
title = "The " + title
title = bill.display_number + ": " + title
bt = truncatewords(title, 11)
if "..." in bt:
bt = truncatewords(title, 15)
bt = u"%s (\u201C%s\u201D)" % (bill.display_number, bt.replace(bill.display_number + ": ", ""))

# create and update the options
for opt_valence, opt_verb in ((True, "support"), (False, "oppose")):
try:
p = ix.positions.get(valence=opt_valence)
except:
p = IssuePosition.objects.create(
text="PLACEHOLDER",
valence=opt_valence,
call_script="PLACEHOLDER",
)
ix.positions.add(p)

p.text = opt_verb.title()
p.call_script = "I %s %s." % (opt_verb, bt)
p.save()

return HttpResponseRedirect(ix.get_absolute_url() + "/join/" + str(ix.positions.get(valence=valence).id))

@anonymous_view
def bill_text_image(request, congress, type_slug, number, image_type):
bill = load_bill_from_url(congress, type_slug, number)
Expand Down
3 changes: 0 additions & 3 deletions build/pipreq.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,10 @@ recaptcha-client
django-wysiwyg
rcssmin
markdown2
django_twilio
twilio<6.0.0
tqdm
pyyaml
pynliner
git+https://github.com/govtrack/django-lorien-common
phonenumbers
git+https://github.com/if-then-fund/[email protected]
xml_diff
diff_match_patch_python
Expand Down
Empty file removed poll_and_call/__init__.py
Empty file.
23 changes: 0 additions & 23 deletions poll_and_call/admin.py

This file was deleted.

Empty file.
Empty file.
Loading

0 comments on commit f18ab4c

Please sign in to comment.