aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pydis_site/apps/content/migrations/0001_add_tags.py4
-rw-r--r--pydis_site/apps/content/models/tag.py9
-rw-r--r--pydis_site/apps/content/tests/test_utils.py8
-rw-r--r--pydis_site/apps/content/utils.py8
4 files changed, 17 insertions, 12 deletions
diff --git a/pydis_site/apps/content/migrations/0001_add_tags.py b/pydis_site/apps/content/migrations/0001_add_tags.py
index 73525243..2c31e4c1 100644
--- a/pydis_site/apps/content/migrations/0001_add_tags.py
+++ b/pydis_site/apps/content/migrations/0001_add_tags.py
@@ -1,4 +1,4 @@
-# Generated by Django 4.0.6 on 2022-08-16 17:38
+# Generated by Django 4.0.6 on 2022-08-23 09:06
import django.db.models.deletion
from django.db import migrations, models
@@ -18,7 +18,7 @@ class Migration(migrations.Migration):
('sha', models.CharField(help_text='The SHA hash of this commit.', max_length=40, primary_key=True, serialize=False)),
('message', models.TextField(help_text='The commit message.')),
('date', models.DateTimeField(help_text='The date and time the commit was created.')),
- ('author', models.TextField(help_text='The person(s) who created the commit.')),
+ ('authors', models.TextField(help_text='The person(s) who created the commit. This is a serialized JSON object. Refer to the GitHub documentation on the commit endpoint (schema/commit.author & schema/commit.committer) for more info. https://docs.github.com/en/rest/commits/commits#get-a-commit')),
],
),
migrations.CreateModel(
diff --git a/pydis_site/apps/content/models/tag.py b/pydis_site/apps/content/models/tag.py
index e06ce067..1a20d775 100644
--- a/pydis_site/apps/content/models/tag.py
+++ b/pydis_site/apps/content/models/tag.py
@@ -16,7 +16,12 @@ class Commit(models.Model):
)
message = models.TextField(help_text="The commit message.")
date = models.DateTimeField(help_text="The date and time the commit was created.")
- author = models.TextField(help_text="The person(s) who created the commit.")
+ authors = models.TextField(help_text=(
+ "The person(s) who created the commit. This is a serialized JSON object. "
+ "Refer to the GitHub documentation on the commit endpoint "
+ "(schema/commit.author & schema/commit.committer) for more info. "
+ "https://docs.github.com/en/rest/commits/commits#get-a-commit"
+ ))
@property
def url(self) -> str:
@@ -30,7 +35,7 @@ class Commit(models.Model):
def format_authors(self) -> collections.abc.Iterable[str]:
"""Return a nice representation of the author(s)' name and email."""
- for author in json.loads(self.author):
+ for author in json.loads(self.authors):
yield f"{author['name']} <{author['email']}>"
diff --git a/pydis_site/apps/content/tests/test_utils.py b/pydis_site/apps/content/tests/test_utils.py
index 2ef033e4..462818b5 100644
--- a/pydis_site/apps/content/tests/test_utils.py
+++ b/pydis_site/apps/content/tests/test_utils.py
@@ -23,7 +23,7 @@ TEST_COMMIT_KWARGS = {
"sha": "123",
"message": "Hello world\n\nThis is a commit message",
"date": _time,
- "author": json.dumps([
+ "authors": json.dumps([
{"name": "Author 1", "email": "[email protected]", "date": _time_str},
{"name": "Author 2", "email": "[email protected]", "date": _time_str},
]),
@@ -314,7 +314,7 @@ class TagUtilsTests(TestCase):
"""Test the get commit function with a normal tag."""
tag = models.Tag.objects.create(name="example")
- authors = json.loads(self.commit.author)
+ authors = json.loads(self.commit.authors)
get_mock.return_value = httpx.Response(
request=httpx.Request("GET", "https://google.com"),
@@ -343,9 +343,9 @@ class TagUtilsTests(TestCase):
"""Test the get commit function with a group tag."""
tag = models.Tag.objects.create(name="example", group="group-name")
- authors = json.loads(self.commit.author)
+ authors = json.loads(self.commit.authors)
authors.pop()
- self.commit.author = json.dumps(authors)
+ self.commit.authors = json.dumps(authors)
self.commit.save()
get_mock.return_value = httpx.Response(
diff --git a/pydis_site/apps/content/utils.py b/pydis_site/apps/content/utils.py
index 32d3d638..a1171a45 100644
--- a/pydis_site/apps/content/utils.py
+++ b/pydis_site/apps/content/utils.py
@@ -137,7 +137,7 @@ def set_tag_commit(tag: Tag) -> None:
sha="68da80efc00d9932a209d5cccd8d344cec0f09ea",
message="Initial Commit\n\nTHIS IS FAKE DEMO DATA",
date=datetime.datetime(2018, 2, 3, 12, 20, 26, tzinfo=datetime.timezone.utc),
- author=json.dumps([{"name": "Joseph", "email": "[email protected]"}]),
+ authors=json.dumps([{"name": "Joseph", "email": "[email protected]"}]),
)
return
@@ -159,15 +159,15 @@ def set_tag_commit(tag: Tag) -> None:
date = date.replace(tzinfo=datetime.timezone.utc)
if author["email"] == committer["email"]:
- commit_author = [author]
+ authors = [author]
else:
- commit_author = [author, committer]
+ authors = [author, committer]
commit_obj, _ = Commit.objects.get_or_create(
sha=data["sha"],
message=commit["message"],
date=date,
- author=json.dumps(commit_author),
+ authors=json.dumps(authors),
)
tag.last_commit = commit_obj
tag.save()