update the assign car make visuals
This commit is contained in:
parent
f24a16d784
commit
5c474e2168
12
inventory/management/commands/initial_services_offered.py
Normal file
12
inventory/management/commands/initial_services_offered.py
Normal file
@ -0,0 +1,12 @@
|
||||
# management/commands/create_plans.py
|
||||
from django.core.management.base import BaseCommand
|
||||
from appointment.models import Service
|
||||
import datetime
|
||||
class Command(BaseCommand):
|
||||
help = 'create initial services offered'
|
||||
|
||||
def handle(self, *args, **options):
|
||||
Service.objects.all().delete()
|
||||
Service.objects.create(name='Call', price=0,duration=datetime.timedelta(minutes=10),currency='SAR',description='15 min call')
|
||||
Service.objects.create(name='Meeting', price=0,duration=datetime.timedelta(minutes=30),currency='SAR',description='30 min meeting')
|
||||
Service.objects.create(name='Visit', price=0,duration=datetime.timedelta(minutes=30),currency='SAR',description='30 min visit')
|
||||
@ -27,19 +27,23 @@ class Command(BaseCommand):
|
||||
# Order.objects.all().delete()
|
||||
# BillingInfo.objects.all().delete()
|
||||
|
||||
three_users_quota = Quota.objects.create(name='3 users', codename='3 users', unit='number')
|
||||
five_users_quota = Quota.objects.create(name='5 users', codename='5 users', unit='number')
|
||||
ten_users_quota = Quota.objects.create(name='10 users', codename='10 users', unit='number')
|
||||
|
||||
users_quota = Quota.objects.create(name='Users', codename='Users', unit='number')
|
||||
cars_quota = Quota.objects.create(name='Cars', codename='Cars', unit='number')
|
||||
# Create plans
|
||||
basic_plan = Plan.objects.create(name='Basic', description='basic plan', available=True, visible=True)
|
||||
pro_plan = Plan.objects.create(name='Pro', description='Pro plan', available=True, visible=True)
|
||||
enterprise_plan = Plan.objects.create(name='Enterprise', description='Enterprise plan', available=True, visible=True)
|
||||
|
||||
# Assign quotas to plans
|
||||
PlanQuota.objects.create(plan=basic_plan, quota=three_users_quota, value=3)
|
||||
PlanQuota.objects.create(plan=pro_plan, quota=five_users_quota, value=5)
|
||||
PlanQuota.objects.create(plan=enterprise_plan, quota=ten_users_quota, value=10)
|
||||
PlanQuota.objects.create(plan=basic_plan, quota=users_quota, value=3)
|
||||
PlanQuota.objects.create(plan=basic_plan, quota=cars_quota, value=3)
|
||||
|
||||
PlanQuota.objects.create(plan=pro_plan, quota=users_quota, value=5)
|
||||
PlanQuota.objects.create(plan=pro_plan, quota=cars_quota, value=5)
|
||||
|
||||
PlanQuota.objects.create(plan=enterprise_plan, quota=users_quota, value=10)
|
||||
PlanQuota.objects.create(plan=enterprise_plan, quota=cars_quota, value=10)
|
||||
|
||||
# PlanQuota.objects.create(plan=pro_plan, quota=project_quota, value=50)
|
||||
# PlanQuota.objects.create(plan=pro_plan, quota=storage_quota, value=100)
|
||||
|
||||
@ -839,7 +839,6 @@ class Dealer(models.Model, LocalizedNameMixin):
|
||||
def active_plan(self):
|
||||
try:
|
||||
plan = UserPlan.objects.get(user=self.user,active=True).plan
|
||||
print(plan)
|
||||
return plan
|
||||
|
||||
except Exception as e:
|
||||
@ -851,8 +850,6 @@ class Dealer(models.Model, LocalizedNameMixin):
|
||||
try:
|
||||
quota_dict = get_user_quota(self.user)
|
||||
allowed_users = quota_dict.get("Users", None)
|
||||
|
||||
print(allowed_users)
|
||||
return allowed_users
|
||||
except Exception as e:
|
||||
print(e)
|
||||
@ -863,8 +860,6 @@ class Dealer(models.Model, LocalizedNameMixin):
|
||||
try:
|
||||
quota_dict = get_user_quota(self.user)
|
||||
allowed_cars = quota_dict.get("Cars", None)
|
||||
|
||||
print(allowed_cars)
|
||||
return allowed_cars
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
@ -7061,6 +7061,8 @@ def assign_car_makes(request):
|
||||
create_accounts_for_make(dealer, makes)
|
||||
form.save()
|
||||
return redirect("dealer_detail", pk=dealer.pk)
|
||||
else:
|
||||
print(form.errors)
|
||||
else:
|
||||
# Pre-fill the form with existing selections
|
||||
existing_car_makes = models.DealersMake.objects.filter(
|
||||
@ -7069,7 +7071,9 @@ def assign_car_makes(request):
|
||||
form = forms.DealersMakeForm(
|
||||
initial={"car_makes": existing_car_makes}, dealer=dealer
|
||||
)
|
||||
|
||||
for choice in form.fields["car_makes"].choices:
|
||||
print(choice[0].instance)
|
||||
break
|
||||
return render(request, "dealers/assign_car_makes.html", {"form": form})
|
||||
|
||||
|
||||
@ -7553,9 +7557,9 @@ def payment_callback(request):
|
||||
tax_number=dealer.vrn,
|
||||
name=dealer.arabic_name,
|
||||
street=dealer.address,
|
||||
zipcode=dealer.entity.zip_code,
|
||||
city=dealer.entity.city,
|
||||
country=dealer.entity.country,
|
||||
zipcode=dealer.entity.zip_code if dealer.entity.zip_code else " ",
|
||||
city=dealer.entity.city if dealer.entity.city else " ",
|
||||
country=dealer.entity.country if dealer.entity.country else " ",
|
||||
)
|
||||
if created:
|
||||
userplan =UserPlan.objects.create(
|
||||
|
||||
@ -1,25 +1,91 @@
|
||||
{% extends "base.html" %}
|
||||
{% load crispy_forms_filters %}
|
||||
{% load static %}
|
||||
|
||||
{% block content %}
|
||||
<style>
|
||||
.car-makes-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(7, 1fr);
|
||||
gap: 16px;
|
||||
}
|
||||
.car-makes-grid label {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
</style>
|
||||
<h2>{{ _("Select Car Makes You Sell")}}</h2>
|
||||
/* Your existing CSS styles here */
|
||||
.car-makes-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
|
||||
gap: 20px;
|
||||
margin: 20px 0;
|
||||
}
|
||||
.car-make-option {
|
||||
position: relative;
|
||||
cursor: pointer;
|
||||
text-align: center;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
.car-make-image {
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
object-fit: contain;
|
||||
border: 2px solid transparent;
|
||||
border-radius: 8px;
|
||||
padding: 8px;
|
||||
background: #f8f9fa;
|
||||
}
|
||||
.car-make-option input[type="checkbox"] {
|
||||
position: absolute;
|
||||
opacity: 0;
|
||||
width: 0;
|
||||
height: 0;
|
||||
}
|
||||
.car-make-option input[type="checkbox"]:checked + .car-make-image-container .car-make-image {
|
||||
border: 2px solid #2c7be5;
|
||||
box-shadow: 0 0 10px rgba(44, 123, 229, 0.5);
|
||||
background: #f0f7ff;
|
||||
}
|
||||
.car-make-name {
|
||||
margin-top: 8px;
|
||||
font-size: 12px;
|
||||
color: #5e6e82;
|
||||
}
|
||||
.car-make-image-container {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
.logo-placeholder {
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: #f8f9fa;
|
||||
border-radius: 8px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<form method="post">
|
||||
{% csrf_token %}
|
||||
<div class="car-makes-grid">
|
||||
{{ form.car_makes }}
|
||||
</div>
|
||||
<button class="btn btn-phoenix-success btn-sm" type="submit">{{ _("Save") }}</button>
|
||||
</form>
|
||||
<h2>{{ _("Select Car Makes You Sell") }}</h2>
|
||||
|
||||
<form method="post" action="{% url 'assign_car_makes' %}">
|
||||
{% csrf_token %}
|
||||
|
||||
<div class="car-makes-grid">
|
||||
{% for car_make in form.fields.car_makes.queryset %}
|
||||
|
||||
<label class="car-make-option">
|
||||
<input type="checkbox"
|
||||
name="car_makes"
|
||||
value="{{ car_make.pk }}"
|
||||
{% if car_make.pk in form.initial.car_makes or car_make.pk|stringformat:"s" in form.car_makes.value %}checked{% endif %}>
|
||||
<div class="car-make-image-container">
|
||||
{% if car_make.logo and car_make.logo.url %}
|
||||
<img src="{{ car_make.logo.url }}"
|
||||
alt="{{ car_make.name }}"
|
||||
class="car-make-image">
|
||||
{% else %}
|
||||
<div class="logo-placeholder">
|
||||
{{ car_make.name|slice:":3" }}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="car-make-name">{{ car_make.name }}</div>
|
||||
</label>
|
||||
{% endfor %}
|
||||
</div>
|
||||
<div class="d-grid gap-2">
|
||||
<button class="btn btn-phoenix-info btn-lg" type="submit">{{ _("Save") }}</button>
|
||||
</div>
|
||||
</form>
|
||||
{% endblock %}
|
||||
Loading…
x
Reference in New Issue
Block a user