2021-03-21 15:50:50 +00:00
|
|
|
|
from django.contrib.auth.forms import UserCreationForm
|
2021-03-23 18:23:04 +00:00
|
|
|
|
from django import forms
|
2021-03-21 15:50:50 +00:00
|
|
|
|
|
|
|
|
|
from .models import User
|
|
|
|
|
|
2021-03-23 18:23:04 +00:00
|
|
|
|
from partners.models import PartnerProfile
|
|
|
|
|
from clients.models import ClientProfile
|
|
|
|
|
|
2021-03-21 15:50:50 +00:00
|
|
|
|
class RegistrationForm(UserCreationForm):
|
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
|
kwargs.pop("request")
|
|
|
|
|
super().__init__(*args, **kwargs)
|
|
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
|
model = User
|
2021-03-23 18:23:04 +00:00
|
|
|
|
fields = ["email", "password1", "password2"]
|
|
|
|
|
|
|
|
|
|
class VerificationForm(forms.Form):
|
|
|
|
|
def get_choices():
|
|
|
|
|
for client in ClientProfile.objects.filter(verified=False):
|
|
|
|
|
yield ("C%i" % client.id, "C%i – %s" % (client.id, client.full_name))
|
|
|
|
|
for partner in PartnerProfile.objects.filter(verified=False):
|
|
|
|
|
yield ("P%i" % partner.id, "P%i – %s" % (partner.id, partner.full_name))
|
|
|
|
|
|
|
|
|
|
profile = forms.ChoiceField(choices=get_choices)
|