diff options
author | 2018-09-23 15:21:42 +0200 | |
---|---|---|
committer | 2018-09-23 15:21:42 +0200 | |
commit | 4fbbf9c2a8b30862bfaab1dddf4e860431bf6046 (patch) | |
tree | 42fa33c0a6b22794d20a2424785803c02c4e391b /api/models.py | |
parent | Revert "Add the `Tag` model." (diff) | |
parent | Add API root view documentation. (diff) |
Merge branch 'django+add-tag-api' into django
Diffstat (limited to 'api/models.py')
-rw-r--r-- | api/models.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/api/models.py b/api/models.py index 6b681ebc..e84e28c0 100644 --- a/api/models.py +++ b/api/models.py @@ -1,8 +1,11 @@ from operator import itemgetter +from django.contrib.postgres import fields as pgfields from django.core.validators import MaxValueValidator, MinValueValidator, RegexValidator from django.db import models +from .validators import validate_tag_embed + class ModelReprMixin: """ @@ -159,3 +162,20 @@ class Member(ModelReprMixin, models.Model): def __str__(self): return f"{self.name}#{self.discriminator}" + + +class Tag(ModelReprMixin, models.Model): + """A tag providing (hopefully) useful information.""" + + title = models.CharField( + max_length=100, + help_text=( + "The title of this tag, shown in searches and providing " + "a quick overview over what this embed contains." + ), + primary_key=True + ) + embed = pgfields.JSONField( + help_text="The actual embed shown by this tag.", + validators=(validate_tag_embed,) + ) |