You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
1.3 KiB
Python

# coding: utf-8
# Author: Grizzly
#
# Models for litl. The main model keeps track of the the matching
# between the URLs and the custom suffix.
from django.db import models
class Slug(models.Model):
"""Model of a slug. The slug represent the URL that leads to litl.*.*/slug
A slug has one user and can have from one to many destination.
"""
slug = models.SlugField(
max_length=20,
null=False,
blank=True,
help_text="Slug of the new URL. Up to 20 caracters including letters, number, underscores and hyphens.", )
bulk = models.BooleanField(
default=False,
help_text="Generate a short URL leading to multiple destinations",
)
uid = models.CharField(
max_length=100,
null=True,)
date = models.DateTimeField(
auto_now=True,)
def __str__(self):
return '{} -> ?'.format(self.slug)
class Destination(models.Model):
"""Model of a destination. A destination is the end URL wanted by the user.
One Slug can have multiple destinations.
"""
slug = models.ForeignKey(Slug, on_delete=models.CASCADE)
destination = models.CharField(
max_length=300,
null=False,
blank=False,
help_text="The destination URL, limited to 300 characters.",)