parent
3730d95a6e
commit
819e13481e
5 changed files with 94 additions and 33 deletions
|
|
@ -146,12 +146,31 @@ class Organization(ServalaModelMixin, models.Model):
|
|||
def get_visible_services(self):
|
||||
from servala.core.models import Service
|
||||
|
||||
queryset = Service.objects.all()
|
||||
if self.limit_osb_services.exists():
|
||||
queryset = self.limit_osb_services.all()
|
||||
if self.limit_cloudproviders.exists():
|
||||
allowed_providers = self.limit_cloudproviders.all()
|
||||
queryset = queryset.filter(
|
||||
offerings__provider__in=allowed_providers
|
||||
).distinct()
|
||||
return queryset.prefetch_related(
|
||||
"offerings", "offerings__provider"
|
||||
).select_related("category")
|
||||
|
||||
def get_deactivated_services(self):
|
||||
from servala.core.models import Service
|
||||
|
||||
if not self.limit_osb_services.exists():
|
||||
return Service.objects.none()
|
||||
|
||||
queryset = Service.objects.select_related("category")
|
||||
if self.limit_cloudproviders.exists():
|
||||
allowed_providers = self.limit_cloudproviders.all()
|
||||
queryset = queryset.filter(
|
||||
offerings__provider__in=allowed_providers
|
||||
).distinct()
|
||||
queryset = queryset.exclude(id__in=self.limit_osb_services.all())
|
||||
return queryset.prefetch_related("offerings", "offerings__provider")
|
||||
|
||||
class Meta:
|
||||
|
|
|
|||
|
|
@ -16,40 +16,9 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row match-height card-grid service-cards-container mb-5">
|
||||
<div class="row match-height card-grid service-cards-container {% if not deactivated_services %}mb-5{% endif %}">
|
||||
{% for service in services %}
|
||||
<div class="col-12 col-md-6 col-lg-3">
|
||||
<div class="card">
|
||||
<div class="card-header card-header-with-logo">
|
||||
{% if service.logo %}<img src="{{ service.logo.url }}" alt="{{ service.name }}">{% endif %}
|
||||
<div class="card-header-content">
|
||||
<h4>{{ service.name }}</h4>
|
||||
<small class="text-muted">{{ service.category }}</small>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-content">
|
||||
<div class="card-body flex-grow-1">
|
||||
{% if service.description %}<p class="card-text">{{ service.description|urlize }}</p>{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-footer d-flex justify-content-between align-items-center gap-2">
|
||||
{% if service.featured_links %}
|
||||
{% with featured_link=service.featured_links.0 %}
|
||||
<a href="{{ featured_link.url }}"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
class="btn btn-outline-primary">
|
||||
{{ featured_link.title }}
|
||||
<i class="bi bi-box-arrow-up-right ms-1"></i>
|
||||
</a>
|
||||
{% endwith %}
|
||||
{% else %}
|
||||
<span></span>
|
||||
{% endif %}
|
||||
<a href="{{ service.slug }}/" class="btn btn-light-primary">{% translate "View Availability" %}</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-12 col-md-6 col-lg-3">{% include "includes/service_card.html" %}</div>
|
||||
{% empty %}
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
|
|
@ -60,6 +29,22 @@
|
|||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% if deactivated_services %}
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">{% translate "You may also be interested in one of these …" %}</h5>
|
||||
<p class="text-muted">
|
||||
<i class="bi bi-info-circle mt-1"></i>
|
||||
{% translate "These services need to be enabled on Exoscale first before they become available in the Servala portal." %}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row match-height card-grid service-cards-container mb-5">
|
||||
{% for service in deactivated_services %}
|
||||
<div class="col-12 col-md-6 col-lg-3 service-deactivated">{% include "includes/service_card.html" %}</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</section>
|
||||
<script src="{% static "js/autosubmit.js" %}" defer></script>
|
||||
{% endblock content %}
|
||||
|
|
|
|||
31
src/servala/frontend/templates/includes/service_card.html
Normal file
31
src/servala/frontend/templates/includes/service_card.html
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
{% load i18n %}
|
||||
<div class="card">
|
||||
<div class="card-header card-header-with-logo">
|
||||
{% if service.logo %}<img src="{{ service.logo.url }}" alt="{{ service.name }}">{% endif %}
|
||||
<div class="card-header-content">
|
||||
<h4>{{ service.name }}</h4>
|
||||
<small class="text-muted">{{ service.category }}</small>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-content">
|
||||
<div class="card-body flex-grow-1">
|
||||
{% if service.description %}<p class="card-text">{{ service.description|urlize }}</p>{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-footer d-flex justify-content-between align-items-center gap-2">
|
||||
{% if service.featured_links %}
|
||||
{% with featured_link=service.featured_links.0 %}
|
||||
<a href="{{ featured_link.url }}"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
class="btn btn-outline-primary">
|
||||
{{ featured_link.title }}
|
||||
<i class="bi bi-box-arrow-up-right ms-1"></i>
|
||||
</a>
|
||||
{% endwith %}
|
||||
{% else %}
|
||||
<span></span>
|
||||
{% endif %}
|
||||
<a href="{{ service.slug }}/" class="btn btn-light-primary">{% translate "View Availability" %}</a>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -49,6 +49,9 @@ class ServiceListView(OrganizationViewMixin, ListView):
|
|||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
context["filter_form"] = self.filter_form
|
||||
context["deactivated_services"] = (
|
||||
self.request.organization.get_deactivated_services()
|
||||
)
|
||||
return context
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -279,3 +279,26 @@ html[data-bs-theme="dark"] .crd-form .nav-tabs .nav-link .mandatory-indicator {
|
|||
.crd-form .nav-tabs .nav-link.has-mandatory {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.service-deactivated .card {
|
||||
opacity: 50%;
|
||||
cursor: not-allowed;
|
||||
img {
|
||||
opacity: 75%
|
||||
}
|
||||
h4, small, p {
|
||||
color: var(--bs-secondary-color) !important;
|
||||
}
|
||||
a.btn-outline-secondary {
|
||||
color: var(--bs-btn-disabled-color) !important;
|
||||
background-color: var(--bs-btn-disabled-bg) !important;
|
||||
border-color: var(--bs-btn-disabled-border-color) !important;
|
||||
opacity: var(--bs-btn-disabled-opacity);
|
||||
}
|
||||
a.btn-secondary {
|
||||
color: white !important;
|
||||
}
|
||||
a.btn {
|
||||
pointer-events: none;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue