Private
Public Access
1
0

Merge branch 'feature/idoklad' into develop

This commit is contained in:
2024-12-26 13:15:52 +01:00
8 changed files with 63 additions and 3 deletions
+2
View File
@@ -328,6 +328,8 @@ def update_subscription(rower, data, method='up'):
'%Y-%m-%d'),
method)
_ = idoklad.create_invoice(rower, amount, result.subscription.id, dosend=True)
return True, amount
else: # pragma: no cover
errors = result.errors.for_object("subscription")
+23
View File
@@ -14,6 +14,13 @@ contacts_url = 'https://api.idoklad.cz/v3/Contacts'
invoice_url = 'https://api.idoklad.cz/v3/IssuedInvoices'
email_url = 'https://api.idoklad.cz/v3/Mails/IssuedInvoice/Send'
from rowers.tasks import handle_send_email_noinvoice
from rowers.utils import myqueue
import django_rq
queuehigh = django_rq.get_queue('high')
from rowers.models import iDokladToken
#idoklad_countries = json.loads(open('rowers/idoklad_countries.json').read())["Data"]["Items"]
@@ -118,6 +125,14 @@ def create_contact(rower):
res = requests.post(contacts_url, json=data, headers=headers)
if res.status_code not in [200, 201]:
dologging('idoklad.log','Contact Created - reason '+str(res.reason)+'\n')
_ = myqueue.enqueue(
queuehigh, handle_send_email_noinvoice,
rower.user.email,
rower.user.first_name,
rower.user.last_name,
'idoklad Contact creation failed for '+str(rower.user.email)+'\n'+str(res.text)
)
return 0
id = res.json()['Data']['Id']
@@ -199,6 +214,14 @@ def create_invoice(rower, amount, braintreeid, dosend=True, contact_id=None, nam
dologging('idoklad.log','Invoice Sent - status code '+str(res.status_code)+'\n')
if res.status_code not in [200, 201]:
dologging('idoklad.log','Invoice Sent - reason '+str(res.text)+'\n')
_ = myqueue.enqueue(
queuehigh, handle_send_email_noinvoice,
rower.user.email,
rower.user.first_name,
rower.user.last_name,
'idoklad Invoice sending failed for '+str(rower.user.email)+'\n'+str(res.text)
)
return id
+16
View File
@@ -1796,6 +1796,22 @@ def sigdig(value, digits=3):
fmtstr = "%.0f"
return fmtstr % (round(value, places))
@app.task
def handle_send_email_noinvoice(
useremail, userfirstname, userlastname, reason, **kwargs):
subject = "Reason"
from_email = 'Rowsandall <admin@rowsandall.com>'
d = {
'name': userfirstname+' '+userlastname,
'siteurl': siteurl,
'reason': reason,
}
_ = send_template_email(from_email, support@rowsandall.com, subject,
'paymentconfirmationemail_noinvoice.html',
d, **kwargs)
@app.task
def handle_send_email_alert(
@@ -0,0 +1,12 @@
{% extends "emailbase.html" %}
{% block body %}
<p>Dear Admin,</p>
<p><strong>{{ name }}</strong>: {{ reason }}.</p>
<p>
Best Regards, the Rowsandall Team
</p>
{% endblock %}
+6 -1
View File
@@ -208,7 +208,12 @@
</table>
<li>
{% endif %}
{% if user.is_staff %}
<li class="rounder">
<h2>Admin</h2>
<p><a href="/rowers/me/idokladauthorize/">iDoklad authorize</a></p>
</li>
{% endif %}
</ul>
</form>
Binary file not shown.
+3
View File
@@ -58,7 +58,10 @@ def process_idokladcallback(request):
t.acces_token = result['access_token'],
t.refresh_token = result['refresh_token']
t.expires_in = result['expires_in']
try:
t.id_token = result['id_token']
except KeyError:
pass
t.save()
except iDokladToken.DoesNotExist:
t = iDokladToken(
-1
View File
@@ -1,4 +1,3 @@
from rowers.views.statements import *
from rowers.rower_rules import user_is_not_basic, user_is_coachee