add phone to user
This commit is contained in:
parent
c9a4bb434f
commit
2c2699de1f
@ -11,13 +11,3 @@ class RacerAdmin(admin.ModelAdmin):
|
|||||||
@admin.register(Profile)
|
@admin.register(Profile)
|
||||||
class ProfileAdmin(admin.ModelAdmin):
|
class ProfileAdmin(admin.ModelAdmin):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@admin.register(User)
|
|
||||||
class UserAdmin(admin.ModelAdmin):
|
|
||||||
change_form_template = "invoice_custom_admin_page.html"
|
|
||||||
|
|
||||||
def response_change(self, request, obj):
|
|
||||||
if "_invoice" in request.POST:
|
|
||||||
return HttpResponseRedirect(f"/api/invoice?invoice_id={obj.invoice_id}")
|
|
||||||
return super().response_change(request, obj)
|
|
18
alkatorapi/migrations/0018_profile_phone.py
Normal file
18
alkatorapi/migrations/0018_profile_phone.py
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 4.2.12 on 2024-10-12 10:48
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('alkatorapi', '0017_racer_register_date'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='profile',
|
||||||
|
name='phone',
|
||||||
|
field=models.CharField(blank=True, max_length=120, null=True),
|
||||||
|
),
|
||||||
|
]
|
@ -49,6 +49,7 @@ class Profile(models.Model):
|
|||||||
user = models.OneToOneField(DjangoUser, related_name='profile', on_delete=models.CASCADE)
|
user = models.OneToOneField(DjangoUser, related_name='profile', on_delete=models.CASCADE)
|
||||||
first_name = models.CharField(max_length=120)
|
first_name = models.CharField(max_length=120)
|
||||||
last_name = models.CharField(max_length=120)
|
last_name = models.CharField(max_length=120)
|
||||||
|
phone = models.CharField(max_length=120, null=True, blank=True)
|
||||||
address = models.CharField(max_length=255, null=True, blank=True)
|
address = models.CharField(max_length=255, null=True, blank=True)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
|
@ -41,6 +41,8 @@ def register_user(request):
|
|||||||
return HttpResponse('{"reason":"Heslo je povinné!"}', status=400, content_type='application/json')
|
return HttpResponse('{"reason":"Heslo je povinné!"}', status=400, content_type='application/json')
|
||||||
if request.POST['password1'] != request.POST['password2']:
|
if request.POST['password1'] != request.POST['password2']:
|
||||||
return HttpResponse('{"reason":"Hesla se neshodují!"}', status=400, content_type='application/json')
|
return HttpResponse('{"reason":"Hesla se neshodují!"}', status=400, content_type='application/json')
|
||||||
|
if not request.POST['phone']:
|
||||||
|
return HttpResponse('{"reason":"Hesla se neshodují!"}', status=400, content_type='application/json')
|
||||||
if DjangoUser.objects.filter(email=request.POST['email']):
|
if DjangoUser.objects.filter(email=request.POST['email']):
|
||||||
return HttpResponse('{"reason":"Email je již registrován!"}', status=400, content_type='application/json')
|
return HttpResponse('{"reason":"Email je již registrován!"}', status=400, content_type='application/json')
|
||||||
email = request.POST['email']
|
email = request.POST['email']
|
||||||
@ -48,7 +50,13 @@ def register_user(request):
|
|||||||
user = DjangoUser.objects.create_user(
|
user = DjangoUser.objects.create_user(
|
||||||
email, email, request.POST['password1']
|
email, email, request.POST['password1']
|
||||||
)
|
)
|
||||||
profile = Profile(user=user, first_name=request.POST['first_name'], last_name=request.POST['last_name'], address=request.POST['address'])
|
profile = Profile(
|
||||||
|
user=user,
|
||||||
|
first_name=request.POST['first_name'],
|
||||||
|
last_name=request.POST['last_name'],
|
||||||
|
address=request.POST['address'],
|
||||||
|
phone=request.POST['phone'],
|
||||||
|
)
|
||||||
profile.save()
|
profile.save()
|
||||||
auth_login(request, user)
|
auth_login(request, user)
|
||||||
return HttpResponse('{"success":"Úspěšná registrace!", "redirect":"/#"}', content_type='application/json')
|
return HttpResponse('{"success":"Úspěšná registrace!", "redirect":"/#"}', content_type='application/json')
|
||||||
|
@ -302,6 +302,10 @@ class Main extends Component {
|
|||||||
<label for="address" class="form-label">Adresa (kvůli fakturaci)</label>
|
<label for="address" class="form-label">Adresa (kvůli fakturaci)</label>
|
||||||
<input type="text" class="form-control" id="address" name="address" />
|
<input type="text" class="form-control" id="address" name="address" />
|
||||||
</div>
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="phone" class="form-label">Telefon</label>
|
||||||
|
<input type="text" class="form-control" id="phone" name="phone" />
|
||||||
|
</div>
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label for="password1" class="form-label">Heslo:</label>
|
<label for="password1" class="form-label">Heslo:</label>
|
||||||
<input type="password" class="form-control" name="password1"/>
|
<input type="password" class="form-control" name="password1"/>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user