From ac0643a3b6088df42150f78fb0cf809469710fda Mon Sep 17 00:00:00 2001 From: ks129 <45097959+ks129@users.noreply.github.com> Date: Mon, 26 Oct 2020 19:42:36 +0200 Subject: Create base events page template --- pydis_site/templates/events/base.html | 38 +++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 pydis_site/templates/events/base.html diff --git a/pydis_site/templates/events/base.html b/pydis_site/templates/events/base.html new file mode 100644 index 00000000..4aa5056d --- /dev/null +++ b/pydis_site/templates/events/base.html @@ -0,0 +1,38 @@ +{% extends "base/base.html" %} +{% load static %} + +{% block head %} + +{% endblock %} + +{% block content %} + {% include "base/navbar.html" %} + + + +
+
+
+

{% block title %}{% endblock %}

+
+
+
+ {% block event_content %}{% endblock %} +
+
+ {% block sidebar %}{% endblock %} +
+
+
+
+
+
+{% endblock %} -- cgit v1.2.3 From 57904f2de4e4ee7d6a12e16a0c96fbd58841d268 Mon Sep 17 00:00:00 2001 From: ks129 <45097959+ks129@users.noreply.github.com> Date: Mon, 26 Oct 2020 19:42:51 +0200 Subject: Create index events page template --- pydis_site/templates/events/index.html | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 pydis_site/templates/events/index.html diff --git a/pydis_site/templates/events/index.html b/pydis_site/templates/events/index.html new file mode 100644 index 00000000..5ec8b0ef --- /dev/null +++ b/pydis_site/templates/events/index.html @@ -0,0 +1,17 @@ +{% extends "events/base.html" %} + +{% block title %}Events{% endblock %} + +{% block breadcrumb %} +
  • Events
  • +{% endblock %} + +{% block event_content %} +
    +

    Code Jams

    +

    Each year, we organize a Winter Code Jam and a Summer Code Jam. During these events, members of our community will work together in teams to create something amazing using a technology we picked for them. One such technology that was picked for the Winter Code Jam 2020 was Kivy, a cross-platform GUI framework.

    +

    To help fuel the creative process, we provide a specific theme, like Ancient Technology or This App Hates You. At the end of the Code Jam, the projects are judged by Python Discord server staff members and guest judges from the larger Python community. The judges will consider creativity, code quality, teamwork, and adherence to the theme.

    +

    If you want to read more about Code Jams, visit our Code Jam info page or watch this video showcasing the best projects created during the Winter Code Jam 2020: Ancient Technology:

    + +
    +{% endblock %} -- cgit v1.2.3 From 99f48fb12dced0f011b2be26cbed9d5c451ff0b5 Mon Sep 17 00:00:00 2001 From: ks129 <45097959+ks129@users.noreply.github.com> Date: Mon, 26 Oct 2020 19:43:35 +0200 Subject: Create basic events app --- pydis_site/apps/events/__init__.py | 0 pydis_site/apps/events/apps.py | 7 +++++++ pydis_site/apps/events/migrations/__init__.py | 0 pydis_site/apps/events/tests/__init__.py | 0 pydis_site/apps/events/urls.py | 9 +++++++++ pydis_site/apps/events/views/__init__.py | 4 ++++ 6 files changed, 20 insertions(+) create mode 100644 pydis_site/apps/events/__init__.py create mode 100644 pydis_site/apps/events/apps.py create mode 100644 pydis_site/apps/events/migrations/__init__.py create mode 100644 pydis_site/apps/events/tests/__init__.py create mode 100644 pydis_site/apps/events/urls.py create mode 100644 pydis_site/apps/events/views/__init__.py diff --git a/pydis_site/apps/events/__init__.py b/pydis_site/apps/events/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/pydis_site/apps/events/apps.py b/pydis_site/apps/events/apps.py new file mode 100644 index 00000000..a1cf09ef --- /dev/null +++ b/pydis_site/apps/events/apps.py @@ -0,0 +1,7 @@ +from django.apps import AppConfig + + +class EventsConfig(AppConfig): + """Django AppConfig for events app.""" + + name = 'events' diff --git a/pydis_site/apps/events/migrations/__init__.py b/pydis_site/apps/events/migrations/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/pydis_site/apps/events/tests/__init__.py b/pydis_site/apps/events/tests/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/pydis_site/apps/events/urls.py b/pydis_site/apps/events/urls.py new file mode 100644 index 00000000..52e7cf47 --- /dev/null +++ b/pydis_site/apps/events/urls.py @@ -0,0 +1,9 @@ +from django.urls import path, re_path + +from pydis_site.apps.events.views import IndexView, PageView + +app_name = "events" +urlpatterns = [ + path("", IndexView.as_view(), name="events"), + re_path("(?P.+)/$", PageView.as_view(), name="page"), +] diff --git a/pydis_site/apps/events/views/__init__.py b/pydis_site/apps/events/views/__init__.py new file mode 100644 index 00000000..8a107e2f --- /dev/null +++ b/pydis_site/apps/events/views/__init__.py @@ -0,0 +1,4 @@ +from .index import IndexView +from .page import PageView + +__all__ = ["IndexView", "PageView"] -- cgit v1.2.3 From de8ea5ab30f8653480c3686fe53b877fec52141e Mon Sep 17 00:00:00 2001 From: ks129 <45097959+ks129@users.noreply.github.com> Date: Mon, 26 Oct 2020 19:43:50 +0200 Subject: Add events app to INSTALLED_APPS --- pydis_site/settings.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pydis_site/settings.py b/pydis_site/settings.py index c7c17bb0..f86b04b3 100644 --- a/pydis_site/settings.py +++ b/pydis_site/settings.py @@ -83,6 +83,7 @@ INSTALLED_APPS = [ 'pydis_site.apps.api', 'pydis_site.apps.home', 'pydis_site.apps.staff', + 'pydis_site.apps.events', 'django.contrib.admin', 'django.contrib.auth', -- cgit v1.2.3 From 00d3d1c651e7032828516a35718dbc8d2e78f6a9 Mon Sep 17 00:00:00 2001 From: ks129 <45097959+ks129@users.noreply.github.com> Date: Mon, 26 Oct 2020 19:44:11 +0200 Subject: Include events URLs to home URLs --- pydis_site/apps/home/urls.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pydis_site/apps/home/urls.py b/pydis_site/apps/home/urls.py index 024437f7..c9d2935d 100644 --- a/pydis_site/apps/home/urls.py +++ b/pydis_site/apps/home/urls.py @@ -1,5 +1,5 @@ from django.contrib import admin -from django.urls import path +from django.urls import include, path from .views import HomeView @@ -7,4 +7,5 @@ app_name = 'home' urlpatterns = [ path('', HomeView.as_view(), name='home'), path('admin/', admin.site.urls), + path('events/', include('pydis_site.apps.events.urls', namespace='events')), ] -- cgit v1.2.3 From 2a502d06a251868eb9c2fb41bf736c11182161b8 Mon Sep 17 00:00:00 2001 From: ks129 <45097959+ks129@users.noreply.github.com> Date: Mon, 26 Oct 2020 19:44:27 +0200 Subject: Create CSS file for events pages --- pydis_site/static/css/events/base.css | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 pydis_site/static/css/events/base.css diff --git a/pydis_site/static/css/events/base.css b/pydis_site/static/css/events/base.css new file mode 100644 index 00000000..b4f233f7 --- /dev/null +++ b/pydis_site/static/css/events/base.css @@ -0,0 +1,3 @@ +.breadcrumb-section { + padding: 1rem; +} -- cgit v1.2.3 From f4409406933581afdeddb25a1b7e6ae53629b77f Mon Sep 17 00:00:00 2001 From: ks129 <45097959+ks129@users.noreply.github.com> Date: Mon, 26 Oct 2020 19:44:42 +0200 Subject: Create events index page view --- pydis_site/apps/events/views/index.py | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 pydis_site/apps/events/views/index.py diff --git a/pydis_site/apps/events/views/index.py b/pydis_site/apps/events/views/index.py new file mode 100644 index 00000000..7ffba74a --- /dev/null +++ b/pydis_site/apps/events/views/index.py @@ -0,0 +1,7 @@ +from django.views.generic import TemplateView + + +class IndexView(TemplateView): + """Events index page view.""" + + template_name = "events/index.html" -- cgit v1.2.3 From 9149973c2a846bddf8690cbd392b2f85bfdd217f Mon Sep 17 00:00:00 2001 From: ks129 <45097959+ks129@users.noreply.github.com> Date: Mon, 26 Oct 2020 19:44:54 +0200 Subject: Create event page view --- pydis_site/apps/events/views/page.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 pydis_site/apps/events/views/page.py diff --git a/pydis_site/apps/events/views/page.py b/pydis_site/apps/events/views/page.py new file mode 100644 index 00000000..fe39a98c --- /dev/null +++ b/pydis_site/apps/events/views/page.py @@ -0,0 +1,31 @@ +from pathlib import Path + +from django.conf import settings +from django.core.handlers.wsgi import WSGIRequest +from django.http import Http404, HttpResponse +from django.template import Context, Template +from django.views import View + +PAGES_PATH = Path(settings.BASE_DIR, "pydis_site", "apps", "events", "pages") + + +class PageView(View): + """Handles event pages showing.""" + + def get(self, request: WSGIRequest, path: str) -> HttpResponse: + """Render event page rendering based on path.""" + # We need to get rid from trailing slash when path have this + if path.endswith("/"): + path = path[:-1] + + page_path = PAGES_PATH.joinpath(path) + if page_path.exists() and page_path.is_dir(): + page_path = page_path.joinpath("_index.html") + else: + page_path = PAGES_PATH.joinpath(f"{path}.html") + + if not page_path.exists(): + raise Http404 + + template = Template(page_path.read_text()) + return HttpResponse(template.render(Context())) -- cgit v1.2.3 From 20e8657de0ca222ff0b1bef0f89c899fd8c1139c Mon Sep 17 00:00:00 2001 From: ks129 <45097959+ks129@users.noreply.github.com> Date: Mon, 26 Oct 2020 19:45:17 +0200 Subject: Create testing event pages --- pydis_site/apps/events/tests/test-pages/my-event/_index.html | 1 + pydis_site/apps/events/tests/test-pages/my-event/subpage.html | 1 + 2 files changed, 2 insertions(+) create mode 100644 pydis_site/apps/events/tests/test-pages/my-event/_index.html create mode 100644 pydis_site/apps/events/tests/test-pages/my-event/subpage.html diff --git a/pydis_site/apps/events/tests/test-pages/my-event/_index.html b/pydis_site/apps/events/tests/test-pages/my-event/_index.html new file mode 100644 index 00000000..1a859fdd --- /dev/null +++ b/pydis_site/apps/events/tests/test-pages/my-event/_index.html @@ -0,0 +1 @@ +{% extends "events/base.html" %} diff --git a/pydis_site/apps/events/tests/test-pages/my-event/subpage.html b/pydis_site/apps/events/tests/test-pages/my-event/subpage.html new file mode 100644 index 00000000..1a859fdd --- /dev/null +++ b/pydis_site/apps/events/tests/test-pages/my-event/subpage.html @@ -0,0 +1 @@ +{% extends "events/base.html" %} -- cgit v1.2.3 From adebc8672a1bab47e82fb912f3d1a81dbbd7d876 Mon Sep 17 00:00:00 2001 From: ks129 <45097959+ks129@users.noreply.github.com> Date: Mon, 26 Oct 2020 19:45:37 +0200 Subject: Create tests for event views --- pydis_site/apps/events/tests/test_views.py | 50 ++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 pydis_site/apps/events/tests/test_views.py diff --git a/pydis_site/apps/events/tests/test_views.py b/pydis_site/apps/events/tests/test_views.py new file mode 100644 index 00000000..81f67c08 --- /dev/null +++ b/pydis_site/apps/events/tests/test_views.py @@ -0,0 +1,50 @@ +from pathlib import Path +from unittest.mock import patch + +from django.conf import settings +from django.test import TestCase +from django_hosts.resolvers import reverse + + +PAGES_PATH = Path(settings.BASE_DIR, "pydis_site", "apps", "events", "tests", "test-pages") + + +class IndexTests(TestCase): + def test_events_index_response_200(self): + """Should return response code 200 when visiting index of events.""" + url = reverse("events:events") + resp = self.client.get(url) + self.assertEqual(resp.status_code, 200) + + +class PageTests(TestCase): + @patch("pydis_site.apps.events.views.page.PAGES_PATH", new=PAGES_PATH) + def test_valid_event_page_reponse_200(self): + """Should return response code 200 when visiting valid event page.""" + pages = ( + reverse("events:page", ("my-event",)), + reverse("events:page", ("my-event/subpage",)), + ) + for page in pages: + with self.subTest(page=page): + resp = self.client.get(page) + self.assertEqual(resp.status_code, 200) + + @patch("pydis_site.apps.events.views.page.PAGES_PATH", new=PAGES_PATH) + def test_invalid_event_page_404(self): + """Should return response code 404 when visiting invalid event page.""" + pages = ( + reverse("events:page", ("invalid",)), + reverse("events:page", ("invalid/invalid",)) + ) + for page in pages: + with self.subTest(page=page): + resp = self.client.get(page) + self.assertEqual(resp.status_code, 404) + + @patch("pydis_site.apps.events.views.page.PAGES_PATH") + def test_removing_trailing_slash_from_path(self, path_mock): + """Should remove trailing slash from path when this exists there.""" + url = reverse("events:page", ("this-is-my-event/",)) + self.client.get(url) + path_mock.joinpath.assert_called_with("this-is-my-event") -- cgit v1.2.3 From 6054260adb3ca118f32054336b77e7a9ae784049 Mon Sep 17 00:00:00 2001 From: ks129 <45097959+ks129@users.noreply.github.com> Date: Mon, 26 Oct 2020 19:46:14 +0200 Subject: Create code jams info page with content ToDo! --- pydis_site/apps/events/pages/code-jams/_index.html | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 pydis_site/apps/events/pages/code-jams/_index.html diff --git a/pydis_site/apps/events/pages/code-jams/_index.html b/pydis_site/apps/events/pages/code-jams/_index.html new file mode 100644 index 00000000..5df3807c --- /dev/null +++ b/pydis_site/apps/events/pages/code-jams/_index.html @@ -0,0 +1,5 @@ +{% extends "events/base.html" %} + +{% block event_content %} +

    ToDo!

    +{% endblock %} -- cgit v1.2.3 From ae79506c40b12d044ecda4f0c03ccd110ec99613 Mon Sep 17 00:00:00 2001 From: ks129 <45097959+ks129@users.noreply.github.com> Date: Mon, 26 Oct 2020 19:46:31 +0200 Subject: Create sidebar for summer code jam 2020 pages --- pydis_site/templates/events/sidebar/code-jams/7.html | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 pydis_site/templates/events/sidebar/code-jams/7.html diff --git a/pydis_site/templates/events/sidebar/code-jams/7.html b/pydis_site/templates/events/sidebar/code-jams/7.html new file mode 100644 index 00000000..d4615c2a --- /dev/null +++ b/pydis_site/templates/events/sidebar/code-jams/7.html @@ -0,0 +1,12 @@ +{% load static %} + +
    + Summer Code Jam 2020 + + + Django + + + JetBrains + +
    -- cgit v1.2.3 From 6bfa3fb1a11fa74b8e32dc8d79cbf32fb6768da7 Mon Sep 17 00:00:00 2001 From: ks129 <45097959+ks129@users.noreply.github.com> Date: Mon, 26 Oct 2020 19:46:49 +0200 Subject: Create Summer Code Jam 2020 page --- .../apps/events/pages/code-jams/7/_index.html | 102 +++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 pydis_site/apps/events/pages/code-jams/7/_index.html diff --git a/pydis_site/apps/events/pages/code-jams/7/_index.html b/pydis_site/apps/events/pages/code-jams/7/_index.html new file mode 100644 index 00000000..eb6d10a1 --- /dev/null +++ b/pydis_site/apps/events/pages/code-jams/7/_index.html @@ -0,0 +1,102 @@ +{% extends "events/base.html" %} + +{% block title %}Summer Code Jam 2020{% endblock %} + +{% block breadcrumb %} +
  • Events
  • +
  • Code Jams
  • +
  • Summer Code Jam 2020
  • +{% endblock %} + +{% block event_content %} +

    + Ladies and gentlemen, it’s that time of year again! The 7th Python Discord Code Jam is imminent. + This code jam will be held from Friday, July 31st to Sunday, August 9th + where you will complete in teams of five for the elusive title of Code Jam Champion and win some of the many prizes listed. +

    +

    + Web development is one of the most popular areas for Python software and development. + For this code jam, you will be utilizing the Django framework to create a web application. + The Django Software Foundation has even decided to sponsor this event, + allowing us to add more prizes to our prize pool. +

    +

    + Are you unsure of what a code jam is? If so, check out our general code jam page. +

    + +
    +
    +

    Signups are closed

    +
    + +
    +

    + The sign-up period for the Summer Code Jam 2020 is over, + which means that you can no longer sign up for the Code Jam. + You can still take a look at + the qualifier + to get an idea of the task we asked the participants to complete in order to qualify for the jam. + If you want to compete in the next Code Jam, + subscribe to the announcements posted in our community by using the + !subscribe command in the #bot-commands channel of our server. +

    +
    +
    + +

    New to Django?

    +

    + Don't worry! This code jam will be the perfect opportunity for you to get to know one of the most popular web frameworks for Python. + Whether it be a REST API or full fledged website, Django can do it! +

    +

    + During the event, feel free to ask Django-specific questions in the code jam channels + or #web-development. As always, our helpers will be there to help you with all the + other Python-related questions that you have via our help channel system. +

    +

    + If you want to get familiar with Django before the event starts, be sure to check out the tutorial in the official + Django documentation. Alternatively, you could have a look at Corey Schafer's Django Tutorials playlist on YouTube. +

    + +

    Prizes

    +

    This year's prize pool includes:

    + +

    + We will award as many Python Discord t-shirts as we can afford! + We want to thank all of our Patrons over at our + Patreon account for making this possible. + We literally couldn't do this without you! +

    +

    Qualifier & Signups

    +

    + It is no longer possible to sign up for the Summer Code Jam 2020. + If you would like to attempt the qualifier assignment as a personal challenge, you can find it on + GitHub. + The repository also includes a test suite and a solution. +

    +

    + If you would like to participate in one of our future events and don't want to risk missing it, + subscribe to our announcements by using the !subscribe command in the #bot-commands channel on our Discord server. +

    +

    Theme

    +

    + Similarly to our previous code jams, the theme was chosen by our community! + By the end of our two-step voting process, + Early Internet came out on top and is the official theme for this code jam. +

    +{% endblock %} + +{% block sidebar %} + {% include "events/sidebar/code-jams/7.html" %} +
    + + +
    +{% endblock %} -- cgit v1.2.3 From 739e13f08a99bedf527ffa6c5a5657471c5d73b5 Mon Sep 17 00:00:00 2001 From: ks129 <45097959+ks129@users.noreply.github.com> Date: Mon, 26 Oct 2020 19:46:57 +0200 Subject: Create Summer Code Jam 2020 rules page --- .../apps/events/pages/code-jams/7/rules.html | 68 ++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 pydis_site/apps/events/pages/code-jams/7/rules.html diff --git a/pydis_site/apps/events/pages/code-jams/7/rules.html b/pydis_site/apps/events/pages/code-jams/7/rules.html new file mode 100644 index 00000000..ebdad108 --- /dev/null +++ b/pydis_site/apps/events/pages/code-jams/7/rules.html @@ -0,0 +1,68 @@ +{% extends "events/base.html" %} + +{% block title %}Rules{% endblock %} + +{% block breadcrumb %} +
  • Events
  • +
  • Code Jams
  • +
  • Summer Code Jam 2020
  • +
  • Rules
  • +{% endblock %} + +{% block event_content %} +
      +
    1. Your solution must use the Django framework. It is not permitted to circumvent this rule by e.g. using Django as a wrapper for another framework.

    2. +
    3. Your solution should be platform agnostic. For example, if you use filepaths in your submission, use pathlib to create platform agnostic Path objects instead of hardcoding the paths.

    4. +
    5. Your project should be a web app which can be run in a standard web browser.

    6. +
    7. +

      + You must document precisely how to install and run your project. + This should be as easy as possible, which means you should consider using dependency managers like pipenv, and npm. + We would also encourage you to use docker and docker-compose to containerize your project, but this isn't a requirement. +

      +
    8. +
    9. + You must get contributions from every member of your team, if you have an issue with someone on your team please contact a member of the administration team. + These contributions do not necessarily have to be code, for example it's absolutely fine for someone to contribute management, documentation, graphics or audio. + + Team members that do not contribute will be removed from the Code Jam, and will not receive their share of any prizes the team may win. + They may also be barred from entering future events. + +
    10. +
    11. You must use GitHub as source control.

    12. +
    13. +

      + All code and assets must be compatible with the MIT license. + This is because we will be merging your submission into our summer-code-jam-2020 repo at the end of the jam, + and this repo is licensed with the MIT license. + Projects that include assets that are incompatible with this license may be disqualified. +

      +
    14. +
    15. All code must be written and committed within the time constrictions of the jam. Late commits may be reverted, so make sure you leave enough time to bug test your program.

    16. +
    17. +

      + Use English as the main language for your project, including names, comments, documentation, and commit messages. + The text displayed in your web application should also be in English, + although you are allowed to provide the user with options for internationalisation and translation. +

      +
    18. +
    + + +
    + Please note that our regular + community rules and code of conduct + also apply during the event and that we reserve the right to make changes to these rules at any time. +
    +{% endblock %} + +{% block sidebar %} + {% include "events/sidebar/code-jams/7.html" %} +
    + + +
    +{% endblock %} -- cgit v1.2.3 From 7642d2137de0a0c230c89f33005509f349ad23b4 Mon Sep 17 00:00:00 2001 From: ks129 <45097959+ks129@users.noreply.github.com> Date: Wed, 28 Oct 2020 20:21:30 +0200 Subject: Rename events index page from events -> index --- pydis_site/apps/events/tests/test_views.py | 2 +- pydis_site/apps/events/urls.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pydis_site/apps/events/tests/test_views.py b/pydis_site/apps/events/tests/test_views.py index 81f67c08..9561255f 100644 --- a/pydis_site/apps/events/tests/test_views.py +++ b/pydis_site/apps/events/tests/test_views.py @@ -12,7 +12,7 @@ PAGES_PATH = Path(settings.BASE_DIR, "pydis_site", "apps", "events", "tests", "t class IndexTests(TestCase): def test_events_index_response_200(self): """Should return response code 200 when visiting index of events.""" - url = reverse("events:events") + url = reverse("events:index") resp = self.client.get(url) self.assertEqual(resp.status_code, 200) diff --git a/pydis_site/apps/events/urls.py b/pydis_site/apps/events/urls.py index 52e7cf47..f55835a4 100644 --- a/pydis_site/apps/events/urls.py +++ b/pydis_site/apps/events/urls.py @@ -4,6 +4,6 @@ from pydis_site.apps.events.views import IndexView, PageView app_name = "events" urlpatterns = [ - path("", IndexView.as_view(), name="events"), + path("", IndexView.as_view(), name="index"), re_path("(?P.+)/$", PageView.as_view(), name="page"), ] -- cgit v1.2.3 From 1a42b4e0ab2728abe8ea6765c601eeccf5317214 Mon Sep 17 00:00:00 2001 From: ks129 <45097959+ks129@users.noreply.github.com> Date: Wed, 28 Oct 2020 20:27:56 +0200 Subject: Use URL tag instead manually writing URL --- pydis_site/apps/events/pages/code-jams/7/_index.html | 4 ++-- pydis_site/apps/events/pages/code-jams/7/rules.html | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pydis_site/apps/events/pages/code-jams/7/_index.html b/pydis_site/apps/events/pages/code-jams/7/_index.html index eb6d10a1..d69d0a9e 100644 --- a/pydis_site/apps/events/pages/code-jams/7/_index.html +++ b/pydis_site/apps/events/pages/code-jams/7/_index.html @@ -3,8 +3,8 @@ {% block title %}Summer Code Jam 2020{% endblock %} {% block breadcrumb %} -
  • Events
  • -
  • Code Jams
  • +
  • Events
  • +
  • Code Jams
  • Summer Code Jam 2020
  • {% endblock %} diff --git a/pydis_site/apps/events/pages/code-jams/7/rules.html b/pydis_site/apps/events/pages/code-jams/7/rules.html index ebdad108..b490551a 100644 --- a/pydis_site/apps/events/pages/code-jams/7/rules.html +++ b/pydis_site/apps/events/pages/code-jams/7/rules.html @@ -3,9 +3,9 @@ {% block title %}Rules{% endblock %} {% block breadcrumb %} -
  • Events
  • -
  • Code Jams
  • -
  • Summer Code Jam 2020
  • +
  • Events
  • +
  • Code Jams
  • +
  • Summer Code Jam 2020
  • Rules
  • {% endblock %} -- cgit v1.2.3 From 78c8a0a0afc479e681af13bd9bb2a1afed3489dc Mon Sep 17 00:00:00 2001 From: ks129 <45097959+ks129@users.noreply.github.com> Date: Wed, 28 Oct 2020 20:30:48 +0200 Subject: Use path converter for event page path argument --- pydis_site/apps/events/urls.py | 4 ++-- pydis_site/apps/events/views/page.py | 4 ---- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/pydis_site/apps/events/urls.py b/pydis_site/apps/events/urls.py index f55835a4..9a65cf1f 100644 --- a/pydis_site/apps/events/urls.py +++ b/pydis_site/apps/events/urls.py @@ -1,9 +1,9 @@ -from django.urls import path, re_path +from django.urls import path from pydis_site.apps.events.views import IndexView, PageView app_name = "events" urlpatterns = [ path("", IndexView.as_view(), name="index"), - re_path("(?P.+)/$", PageView.as_view(), name="page"), + path("/", PageView.as_view(), name="page"), ] diff --git a/pydis_site/apps/events/views/page.py b/pydis_site/apps/events/views/page.py index fe39a98c..8a99ce13 100644 --- a/pydis_site/apps/events/views/page.py +++ b/pydis_site/apps/events/views/page.py @@ -14,10 +14,6 @@ class PageView(View): def get(self, request: WSGIRequest, path: str) -> HttpResponse: """Render event page rendering based on path.""" - # We need to get rid from trailing slash when path have this - if path.endswith("/"): - path = path[:-1] - page_path = PAGES_PATH.joinpath(path) if page_path.exists() and page_path.is_dir(): page_path = page_path.joinpath("_index.html") -- cgit v1.2.3 From f7dc1a863a195756eb9ad148478f8b2bd42dbebe Mon Sep 17 00:00:00 2001 From: ks129 <45097959+ks129@users.noreply.github.com> Date: Wed, 28 Oct 2020 20:40:27 +0200 Subject: Port View to TemplateView for events page view --- pydis_site/apps/events/views/page.py | 22 +++++++++++----------- pydis_site/settings.py | 5 ++++- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/pydis_site/apps/events/views/page.py b/pydis_site/apps/events/views/page.py index 8a99ce13..1e3532f9 100644 --- a/pydis_site/apps/events/views/page.py +++ b/pydis_site/apps/events/views/page.py @@ -1,27 +1,27 @@ from pathlib import Path +from typing import List from django.conf import settings -from django.core.handlers.wsgi import WSGIRequest -from django.http import Http404, HttpResponse -from django.template import Context, Template -from django.views import View +from django.http import Http404 +from django.views.generic import TemplateView PAGES_PATH = Path(settings.BASE_DIR, "pydis_site", "apps", "events", "pages") -class PageView(View): +class PageView(TemplateView): """Handles event pages showing.""" - def get(self, request: WSGIRequest, path: str) -> HttpResponse: - """Render event page rendering based on path.""" - page_path = PAGES_PATH.joinpath(path) + def get_template_names(self) -> List[str]: + """Get specific template names""" + page_path = PAGES_PATH / self.kwargs['path'] if page_path.exists() and page_path.is_dir(): page_path = page_path.joinpath("_index.html") + self.kwargs['path'] = f"{self.kwargs['path']}/_index.html" else: - page_path = PAGES_PATH.joinpath(f"{path}.html") + page_path = PAGES_PATH.joinpath(f"{self.kwargs['path']}.html") + self.kwargs['path'] = f"{self.kwargs['path']}.html" if not page_path.exists(): raise Http404 - template = Template(page_path.read_text()) - return HttpResponse(template.render(Context())) + return [self.kwargs['path']] diff --git a/pydis_site/settings.py b/pydis_site/settings.py index a73ac463..0387567f 100644 --- a/pydis_site/settings.py +++ b/pydis_site/settings.py @@ -120,7 +120,10 @@ ROOT_URLCONF = 'pydis_site.urls' TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', - 'DIRS': [os.path.join(BASE_DIR, 'pydis_site', 'templates')], + 'DIRS': [ + os.path.join(BASE_DIR, 'pydis_site', 'templates'), + os.path.join(BASE_DIR, 'pydis_site', 'apps', 'events', 'pages'), + ], 'APP_DIRS': True, 'OPTIONS': { 'builtins': [ -- cgit v1.2.3 From 3a8d3fb31f32ea55dab2b3636613ca735db8c958 Mon Sep 17 00:00:00 2001 From: ks129 <45097959+ks129@users.noreply.github.com> Date: Thu, 29 Oct 2020 20:07:11 +0200 Subject: Move events pages to templates folder --- .../apps/events/pages/code-jams/7/_index.html | 102 --------------------- .../apps/events/pages/code-jams/7/rules.html | 68 -------------- pydis_site/apps/events/pages/code-jams/_index.html | 5 - .../events/tests/test-pages/my-event/_index.html | 1 - .../events/tests/test-pages/my-event/subpage.html | 1 - .../templates/events/pages/code-jams/7/_index.html | 102 +++++++++++++++++++++ .../templates/events/pages/code-jams/7/rules.html | 68 ++++++++++++++ .../templates/events/pages/code-jams/_index.html | 5 + .../events/test-pages/my-event/_index.html | 1 + .../events/test-pages/my-event/subpage.html | 1 + 10 files changed, 177 insertions(+), 177 deletions(-) delete mode 100644 pydis_site/apps/events/pages/code-jams/7/_index.html delete mode 100644 pydis_site/apps/events/pages/code-jams/7/rules.html delete mode 100644 pydis_site/apps/events/pages/code-jams/_index.html delete mode 100644 pydis_site/apps/events/tests/test-pages/my-event/_index.html delete mode 100644 pydis_site/apps/events/tests/test-pages/my-event/subpage.html create mode 100644 pydis_site/templates/events/pages/code-jams/7/_index.html create mode 100644 pydis_site/templates/events/pages/code-jams/7/rules.html create mode 100644 pydis_site/templates/events/pages/code-jams/_index.html create mode 100644 pydis_site/templates/events/test-pages/my-event/_index.html create mode 100644 pydis_site/templates/events/test-pages/my-event/subpage.html diff --git a/pydis_site/apps/events/pages/code-jams/7/_index.html b/pydis_site/apps/events/pages/code-jams/7/_index.html deleted file mode 100644 index d69d0a9e..00000000 --- a/pydis_site/apps/events/pages/code-jams/7/_index.html +++ /dev/null @@ -1,102 +0,0 @@ -{% extends "events/base.html" %} - -{% block title %}Summer Code Jam 2020{% endblock %} - -{% block breadcrumb %} -
  • Events
  • -
  • Code Jams
  • -
  • Summer Code Jam 2020
  • -{% endblock %} - -{% block event_content %} -

    - Ladies and gentlemen, it’s that time of year again! The 7th Python Discord Code Jam is imminent. - This code jam will be held from Friday, July 31st to Sunday, August 9th - where you will complete in teams of five for the elusive title of Code Jam Champion and win some of the many prizes listed. -

    -

    - Web development is one of the most popular areas for Python software and development. - For this code jam, you will be utilizing the Django framework to create a web application. - The Django Software Foundation has even decided to sponsor this event, - allowing us to add more prizes to our prize pool. -

    -

    - Are you unsure of what a code jam is? If so, check out our general code jam page. -

    - -
    -
    -

    Signups are closed

    -
    - -
    -

    - The sign-up period for the Summer Code Jam 2020 is over, - which means that you can no longer sign up for the Code Jam. - You can still take a look at - the qualifier - to get an idea of the task we asked the participants to complete in order to qualify for the jam. - If you want to compete in the next Code Jam, - subscribe to the announcements posted in our community by using the - !subscribe command in the #bot-commands channel of our server. -

    -
    -
    - -

    New to Django?

    -

    - Don't worry! This code jam will be the perfect opportunity for you to get to know one of the most popular web frameworks for Python. - Whether it be a REST API or full fledged website, Django can do it! -

    -

    - During the event, feel free to ask Django-specific questions in the code jam channels - or #web-development. As always, our helpers will be there to help you with all the - other Python-related questions that you have via our help channel system. -

    -

    - If you want to get familiar with Django before the event starts, be sure to check out the tutorial in the official - Django documentation. Alternatively, you could have a look at Corey Schafer's Django Tutorials playlist on YouTube. -

    - -

    Prizes

    -

    This year's prize pool includes:

    -
      -
    • 5 JetBrains 1-year any product licenses
    • -
    • 5 Django hoodies
    • -
    • Python Discord t-shirts
    • -
    -

    - We will award as many Python Discord t-shirts as we can afford! - We want to thank all of our Patrons over at our - Patreon account for making this possible. - We literally couldn't do this without you! -

    -

    Qualifier & Signups

    -

    - It is no longer possible to sign up for the Summer Code Jam 2020. - If you would like to attempt the qualifier assignment as a personal challenge, you can find it on - GitHub. - The repository also includes a test suite and a solution. -

    -

    - If you would like to participate in one of our future events and don't want to risk missing it, - subscribe to our announcements by using the !subscribe command in the #bot-commands channel on our Discord server. -

    -

    Theme

    -

    - Similarly to our previous code jams, the theme was chosen by our community! - By the end of our two-step voting process, - Early Internet came out on top and is the official theme for this code jam. -

    -{% endblock %} - -{% block sidebar %} - {% include "events/sidebar/code-jams/7.html" %} -
    - - -
    -{% endblock %} diff --git a/pydis_site/apps/events/pages/code-jams/7/rules.html b/pydis_site/apps/events/pages/code-jams/7/rules.html deleted file mode 100644 index b490551a..00000000 --- a/pydis_site/apps/events/pages/code-jams/7/rules.html +++ /dev/null @@ -1,68 +0,0 @@ -{% extends "events/base.html" %} - -{% block title %}Rules{% endblock %} - -{% block breadcrumb %} -
  • Events
  • -
  • Code Jams
  • -
  • Summer Code Jam 2020
  • -
  • Rules
  • -{% endblock %} - -{% block event_content %} -
      -
    1. Your solution must use the Django framework. It is not permitted to circumvent this rule by e.g. using Django as a wrapper for another framework.

    2. -
    3. Your solution should be platform agnostic. For example, if you use filepaths in your submission, use pathlib to create platform agnostic Path objects instead of hardcoding the paths.

    4. -
    5. Your project should be a web app which can be run in a standard web browser.

    6. -
    7. -

      - You must document precisely how to install and run your project. - This should be as easy as possible, which means you should consider using dependency managers like pipenv, and npm. - We would also encourage you to use docker and docker-compose to containerize your project, but this isn't a requirement. -

      -
    8. -
    9. - You must get contributions from every member of your team, if you have an issue with someone on your team please contact a member of the administration team. - These contributions do not necessarily have to be code, for example it's absolutely fine for someone to contribute management, documentation, graphics or audio. - - Team members that do not contribute will be removed from the Code Jam, and will not receive their share of any prizes the team may win. - They may also be barred from entering future events. - -
    10. -
    11. You must use GitHub as source control.

    12. -
    13. -

      - All code and assets must be compatible with the MIT license. - This is because we will be merging your submission into our summer-code-jam-2020 repo at the end of the jam, - and this repo is licensed with the MIT license. - Projects that include assets that are incompatible with this license may be disqualified. -

      -
    14. -
    15. All code must be written and committed within the time constrictions of the jam. Late commits may be reverted, so make sure you leave enough time to bug test your program.

    16. -
    17. -

      - Use English as the main language for your project, including names, comments, documentation, and commit messages. - The text displayed in your web application should also be in English, - although you are allowed to provide the user with options for internationalisation and translation. -

      -
    18. -
    - - -
    - Please note that our regular - community rules and code of conduct - also apply during the event and that we reserve the right to make changes to these rules at any time. -
    -{% endblock %} - -{% block sidebar %} - {% include "events/sidebar/code-jams/7.html" %} -
    - - -
    -{% endblock %} diff --git a/pydis_site/apps/events/pages/code-jams/_index.html b/pydis_site/apps/events/pages/code-jams/_index.html deleted file mode 100644 index 5df3807c..00000000 --- a/pydis_site/apps/events/pages/code-jams/_index.html +++ /dev/null @@ -1,5 +0,0 @@ -{% extends "events/base.html" %} - -{% block event_content %} -

    ToDo!

    -{% endblock %} diff --git a/pydis_site/apps/events/tests/test-pages/my-event/_index.html b/pydis_site/apps/events/tests/test-pages/my-event/_index.html deleted file mode 100644 index 1a859fdd..00000000 --- a/pydis_site/apps/events/tests/test-pages/my-event/_index.html +++ /dev/null @@ -1 +0,0 @@ -{% extends "events/base.html" %} diff --git a/pydis_site/apps/events/tests/test-pages/my-event/subpage.html b/pydis_site/apps/events/tests/test-pages/my-event/subpage.html deleted file mode 100644 index 1a859fdd..00000000 --- a/pydis_site/apps/events/tests/test-pages/my-event/subpage.html +++ /dev/null @@ -1 +0,0 @@ -{% extends "events/base.html" %} diff --git a/pydis_site/templates/events/pages/code-jams/7/_index.html b/pydis_site/templates/events/pages/code-jams/7/_index.html new file mode 100644 index 00000000..d69d0a9e --- /dev/null +++ b/pydis_site/templates/events/pages/code-jams/7/_index.html @@ -0,0 +1,102 @@ +{% extends "events/base.html" %} + +{% block title %}Summer Code Jam 2020{% endblock %} + +{% block breadcrumb %} +
  • Events
  • +
  • Code Jams
  • +
  • Summer Code Jam 2020
  • +{% endblock %} + +{% block event_content %} +

    + Ladies and gentlemen, it’s that time of year again! The 7th Python Discord Code Jam is imminent. + This code jam will be held from Friday, July 31st to Sunday, August 9th + where you will complete in teams of five for the elusive title of Code Jam Champion and win some of the many prizes listed. +

    +

    + Web development is one of the most popular areas for Python software and development. + For this code jam, you will be utilizing the Django framework to create a web application. + The Django Software Foundation has even decided to sponsor this event, + allowing us to add more prizes to our prize pool. +

    +

    + Are you unsure of what a code jam is? If so, check out our general code jam page. +

    + +
    +
    +

    Signups are closed

    +
    + +
    +

    + The sign-up period for the Summer Code Jam 2020 is over, + which means that you can no longer sign up for the Code Jam. + You can still take a look at + the qualifier + to get an idea of the task we asked the participants to complete in order to qualify for the jam. + If you want to compete in the next Code Jam, + subscribe to the announcements posted in our community by using the + !subscribe command in the #bot-commands channel of our server. +

    +
    +
    + +

    New to Django?

    +

    + Don't worry! This code jam will be the perfect opportunity for you to get to know one of the most popular web frameworks for Python. + Whether it be a REST API or full fledged website, Django can do it! +

    +

    + During the event, feel free to ask Django-specific questions in the code jam channels + or #web-development. As always, our helpers will be there to help you with all the + other Python-related questions that you have via our help channel system. +

    +

    + If you want to get familiar with Django before the event starts, be sure to check out the tutorial in the official + Django documentation. Alternatively, you could have a look at Corey Schafer's Django Tutorials playlist on YouTube. +

    + +

    Prizes

    +

    This year's prize pool includes:

    +
      +
    • 5 JetBrains 1-year any product licenses
    • +
    • 5 Django hoodies
    • +
    • Python Discord t-shirts
    • +
    +

    + We will award as many Python Discord t-shirts as we can afford! + We want to thank all of our Patrons over at our + Patreon account for making this possible. + We literally couldn't do this without you! +

    +

    Qualifier & Signups

    +

    + It is no longer possible to sign up for the Summer Code Jam 2020. + If you would like to attempt the qualifier assignment as a personal challenge, you can find it on + GitHub. + The repository also includes a test suite and a solution. +

    +

    + If you would like to participate in one of our future events and don't want to risk missing it, + subscribe to our announcements by using the !subscribe command in the #bot-commands channel on our Discord server. +

    +

    Theme

    +

    + Similarly to our previous code jams, the theme was chosen by our community! + By the end of our two-step voting process, + Early Internet came out on top and is the official theme for this code jam. +

    +{% endblock %} + +{% block sidebar %} + {% include "events/sidebar/code-jams/7.html" %} +
    + + +
    +{% endblock %} diff --git a/pydis_site/templates/events/pages/code-jams/7/rules.html b/pydis_site/templates/events/pages/code-jams/7/rules.html new file mode 100644 index 00000000..b490551a --- /dev/null +++ b/pydis_site/templates/events/pages/code-jams/7/rules.html @@ -0,0 +1,68 @@ +{% extends "events/base.html" %} + +{% block title %}Rules{% endblock %} + +{% block breadcrumb %} +
  • Events
  • +
  • Code Jams
  • +
  • Summer Code Jam 2020
  • +
  • Rules
  • +{% endblock %} + +{% block event_content %} +
      +
    1. Your solution must use the Django framework. It is not permitted to circumvent this rule by e.g. using Django as a wrapper for another framework.

    2. +
    3. Your solution should be platform agnostic. For example, if you use filepaths in your submission, use pathlib to create platform agnostic Path objects instead of hardcoding the paths.

    4. +
    5. Your project should be a web app which can be run in a standard web browser.

    6. +
    7. +

      + You must document precisely how to install and run your project. + This should be as easy as possible, which means you should consider using dependency managers like pipenv, and npm. + We would also encourage you to use docker and docker-compose to containerize your project, but this isn't a requirement. +

      +
    8. +
    9. + You must get contributions from every member of your team, if you have an issue with someone on your team please contact a member of the administration team. + These contributions do not necessarily have to be code, for example it's absolutely fine for someone to contribute management, documentation, graphics or audio. + + Team members that do not contribute will be removed from the Code Jam, and will not receive their share of any prizes the team may win. + They may also be barred from entering future events. + +
    10. +
    11. You must use GitHub as source control.

    12. +
    13. +

      + All code and assets must be compatible with the MIT license. + This is because we will be merging your submission into our summer-code-jam-2020 repo at the end of the jam, + and this repo is licensed with the MIT license. + Projects that include assets that are incompatible with this license may be disqualified. +

      +
    14. +
    15. All code must be written and committed within the time constrictions of the jam. Late commits may be reverted, so make sure you leave enough time to bug test your program.

    16. +
    17. +

      + Use English as the main language for your project, including names, comments, documentation, and commit messages. + The text displayed in your web application should also be in English, + although you are allowed to provide the user with options for internationalisation and translation. +

      +
    18. +
    + + +
    + Please note that our regular + community rules and code of conduct + also apply during the event and that we reserve the right to make changes to these rules at any time. +
    +{% endblock %} + +{% block sidebar %} + {% include "events/sidebar/code-jams/7.html" %} +
    + + +
    +{% endblock %} diff --git a/pydis_site/templates/events/pages/code-jams/_index.html b/pydis_site/templates/events/pages/code-jams/_index.html new file mode 100644 index 00000000..5df3807c --- /dev/null +++ b/pydis_site/templates/events/pages/code-jams/_index.html @@ -0,0 +1,5 @@ +{% extends "events/base.html" %} + +{% block event_content %} +

    ToDo!

    +{% endblock %} diff --git a/pydis_site/templates/events/test-pages/my-event/_index.html b/pydis_site/templates/events/test-pages/my-event/_index.html new file mode 100644 index 00000000..1a859fdd --- /dev/null +++ b/pydis_site/templates/events/test-pages/my-event/_index.html @@ -0,0 +1 @@ +{% extends "events/base.html" %} diff --git a/pydis_site/templates/events/test-pages/my-event/subpage.html b/pydis_site/templates/events/test-pages/my-event/subpage.html new file mode 100644 index 00000000..1a859fdd --- /dev/null +++ b/pydis_site/templates/events/test-pages/my-event/subpage.html @@ -0,0 +1 @@ +{% extends "events/base.html" %} -- cgit v1.2.3 From 3f9e84876363602f6caa3c760152c50cb21e9a79 Mon Sep 17 00:00:00 2001 From: ks129 <45097959+ks129@users.noreply.github.com> Date: Thu, 29 Oct 2020 20:07:28 +0200 Subject: Fix resources pre-commit --- pydis_site/apps/resources/views/resources.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pydis_site/apps/resources/views/resources.py b/pydis_site/apps/resources/views/resources.py index e770954b..25ce3e50 100644 --- a/pydis_site/apps/resources/views/resources.py +++ b/pydis_site/apps/resources/views/resources.py @@ -1,6 +1,6 @@ from django.views.generic import TemplateView - + class ResourcesView(TemplateView): """View for resources index page.""" -- cgit v1.2.3 From e588e7476671475583dbc00cd1db81c9d73415f2 Mon Sep 17 00:00:00 2001 From: ks129 <45097959+ks129@users.noreply.github.com> Date: Thu, 29 Oct 2020 20:07:56 +0200 Subject: Apply changes of pages location to views and settings --- pydis_site/apps/events/tests/test_views.py | 16 ++++------------ pydis_site/apps/events/views/page.py | 15 ++++++--------- pydis_site/settings.py | 9 +++++---- 3 files changed, 15 insertions(+), 25 deletions(-) diff --git a/pydis_site/apps/events/tests/test_views.py b/pydis_site/apps/events/tests/test_views.py index 9561255f..0db0ef9a 100644 --- a/pydis_site/apps/events/tests/test_views.py +++ b/pydis_site/apps/events/tests/test_views.py @@ -1,12 +1,11 @@ from pathlib import Path -from unittest.mock import patch from django.conf import settings -from django.test import TestCase +from django.test import TestCase, override_settings from django_hosts.resolvers import reverse -PAGES_PATH = Path(settings.BASE_DIR, "pydis_site", "apps", "events", "tests", "test-pages") +PAGES_PATH = Path(settings.BASE_DIR, "pydis_site", "templates", "events", "test-pages") class IndexTests(TestCase): @@ -18,7 +17,7 @@ class IndexTests(TestCase): class PageTests(TestCase): - @patch("pydis_site.apps.events.views.page.PAGES_PATH", new=PAGES_PATH) + @override_settings(PAGES_PATH=PAGES_PATH) def test_valid_event_page_reponse_200(self): """Should return response code 200 when visiting valid event page.""" pages = ( @@ -30,7 +29,7 @@ class PageTests(TestCase): resp = self.client.get(page) self.assertEqual(resp.status_code, 200) - @patch("pydis_site.apps.events.views.page.PAGES_PATH", new=PAGES_PATH) + @override_settings(PAGES_PATH=PAGES_PATH) def test_invalid_event_page_404(self): """Should return response code 404 when visiting invalid event page.""" pages = ( @@ -41,10 +40,3 @@ class PageTests(TestCase): with self.subTest(page=page): resp = self.client.get(page) self.assertEqual(resp.status_code, 404) - - @patch("pydis_site.apps.events.views.page.PAGES_PATH") - def test_removing_trailing_slash_from_path(self, path_mock): - """Should remove trailing slash from path when this exists there.""" - url = reverse("events:page", ("this-is-my-event/",)) - self.client.get(url) - path_mock.joinpath.assert_called_with("this-is-my-event") diff --git a/pydis_site/apps/events/views/page.py b/pydis_site/apps/events/views/page.py index 1e3532f9..d3dcdf3f 100644 --- a/pydis_site/apps/events/views/page.py +++ b/pydis_site/apps/events/views/page.py @@ -1,27 +1,24 @@ -from pathlib import Path from typing import List from django.conf import settings from django.http import Http404 from django.views.generic import TemplateView -PAGES_PATH = Path(settings.BASE_DIR, "pydis_site", "apps", "events", "pages") - class PageView(TemplateView): """Handles event pages showing.""" def get_template_names(self) -> List[str]: - """Get specific template names""" - page_path = PAGES_PATH / self.kwargs['path'] - if page_path.exists() and page_path.is_dir(): - page_path = page_path.joinpath("_index.html") + """Get specific template names.""" + page_path = settings.PAGES_PATH / self.kwargs['path'] + if page_path.is_dir(): + page_path = page_path / "_index.html" self.kwargs['path'] = f"{self.kwargs['path']}/_index.html" else: - page_path = PAGES_PATH.joinpath(f"{self.kwargs['path']}.html") + page_path = settings.PAGES_PATH / f"{self.kwargs['path']}.html" self.kwargs['path'] = f"{self.kwargs['path']}.html" if not page_path.exists(): raise Http404 - return [self.kwargs['path']] + return [f"events/{settings.PAGES_PATH.name}/{self.kwargs['path']}"] diff --git a/pydis_site/settings.py b/pydis_site/settings.py index 0387567f..67afdbcb 100644 --- a/pydis_site/settings.py +++ b/pydis_site/settings.py @@ -13,6 +13,7 @@ https://docs.djangoproject.com/en/2.1/ref/settings/ import os import secrets import sys +from pathlib import Path import environ import sentry_sdk @@ -117,13 +118,13 @@ MIDDLEWARE = [ ] ROOT_URLCONF = 'pydis_site.urls' +# Path for events pages +PAGES_PATH = Path(BASE_DIR, "pydis_site", "templates", "events", "pages") + TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', - 'DIRS': [ - os.path.join(BASE_DIR, 'pydis_site', 'templates'), - os.path.join(BASE_DIR, 'pydis_site', 'apps', 'events', 'pages'), - ], + 'DIRS': [os.path.join(BASE_DIR, 'pydis_site', 'templates')], 'APP_DIRS': True, 'OPTIONS': { 'builtins': [ -- cgit v1.2.3 From ce70ac3aba5c5123bc72f9272ce74d2c258d311f Mon Sep 17 00:00:00 2001 From: ks129 <45097959+ks129@users.noreply.github.com> Date: Sun, 8 Nov 2020 18:58:53 +0200 Subject: Fix missing URL tag in events index page Co-authored-by: Jeremiah Boby --- pydis_site/templates/events/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pydis_site/templates/events/index.html b/pydis_site/templates/events/index.html index 5ec8b0ef..72a47557 100644 --- a/pydis_site/templates/events/index.html +++ b/pydis_site/templates/events/index.html @@ -11,7 +11,7 @@

    Code Jams

    Each year, we organize a Winter Code Jam and a Summer Code Jam. During these events, members of our community will work together in teams to create something amazing using a technology we picked for them. One such technology that was picked for the Winter Code Jam 2020 was Kivy, a cross-platform GUI framework.

    To help fuel the creative process, we provide a specific theme, like Ancient Technology or This App Hates You. At the end of the Code Jam, the projects are judged by Python Discord server staff members and guest judges from the larger Python community. The judges will consider creativity, code quality, teamwork, and adherence to the theme.

    -

    If you want to read more about Code Jams, visit our Code Jam info page or watch this video showcasing the best projects created during the Winter Code Jam 2020: Ancient Technology:

    +

    If you want to read more about Code Jams, visit our Code Jam info page or watch this video showcasing the best projects created during the Winter Code Jam 2020: Ancient Technology:

    {% endblock %} -- cgit v1.2.3 From fcfcdd5463602eaedfe3ee13c45da248b1296923 Mon Sep 17 00:00:00 2001 From: ks129 <45097959+ks129@users.noreply.github.com> Date: Sun, 8 Nov 2020 19:05:06 +0200 Subject: Use path in variable instead getting it every time in kwargs --- pydis_site/apps/events/views/page.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/pydis_site/apps/events/views/page.py b/pydis_site/apps/events/views/page.py index d3dcdf3f..89b03c1f 100644 --- a/pydis_site/apps/events/views/page.py +++ b/pydis_site/apps/events/views/page.py @@ -10,15 +10,16 @@ class PageView(TemplateView): def get_template_names(self) -> List[str]: """Get specific template names.""" - page_path = settings.PAGES_PATH / self.kwargs['path'] + path: str = self.kwargs['path'] + page_path = settings.PAGES_PATH / path if page_path.is_dir(): page_path = page_path / "_index.html" - self.kwargs['path'] = f"{self.kwargs['path']}/_index.html" + path = f"{path}/_index.html" else: - page_path = settings.PAGES_PATH / f"{self.kwargs['path']}.html" - self.kwargs['path'] = f"{self.kwargs['path']}.html" + page_path = settings.PAGES_PATH / f"{path}.html" + path = f"{path}.html" if not page_path.exists(): raise Http404 - return [f"events/{settings.PAGES_PATH.name}/{self.kwargs['path']}"] + return [f"events/{settings.PAGES_PATH.name}/path}"] -- cgit v1.2.3 From a29896d221626206d904203b2c8ce3d7558e4456 Mon Sep 17 00:00:00 2001 From: ks129 <45097959+ks129@users.noreply.github.com> Date: Thu, 12 Nov 2020 06:25:13 +0200 Subject: Update pydis_site/apps/events/views/page.py Co-authored-by: Jeremiah Boby --- pydis_site/apps/events/views/page.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pydis_site/apps/events/views/page.py b/pydis_site/apps/events/views/page.py index 89b03c1f..f4c37aeb 100644 --- a/pydis_site/apps/events/views/page.py +++ b/pydis_site/apps/events/views/page.py @@ -22,4 +22,4 @@ class PageView(TemplateView): if not page_path.exists(): raise Http404 - return [f"events/{settings.PAGES_PATH.name}/path}"] + return [f"events/{settings.PAGES_PATH.name}/{path}"] -- cgit v1.2.3 From 40eb7d44b9785cf7f86c0418e0f7c8e2620de41c Mon Sep 17 00:00:00 2001 From: ks129 <45097959+ks129@users.noreply.github.com> Date: Thu, 12 Nov 2020 08:34:53 +0200 Subject: Use URL tag for code jam 7 rules page Co-authored-by: Jeremiah Boby --- pydis_site/templates/events/pages/code-jams/7/rules.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pydis_site/templates/events/pages/code-jams/7/rules.html b/pydis_site/templates/events/pages/code-jams/7/rules.html index b490551a..f77d7129 100644 --- a/pydis_site/templates/events/pages/code-jams/7/rules.html +++ b/pydis_site/templates/events/pages/code-jams/7/rules.html @@ -61,7 +61,7 @@ -- cgit v1.2.3 From d889a4b2575a1acb83b2c40d47400d0bcae8f69b Mon Sep 17 00:00:00 2001 From: ks129 <45097959+ks129@users.noreply.github.com> Date: Thu, 12 Nov 2020 08:35:11 +0200 Subject: Use URL tag for code jam 7 page Co-authored-by: Jeremiah Boby --- pydis_site/templates/events/pages/code-jams/7/_index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pydis_site/templates/events/pages/code-jams/7/_index.html b/pydis_site/templates/events/pages/code-jams/7/_index.html index d69d0a9e..ac86b0c9 100644 --- a/pydis_site/templates/events/pages/code-jams/7/_index.html +++ b/pydis_site/templates/events/pages/code-jams/7/_index.html @@ -96,7 +96,7 @@ {% endblock %} -- cgit v1.2.3