diff options
author | 2019-04-13 16:16:11 +0200 | |
---|---|---|
committer | 2019-04-13 16:16:11 +0200 | |
commit | f29472a56f925127a077c4cadcc13fa852dc665b (patch) | |
tree | 34fcafe8e98ab0d9babc87f2118250ecbe697bda /pydis_site | |
parent | Added hrefs for the cards (diff) |
refactoring slightly to use a class-based view, changing home to main. Ready to write the API search stuff now.
Diffstat (limited to 'pydis_site')
-rw-r--r-- | pydis_site/apps/home/views.py | 3 | ||||
-rw-r--r-- | pydis_site/apps/main/__init__.py (renamed from pydis_site/apps/home/__init__.py) | 0 | ||||
-rw-r--r-- | pydis_site/apps/main/admin.py (renamed from pydis_site/apps/home/admin.py) | 0 | ||||
-rw-r--r-- | pydis_site/apps/main/apps.py (renamed from pydis_site/apps/home/apps.py) | 0 | ||||
-rw-r--r-- | pydis_site/apps/main/migrations/__init__.py (renamed from pydis_site/apps/home/migrations/__init__.py) | 0 | ||||
-rw-r--r-- | pydis_site/apps/main/models.py (renamed from pydis_site/apps/home/models.py) | 0 | ||||
-rw-r--r-- | pydis_site/apps/main/templatetags/__init__.py (renamed from pydis_site/apps/home/templatetags/__init__.py) | 0 | ||||
-rw-r--r-- | pydis_site/apps/main/templatetags/extra_filters.py (renamed from pydis_site/apps/home/templatetags/extra_filters.py) | 0 | ||||
-rw-r--r-- | pydis_site/apps/main/tests.py (renamed from pydis_site/apps/home/tests.py) | 0 | ||||
-rw-r--r-- | pydis_site/apps/main/urls.py (renamed from pydis_site/apps/home/urls.py) | 5 | ||||
-rw-r--r-- | pydis_site/apps/main/views/__init__.py | 3 | ||||
-rw-r--r-- | pydis_site/apps/main/views/home.py | 47 | ||||
-rw-r--r-- | pydis_site/apps/wiki/__init__.py | 0 | ||||
-rw-r--r-- | pydis_site/apps/wiki/admin.py | 3 | ||||
-rw-r--r-- | pydis_site/apps/wiki/apps.py | 5 | ||||
-rw-r--r-- | pydis_site/apps/wiki/migrations/__init__.py | 0 | ||||
-rw-r--r-- | pydis_site/apps/wiki/models.py | 3 | ||||
-rw-r--r-- | pydis_site/apps/wiki/tests.py | 3 | ||||
-rw-r--r-- | pydis_site/apps/wiki/views.py | 3 | ||||
-rw-r--r-- | pydis_site/hosts.py | 3 | ||||
-rw-r--r-- | pydis_site/settings.py | 3 | ||||
-rw-r--r-- | pydis_site/urls.py | 2 |
22 files changed, 56 insertions, 27 deletions
diff --git a/pydis_site/apps/home/views.py b/pydis_site/apps/home/views.py deleted file mode 100644 index fd0e0449..00000000 --- a/pydis_site/apps/home/views.py +++ /dev/null @@ -1,3 +0,0 @@ -# from django.shortcuts import render - -# Create your views here. diff --git a/pydis_site/apps/home/__init__.py b/pydis_site/apps/main/__init__.py index e69de29b..e69de29b 100644 --- a/pydis_site/apps/home/__init__.py +++ b/pydis_site/apps/main/__init__.py diff --git a/pydis_site/apps/home/admin.py b/pydis_site/apps/main/admin.py index 4185d360..4185d360 100644 --- a/pydis_site/apps/home/admin.py +++ b/pydis_site/apps/main/admin.py diff --git a/pydis_site/apps/home/apps.py b/pydis_site/apps/main/apps.py index 90dc7137..90dc7137 100644 --- a/pydis_site/apps/home/apps.py +++ b/pydis_site/apps/main/apps.py diff --git a/pydis_site/apps/home/migrations/__init__.py b/pydis_site/apps/main/migrations/__init__.py index e69de29b..e69de29b 100644 --- a/pydis_site/apps/home/migrations/__init__.py +++ b/pydis_site/apps/main/migrations/__init__.py diff --git a/pydis_site/apps/home/models.py b/pydis_site/apps/main/models.py index 0b4331b3..0b4331b3 100644 --- a/pydis_site/apps/home/models.py +++ b/pydis_site/apps/main/models.py diff --git a/pydis_site/apps/home/templatetags/__init__.py b/pydis_site/apps/main/templatetags/__init__.py index e69de29b..e69de29b 100644 --- a/pydis_site/apps/home/templatetags/__init__.py +++ b/pydis_site/apps/main/templatetags/__init__.py diff --git a/pydis_site/apps/home/templatetags/extra_filters.py b/pydis_site/apps/main/templatetags/extra_filters.py index edffe9ac..edffe9ac 100644 --- a/pydis_site/apps/home/templatetags/extra_filters.py +++ b/pydis_site/apps/main/templatetags/extra_filters.py diff --git a/pydis_site/apps/home/tests.py b/pydis_site/apps/main/tests.py index 54fac6e8..54fac6e8 100644 --- a/pydis_site/apps/home/tests.py +++ b/pydis_site/apps/main/tests.py diff --git a/pydis_site/apps/home/urls.py b/pydis_site/apps/main/urls.py index 56525af8..11142040 100644 --- a/pydis_site/apps/home/urls.py +++ b/pydis_site/apps/main/urls.py @@ -1,10 +1,11 @@ from django.contrib import admin from django.urls import path -from django.views.generic import TemplateView + +from .views import Home app_name = 'home' urlpatterns = [ - path('', TemplateView.as_view(template_name='home/index.html'), name='home.index'), + path('', Home.as_view(), name='home.index'), path('admin/', admin.site.urls) ] diff --git a/pydis_site/apps/main/views/__init__.py b/pydis_site/apps/main/views/__init__.py new file mode 100644 index 00000000..ab52894b --- /dev/null +++ b/pydis_site/apps/main/views/__init__.py @@ -0,0 +1,3 @@ +from .home import Home + +__all__ = ["Home"] diff --git a/pydis_site/apps/main/views/home.py b/pydis_site/apps/main/views/home.py new file mode 100644 index 00000000..8f45b912 --- /dev/null +++ b/pydis_site/apps/main/views/home.py @@ -0,0 +1,47 @@ +import requests +from django.shortcuts import render +from django.views import View + + + +class Home(View): + + projects = [ + "site", + "bot", + "snekbox", + "seasonalbot", + "django-simple-bulma", + "django-crispy-bulma", + ] + + def _get_repo_data(self): + """ + This will get language, stars and forks for the projects listed in Home.projects. + + Returns a dictionary with the data, in a template-friendly manner. The rate limit for + this particular endpoint is 30 requests per minute. This should be plenty for now, + but if we ever run into rate limiting issues, we should implement some form of caching + for this data. + """ + + # Gotta authenticate, or we get terrible rate limits. + + # We need to query the Search API https://developer.github.com/v3/search/, using a single + # query to query for all of the projects at the same time, and making sure we cache that data + # and make the request no more often than once per minute or something reasonable + # like that. + + endpoint = "https://api.github.com/search/repositories?q=" + "repo+name+separated+by+pluses" + + # And finally + + + + + + + def get(self, request): + + # Call the GitHub API and ask it for some data + return render(request, "home/index.html", {}) diff --git a/pydis_site/apps/wiki/__init__.py b/pydis_site/apps/wiki/__init__.py deleted file mode 100644 index e69de29b..00000000 --- a/pydis_site/apps/wiki/__init__.py +++ /dev/null diff --git a/pydis_site/apps/wiki/admin.py b/pydis_site/apps/wiki/admin.py deleted file mode 100644 index 4185d360..00000000 --- a/pydis_site/apps/wiki/admin.py +++ /dev/null @@ -1,3 +0,0 @@ -# from django.contrib import admin - -# Register your models here. diff --git a/pydis_site/apps/wiki/apps.py b/pydis_site/apps/wiki/apps.py deleted file mode 100644 index fce4708e..00000000 --- a/pydis_site/apps/wiki/apps.py +++ /dev/null @@ -1,5 +0,0 @@ -from django.apps import AppConfig - - -class WikiConfig(AppConfig): - name = 'wiki' diff --git a/pydis_site/apps/wiki/migrations/__init__.py b/pydis_site/apps/wiki/migrations/__init__.py deleted file mode 100644 index e69de29b..00000000 --- a/pydis_site/apps/wiki/migrations/__init__.py +++ /dev/null diff --git a/pydis_site/apps/wiki/models.py b/pydis_site/apps/wiki/models.py deleted file mode 100644 index 0b4331b3..00000000 --- a/pydis_site/apps/wiki/models.py +++ /dev/null @@ -1,3 +0,0 @@ -# from django.db import models - -# Create your models here. diff --git a/pydis_site/apps/wiki/tests.py b/pydis_site/apps/wiki/tests.py deleted file mode 100644 index a79ca8be..00000000 --- a/pydis_site/apps/wiki/tests.py +++ /dev/null @@ -1,3 +0,0 @@ -# from django.test import TestCase - -# Create your tests here. diff --git a/pydis_site/apps/wiki/views.py b/pydis_site/apps/wiki/views.py deleted file mode 100644 index fd0e0449..00000000 --- a/pydis_site/apps/wiki/views.py +++ /dev/null @@ -1,3 +0,0 @@ -# from django.shortcuts import render - -# Create your views here. diff --git a/pydis_site/hosts.py b/pydis_site/hosts.py index 34acfd09..9e58628c 100644 --- a/pydis_site/hosts.py +++ b/pydis_site/hosts.py @@ -3,8 +3,7 @@ from django_hosts import host, patterns host_patterns = patterns( '', - # host(r"subdomain pattern", "URLs module", "host entry name") host(r'admin', 'pydis_site.apps.admin.urls', name="admin"), host(r'api', 'pydis_site.apps.api.urls', name='api'), - host(r'.*', 'pydis_site.apps.home.urls', name=settings.DEFAULT_HOST) + host(r'.*', 'pydis_site.apps.main.urls', name=settings.DEFAULT_HOST) ) diff --git a/pydis_site/settings.py b/pydis_site/settings.py index 03ad6bc5..4a5b0523 100644 --- a/pydis_site/settings.py +++ b/pydis_site/settings.py @@ -63,8 +63,7 @@ else: INSTALLED_APPS = [ 'pydis_site.apps.api', - 'pydis_site.apps.home', - 'pydis_site.apps.wiki', + 'pydis_site.apps.main', 'django.contrib.admin', 'django.contrib.auth', diff --git a/pydis_site/urls.py b/pydis_site/urls.py index c68375da..e4ef058b 100644 --- a/pydis_site/urls.py +++ b/pydis_site/urls.py @@ -2,5 +2,5 @@ from django.urls import include, path urlpatterns = ( - path('', include('pydis_site.apps.home.urls', namespace='home')), + path('', include('pydis_site.apps.main.urls', namespace='home')), ) |