aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Leon Sandøy <[email protected]>2019-04-20 00:56:18 +0200
committerGravatar Leon Sandøy <[email protected]>2019-04-20 00:56:18 +0200
commit57056c9db8cdb14204702dbb18c5ff02344abe71 (patch)
tree19e46f53619385a2e98b707ee45c0cfbbdc20c09
parentAddressing all comments in volcyy's second review. The tests now mock the API... (diff)
Addressing volcyys third review.
-rwxr-xr-xdocker/app/migrate_and_serve.sh4
-rw-r--r--pydis_site/apps/home/models/repository_metadata.py (renamed from pydis_site/apps/home/models/repo_data.py)0
-rw-r--r--pydis_site/apps/home/views/home.py7
-rw-r--r--pydis_site/templates/home/index.html2
4 files changed, 7 insertions, 6 deletions
diff --git a/docker/app/migrate_and_serve.sh b/docker/app/migrate_and_serve.sh
index 7e60a796..42bf67a3 100755
--- a/docker/app/migrate_and_serve.sh
+++ b/docker/app/migrate_and_serve.sh
@@ -13,8 +13,8 @@ python manage.py migrate --verbosity 1
echo [i] Collecting static files.
python manage.py collectstatic --no-input --clear --verbosity 0
-echo [i] Creating a superuser
-echo "from django.contrib.auth import get_user_model; User = get_user_model(); User.objects.create_superuser('admin', 'admin', 'admin') if not User.objects.filter(username='admin').exists() else print('Username already exists')" | python manage.py shell
+echo [i] Creating a superuser.
+echo "from django.contrib.auth import get_user_model; User = get_user_model(); User.objects.create_superuser('admin', 'admin', 'admin') if not User.objects.filter(username='admin').exists() else print('Admin user already exists')" | python manage.py shell
echo [i] Starting server.
python manage.py runserver 0.0.0.0:8000
diff --git a/pydis_site/apps/home/models/repo_data.py b/pydis_site/apps/home/models/repository_metadata.py
index c975c904..c975c904 100644
--- a/pydis_site/apps/home/models/repo_data.py
+++ b/pydis_site/apps/home/models/repository_metadata.py
diff --git a/pydis_site/apps/home/views/home.py b/pydis_site/apps/home/views/home.py
index c91d13e2..dbd65faf 100644
--- a/pydis_site/apps/home/views/home.py
+++ b/pydis_site/apps/home/views/home.py
@@ -7,9 +7,10 @@ from pydis_site.apps.home.models import RepositoryMetadata
class HomeView(View):
- """The view"""
+ """The main landing page for the website."""
github_api = "https://api.github.com/users/python-discord/repos"
+ repository_cache_ttl = 600
# Which of our GitHub repos should be displayed on the front page, and in which order?
repos = [
@@ -51,8 +52,8 @@ class HomeView(View):
try:
repo_data = RepositoryMetadata.objects.get(repo_name="python-discord/site")
- # If the data is older than 2 minutes, we should refresh it.
- if (timezone.now() - repo_data.last_updated).seconds > 120:
+ # If the data is stale, we should refresh it.
+ if (timezone.now() - repo_data.last_updated).seconds > self.repository_cache_ttl:
# Get new data from API
api_repositories = self._get_api_data()
diff --git a/pydis_site/templates/home/index.html b/pydis_site/templates/home/index.html
index dfb74f96..205e92ff 100644
--- a/pydis_site/templates/home/index.html
+++ b/pydis_site/templates/home/index.html
@@ -52,7 +52,7 @@
<br>
<div class="columns is-multiline">
- {# Display projects from settings.HOMEPAGE_REPOS #}
+ {# Display projects from HomeView.repos #}
{% for repo in repo_data %}
<div class="column is-one-third">
<div class="card has-equal-height github-card">