Skip to content

Commit

Permalink
stashing changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Flaxman committed Apr 9, 2015
1 parent 243571c commit 63d7b78
Show file tree
Hide file tree
Showing 5 changed files with 116 additions and 1 deletion.
7 changes: 7 additions & 0 deletions addresses/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,10 @@ class NewUserAddressSubscriptionForm(KnownUserAddressSubscriptionForm):
max_length=100,
widget=forms.TextInput(attrs={'placeholder': '[email protected]', 'class': 'input-lg'}),
)


class AddressSearchForm(KnownUserAddressSubscriptionForm):

def __init__(self, *args, **kwargs):
super(AddressSearchForm, self).__init__(*args, **kwargs)
self.fields['coin_address'].label = "Address"
42 changes: 41 additions & 1 deletion addresses/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from services.models import WebHook
from emails.models import SentEmail

from addresses.forms import KnownUserAddressSubscriptionForm, NewUserAddressSubscriptionForm
from addresses.forms import KnownUserAddressSubscriptionForm, NewUserAddressSubscriptionForm, AddressSearchForm

from utils import get_max_pages, get_user_agent, get_client_ip, uri_to_url, simple_pw_generator

Expand Down Expand Up @@ -341,3 +341,43 @@ def address_webhook(request, secret_key, ignored_key):

# Return something
return HttpResponse("*ok*")


def render_address_widget(request, coin_symbol, b58_address):
pass


@render_to('search_widgets.html')
def search_widgets(request, coin_symbol):
form = AddressSearchForm()
if request.method == 'POST':
form = AddressSearchForm(data=request.POST)
if form.is_valid():
kwargs = {
'coin_symbol': form.cleaned_data['coin_symbol'],
'address': form.cleaned_data['coin_address'],
}
redir_url = reverse('widgets_overview', kwargs=kwargs)
return HttpResponseRedirect(redir_url)
elif request.method == 'GET':
new_coin_symbol = request.GET.get('c')
if new_coin_symbol:
initial = {'coin_symbol': new_coin_symbol}
form = AddressSearchForm(initial=initial)

return {
'form': form,
'coin_symbol': coin_symbol,
}


@render_to('widgets.html')
def widgets_overview(request, coin_symbol, address):
#FIXME: implement
return {}


def widget_forwarding(request):
kwargs = {'coin_symbol': 'btc'}
redir_url = reverse('search_widgets', kwargs=kwargs)
return HttpResponseRedirect(redir_url)
6 changes: 6 additions & 0 deletions blockexplorer/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@
url(r'(?P<coin_symbol>[-\w]+)/pushtx/$', 'transactions.views.push_tx', name='push_tx'),
url(r'(?P<coin_symbol>[-\w]+)/decodetx/$', 'transactions.views.decode_tx', name='decode_tx'),

# Widget
url(r'^widgets/(?P<coin_symbol>[-\w]+)/?$', 'addresses.views.search_widgets', name='search_widgets'),
url(r'show-widgets/(?P<coin_symbol>[-\w]+)/(?P<address>[-\w]+)/$', 'addresses.views.widgets_overview', name='widgets_overview'),
url(r'widget/(?P<coin_symbol>[-\w]+)/(?P<address>[-\w]+)/$', 'addresses.views.render_address_widget', name='render_address_widget'),
url(r'^widgets/$', 'addresses.views.widget_forwarding', name='widget_forwarding'),

# Forwarding Pages (URL hacks)
url(r'^subscribe/$', 'addresses.views.subscribe_forwarding', name='subscribe_forwarding'),
url(r'^pushtx/$', 'transactions.views.pushtx_forwarding', name='pushtx_forwarding'),
Expand Down
35 changes: 35 additions & 0 deletions templates/search_widgets.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{% extends "base.html" %}

{% load i18n %}
{% load humanize %}
{% load btc_formats %}
{% load static %}

{% block title %}
Embeddable Address Widgets
{% endblock title %}

{% block page_header %}
<h1>
<i class="fa fa-send"></i>
See Embeddable Address Widgets
</h1>
{% endblock page_header %}

{% block content %}

<div class="section">
<div class="container">
<form role="form" method="post" action="{% url 'search_widgets' coin_symbol %}">
{% load crispy_forms_tags %}
{{ form|crispy }}
{% csrf_token %}
<p class="text-center">
<button type="submit" class="btn btn-primary btn-lg">{% trans "See Widgets" %} </button>
</p>
</form>
</div>
</div>

{% endblock content %}

27 changes: 27 additions & 0 deletions templates/widgets.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{% extends "base.html" %}

{% load i18n %}
{% load humanize %}
{% load btc_formats %}
{% load static %}

{% block title %}
Embeddable Address Widgets
{% endblock title %}

{% block page_header %}
<h1>
<i class="fa fa-send"></i>
Embeddable Address Widgets
</h1>
{% endblock page_header %}

{% block content %}

<div class="section">
<div class="container">
<p>Put widgets here</p>
</div>
</div>

{% endblock content %}

0 comments on commit 63d7b78

Please sign in to comment.