Fix registration views

Hide client profile for partners
This commit is contained in:
Kumi 2021-04-14 13:15:36 +02:00
parent 8594574ebe
commit 558c072986
6 changed files with 32 additions and 19 deletions

View file

@ -14,7 +14,7 @@ class ClientRegistrationView(InConstructionMixin, LoginRequiredMixin, CreateView
model = ClientProfile
exclude = ["user"]
template_name = "clients/signup.html"
fields = ["company", "vat_id", "first_name", "last_name", "street", "city", "zip", "state", "country"]
fields = ["company", "vat_id", "first_name", "last_name", "street", "city", "zip", "state", "country", "phone"]
def dispatch(self, request, *args, **kwargs):
try:
@ -43,11 +43,15 @@ class ClientRegistrationView(InConstructionMixin, LoginRequiredMixin, CreateView
"city": partner.city,
"zip": partner.zip,
"state": partner.state,
"country": partner.country
"country": partner.country,
"phone": partner.phone,
}
except:
return {}
return {
"country": "AT",
"phone": "+43"
}
class ClientProfileView(InConstructionMixin, LoginRequiredMixin, UpdateView):
model = ClientProfile

View file

@ -22,7 +22,6 @@ class UserManager(BaseUserManager):
email = self.normalize_email(email)
user = self.model(
email=email,
display_name=display_name,
**extra_fields
)
user.set_password(password)
@ -64,11 +63,11 @@ class User(AbstractBaseUser):
has_perm = has_permission
class AddressMixin(models.Model):
street = models.CharField(max_length=64)
city = models.CharField(max_length=64)
zip = models.CharField(max_length=16)
state = models.CharField(max_length=64, null=True, blank=True)
country = CountryField()
street = models.CharField("Straße", max_length=64)
city = models.CharField("Stadt", max_length=64)
zip = models.CharField("PLZ", max_length=16)
state = models.CharField("Bundesland", max_length=64, null=True, blank=True)
country = CountryField("Staat")
@property
def full_address(self):
@ -96,17 +95,17 @@ class ImageMixin(models.Model):
abstract = True
class PhoneMixin(models.Model):
phone = PhoneNumberField()
phone = PhoneNumberField("Mobiltelefon")
class Meta:
abstract = True
class Profile(AddressMixin, PhoneMixin):
user = models.OneToOneField(User, models.CASCADE)
company = models.CharField(max_length=64, null=True, blank=True)
vat_id = models.CharField(max_length=32, null=True, blank=True)
first_name = models.CharField(max_length=64)
last_name = models.CharField(max_length=64)
company = models.CharField("Firma", max_length=64, null=True, blank=True)
vat_id = models.CharField("UID-Nummer", max_length=32, null=True, blank=True)
first_name = models.CharField("Vorname", max_length=64)
last_name = models.CharField("Nachname", max_length=64)
verified = models.BooleanField(default=False)
enabled = models.BooleanField(default=True)

View file

@ -26,6 +26,8 @@ class RegistrationView(Login):
def form_valid(self, form):
user = User.objects.create_user(form.cleaned_data["email"])
user.set_password(form.cleaned_data["password1"])
user.save()
login(self.request, user)
messages.success(self.request, "Erfolgreich registriert!")

View file

@ -16,7 +16,7 @@ class PartnerRegistrationView(InConstructionMixin, LoginRequiredMixin, CreateVie
model = PartnerProfile
exclude = ["user"]
template_name = "partners/signup.html"
fields = ["company", "vat_id", "first_name", "last_name", "street", "city", "zip", "state", "country"]
fields = ["company", "vat_id", "first_name", "last_name", "street", "city", "zip", "state", "country", "phone"]
def dispatch(self, request, *args, **kwargs):
try:
@ -46,11 +46,15 @@ class PartnerRegistrationView(InConstructionMixin, LoginRequiredMixin, CreateVie
"city": client.city,
"zip": client.zip,
"state": client.state,
"country": client.country
"country": client.country,
"phone": client.phone
}
except:
return {}
return {
"country": "AT",
"phone": "+43"
}
class PartnerProfileView(InConstructionMixin, PartnerProfileRequiredMixin, UpdateView):
model = PartnerProfile

View file

@ -145,6 +145,7 @@
<li class="nav-item active">
<a href="/" class="nav-link" id="navbarDropdown" role="button">{% trans "Home" %}</a>
</li>
{% if request.user.is_superuser or not request.user.partnerprofile %}
<li class="nav-item dropdown">
<a href="#" class="nav-link" data-toggle="dropdown">{% trans "Mein&nbsp;Urlaub" %}<span><i class="fa fa-angle-down"></i></span></a>
<ul class="dropdown-menu">
@ -158,6 +159,7 @@
{% endif %}
</ul>
</li>
{% endif %}
{% if request.user.partnerprofile %}
<li class="nav-item dropdown">
<a href="#" class="nav-link" data-toggle="dropdown">Partnerprofil<span><i class="fa fa-angle-down"></i></span></a>

View file

@ -36,6 +36,7 @@
</ul>
</div><!-- end slider -->
{% if request.user.is_superuser or not request.user.partnerprofile %}
<div class="search-tabs" id="search-tabs-1">
<div class="container">
<div class="row">
@ -148,6 +149,7 @@
</div><!-- end row -->
</div><!-- end container -->
</div><!-- end search-tabs -->
{% endif %}
</section><!-- end flexslider-container -->
@ -187,8 +189,8 @@
</div><!-- end arrow -->
<div class="main-title hotel-title">
<a href="#">Herta Berlin Hotel</a>
<p>1020 Wien</p>
<a href="#">Habbo Hotel</a>
<p>1010 Wien</p>
</div><!-- end hotel-title -->
</div><!-- end hotel-info -->
</div><!-- end hotel-block -->