remotes/origin/PR-39
ArturBaybulatov 10 years ago
parent 2a9f5e5288
commit 0a04dad21a
  1. 16
      archilance/settings/base.py
  2. 52
      archilance/urls.py
  3. 1
      templates/home.html
  4. 11
      templates/message.html
  5. 2
      templates/partials/base.html
  6. 2
      users/views.py
  7. 50
      wallets/forms.py
  8. 20
      wallets/templates/tmp_yandex_money_request_example.html
  9. 54
      wallets/templates/tmp_yandex_money_responses_sumulation.html
  10. 19
      wallets/urls.py
  11. 99
      wallets/views.py

@ -267,3 +267,19 @@ SHELL_PLUS_POST_IMPORTS = ( # Extra auto imports
)
PAGE_SIZE = 10 # Pagination
YANDEX_MONEY = {'shop_password': 'x1uvmS9Iq8WBE3Oo'}
if DEBUG:
YANDEX_MONEY.update({
'url': 'https://demomoney.yandex.ru/eshop.xml',
'shop_id': 59838,
'scid': 537400,
})
else:
YANDEX_MONEY.update({
'url': 'https://money.yandex.ru/eshop.xml',
'shop_id': 0,
'scid': 0,
})

@ -6,26 +6,42 @@ from django.contrib.staticfiles.urls import staticfiles_urlpatterns
from django.views.generic import TemplateView
from .views import HomeTemplateView, TestChatTemplateView
from wallets.views import TmpCheckOrderView, TmpPaymentAvisoView
urlpatterns = [
url(r'^$', HomeTemplateView.as_view()),
url('', include('social.apps.django_app.urls', namespace='social')),
url(r'^chattest/$', TestChatTemplateView.as_view()),
url(r'^work_sell/', include('work_sell.urls')),
url(r'^test/$', TemplateView.as_view(template_name='test.html'), name='test'),
url(r'^projects/', include('projects.urls')),
url(r'^reviews/', include('reviews.urls')),
url(r'^wallets/', include('wallets.urls')),
url(r'^chat/', include('chat.urls')),
url(r'^specializations/', include('specializations.urls')),
url(r'^users/', include('users.urls')),
url(r'^common/', include('common.urls')),
url(r'^password/', include('password_reset.urls')),
url(r'^users/', include('registration.backends.default.urls')),
url(r'^admin/', admin.site.urls),
url(r'^api/', include('api.urls')),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
urlpatterns = [
url(r'^$', HomeTemplateView.as_view()),
url('', include('social.apps.django_app.urls', namespace='social')),
url(r'^chattest/$', TestChatTemplateView.as_view()),
url(r'^work_sell/', include('work_sell.urls')),
url(r'^test/$', TemplateView.as_view(template_name='test.html'), name='test'),
url(r'^projects/', include('projects.urls')),
url(r'^reviews/', include('reviews.urls')),
url(r'^wallets/', include('wallets.urls')),
url(r'^chat/', include('chat.urls')),
url(r'^specializations/', include('specializations.urls')),
url(r'^users/', include('users.urls')),
url(r'^common/', include('common.urls')),
url(r'^password/', include('password_reset.urls')),
url(r'^users/', include('registration.backends.default.urls')),
url(r'^admin/', admin.site.urls),
url(r'^api/', include('api.urls')),
# TODO: Move URLs into the "wallets" app (Yandex Money settings modification needed):
url(r'^yandex/check$', TmpCheckOrderView.as_view(), name='tmp-check-order'),
url(r'^yandex/aviso$', TmpPaymentAvisoView.as_view(), name='tmp-payment-aviso'),
url(r'^payment/success$', TemplateView.as_view(template_name='message.html'), {
'message': 'Оплата прошла успешно',
}, name='tmp-payment-success'),
url(r'^payment/fail$', TemplateView.as_view(template_name='message.html'), {
'message': 'Произошла ошибка при оплате',
}, name='tmp-payment-fail'),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
if settings.DEBUG:
urlpatterns += staticfiles_urlpatterns()

@ -1,5 +1,4 @@
{% extends 'partials/base.html' %}
{% load staticfiles %}
{% block content %}
<section class="mainContainer">

@ -0,0 +1,11 @@
{% extends 'partials/base.html' %}
{% block content %}
<div class='container-fluid'>
<div class='row'>
<div class='col-xs-12' style='margin-top: 15px'>
<h1 style="text-align: center">{{ message }}</h1>
</div>
</div>
</div>
{% endblock %}

@ -37,7 +37,7 @@
{% endfor %}
{% endif %}
<div style="position: absolute; left: 0; top: 0; padding: 6px; color: black; background-color: {% if request.user.is_contractor %}#BADA55{% else %}#C0FFEE{% endif %}; z-index: 50">
<div style="position: absolute; left: 0; bottom: 0; padding: 6px; color: black; background-color: {% if request.user.is_contractor %}#BADA55{% else %}#C0FFEE{% endif %}; z-index: 50">
{{ request.user }}<br>
{% if request.user.is_authenticated %}

@ -67,7 +67,7 @@ class UserProfileEditView(BaseMixin, View):
if form.is_valid():
form.save()
messages.info(request, 'Заказчик успешно отредактирован')
messages.info(request, 'Пользователь успешно отредактирован')
redirect_to = request.POST.get('next')
return redirect(redirect_to)
else:

@ -1,13 +1,61 @@
from django import forms
from django.conf import settings
from .models import WithDraw
class WithDrawForm(forms.ModelForm):
class Meta:
model = WithDraw
fields = (
'sum',
'yandex_card',
'user',
)
class TmpCheckOrderForm(forms.Form):
action = forms.CharField() # Has to be "checkOrder"
md5 = forms.CharField()
shopId = forms.IntegerField()
invoiceId = forms.IntegerField()
def clean_action(self):
action = self.cleaned_data.get('action')
if action != 'checkOrder':
raise forms.ValidationError('Wrong action')
return action
def clean_shopId(self):
shopId = self.cleaned_data.get('shopId')
if shopId != settings.YANDEX_MONEY['shop_id']:
raise forms.ValidationError('Wrong shop ID')
return shopId
class TmpPaymentAvisoForm(forms.Form):
action = forms.CharField() # Has to be "paymentAviso"
md5 = forms.CharField()
shopId = forms.IntegerField()
invoiceId = forms.IntegerField()
def clean_action(self):
action = self.cleaned_data.get('action')
if action != 'paymentAviso':
raise forms.ValidationError('Wrong action')
return action
def clean_shopId(self):
shopId = self.cleaned_data.get('shopId')
if shopId != settings.YANDEX_MONEY['shop_id']:
raise forms.ValidationError('Wrong shop ID')
return shopId

@ -0,0 +1,20 @@
{% extends 'partials/base.html' %}
{% block content %}
<div class='container-fluid'>
<div class='row'>
<div class='a col-xs-12'>
<form action='{{ YANDEX_MONEY.url }}' method='POST' novalidate>
<p>shopId: <input type='text' name='shopId' value='{{ YANDEX_MONEY.shop_id }}'></p>
<p>scid: <input type='text' name='scid' value='{{ YANDEX_MONEY.scid }}'></p>
<p>sum: <input type='text' name='sum' value='100'></p>
<p>customerNumber: <input type='text' name='customerNumber' value='123'></p>
<p>paymentType: <input type='text' name='paymentType' value='AC'></p>
<p><button type='submit'>Simulate check</button></p>
</form>
</div>
</div>
</div>
{% endblock %}

@ -0,0 +1,54 @@
{% extends 'partials/base.html' %}
{% block content %}
<div class='container-fluid'>
<div class='row'>
<div class='a col-xs-12'>
<h3>Simulating a Yandex "checkOrder" request</h3>
<form action='{% url 'tmp-check-order' %}' method='POST' novalidate>
<p>action: <input name='action' value='checkOrder'></p>
<p>md5: <input name='md5' value='8256D2A032A35709EAF156270C9EFE2E'></p>
<p>shopId: <input name='shopId' value='59838'></p>
<p>invoiceId: <input name='invoiceId' value='1234567'></p>
<p>customerNumber: <input name='customerNumber' value='8123294469'></p>
<p>orderSumAmount: <input name='orderSumAmount' value='87.1'></p>
<p>orderSumCurrencyPaycash: <input name='orderSumCurrencyPaycash' value='643'></p>
<p>orderSumBankPaycash: <input name='orderSumBankPaycash' value='1001'></p>
<p>shopPassword: <input name='shopPassword' value='x1uvmS9Iq8WBE3Oo'></p>
<p>orderNumber: <input name='orderNumber' value='123'></p>
<p><button type='submit'>Simulate check</button></p>
</form>
</div>
</div>
<div class='row'>
<div class='b col-xs-12'>
<h3>Simulating a Yandex "paymentAviso" request</h3>
<form action='{% url 'tmp-payment-aviso' %}' method='POST' novalidate>
<p>action: <input name='action' value='paymentAviso'></p>
<p>md5: <input name='md5' value='45125C95A20A7F25B63D58EA304AFED2'></p>
<p>shopId: <input name='shopId' value='59838'></p>
<p>invoiceId: <input name='invoiceId' value='1234567'></p>
<p>customerNumber: <input name='customerNumber' value='8123294469'></p>
<p>orderSumAmount: <input name='orderSumAmount' value='87.1'></p>
<p>orderSumCurrencyPaycash: <input name='orderSumCurrencyPaycash' value='643'></p>
<p>orderSumBankPaycash: <input name='orderSumBankPaycash' value='1001'></p>
<p>shopPassword: <input name='shopPassword' value='x1uvmS9Iq8WBE3Oo'></p>
<p>orderNumber: <input name='orderNumber' value='123'></p>
<p><button type='submit'>Simulate aviso</button></p>
</form>
</div>
</div>
</div>
{% endblock %}

@ -1,10 +1,25 @@
from django.conf import urls
from django.conf import urls, settings
from django.views.generic import TemplateView
from .views import ScoreDetailView, WithDrawCreate
app_name = 'wallets'
urlpatterns = [
urls.url(r'^score/(?P<pk>\d+)/$', ScoreDetailView.as_view(), name='score-detail'),
urls.url(r'^withdraw/create/$', WithDrawCreate.as_view(), name='withdraw-create'),
urls.url(
r'^tmp-yamoney-req/$',
TemplateView.as_view(template_name='tmp_yandex_money_request_example.html'),
{'YANDEX_MONEY': settings.YANDEX_MONEY},
name='tmp-yamoney-req',
),
urls.url(
r'^tmp-yamoney-sim/$',
TemplateView.as_view(template_name='tmp_yandex_money_responses_sumulation.html'),
name='tmp-yamoney-sim',
),
]

@ -1,11 +1,17 @@
from django.http import JsonResponse
from django.contrib import messages
from django.db.models import Sum
from django.http import HttpResponse, JsonResponse
from django.utils import timezone
from django.utils.decorators import method_decorator
from django.views.decorators.csrf import csrf_exempt
from django.views.generic import DetailView, CreateView
from users.models import User
from users.mixins import CheckForUserMixin
from django.views.generic.base import View
from pprint import pprint, pformat
from .forms import WithDrawForm, TmpCheckOrderForm, TmpPaymentAvisoForm
from .models import InvoiceHistory, WithDraw
from .forms import WithDrawForm
from users.mixins import CheckForUserMixin
from users.models import User
class ScoreDetailView(CheckForUserMixin, DetailView):
@ -67,3 +73,88 @@ class WithDrawCreate(CreateView):
if self.request.is_ajax():
return JsonResponse(form.errors, status=400)
return super().form_invalid(form)
# Yandex Money ------------------------------------------------
class TmpCheckOrderView(View):
form_class = TmpCheckOrderForm
@method_decorator(csrf_exempt)
def dispatch(self, request, *args, **kwargs):
return super().dispatch(request, *args, **kwargs)
def post(self, request, *args, **kwargs):
form = self.form_class(request.POST)
if form.is_valid():
res = """<?xml version="1.0" encoding="utf-8"?>
<checkOrderResponse
performedDatetime="{date}"
code="0"
invoiceId="{invoice_id}"
shopId="{shop_id}"/>
""".format(
date=timezone.now().isoformat(),
invoice_id=form.cleaned_data.get('invoiceId'),
shop_id=form.cleaned_data.get('shopId'),
)
return HttpResponse(res, content_type='application/xml')
else:
res = """<?xml version="1.0" encoding="utf-8"?>
<checkOrderResponse
performedDatetime="{date}"
code="1"
invoiceId="{invoice_id}"
shopId="{shop_id}"
message="Check order, validation error"
techMessage="Check order, validation error"/>
""".format(
date=timezone.now().isoformat(),
invoice_id=form.cleaned_data.get('invoiceId'),
shop_id=form.cleaned_data.get('shopId'),
)
# return HttpResponse(res, content_type='application/xml')
return HttpResponse('<pre>{msg}</pre>'.format(msg=pformat(form.errors))) # Debug
class TmpPaymentAvisoView(View):
form_class = TmpPaymentAvisoForm
@method_decorator(csrf_exempt)
def dispatch(self, request, *args, **kwargs):
return super().dispatch(request, *args, **kwargs)
def post(self, request, *args, **kwargs):
form = self.form_class(request.POST)
if form.is_valid():
res = """<?xml version="1.0" encoding="utf-8"?>
<paymentAvisoResponse
performedDatetime="{date}"
code="0"
invoiceId="{invoice_id}"
shopId="{shop_id}"/>
""".format(
date=timezone.now().isoformat(),
invoice_id=form.cleaned_data.get('invoiceId'),
shop_id=form.cleaned_data.get('shopId'),
)
return HttpResponse(res, content_type='application/xml')
else:
res = """<?xml version="1.0" encoding="utf-8"?>
<paymentAvisoResponse
performedDatetime="{date}"
code="1"
message="Payment aviso, validation error"
techMessage="Payment aviso, validation error"/>
""".format(date=timezone.now().isoformat())
# return HttpResponse(res, content_type='application/xml')
return HttpResponse('<pre>{msg}</pre>'.format(msg=pformat(form.errors))) # Debug

Loading…
Cancel
Save