Coverage for website/shortlinks/models.py: 100.00%
9 statements
« prev ^ index » next coverage.py v7.6.7, created at 2025-08-14 10:31 +0000
« prev ^ index » next coverage.py v7.6.7, created at 2025-08-14 10:31 +0000
1from django.conf import settings
2from django.db import models
3from django.utils.translation import gettext_lazy as _
6class ShortLink(models.Model):
7 slug = models.SlugField(
8 unique=True,
9 max_length=32,
10 verbose_name=_("name for the url"),
11 help_text=_(
12 "This is what you use after the root domain. Be mindful that the url "
13 "this creates could be overridden by a website update."
14 ),
15 )
17 url = models.URLField(
18 verbose_name=_("redirection target"),
19 help_text=_("The url the user will be redirected to."),
20 )
22 immediate = models.BooleanField(
23 default=False,
24 verbose_name=_("redirect without information page"),
25 help_text=_(
26 "Make sure to only do this when users expect an immediate redirect, if "
27 "they expect a Thalia site a redirect will be confusing."
28 ),
29 )
31 def __str__(self):
32 return f"https://{settings.SITE_DOMAIN}/{self.slug}"