feat(services): Add an icon, and a transitive redirect view
This commit is contained in:
parent
8c3cba0af8
commit
cab8369558
6 changed files with 61 additions and 1 deletions
19
src/dgsi/migrations/0003_service_icon.py
Normal file
19
src/dgsi/migrations/0003_service_icon.py
Normal file
|
@ -0,0 +1,19 @@
|
|||
# Generated by Django 4.2.12 on 2024-09-23 21:29
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
("dgsi", "0002_service"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name="service",
|
||||
name="icon",
|
||||
field=models.CharField(
|
||||
blank=True, max_length=255, verbose_name="Icône du service"
|
||||
),
|
||||
),
|
||||
]
|
|
@ -17,6 +17,7 @@ ADMIN_GROUP = "dgnum_admins@sso.dgnum.eu"
|
|||
class Service(models.Model):
|
||||
name = models.CharField(_("Nom du service proposé"), max_length=255)
|
||||
url = models.URLField(_("Adresse du service"))
|
||||
icon = models.CharField(_("Icône du service"), max_length=255, blank=True)
|
||||
|
||||
def __str__(self) -> str:
|
||||
return f"{self.name} [{self.url}]"
|
||||
|
|
18
src/dgsi/templates/dgsi/service_list.html
Normal file
18
src/dgsi/templates/dgsi/service_list.html
Normal file
|
@ -0,0 +1,18 @@
|
|||
{% extends "base.html" %}
|
||||
|
||||
{% load i18n %}
|
||||
|
||||
{% block content %}
|
||||
<h2 class="subtitle">{% trans "Services accessibles via la DGNum" %}</h2>
|
||||
<hr>
|
||||
|
||||
<div class="buttons bt-links">
|
||||
{% for service in service_list %}
|
||||
<a class="button is-medium"
|
||||
href="{% url "dgsi:dgn-services_redirect" service.pk %}">
|
||||
<span class="icon"><i class="ti ti-{{ service.icon }}"></i></span>
|
||||
<span>{{ service.name }}</span>
|
||||
</a>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endblock content %}
|
|
@ -17,4 +17,9 @@ urlpatterns = [
|
|||
name="dgn-forbidden_account",
|
||||
),
|
||||
path("services/", views.ServiceListView.as_view(), name="dgn-services"),
|
||||
path(
|
||||
"services/redirect/<int:pk>",
|
||||
views.ServiceRedirectView.as_view(),
|
||||
name="dgn-services_redirect",
|
||||
),
|
||||
]
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
from typing import Any
|
||||
from asgiref.sync import async_to_sync
|
||||
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||
from django.contrib.messages.views import SuccessMessageMixin
|
||||
|
@ -5,7 +6,8 @@ from django.core.mail import EmailMessage
|
|||
from django.template.loader import render_to_string
|
||||
from django.urls import reverse_lazy
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.views.generic import FormView, ListView, TemplateView
|
||||
from django.views.generic import FormView, ListView, RedirectView, TemplateView
|
||||
from django.views.generic.detail import SingleObjectMixin
|
||||
|
||||
from dgsi.forms import CreateKanidmAccountForm
|
||||
from dgsi.mixins import StaffRequiredMixin
|
||||
|
@ -30,6 +32,13 @@ class ServiceListView(LoginRequiredMixin, ListView):
|
|||
model = Service
|
||||
|
||||
|
||||
class ServiceRedirectView(LoginRequiredMixin, SingleObjectMixin, RedirectView):
|
||||
model = Service
|
||||
|
||||
def get_redirect_url(self, *args: Any, **kwargs: Any) -> str:
|
||||
return self.get_object().url
|
||||
|
||||
|
||||
##
|
||||
# INFO: Below are views related to the administration of DGSI
|
||||
|
||||
|
|
8
src/shared/static/bulma/bulma.scss
vendored
8
src/shared/static/bulma/bulma.scss
vendored
|
@ -33,6 +33,14 @@ body {
|
|||
);
|
||||
}
|
||||
|
||||
.bt-links {
|
||||
justify-content: space-evenly;
|
||||
}
|
||||
|
||||
.bt-links > .button {
|
||||
width: 47.5%;
|
||||
}
|
||||
|
||||
.grid.groups {
|
||||
--bulma-grid-column-min: 24rem;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue