aboutsummaryrefslogtreecommitdiffstats
path: root/pydis_site/apps/content/models
diff options
context:
space:
mode:
Diffstat (limited to 'pydis_site/apps/content/models')
-rw-r--r--pydis_site/apps/content/models/tag.py17
1 files changed, 16 insertions, 1 deletions
diff --git a/pydis_site/apps/content/models/tag.py b/pydis_site/apps/content/models/tag.py
index 1437b96a..01264ff1 100644
--- a/pydis_site/apps/content/models/tag.py
+++ b/pydis_site/apps/content/models/tag.py
@@ -4,6 +4,8 @@ from django.db import models
class Tag(models.Model):
"""A tag from the python-discord server."""
+ URL_BASE = "https://github.com/python-discord/bot/tree/main/bot/resources/tags"
+
last_updated = models.DateTimeField(
help_text="The date and time this data was last fetched.",
auto_now=True,
@@ -13,5 +15,18 @@ class Tag(models.Model):
primary_key=True,
max_length=50,
)
+ group = models.CharField(
+ help_text="The group the tag belongs to.",
+ null=True,
+ max_length=50,
+ )
body = models.TextField(help_text="The content of the tag.")
- url = models.URLField(help_text="The URL to this tag on GitHub.")
+
+ @property
+ def url(self) -> str:
+ """Get the URL of the tag on GitHub."""
+ url = Tag.URL_BASE
+ if self.group:
+ url += f"/{self.group}"
+ url += f"/{self.name}.md"
+ return url