introduce service offering status

This commit is contained in:
Tobias Brunner 2025-01-31 16:50:50 +01:00
parent a4850683c9
commit 5eb40ffc4f
No known key found for this signature in database
6 changed files with 65 additions and 6 deletions

View file

@ -143,7 +143,7 @@ class PlanInline(admin.StackedInline):
@admin.register(ServiceOffering)
class ServiceOfferingAdmin(admin.ModelAdmin):
list_display = ("service", "cloud_provider")
list_display = ("service", "cloud_provider", "status")
list_filter = ("service", "cloud_provider")
search_fields = ("service__name", "cloud_provider__name", "description")
inlines = [PlanInline]

View file

@ -0,0 +1,26 @@
# Generated by Django 5.1.5 on 2025-01-31 15:45
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("services", "0002_lead_offering"),
]
operations = [
migrations.AddField(
model_name="serviceoffering",
name="status",
field=models.CharField(
choices=[
("available", "Available"),
("planned", "Planned"),
("on_request", "On Request"),
],
default="available",
max_length=20,
),
),
]

View file

@ -166,6 +166,15 @@ class ServiceOffering(models.Model):
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
STATUS_CHOICES = [
("available", "Available"),
("planned", "Planned"),
("on_request", "On Request"),
]
status = models.CharField(
max_length=20, choices=STATUS_CHOICES, default="available"
)
class Meta:
unique_together = ["service", "cloud_provider"]
ordering = ["service__name", "cloud_provider__name"]

View file

@ -107,15 +107,16 @@
<div class="mt-auto d-flex gap-2">
<a href="{{ offering.get_absolute_url }}" class="btn btn-primary">View Details</a>
{% if offering.plans.exists %}
{% if offering.status == 'available' %}
{% if offering.plans.count == 1 %}
{% with plan=offering.plans.first %}
<a href="{% url 'services:create_lead' offering.service.slug %}?offering={{ offering.id }}&plan={{ plan.id }}"
class="btn btn-success">Show Interest</a>
class="btn btn-success">Order</a>
{% endwith %}
{% else %}
<div class="dropdown">
<button class="btn btn-success dropdown-toggle" type="button" data-bs-toggle="dropdown">
Show Interest
Order
</button>
<ul class="dropdown-menu">
{% for plan in offering.plans.all %}
@ -130,9 +131,24 @@
</ul>
</div>
{% endif %}
{% else %}
{% elif offering.status == 'planned' %}
<a href="{% url 'services:create_lead' offering.service.slug %}?offering={{ offering.id }}"
class="btn btn-success">Show Interest</a>
{% else %}
<a href="{% url 'services:create_lead' offering.service.slug %}?offering={{ offering.id }}"
class="btn btn-success">Request Information</a>
{% endif %}
{% else %}
{% if offering.status == 'available' %}
<a href="{% url 'services:create_lead' offering.service.slug %}?offering={{ offering.id }}"
class="btn btn-success">Order</a>
{% elif offering.status == 'planned' %}
<a href="{% url 'services:create_lead' offering.service.slug %}?offering={{ offering.id }}"
class="btn btn-success">Show Interest</a>
{% else %}
<a href="{% url 'services:create_lead' offering.service.slug %}?offering={{ offering.id }}"
class="btn btn-success">Request Information</a>
{% endif %}
{% endif %}
</div>
</div>

View file

@ -83,7 +83,15 @@
{% endif %}
<a href="{% url 'services:create_lead' service.slug %}?offering={{ offering.id }}"
class="btn btn-success">Show Interest</a>
class="btn btn-success">
{% if offering.status == 'available' %}
Order
{% elif offering.status == 'planned' %}
Show Interest
{% else %}
Request Information
{% endif %}
</a>
</div>
</div>
</div>

View file

@ -104,7 +104,7 @@
{% if service.offerings.exists %}
<div class="dropdown d-inline-block">
<button class="btn btn-success dropdown-toggle" type="button" data-bs-toggle="dropdown">
Show Interest
Order
</button>
<ul class="dropdown-menu">
{% for offering in service.offerings.all %}