aboutsummaryrefslogtreecommitdiffstats
path: root/pydis_site/apps
diff options
context:
space:
mode:
authorGravatar Johannes Christ <[email protected]>2021-10-06 23:20:56 +0200
committerGravatar Johannes Christ <[email protected]>2021-10-06 23:22:45 +0200
commitce75197fc1d0b2086631277d29f9396908bdc86c (patch)
tree2eab9855ab1a83352a5d83050d8a1fc0524f3285 /pydis_site/apps
parentMerge branch 'main' into subdomains-to-query-paths (diff)
parentMerge pull request #599 from python-discord/fix-http-links (diff)
Merge branch 'master' into subdomains-to-query-paths
Diffstat (limited to 'pydis_site/apps')
-rw-r--r--pydis_site/apps/api/admin.py4
-rw-r--r--pydis_site/apps/api/migrations/0072_doc_allow_blank_base_url.py19
-rw-r--r--pydis_site/apps/api/migrations/0073_otn_allow_GT_and_LT.py19
-rw-r--r--pydis_site/apps/api/models/bot/documentation_link.py1
-rw-r--r--pydis_site/apps/api/models/bot/metricity.py10
-rw-r--r--pydis_site/apps/api/models/bot/off_topic_channel_name.py2
-rw-r--r--pydis_site/apps/api/models/utils.py2
-rw-r--r--pydis_site/apps/api/tests/test_users.py10
-rw-r--r--pydis_site/apps/api/tests/test_validators.py2
-rw-r--r--pydis_site/apps/api/urls.py2
-rw-r--r--pydis_site/apps/api/viewsets/bot/user.py6
-rw-r--r--pydis_site/apps/content/resources/frequently-asked-questions.md2
-rw-r--r--pydis_site/apps/content/resources/guides/pydis-guides/contributing/contributing-guidelines/supplemental-information.md2
-rw-r--r--pydis_site/apps/content/resources/guides/pydis-guides/contributing/sir-lancebot.md9
-rw-r--r--pydis_site/apps/content/resources/guides/pydis-guides/contributing/sir-lancebot/env-var-reference.md2
-rw-r--r--pydis_site/apps/home/tests/mock_github_api_response.json2
-rw-r--r--pydis_site/apps/home/views/home.py17
-rw-r--r--pydis_site/apps/resources/resources/communities/panda3d.yaml2
-rw-r--r--pydis_site/apps/resources/resources/reading/books/byte_of_python.yaml2
-rw-r--r--pydis_site/apps/resources/resources/reading/books/flask_web_development.yaml2
-rw-r--r--pydis_site/apps/resources/resources/reading/books/python_cookbook.yaml2
-rw-r--r--pydis_site/apps/resources/resources/reading/tutorials/simple_guide_to_git.yaml2
-rw-r--r--pydis_site/apps/resources/resources/videos/microsoft.yaml2
23 files changed, 89 insertions, 34 deletions
diff --git a/pydis_site/apps/api/admin.py b/pydis_site/apps/api/admin.py
index 449e660e..2aca38a1 100644
--- a/pydis_site/apps/api/admin.py
+++ b/pydis_site/apps/api/admin.py
@@ -48,8 +48,8 @@ class BotSettingAdmin(admin.ModelAdmin):
class DocumentationLinkAdmin(admin.ModelAdmin):
"""Admin formatting for the DocumentationLink model."""
- fields = ("package", "base_url", "inventory_url")
- list_display = ("package", "base_url", "inventory_url")
+ fields = ("package", "inventory_url", "base_url")
+ list_display = ("package", "inventory_url", "base_url")
list_editable = ("base_url", "inventory_url")
search_fields = ("package",)
diff --git a/pydis_site/apps/api/migrations/0072_doc_allow_blank_base_url.py b/pydis_site/apps/api/migrations/0072_doc_allow_blank_base_url.py
new file mode 100644
index 00000000..d4899354
--- /dev/null
+++ b/pydis_site/apps/api/migrations/0072_doc_allow_blank_base_url.py
@@ -0,0 +1,19 @@
+# Generated by Django 3.0.14 on 2021-08-30 21:09
+
+from django.db import migrations, models
+import pydis_site.apps.api.models.bot.documentation_link
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('api', '0071_increase_message_content_4000'),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name='documentationlink',
+ name='base_url',
+ field=models.URLField(blank=True, help_text='The base URL from which documentation will be available for this project. Used to generate links to various symbols within this package.', validators=[pydis_site.apps.api.models.bot.documentation_link.ends_with_slash_validator]),
+ ),
+ ]
diff --git a/pydis_site/apps/api/migrations/0073_otn_allow_GT_and_LT.py b/pydis_site/apps/api/migrations/0073_otn_allow_GT_and_LT.py
new file mode 100644
index 00000000..09ad13da
--- /dev/null
+++ b/pydis_site/apps/api/migrations/0073_otn_allow_GT_and_LT.py
@@ -0,0 +1,19 @@
+# Generated by Django 3.0.14 on 2021-09-27 20:38
+
+import django.core.validators
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('api', '0072_doc_allow_blank_base_url'),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name='offtopicchannelname',
+ name='name',
+ field=models.CharField(help_text='The actual channel name that will be used on our Discord server.', max_length=96, primary_key=True, serialize=False, validators=[django.core.validators.RegexValidator(regex="^[a-z0-9\\U0001d5a0-\\U0001d5b9-ǃ?’'<>]+$")]),
+ ),
+ ]
diff --git a/pydis_site/apps/api/models/bot/documentation_link.py b/pydis_site/apps/api/models/bot/documentation_link.py
index 3dcc71fc..9941907c 100644
--- a/pydis_site/apps/api/models/bot/documentation_link.py
+++ b/pydis_site/apps/api/models/bot/documentation_link.py
@@ -30,6 +30,7 @@ class DocumentationLink(ModelReprMixin, models.Model):
"The base URL from which documentation will be available for this project. "
"Used to generate links to various symbols within this package."
),
+ blank=True,
validators=(ends_with_slash_validator,)
)
inventory_url = models.URLField(
diff --git a/pydis_site/apps/api/models/bot/metricity.py b/pydis_site/apps/api/models/bot/metricity.py
index 5daa5c66..33fb7ad7 100644
--- a/pydis_site/apps/api/models/bot/metricity.py
+++ b/pydis_site/apps/api/models/bot/metricity.py
@@ -10,7 +10,7 @@ EXCLUDE_CHANNELS = [
]
-class NotFound(Exception):
+class NotFoundError(Exception):
"""Raised when an entity cannot be found."""
pass
@@ -37,7 +37,7 @@ class Metricity:
values = self.cursor.fetchone()
if not values:
- raise NotFound()
+ raise NotFoundError()
return dict(zip(columns, values))
@@ -58,7 +58,7 @@ class Metricity:
values = self.cursor.fetchone()
if not values:
- raise NotFound()
+ raise NotFoundError()
return values[0]
@@ -88,7 +88,7 @@ class Metricity:
values = self.cursor.fetchone()
if not values:
- raise NotFound()
+ raise NotFoundError()
return values[0]
@@ -127,6 +127,6 @@ class Metricity:
values = self.cursor.fetchall()
if not values:
- raise NotFound()
+ raise NotFoundError()
return values
diff --git a/pydis_site/apps/api/models/bot/off_topic_channel_name.py b/pydis_site/apps/api/models/bot/off_topic_channel_name.py
index 403c7465..8999e560 100644
--- a/pydis_site/apps/api/models/bot/off_topic_channel_name.py
+++ b/pydis_site/apps/api/models/bot/off_topic_channel_name.py
@@ -11,7 +11,7 @@ class OffTopicChannelName(ModelReprMixin, models.Model):
primary_key=True,
max_length=96,
validators=(
- RegexValidator(regex=r"^[a-z0-9\U0001d5a0-\U0001d5b9-ǃ?’']+$"),
+ RegexValidator(regex=r"^[a-z0-9\U0001d5a0-\U0001d5b9-ǃ?’'<>]+$"),
),
help_text="The actual channel name that will be used on our Discord server."
)
diff --git a/pydis_site/apps/api/models/utils.py b/pydis_site/apps/api/models/utils.py
index 107231ba..0e220a1d 100644
--- a/pydis_site/apps/api/models/utils.py
+++ b/pydis_site/apps/api/models/utils.py
@@ -142,7 +142,7 @@ def validate_embed(embed: Any) -> None:
),
MaxLengthValidator(limit_value=256)
),
- 'description': (MaxLengthValidator(limit_value=2048),),
+ 'description': (MaxLengthValidator(limit_value=4096),),
'fields': (
MaxLengthValidator(limit_value=25),
validate_embed_fields
diff --git a/pydis_site/apps/api/tests/test_users.py b/pydis_site/apps/api/tests/test_users.py
index bed6342e..77876d6f 100644
--- a/pydis_site/apps/api/tests/test_users.py
+++ b/pydis_site/apps/api/tests/test_users.py
@@ -5,7 +5,7 @@ from django.urls import reverse
from .base import AuthenticatedAPITestCase
from ..models import Role, User
-from ..models.bot.metricity import NotFound
+from ..models.bot.metricity import NotFoundError
class UnauthedUserAPITests(AuthenticatedAPITestCase):
@@ -501,7 +501,7 @@ class UserMetricityTests(AuthenticatedAPITestCase):
self.metricity = patcher.start()
self.addCleanup(patcher.stop)
self.metricity = self.metricity.return_value.__enter__.return_value
- self.metricity.user.side_effect = NotFound()
- self.metricity.total_messages.side_effect = NotFound()
- self.metricity.total_message_blocks.side_effect = NotFound()
- self.metricity.top_channel_activity.side_effect = NotFound()
+ self.metricity.user.side_effect = NotFoundError()
+ self.metricity.total_messages.side_effect = NotFoundError()
+ self.metricity.total_message_blocks.side_effect = NotFoundError()
+ self.metricity.top_channel_activity.side_effect = NotFoundError()
diff --git a/pydis_site/apps/api/tests/test_validators.py b/pydis_site/apps/api/tests/test_validators.py
index 8bb7b917..551cc2aa 100644
--- a/pydis_site/apps/api/tests/test_validators.py
+++ b/pydis_site/apps/api/tests/test_validators.py
@@ -72,7 +72,7 @@ class TagEmbedValidatorTests(TestCase):
def test_rejects_too_long_description(self):
with self.assertRaises(ValidationError):
validate_embed({
- 'description': 'd' * 2049
+ 'description': 'd' * 4097
})
def test_allows_valid_embed(self):
diff --git a/pydis_site/apps/api/urls.py b/pydis_site/apps/api/urls.py
index 2e1ef0b4..b0ab545b 100644
--- a/pydis_site/apps/api/urls.py
+++ b/pydis_site/apps/api/urls.py
@@ -16,7 +16,7 @@ from .viewsets import (
UserViewSet
)
-# http://www.django-rest-framework.org/api-guide/routers/#defaultrouter
+# https://www.django-rest-framework.org/api-guide/routers/#defaultrouter
bot_router = DefaultRouter(trailing_slash=False)
bot_router.register(
'filter-lists',
diff --git a/pydis_site/apps/api/viewsets/bot/user.py b/pydis_site/apps/api/viewsets/bot/user.py
index 25722f5a..0356e193 100644
--- a/pydis_site/apps/api/viewsets/bot/user.py
+++ b/pydis_site/apps/api/viewsets/bot/user.py
@@ -11,7 +11,7 @@ from rest_framework.serializers import ModelSerializer
from rest_framework.viewsets import ModelViewSet
from pydis_site.apps.api.models.bot.infraction import Infraction
-from pydis_site.apps.api.models.bot.metricity import Metricity, NotFound
+from pydis_site.apps.api.models.bot.metricity import Metricity, NotFoundError
from pydis_site.apps.api.models.bot.user import User
from pydis_site.apps.api.serializers import UserSerializer
@@ -275,7 +275,7 @@ class UserViewSet(ModelViewSet):
data["voice_banned"] = voice_banned
data["activity_blocks"] = metricity.total_message_blocks(user.id)
return Response(data, status=status.HTTP_200_OK)
- except NotFound:
+ except NotFoundError:
return Response(dict(detail="User not found in metricity"),
status=status.HTTP_404_NOT_FOUND)
@@ -290,6 +290,6 @@ class UserViewSet(ModelViewSet):
data["total_messages"] = metricity.total_messages(user.id)
data["top_channel_activity"] = metricity.top_channel_activity(user.id)
return Response(data, status=status.HTTP_200_OK)
- except NotFound:
+ except NotFoundError:
return Response(dict(detail="User not found in metricity"),
status=status.HTTP_404_NOT_FOUND)
diff --git a/pydis_site/apps/content/resources/frequently-asked-questions.md b/pydis_site/apps/content/resources/frequently-asked-questions.md
index 212ea5f8..a9a092fe 100644
--- a/pydis_site/apps/content/resources/frequently-asked-questions.md
+++ b/pydis_site/apps/content/resources/frequently-asked-questions.md
@@ -89,7 +89,7 @@ It's also to ease the burden on our moderators, otherwise they would have to dow
Even though Discord does support previewing of files like `.txt` and `.py`, that support is only available on Desktop, not mobile. Additionally, we prefer people to use hastebin as it encourages them to only copy over the relevant code snippets instead of their whole code; this makes helping much easier for all involved.
-If you want to share code please use our hosted hastebin, [paste.pythondiscord.com](http://paste.pythondiscord.com).
+If you want to share code please use our hosted hastebin, [paste.pythondiscord.com](https://paste.pythondiscord.com).
#### **Q: Why is this permission not allowed in that channel?**
diff --git a/pydis_site/apps/content/resources/guides/pydis-guides/contributing/contributing-guidelines/supplemental-information.md b/pydis_site/apps/content/resources/guides/pydis-guides/contributing/contributing-guidelines/supplemental-information.md
index 70d47563..e64e4fc6 100644
--- a/pydis_site/apps/content/resources/guides/pydis-guides/contributing/contributing-guidelines/supplemental-information.md
+++ b/pydis_site/apps/content/resources/guides/pydis-guides/contributing/contributing-guidelines/supplemental-information.md
@@ -90,7 +90,7 @@ Our projects currently defines logging levels as follows, from lowest to highest
- **ERROR:** These events can cause a failure in a specific part of the application and require urgent attention.
- **CRITICAL:** These events can cause the whole application to fail and require immediate intervention.
-Any logging above the **INFO** level will trigger a [Sentry](http://sentry.io) issue and alert the Core Developer team.
+Any logging above the **INFO** level will trigger a [Sentry](https://sentry.io) issue and alert the Core Developer team.
## Draft Pull Requests
diff --git a/pydis_site/apps/content/resources/guides/pydis-guides/contributing/sir-lancebot.md b/pydis_site/apps/content/resources/guides/pydis-guides/contributing/sir-lancebot.md
index 068b08ae..60169c01 100644
--- a/pydis_site/apps/content/resources/guides/pydis-guides/contributing/sir-lancebot.md
+++ b/pydis_site/apps/content/resources/guides/pydis-guides/contributing/sir-lancebot.md
@@ -16,6 +16,15 @@ toc: 1
- [MacOS Installer](https://git-scm.com/download/mac) or `brew install git`
- [Linux](https://git-scm.com/download/linux)
+## Using Gitpod
+Sir Lancebot can be edited and tested on Gitpod. Gitpod will automatically install the correct dependencies and Python version, so you can get straight to coding.
+To do this, you will need a Gitpod account, which you can get [here](https://www.gitpod.io/#get-started), and a fork of Sir Lancebot. This guide covers forking the repository [here](#fork-the-project). Afterwards, either click the button on Sir Lancebot's README or go to [https://gitpod.io/#/python-discord/sir-lancebot]() and run the following commands in the terminal:
+```sh
+git remote rename origin upstream
+git add remote origin https://github.com/{your_username}/sir-lancebot
+```
+Make sure you replace `{your_username}` with your Github username. These commands will set Python Discord as the parent repository, and your branch as the fork. This means you can easily grab new changes from the parent repository. Once you set your environment variables to test your code, you are ready to begin contributing to Sir Lancebot.
+
## Using Docker
Sir Lancebot can be started using Docker. Using Docker is generally recommended (but not strictly required) because it abstracts away some additional set up work.
diff --git a/pydis_site/apps/content/resources/guides/pydis-guides/contributing/sir-lancebot/env-var-reference.md b/pydis_site/apps/content/resources/guides/pydis-guides/contributing/sir-lancebot/env-var-reference.md
index 2a7ef0d6..eba737ad 100644
--- a/pydis_site/apps/content/resources/guides/pydis-guides/contributing/sir-lancebot/env-var-reference.md
+++ b/pydis_site/apps/content/resources/guides/pydis-guides/contributing/sir-lancebot/env-var-reference.md
@@ -43,7 +43,7 @@ If you will be working with an external service, you might have to set one of th
| -------- | -------- |
| `GITHUB_TOKEN` | Personal access token for GitHub, raises rate limits from 60 to 5000 requests per hour. |
| `GIPHY_TOKEN` | Required for API access. [Docs](https://developers.giphy.com/docs/api) |
-| `OMDB_API_KEY` | Required for API access. [Docs](http://www.omdbapi.com/) |
+| `OMDB_API_KEY` | Required for API access. [Docs](https://www.omdbapi.com/) |
| `REDDIT_CLIENT_ID` | OAuth2 client ID for authenticating with the [reddit API](https://github.com/reddit-archive/reddit/wiki/OAuth2). |
| `REDDIT_SECRET` | OAuth2 secret for authenticating with the reddit API. *Leave empty if you're not using the reddit API.* |
| `REDDIT_WEBHOOK` | Webhook ID for Reddit channel |
diff --git a/pydis_site/apps/home/tests/mock_github_api_response.json b/pydis_site/apps/home/tests/mock_github_api_response.json
index ddbffed8..3b0a7078 100644
--- a/pydis_site/apps/home/tests/mock_github_api_response.json
+++ b/pydis_site/apps/home/tests/mock_github_api_response.json
@@ -21,7 +21,7 @@
"forks_count": 31
},
{
- "full_name": "python-discord/django-simple-bulma",
+ "full_name": "python-discord/king-arthur",
"description": "test",
"stargazers_count": 97,
"language": "Python",
diff --git a/pydis_site/apps/home/views/home.py b/pydis_site/apps/home/views/home.py
index 0f26cef3..401c768f 100644
--- a/pydis_site/apps/home/views/home.py
+++ b/pydis_site/apps/home/views/home.py
@@ -9,7 +9,7 @@ from django.utils import timezone
from django.views import View
from pydis_site.apps.home.models import RepositoryMetadata
-from pydis_site.constants import GITHUB_TOKEN
+from pydis_site.constants import GITHUB_TOKEN, TIMEOUT_PERIOD
log = logging.getLogger(__name__)
@@ -27,7 +27,7 @@ class HomeView(View):
"python-discord/snekbox",
"python-discord/sir-lancebot",
"python-discord/metricity",
- "python-discord/django-simple-bulma",
+ "python-discord/king-arthur",
]
def __init__(self):
@@ -51,9 +51,16 @@ class HomeView(View):
If we're unable to get that info for any reason, return an empty dict.
"""
repo_dict = {}
-
- # Fetch the data from the GitHub API
- api_data: List[dict] = requests.get(self.github_api, headers=self.headers).json()
+ try:
+ # Fetch the data from the GitHub API
+ api_data: List[dict] = requests.get(
+ self.github_api,
+ headers=self.headers,
+ timeout=TIMEOUT_PERIOD
+ ).json()
+ except requests.exceptions.Timeout:
+ log.error("Request to fetch GitHub repository metadata for timed out!")
+ return repo_dict
# Process the API data into our dict
for repo in api_data:
diff --git a/pydis_site/apps/resources/resources/communities/panda3d.yaml b/pydis_site/apps/resources/resources/communities/panda3d.yaml
index 4235793d..47797882 100644
--- a/pydis_site/apps/resources/resources/communities/panda3d.yaml
+++ b/pydis_site/apps/resources/resources/communities/panda3d.yaml
@@ -1,6 +1,6 @@
description: Panda3D is a Python-focused 3-D framework for rapid development of games,
visualizations, and simulations, written in C++ with an emphasis on performance and flexibility.
-title_image: http://www.panda3d.org/wp-content/uploads/2019/01/panda3d_logo.png
+title_image: https://www.panda3d.org/wp-content/uploads/2019/01/panda3d_logo.png
title_url: https://discord.gg/9XsucTT
position: 9
urls:
diff --git a/pydis_site/apps/resources/resources/reading/books/byte_of_python.yaml b/pydis_site/apps/resources/resources/reading/books/byte_of_python.yaml
index 1f9642ad..2530c1a4 100644
--- a/pydis_site/apps/resources/resources/reading/books/byte_of_python.yaml
+++ b/pydis_site/apps/resources/resources/reading/books/byte_of_python.yaml
@@ -8,7 +8,7 @@ urls:
url: https://python.swaroopch.com/
color: teal
- icon: regular/book
- url: http://www.lulu.com/shop/swaroop-c-h/a-byte-of-python/paperback/product-21142968.html
+ url: https://www.lulu.com/shop/swaroop-c-h/a-byte-of-python/paperback/product-21142968.html
color: black
- icon: branding/amazon
url: https://www.amazon.com/Byte-Python-Swaroop-C-H-ebook/dp/B00FJ7S2JU/
diff --git a/pydis_site/apps/resources/resources/reading/books/flask_web_development.yaml b/pydis_site/apps/resources/resources/reading/books/flask_web_development.yaml
index cc83a331..d191f02d 100644
--- a/pydis_site/apps/resources/resources/reading/books/flask_web_development.yaml
+++ b/pydis_site/apps/resources/resources/reading/books/flask_web_development.yaml
@@ -4,7 +4,7 @@ name: Flask Web Development
position: 6
urls:
- icon: regular/link
- url: http://shop.oreilly.com/product/0636920031116.do
+ url: https://shop.oreilly.com/product/0636920031116.do
color: teal
- icon: branding/amazon
url: https://www.amazon.com/Flask-Web-Development-Developing-Applications/dp/1449372627
diff --git a/pydis_site/apps/resources/resources/reading/books/python_cookbook.yaml b/pydis_site/apps/resources/resources/reading/books/python_cookbook.yaml
index 032f8c64..c939ab9e 100644
--- a/pydis_site/apps/resources/resources/reading/books/python_cookbook.yaml
+++ b/pydis_site/apps/resources/resources/reading/books/python_cookbook.yaml
@@ -4,7 +4,7 @@ name: Python Cookbook
position: 8
urls:
- icon: regular/link
- url: http://shop.oreilly.com/product/0636920027072.do
+ url: https://shop.oreilly.com/product/0636920027072.do
color: teal
- icon: branding/amazon
url: https://www.amazon.com/Python-Cookbook-Third-David-Beazley/dp/1449340377
diff --git a/pydis_site/apps/resources/resources/reading/tutorials/simple_guide_to_git.yaml b/pydis_site/apps/resources/resources/reading/tutorials/simple_guide_to_git.yaml
index a505715d..9d151bf9 100644
--- a/pydis_site/apps/resources/resources/reading/tutorials/simple_guide_to_git.yaml
+++ b/pydis_site/apps/resources/resources/reading/tutorials/simple_guide_to_git.yaml
@@ -1,6 +1,6 @@
description: A simple, no-nonsense guide to the basics of using Git.
name: A Simple Guide to Git
-title_url: http://rogerdudler.github.io/git-guide/
+title_url: https://rogerdudler.github.io/git-guide/
title_icon: branding/github
title_icon_color: black
position: 4
diff --git a/pydis_site/apps/resources/resources/videos/microsoft.yaml b/pydis_site/apps/resources/resources/videos/microsoft.yaml
index 720ee202..3ceaa1a2 100644
--- a/pydis_site/apps/resources/resources/videos/microsoft.yaml
+++ b/pydis_site/apps/resources/resources/videos/microsoft.yaml
@@ -7,7 +7,7 @@ description: A trove of tutorials & guides for developers from Microsoft's Devel
</ul>
Microsoft's Python Development Team also runs a Discord Server for discussions of Python in the Microsoft ecosystem,
including Visual Studio Code and Azure.
-title_image: http://img-prod-cms-rt-microsoft-com.akamaized.net/cms/api/am/imageFileData/RE2qVsJ?ver=3f74
+title_image: https://img-prod-cms-rt-microsoft-com.akamaized.net/cms/api/am/imageFileData/RE2qVsJ?ver=3f74
position: 4
urls:
- icon: branding/youtube