diff --git a/src/phonebook/models.py b/src/phonebook/models.py index 73d8aa83c..d9dc08726 100644 --- a/src/phonebook/models.py +++ b/src/phonebook/models.py @@ -95,6 +95,9 @@ def save(self, *args, **kwargs) -> None: self.check_unique_ipei() super().save(*args, **kwargs) + def __str__(self) -> str: + return f"{self.number or self.letters} ({self.user.profile.get_name})" + def check_unique_ipei(self) -> None: """Check IPEI is unique.""" if ( diff --git a/src/teams/migrations/0065_team_public_dect_number_team_public_phone_number.py b/src/teams/migrations/0065_team_public_dect_number_team_public_phone_number.py new file mode 100644 index 000000000..9264c7e73 --- /dev/null +++ b/src/teams/migrations/0065_team_public_dect_number_team_public_phone_number.py @@ -0,0 +1,37 @@ +# Generated by Django 5.2.9 on 2026-01-23 11:48 + +import django.db.models.deletion +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("phonebook", "0005_alter_dectregistration_ipei"), + ("teams", "0064_alter_team_facilitator_group_and_more"), + ] + + operations = [ + migrations.AddField( + model_name="team", + name="public_dect_number", + field=models.ForeignKey( + blank=True, + help_text="The public DECT for this team.", + null=True, + on_delete=django.db.models.deletion.PROTECT, + related_name="public_team_numbers", + to="phonebook.dectregistration", + ), + ), + migrations.AddField( + model_name="team", + name="public_phone_number", + field=models.CharField( + blank=True, + help_text="The public phonenumber for this team.", + max_length=14, + null=True, + ), + ), + ] diff --git a/src/teams/models.py b/src/teams/models.py index a838e11f1..15c458e74 100644 --- a/src/teams/models.py +++ b/src/teams/models.py @@ -5,15 +5,15 @@ from typing import TYPE_CHECKING from django.conf import settings +from django.core.validators import MaxValueValidator +from django.core.validators import MinValueValidator from django.contrib.auth.models import Group -from django.contrib.auth.models import Permission -from django.contrib.contenttypes.models import ContentType from django.contrib.postgres.fields import DateTimeRangeField from django.db import models from django.urls import reverse_lazy from django_prometheus.models import ExportModelOperationsMixin -from camps.models import Permission as CampPermission +from phonebook.models import DectRegistration from utils.models import CampRelatedModel from utils.models import CreatedUpdatedModel from utils.models import UUIDModel @@ -211,6 +211,22 @@ class Team(ExportModelOperationsMixin("team"), CampRelatedModel): public_signal_channel_link = models.URLField(null=True, blank=True, default="") private_signal_channel_link = models.URLField(null=True, blank=True, default="") + public_phone_number = models.CharField( + max_length=14, # Allow for "+00 1234567890" + blank=True, + null=True, + help_text="The public phonenumber for this team.", + ) + + public_dect_number = models.ForeignKey( + DectRegistration, + on_delete=models.PROTECT, + blank=True, + null=True, + related_name="public_team_numbers", + help_text="The public DECT for this team.", + ) + shifts_enabled = models.BooleanField( default=False, help_text="Does this team have shifts? This enables defining shifts for this team.", diff --git a/src/teams/templates/team_base.html b/src/teams/templates/team_base.html index 557eac6d0..9cf084716 100644 --- a/src/teams/templates/team_base.html +++ b/src/teams/templates/team_base.html @@ -22,6 +22,14 @@
Your membership status: {% membershipstatus user team %}
- {% if request.user in team.leads.all %} - Manage Team - {% endif %} - {% else %} {% if team.needs_members %} This team is looking for members! Join Team diff --git a/src/teams/templates/team_general.html b/src/teams/templates/team_general.html index 1a08b4efd..2c382d5fc 100644 --- a/src/teams/templates/team_general.html +++ b/src/teams/templates/team_general.html @@ -50,6 +50,20 @@The {{ team.name }} Team does not have a public Signal Group.
{% endif %} +The {{ team.name }} Team public phone number {{ team.public_phone_number|urlize }}
+ {% else %} +The {{ team.name }} Team does not have a public phone number.
+ {% endif %} + +The {{ team.name }} Team public DECT number is {{ team.public_dect_number.number }}
+ {% else %} +The {{ team.name }} Team does not have a public DECT number.
+ {% endif %} + {% if request.user in team.approved_members.all and team.private_signal_channel_link %}The {{ team.name }} Team private Signal group is {{ team.private_signal_channel_link|urlize }}
{% endif %} diff --git a/src/teams/templates/team_guide.html b/src/teams/templates/team_guide.html index a5640816b..2fdf891a0 100644 --- a/src/teams/templates/team_guide.html +++ b/src/teams/templates/team_guide.html @@ -9,19 +9,21 @@diff --git a/src/teams/templates/team_list.html b/src/teams/templates/team_list.html index d16e8f8d8..5eda9bccd 100644 --- a/src/teams/templates/team_list.html +++ b/src/teams/templates/team_list.html @@ -99,7 +99,7 @@