add phone

This commit is contained in:
Martin Quarda 2024-08-06 07:47:32 +02:00
parent d024364e00
commit 3adb9f0974
4 changed files with 33 additions and 4 deletions

View File

@ -0,0 +1,18 @@
# Generated by Django 4.2.12 on 2024-08-06 05:47
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('alkatorapi', '0012_user_paid_user_trans_id'),
]
operations = [
migrations.AddField(
model_name='user',
name='phone',
field=models.CharField(blank=True, max_length=120, null=True),
),
]

View File

@ -26,6 +26,7 @@ class User(models.Model):
last_name = models.CharField(max_length=120)
address = models.CharField(max_length=255, null=True, blank=True)
email = models.EmailField(max_length=120, null=True, blank=True)
phone = models.CharField(max_length=120, null=True, blank=True)
date_of_birth = models.DateField(null=True, blank=True)
register_date = models.DateTimeField(auto_now=True)
duration = models.DurationField(null=True, blank=True)

View File

@ -29,6 +29,8 @@ def register(request):
return HttpResponse('{"reason":"Email je povinný!"}', status=400, content_type='application/json')
if not request.POST['address']:
return HttpResponse('{"reason":"Adresa je povinná!"}', status=400, content_type='application/json')
if not request.POST['phone']:
return HttpResponse('{"reason":"Telefoní číslo je povinný!"}', status=400, content_type='application/json')
if User.objects.filter(email=request.POST['email'], alkator_class=ALKATOR_CLASS):
return HttpResponse('{"reason":"Email je již registrován!"}', status=400, content_type='application/json')
try:
@ -46,6 +48,7 @@ def register(request):
email=request.POST['email'],
date_of_birth=dat,
address=request.POST['address'],
phone=request.POST['phone'],
alkator_class=ALKATOR_CLASS,
)
user.save()
@ -81,14 +84,17 @@ def register(request):
def payment_result(request):
result = parse_qs(request.body.decode('utf8'))
ref_id = int(result['refId'][0])
paid = result['status'][0] == 'PAID'
paid = result['status'][0]
secret_match = result['secret'][0] == COMGATE_SECRET
test = result['test'][0] != 'false'
if not secret_match or test != COMGATE_TEST:
return HttpResponse(status=400)
user = User.objects.get(id=ref_id)
user.paid = paid
user.save()
if paid == 'PAID':
user.paid = True
user.save()
elif paid == 'CANCELLED':
user.delete()
return HttpResponse(status=200)

View File

@ -285,6 +285,10 @@ class Main extends Component {
<label for="date_of_birth" class="form-label">Datum narození</label>
<input type="date" class="form-control" id="date_of_birth" name="date_of_birth" max={new Date().toJSON().slice(0, 10)} />
</div>
<div class="mb-3">
<label for="phone" class="form-label">Telefonní číslo</label>
<input type="text" class="form-control" id="phone" name="phone" />
</div>
<div class="mb-3">
<label for="address" class="form-label">Adresa (kvůli fakturaci)</label>
<input type="text" class="form-control" id="address" name="address" />
@ -316,7 +320,7 @@ class Main extends Component {
Nejsme plátci DPH.<br />
Název společnosti: Zhoor s.r.o.<br />
sídlo: Červenovodská 548, Králíky, 561 69<br />
Číslo účtu: 131-2219860207/0100<br />)
Číslo účtu: 131-2219860207/0100<br />
</div>
</div>
);