remove slug from offerings
This commit is contained in:
parent
20f27bd6b5
commit
03b5af8244
8 changed files with 55 additions and 12 deletions
|
@ -115,7 +115,11 @@ class ServiceBrokerViewSet(viewsets.ViewSet):
|
||||||
{
|
{
|
||||||
"dashboard_url": settings.WEBSITE_URL
|
"dashboard_url": settings.WEBSITE_URL
|
||||||
+ reverse(
|
+ reverse(
|
||||||
"services:offering_detail", kwargs={"slug": offering.slug}
|
"services:offering_detail",
|
||||||
|
kwargs={
|
||||||
|
"provider_slug": offering.cloud_provider.slug,
|
||||||
|
"service_slug": offering.service.slug,
|
||||||
|
},
|
||||||
),
|
),
|
||||||
"operation": "provision",
|
"operation": "provision",
|
||||||
},
|
},
|
||||||
|
@ -152,7 +156,11 @@ class ServiceBrokerViewSet(viewsets.ViewSet):
|
||||||
"plan_id": str(instance.plan.id),
|
"plan_id": str(instance.plan.id),
|
||||||
"dashboard_url": settings.WEBSITE_URL
|
"dashboard_url": settings.WEBSITE_URL
|
||||||
+ reverse(
|
+ reverse(
|
||||||
"services:offering_detail", kwargs={"slug": instance.offering.slug}
|
"services:offering_detail",
|
||||||
|
kwargs={
|
||||||
|
"provider_slug": instance.offering.cloud_provider.slug,
|
||||||
|
"service_slug": instance.offering.service.slug,
|
||||||
|
},
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -179,7 +187,11 @@ class ServiceBrokerViewSet(viewsets.ViewSet):
|
||||||
"operation": "update",
|
"operation": "update",
|
||||||
"dashboard_url": settings.WEBSITE_URL
|
"dashboard_url": settings.WEBSITE_URL
|
||||||
+ reverse(
|
+ reverse(
|
||||||
"services:offering_detail", kwargs={"slug": instance.offering.slug}
|
"services:offering_detail",
|
||||||
|
kwargs={
|
||||||
|
"provider_slug": instance.offering.cloud_provider.slug,
|
||||||
|
"service_slug": instance.offering.service.slug,
|
||||||
|
},
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
|
@ -97,7 +97,7 @@ class ExternalLinkOfferingInline(admin.TabularInline):
|
||||||
|
|
||||||
@admin.register(ServiceOffering)
|
@admin.register(ServiceOffering)
|
||||||
class ServiceOfferingAdmin(admin.ModelAdmin):
|
class ServiceOfferingAdmin(admin.ModelAdmin):
|
||||||
list_display = ("service", "slug", "cloud_provider")
|
list_display = ("service", "cloud_provider")
|
||||||
list_filter = ("service", "cloud_provider")
|
list_filter = ("service", "cloud_provider")
|
||||||
search_fields = ("service__name", "cloud_provider__name", "description")
|
search_fields = ("service__name", "cloud_provider__name", "description")
|
||||||
inlines = [ExternalLinkOfferingInline, PlanInline]
|
inlines = [ExternalLinkOfferingInline, PlanInline]
|
||||||
|
|
17
hub/services/migrations/0012_remove_serviceoffering_slug.py
Normal file
17
hub/services/migrations/0012_remove_serviceoffering_slug.py
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
# Generated by Django 5.1.5 on 2025-02-28 13:24
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
("services", "0011_reusabletext_textsnippet"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name="serviceoffering",
|
||||||
|
name="slug",
|
||||||
|
),
|
||||||
|
]
|
|
@ -194,7 +194,6 @@ class ServiceOffering(models.Model):
|
||||||
cloud_provider = models.ForeignKey(
|
cloud_provider = models.ForeignKey(
|
||||||
CloudProvider, on_delete=models.CASCADE, related_name="offerings"
|
CloudProvider, on_delete=models.CASCADE, related_name="offerings"
|
||||||
)
|
)
|
||||||
slug = models.SlugField(max_length=250, unique=True)
|
|
||||||
description = ProseEditorField(blank=True, null=True)
|
description = ProseEditorField(blank=True, null=True)
|
||||||
offer_description = models.ForeignKey(
|
offer_description = models.ForeignKey(
|
||||||
ReusableText,
|
ReusableText,
|
||||||
|
@ -225,7 +224,13 @@ class ServiceOffering(models.Model):
|
||||||
super().save(*args, **kwargs)
|
super().save(*args, **kwargs)
|
||||||
|
|
||||||
def get_absolute_url(self):
|
def get_absolute_url(self):
|
||||||
return reverse("services:offering_detail", kwargs={"slug": self.slug})
|
return reverse(
|
||||||
|
"services:offering_detail",
|
||||||
|
kwargs={
|
||||||
|
"provider_slug": self.cloud_provider.slug,
|
||||||
|
"service_slug": self.service.slug,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class Plan(models.Model):
|
class Plan(models.Model):
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
<ul class="list-unstyled space-y-12 fs-19 ps-0">
|
<ul class="list-unstyled space-y-12 fs-19 ps-0">
|
||||||
{% for offering in service.offerings.all %}
|
{% for offering in service.offerings.all %}
|
||||||
<li>
|
<li>
|
||||||
<a class="d-flex align-items-center text-gray-500 h-32 lh-32" href="{% url 'services:offering_detail' offering.slug %}">
|
<a class="d-flex align-items-center text-gray-500 h-32 lh-32" href="{% url 'services:offering_detail' offering.cloud_provider.slug offering.service.slug %}">
|
||||||
<span class="pr-10">
|
<span class="pr-10">
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-cloud-fill" viewBox="0 0 16 16">
|
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-cloud-fill" viewBox="0 0 16 16">
|
||||||
<path d="M4.406 3.342A5.53 5.53 0 0 1 8 2c2.69 0 4.923 2 5.166 4.579C14.758 6.804 16 8.137 16 9.773 16 11.569 14.502 13 12.687 13H3.781C1.708 13 0 11.366 0 9.318c0-1.763 1.266-3.223 2.942-3.593.143-.863.698-1.723 1.464-2.383" fill="#9A63EC"/>
|
<path d="M4.406 3.342A5.53 5.53 0 0 1 8 2c2.69 0 4.923 2 5.166 4.579C14.758 6.804 16 8.137 16 9.773 16 11.569 14.502 13 12.687 13H3.781C1.708 13 0 11.366 0 9.318c0-1.763 1.266-3.223 2.942-3.593.143-.863.698-1.723 1.464-2.383" fill="#9A63EC"/>
|
||||||
|
@ -128,7 +128,7 @@
|
||||||
<div class="pt-24">
|
<div class="pt-24">
|
||||||
<div class="page-action">
|
<div class="page-action">
|
||||||
{% for offering in service.offerings.all %}
|
{% for offering in service.offerings.all %}
|
||||||
<a class="btn btn-primary btn-lg mr-md-17 mb-17 mb-md-0px mb-lg-17 mb-xl-0 w-100 w-md-auto" href="{% url 'services:offering_detail' offering.slug %}"
|
<a class="btn btn-primary btn-lg mr-md-17 mb-17 mb-md-0px mb-lg-17 mb-xl-0 w-100 w-md-auto" href="{% url 'services:offering_detail' offering.cloud_provider.slug offering.service.slug %}"
|
||||||
role="button">Get it on {{ offering.cloud_provider.name }}</a>
|
role="button">Get it on {{ offering.cloud_provider.name }}</a>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -10,7 +10,11 @@ urlpatterns = [
|
||||||
path("partners/", views.partner_list, name="partner_list"),
|
path("partners/", views.partner_list, name="partner_list"),
|
||||||
path("service/", views.service_list, name="service_list"),
|
path("service/", views.service_list, name="service_list"),
|
||||||
path("service/<slug:slug>/", views.service_detail, name="service_detail"),
|
path("service/<slug:slug>/", views.service_detail, name="service_detail"),
|
||||||
path("offering/<slug:slug>/", views.offering_detail, name="offering_detail"),
|
path(
|
||||||
|
"offering/<slug:provider_slug>/<slug:service_slug>/",
|
||||||
|
views.offering_detail,
|
||||||
|
name="offering_detail",
|
||||||
|
),
|
||||||
path("provider/<slug:slug>/", views.provider_detail, name="provider_detail"),
|
path("provider/<slug:slug>/", views.provider_detail, name="provider_detail"),
|
||||||
path("partner/<slug:slug>/", views.partner_detail, name="partner_detail"),
|
path("partner/<slug:slug>/", views.partner_detail, name="partner_detail"),
|
||||||
path("service/<slug:slug>/interest/", views.create_lead, name="create_lead"),
|
path("service/<slug:slug>/interest/", views.create_lead, name="create_lead"),
|
||||||
|
|
|
@ -39,7 +39,11 @@ def create_lead(request, slug):
|
||||||
f"{reverse('services:create_lead', kwargs={'slug': service.slug})}?offering={selected_offering.id}&plan={selected_offering.plans.first().id}"
|
f"{reverse('services:create_lead', kwargs={'slug': service.slug})}?offering={selected_offering.id}&plan={selected_offering.plans.first().id}"
|
||||||
)
|
)
|
||||||
# If there are multiple plans, redirect to offering detail
|
# If there are multiple plans, redirect to offering detail
|
||||||
return redirect("services:offering_detail", slug=selected_offering.slug)
|
return redirect(
|
||||||
|
"services:offering_detail",
|
||||||
|
provider_slug=selected_offering.cloud_provider.slug,
|
||||||
|
service_slug=selected_offering.service.slug,
|
||||||
|
)
|
||||||
|
|
||||||
# Get the selected plan
|
# Get the selected plan
|
||||||
selected_plan = get_object_or_404(
|
selected_plan = get_object_or_404(
|
||||||
|
|
|
@ -55,12 +55,13 @@ def offering_list(request):
|
||||||
return render(request, "services/offering_list.html", context)
|
return render(request, "services/offering_list.html", context)
|
||||||
|
|
||||||
|
|
||||||
def offering_detail(request, slug):
|
def offering_detail(request, provider_slug, service_slug):
|
||||||
offering = get_object_or_404(
|
offering = get_object_or_404(
|
||||||
ServiceOffering.objects.select_related(
|
ServiceOffering.objects.select_related(
|
||||||
"service", "cloud_provider"
|
"service", "cloud_provider"
|
||||||
).prefetch_related("plans"),
|
).prefetch_related("plans"),
|
||||||
slug=slug,
|
cloud_provider__slug=provider_slug,
|
||||||
|
service__slug=service_slug,
|
||||||
)
|
)
|
||||||
|
|
||||||
context = {
|
context = {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue