From 1ced4fc37f2969765feac4f090d42148ad4377e9 Mon Sep 17 00:00:00 2001 From: Leon Sandøy Date: Tue, 1 Oct 2019 22:55:19 +0200 Subject: Update the landing page text. The new text was written by Tizzysaurus in his website cleanup project, and lifted from his google doc. --- pydis_site/templates/home/index.html | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'pydis_site/templates') diff --git a/pydis_site/templates/home/index.html b/pydis_site/templates/home/index.html index 205e92ff..bccea71a 100644 --- a/pydis_site/templates/home/index.html +++ b/pydis_site/templates/home/index.html @@ -19,21 +19,21 @@

We're a large community focused around the Python programming language. - We believe anyone can learn programming, and are very dedicated to helping - novice developers take their first steps into the world of code. We also + We believe anyone can learn to code, and are very dedicated to helping + novice developers take their first steps into the world of programming. We also attract a lot of expert developers who are seeking friendships, collaborators, - or looking to hone their craft by teaching and getting involved in the community. + or to hone their craft by teaching and getting involved with the community.

- We organise regular community events like code jams, open source hackathons, - seasonal events and community challenges. Through our sponsorships and with - help from donations, we are even able to award prizes to the winners of our events. + We organise regular community events such as code jams, open-source hackathons, + seasonal events and community challenges. Through our sponsorships, and with + the help from donations, many of our events even have prizes to win!

You can find help with most Python-related problems in one of our help channels. - Our staff of nearly 50 dedicated expert Helpers are available around the clock + Our staff of over 50 dedicated expert Helpers, are available around the clock in every timezone. Whether you're looking to learn the language or working on a complex project, we've got someone who can help you if you get stuck.

-- cgit v1.2.3 From 0c43428ef86666dfb9d4baf119b0a30ba8dbe5cf Mon Sep 17 00:00:00 2001 From: Leon Sandøy Date: Sat, 5 Oct 2019 09:20:23 +0200 Subject: Address code review from Scragly and Mark. Makes various minor changes to commas and formulations. --- pydis_site/templates/home/index.html | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'pydis_site/templates') diff --git a/pydis_site/templates/home/index.html b/pydis_site/templates/home/index.html index bccea71a..bf217fe8 100644 --- a/pydis_site/templates/home/index.html +++ b/pydis_site/templates/home/index.html @@ -22,18 +22,18 @@ We believe anyone can learn to code, and are very dedicated to helping novice developers take their first steps into the world of programming. We also attract a lot of expert developers who are seeking friendships, collaborators, - or to hone their craft by teaching and getting involved with the community. + and who wish to hone their craft by teaching and getting involved in the community.

We organise regular community events such as code jams, open-source hackathons, - seasonal events and community challenges. Through our sponsorships, and with - the help from donations, many of our events even have prizes to win! + seasonal events, and community challenges. Through our sponsorships and donations, + many of our events even have prizes to win!

You can find help with most Python-related problems in one of our help channels. - Our staff of over 50 dedicated expert Helpers, are available around the clock + Our staff of over 50 dedicated expert Helpers are available around the clock in every timezone. Whether you're looking to learn the language or working on a complex project, we've got someone who can help you if you get stuck.

-- cgit v1.2.3 From 23f7f9e5f09e7b5b52810d19ffe7ad31eeabd054 Mon Sep 17 00:00:00 2001 From: Gareth Coles Date: Sat, 5 Oct 2019 14:49:29 +0100 Subject: Add MessageRedirectView and show messages on the index page --- pydis_site/settings.py | 10 ++++++++++ pydis_site/static/css/base/base.css | 8 ++++++++ pydis_site/templates/home/index.html | 16 ++++++++++++++++ pydis_site/utils/views.py | 25 +++++++++++++++++++++++++ 4 files changed, 59 insertions(+) create mode 100644 pydis_site/utils/views.py (limited to 'pydis_site/templates') diff --git a/pydis_site/settings.py b/pydis_site/settings.py index 21841e15..919547de 100644 --- a/pydis_site/settings.py +++ b/pydis_site/settings.py @@ -272,6 +272,16 @@ LOGGING = { } } +# Django Messages framework config + +MESSAGE_TAGS = { + messages.DEBUG: 'primary', + messages.INFO: 'info', + messages.SUCCESS: 'success', + messages.WARNING: 'warning', + messages.ERROR: 'danger', +} + # Custom settings for Crispyforms CRISPY_ALLOWED_TEMPLATE_PACKS = ( "bootstrap", diff --git a/pydis_site/static/css/base/base.css b/pydis_site/static/css/base/base.css index ce1503a3..283e89cb 100644 --- a/pydis_site/static/css/base/base.css +++ b/pydis_site/static/css/base/base.css @@ -70,3 +70,11 @@ div.card.has-equal-height { #pydis-text { font-weight: bold; } + +button.is-size-navbar-menu { + font-size: 14px; +} + +section.message-section { + padding: 1.5rem 1.5rem 0 1.5rem; +} diff --git a/pydis_site/templates/home/index.html b/pydis_site/templates/home/index.html index 205e92ff..a367fe70 100644 --- a/pydis_site/templates/home/index.html +++ b/pydis_site/templates/home/index.html @@ -9,6 +9,22 @@ {% block content %} {% include "base/navbar.html" %} + {% if messages %} +
+
+
+ {% for message in messages %} +
+ + + {{ message }} +
+ {% endfor %} +
+
+
+ {% endif %} +
{# Who are we? #} diff --git a/pydis_site/utils/views.py b/pydis_site/utils/views.py new file mode 100644 index 00000000..c9803bd6 --- /dev/null +++ b/pydis_site/utils/views.py @@ -0,0 +1,25 @@ +from django.contrib import messages +from django.http import HttpRequest +from django.views.generic import RedirectView + + +class MessageRedirectView(RedirectView): + """ + Redirects to another URL, also setting a message using the Django Messages framework. + + This is based on Django's own `RedirectView` and works the same way, but takes two additional + parameters. + + * `message`: Set to the message content you wish to display. + * `message_level`: Set to one of the message levels from the Django messages framework. This + parameter defaults to `messages.INFO`. + """ + + message: str = "" + message_level: int = messages.INFO + + def get(self, request: HttpRequest, *args, **kwargs) -> None: + """Called upon a GET request.""" + messages.add_message(request, self.message_level, self.message) + + return super().get(request, *args, **kwargs) -- cgit v1.2.3 From 0ebaa16646ad3723a6c365ebe4208586216b609c Mon Sep 17 00:00:00 2001 From: Gareth Coles Date: Sat, 5 Oct 2019 14:50:24 +0100 Subject: Set up needed Allauth URLs and add login/logout to navbar --- pydis_site/apps/home/urls.py | 24 +++++++++++++++++++++++- pydis_site/settings.py | 1 + pydis_site/templates/base/navbar.html | 21 +++++++++++++++++++++ 3 files changed, 45 insertions(+), 1 deletion(-) (limited to 'pydis_site/templates') diff --git a/pydis_site/apps/home/urls.py b/pydis_site/apps/home/urls.py index b9e7341b..dbb53cb6 100644 --- a/pydis_site/apps/home/urls.py +++ b/pydis_site/apps/home/urls.py @@ -1,15 +1,37 @@ +from allauth.account.views import LogoutView +from allauth.socialaccount.views import ConnectionsView from django.conf import settings from django.conf.urls.static import static from django.contrib import admin +from django.contrib.messages import ERROR from django.urls import include, path +from pydis_site.utils.views import MessageRedirectView from .views import HomeView app_name = 'home' urlpatterns = [ path('', HomeView.as_view(), name='home'), path('pages/', include('wiki.urls')), - path('accounts/', include('allauth.urls'), name='auth'), + + path('accounts/', include('allauth.socialaccount.providers.discord.urls')), + path('accounts/', include('allauth.socialaccount.providers.github.urls')), + + path( + 'accounts/login/cancelled', MessageRedirectView.as_view( + pattern_name="home", message="Login cancelled." + ), name='socialaccount_login_cancelled' + ), + path( + 'accounts/login/error', MessageRedirectView.as_view( + pattern_name="home", message="Login failed due to an error, please try again.", + message_level=ERROR + ), name='socialaccount_login_error' + ), + + path('connections', ConnectionsView.as_view()), + path('logout', LogoutView.as_view(), name="logout"), + path('admin/', admin.site.urls), path('notifications/', include('django_nyt.urls')), ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) diff --git a/pydis_site/settings.py b/pydis_site/settings.py index 919547de..cc741117 100644 --- a/pydis_site/settings.py +++ b/pydis_site/settings.py @@ -376,3 +376,4 @@ AUTHENTICATION_BACKENDS = ( ) ACCOUNT_EMAIL_VERIFICATION = "none" # No verification required; we don't use emails for anything +LOGIN_REDIRECT_URL = "home" diff --git a/pydis_site/templates/base/navbar.html b/pydis_site/templates/base/navbar.html index ee68852a..e73864fe 100644 --- a/pydis_site/templates/base/navbar.html +++ b/pydis_site/templates/base/navbar.html @@ -1,3 +1,5 @@ +{% load account %} +{% load socialaccount %} {% load static %}
-- cgit v1.2.3 From c44b5a740a69de5b479100f4c023bb80db8605a6 Mon Sep 17 00:00:00 2001 From: Leon Sandøy Date: Sat, 5 Oct 2019 17:47:05 +0200 Subject: Make the homepage paragraphier. --- pydis_site/templates/home/index.html | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'pydis_site/templates') diff --git a/pydis_site/templates/home/index.html b/pydis_site/templates/home/index.html index bf217fe8..45fb56e9 100644 --- a/pydis_site/templates/home/index.html +++ b/pydis_site/templates/home/index.html @@ -23,15 +23,13 @@ novice developers take their first steps into the world of programming. We also attract a lot of expert developers who are seeking friendships, collaborators, and who wish to hone their craft by teaching and getting involved in the community. - -

- +

+

We organise regular community events such as code jams, open-source hackathons, seasonal events, and community challenges. Through our sponsorships and donations, many of our events even have prizes to win! - -

- +

+

You can find help with most Python-related problems in one of our help channels. Our staff of over 50 dedicated expert Helpers are available around the clock in every timezone. Whether you're looking to learn the language or working on a -- cgit v1.2.3 From 486b37b9aeac4a3389aba43970a46024b7ee8c65 Mon Sep 17 00:00:00 2001 From: Gareth Coles Date: Sun, 6 Oct 2019 12:33:53 +0100 Subject: Move messages to the top right --- pydis_site/static/css/base/base.css | 25 +++++++++++++++++++++++-- pydis_site/templates/base/base.html | 12 ++++++++++++ pydis_site/templates/home/index.html | 16 ---------------- 3 files changed, 35 insertions(+), 18 deletions(-) (limited to 'pydis_site/templates') diff --git a/pydis_site/static/css/base/base.css b/pydis_site/static/css/base/base.css index 283e89cb..256bec2c 100644 --- a/pydis_site/static/css/base/base.css +++ b/pydis_site/static/css/base/base.css @@ -71,10 +71,31 @@ div.card.has-equal-height { font-weight: bold; } + +/* Fix for logout form submit button in navbar */ + button.is-size-navbar-menu { font-size: 14px; } -section.message-section { - padding: 1.5rem 1.5rem 0 1.5rem; +/* On-page message styling */ + +@keyframes message-slide-in { + 0% { + transform: translateX(100%); + } + + 100% { + transform: translateX(0); + } +} + +div.messages { + animation: 0.5s ease-out 0s 1 message-slide-in; + padding: 0.5rem; + position: fixed; + right: 0; + top: 76px; + + z-index: 1000; /* On top of everything else */ } diff --git a/pydis_site/templates/base/base.html b/pydis_site/templates/base/base.html index a419521c..7b197be3 100644 --- a/pydis_site/templates/base/base.html +++ b/pydis_site/templates/base/base.html @@ -26,6 +26,18 @@

+ {% if messages %} +
+ {% for message in messages %} +
+ + + {{ message }} +
+ {% endfor %} +
+ {% endif %} + {% block content %} {{ block.super }} {% endblock %} diff --git a/pydis_site/templates/home/index.html b/pydis_site/templates/home/index.html index a367fe70..205e92ff 100644 --- a/pydis_site/templates/home/index.html +++ b/pydis_site/templates/home/index.html @@ -9,22 +9,6 @@ {% block content %} {% include "base/navbar.html" %} - {% if messages %} -
-
-
- {% for message in messages %} -
- - - {{ message }} -
- {% endfor %} -
-
-
- {% endif %} -
{# Who are we? #} -- cgit v1.2.3 From b437c261512c0753c738457804e4d4ac5f4bd8c9 Mon Sep 17 00:00:00 2001 From: Gareth Coles Date: Sun, 6 Oct 2019 14:26:43 +0100 Subject: Message styling (default to light for now) --- pydis_site/settings.py | 4 +++- pydis_site/static/css/base/base.css | 22 ---------------------- pydis_site/templates/base/base.html | 5 +++-- pydis_site/templates/wiki/base.html | 13 +++++++++++++ 4 files changed, 19 insertions(+), 25 deletions(-) (limited to 'pydis_site/templates') diff --git a/pydis_site/settings.py b/pydis_site/settings.py index cc741117..93867101 100644 --- a/pydis_site/settings.py +++ b/pydis_site/settings.py @@ -295,7 +295,7 @@ CRISPY_TEMPLATE_PACK = "bulma" # Custom settings for django-simple-bulma BULMA_SETTINGS = { - "variables": { + "variables": { # If you update these colours, please update the notification.css file "green": "#21c65c", # Accessibility: Better contrast with the light text "primary": "#7289DA", "link": "$primary", @@ -303,6 +303,8 @@ BULMA_SETTINGS = { "dimensions": "16 24 32 48 64 96 128 256 512", # Possible image dimensions "navbar-height": "4.75rem", "footer-padding": "1rem 1.5rem 1rem", + + "notification-background-color": "#33353C", # Discord embed background colour } } diff --git a/pydis_site/static/css/base/base.css b/pydis_site/static/css/base/base.css index 256bec2c..87175922 100644 --- a/pydis_site/static/css/base/base.css +++ b/pydis_site/static/css/base/base.css @@ -77,25 +77,3 @@ div.card.has-equal-height { button.is-size-navbar-menu { font-size: 14px; } - -/* On-page message styling */ - -@keyframes message-slide-in { - 0% { - transform: translateX(100%); - } - - 100% { - transform: translateX(0); - } -} - -div.messages { - animation: 0.5s ease-out 0s 1 message-slide-in; - padding: 0.5rem; - position: fixed; - right: 0; - top: 76px; - - z-index: 1000; /* On top of everything else */ -} diff --git a/pydis_site/templates/base/base.html b/pydis_site/templates/base/base.html index 7b197be3..9d114bd8 100644 --- a/pydis_site/templates/base/base.html +++ b/pydis_site/templates/base/base.html @@ -19,6 +19,7 @@ + {% block head %}{% endblock %} {% render_block "css" %} @@ -27,9 +28,9 @@
{% if messages %} -
+
{% for message in messages %} -
+
{{ message }} diff --git a/pydis_site/templates/wiki/base.html b/pydis_site/templates/wiki/base.html index da4d5de1..2f92d83b 100644 --- a/pydis_site/templates/wiki/base.html +++ b/pydis_site/templates/wiki/base.html @@ -15,6 +15,7 @@ + {% endblock %} {% block content %} @@ -24,6 +25,18 @@ {% block wiki_navbar %}{% endblock %} + {% if messages %} +
+ {% for message in messages %} +
+ + + {{ message }} +
+ {% endfor %} +
+ {% endif %} + {% block wiki_breadcrumbs %} {% include "wiki/includes/breadcrumbs.html" %} {% endblock %} -- cgit v1.2.3 From 8e4fb9472b786c06877b9e67eea41bb1697496d3 Mon Sep 17 00:00:00 2001 From: Gareth Coles Date: Sun, 6 Oct 2019 17:40:45 +0100 Subject: Login page and styling fixes --- pydis_site/apps/home/urls.py | 2 + pydis_site/apps/home/views/login.py | 31 +++++++++++++++ pydis_site/static/css/base/base.css | 11 ++++++ pydis_site/static/css/base/notification.css | 24 ++++++------ pydis_site/templates/base/navbar.html | 14 ++----- pydis_site/templates/home/login.html | 58 +++++++++++++++++++++++++++++ 6 files changed, 117 insertions(+), 23 deletions(-) create mode 100644 pydis_site/apps/home/views/login.py create mode 100644 pydis_site/templates/home/login.html (limited to 'pydis_site/templates') diff --git a/pydis_site/apps/home/urls.py b/pydis_site/apps/home/urls.py index dbb53cb6..150b5b12 100644 --- a/pydis_site/apps/home/urls.py +++ b/pydis_site/apps/home/urls.py @@ -6,6 +6,7 @@ from django.contrib import admin from django.contrib.messages import ERROR from django.urls import include, path +from pydis_site.apps.home.views.login import LoginView from pydis_site.utils.views import MessageRedirectView from .views import HomeView @@ -30,6 +31,7 @@ urlpatterns = [ ), path('connections', ConnectionsView.as_view()), + path('login', LoginView.as_view(), name="login"), path('logout', LogoutView.as_view(), name="logout"), path('admin/', admin.site.urls), diff --git a/pydis_site/apps/home/views/login.py b/pydis_site/apps/home/views/login.py new file mode 100644 index 00000000..d74403a8 --- /dev/null +++ b/pydis_site/apps/home/views/login.py @@ -0,0 +1,31 @@ +from allauth.socialaccount.providers import registry +from allauth.socialaccount.providers.discord.provider import DiscordProvider +from django.contrib import messages +from django.http import HttpRequest, HttpResponse +from django.shortcuts import redirect +from django.views.generic import View +from django.views.generic.base import TemplateResponseMixin + + +class LoginView(View, TemplateResponseMixin): + """Login view for collecting email collection consent from users.""" + + template_name = "home/login.html" + + def get(self, request: HttpRequest) -> HttpResponse: + """Render the login page view.""" + return self.render_to_response({}) + + def post(self, request: HttpRequest) -> HttpResponse: + """Check whether the user provided consent, and action appropriately.""" + if request.POST.get("consent", None) != "on": # I bet IE breaks this standard... + messages.add_message( + request, + messages.ERROR, + "Consent is required to login with Discord.", + ) + + return self.render_to_response({}) + + provider: DiscordProvider = registry.by_id("discord") + return redirect(provider.get_login_url(request)) diff --git a/pydis_site/static/css/base/base.css b/pydis_site/static/css/base/base.css index 87175922..3ca6b2a7 100644 --- a/pydis_site/static/css/base/base.css +++ b/pydis_site/static/css/base/base.css @@ -72,8 +72,19 @@ div.card.has-equal-height { } +/* Navbar "more" menu should be on top of messages. I could not figure + * out a better way to fix this one without just applying a high z-index + * to everything - anyone have any better ideas? Does it matter since the + * navbar should be above everything anyway? + */ + +.navbar, .navbar * { + z-index: 1001; +} + /* Fix for logout form submit button in navbar */ button.is-size-navbar-menu { font-size: 14px; } + diff --git a/pydis_site/static/css/base/notification.css b/pydis_site/static/css/base/notification.css index 398379f1..b2824641 100644 --- a/pydis_site/static/css/base/notification.css +++ b/pydis_site/static/css/base/notification.css @@ -22,38 +22,38 @@ div.messages { /* Discord light theme inspired notifications */ -.notification { +.messages .notification { background-color: #fdfdfd; /* Discord embed background */ border: #eeeeee 1px solid; /* Discord embed border */ border-left: #4f545c 4px solid; /* Discord default embed colour */ color: #4a4a4a; /* Bulma default colour */ } -.notification.is-primary { +.messages .notification.is-primary { background-color: #fdfdfd; border-left-color: #7289DA; color: #4a4a4a; /* Bulma default colour */ } -.notification.is-info { +.messages .notification.is-info { background-color: #fdfdfd; border-left-color: #1c8ad3; /* Bulma default colour */ color: #4a4a4a; /* Bulma default colour */ } -.notification.is-success { +.messages .notification.is-success { background-color: #fdfdfd; border-left-color: #21c65c; color: #4a4a4a; /* Bulma default colour */ } -.notification.is-warning { +.messages .notification.is-warning { background-color: #fdfdfd; border-left-color: #ffdd57; /* Bulma default colour */ color: #4a4a4a; /* Bulma default colour */ } -.notification.is-danger { +.messages .notification.is-danger { background-color: #fdfdfd; border-left-color: #ff3860; /* Bulma default colour */ color: #4a4a4a; /* Bulma default colour */ @@ -61,38 +61,38 @@ div.messages { /* Discord dark theme inspired notifications */ -.notification.is-dark { +.messages .notification.is-dark { background-color: #33353C; /* Discord embed background */ border: #36393f 1px solid; /* Discord embed border */ border-left: #4f545c 4px solid; /* Discord default embed colour */ color: #fff; /* Bulma default colour */ } -.notification.is-dark.is-primary { +.messages .notification.is-dark.is-primary { background-color: #33353C; border-left-color: #7289DA; color: #fff; /* Bulma default colour */ } -.notification.is-dark.is-info { +.messages .notification.is-dark.is-info { background-color: #33353C; border-left-color: #1c8ad3; /* Bulma default colour */ color: #fff; /* Bulma default colour */ } -.notification.is-dark.is-success { +.messages .notification.is-dark.is-success { background-color: #33353C; border-left-color: #21c65c; color: #fff; /* Bulma default colour */ } -.notification.is-dark.is-warning { +.messages .notification.is-dark.is-warning { background-color: #33353C; border-left-color: #ffdd57; /* Bulma default colour */ color: #fff; /* Bulma default colour */ } -.notification.is-dark.is-danger { +.messages .notification.is-dark.is-danger { background-color: #33353C; border-left-color: #ff3860; /* Bulma default colour */ color: #fff; /* Bulma default colour */ diff --git a/pydis_site/templates/base/navbar.html b/pydis_site/templates/base/navbar.html index e73864fe..f51f7c53 100644 --- a/pydis_site/templates/base/navbar.html +++ b/pydis_site/templates/base/navbar.html @@ -1,5 +1,3 @@ -{% load account %} -{% load socialaccount %} {% load static %}
-- cgit v1.2.3 From e736381dc00b495a853b4aa71f1a4f381f665a76 Mon Sep 17 00:00:00 2001 From: Gareth Coles Date: Sun, 6 Oct 2019 21:27:11 +0100 Subject: Prevent saving emails, remove login page --- pydis_site/apps/home/apps.py | 24 +++++++++++++++++ pydis_site/apps/home/urls.py | 2 -- pydis_site/apps/home/views/login.py | 31 ---------------------- pydis_site/templates/base/navbar.html | 13 ++++++--- pydis_site/templates/home/login.html | 50 ----------------------------------- 5 files changed, 34 insertions(+), 86 deletions(-) delete mode 100644 pydis_site/apps/home/views/login.py delete mode 100644 pydis_site/templates/home/login.html (limited to 'pydis_site/templates') diff --git a/pydis_site/apps/home/apps.py b/pydis_site/apps/home/apps.py index 055d721b..a7c47dc5 100644 --- a/pydis_site/apps/home/apps.py +++ b/pydis_site/apps/home/apps.py @@ -1,3 +1,5 @@ +from typing import Any, Dict + from django.apps import AppConfig @@ -12,3 +14,25 @@ class HomeConfig(AppConfig): from pydis_site.apps.home.signals import SignalListener self.signal_listener = SignalListener() + self.patch_allauth() + + def patch_allauth(self) -> None: + """Monkey-patches Allauth classes so we never collect email addresses.""" + # Imported here because we can't import it before our apps are loaded up + from allauth.socialaccount.providers.base import Provider + + def extract_extra_data(_: Provider, data: Dict[str, Any]) -> Dict[str, Any]: + """ + Extracts extra data for a SocialAccount provided by Allauth. + + This is our version of this function that strips the email address from incoming extra + data. We do this so that we never have to store it. + + This is monkey-patched because most OAuth providers - or at least the ones we care + about - all use the function from the base Provider class. This means we don't have + to make a new Django app for each one we want to work with. + """ + data["email"] = "" + return data + + Provider.extract_extra_data = extract_extra_data diff --git a/pydis_site/apps/home/urls.py b/pydis_site/apps/home/urls.py index 150b5b12..dbb53cb6 100644 --- a/pydis_site/apps/home/urls.py +++ b/pydis_site/apps/home/urls.py @@ -6,7 +6,6 @@ from django.contrib import admin from django.contrib.messages import ERROR from django.urls import include, path -from pydis_site.apps.home.views.login import LoginView from pydis_site.utils.views import MessageRedirectView from .views import HomeView @@ -31,7 +30,6 @@ urlpatterns = [ ), path('connections', ConnectionsView.as_view()), - path('login', LoginView.as_view(), name="login"), path('logout', LogoutView.as_view(), name="logout"), path('admin/', admin.site.urls), diff --git a/pydis_site/apps/home/views/login.py b/pydis_site/apps/home/views/login.py deleted file mode 100644 index d74403a8..00000000 --- a/pydis_site/apps/home/views/login.py +++ /dev/null @@ -1,31 +0,0 @@ -from allauth.socialaccount.providers import registry -from allauth.socialaccount.providers.discord.provider import DiscordProvider -from django.contrib import messages -from django.http import HttpRequest, HttpResponse -from django.shortcuts import redirect -from django.views.generic import View -from django.views.generic.base import TemplateResponseMixin - - -class LoginView(View, TemplateResponseMixin): - """Login view for collecting email collection consent from users.""" - - template_name = "home/login.html" - - def get(self, request: HttpRequest) -> HttpResponse: - """Render the login page view.""" - return self.render_to_response({}) - - def post(self, request: HttpRequest) -> HttpResponse: - """Check whether the user provided consent, and action appropriately.""" - if request.POST.get("consent", None) != "on": # I bet IE breaks this standard... - messages.add_message( - request, - messages.ERROR, - "Consent is required to login with Discord.", - ) - - return self.render_to_response({}) - - provider: DiscordProvider = registry.by_id("discord") - return redirect(provider.get_login_url(request)) diff --git a/pydis_site/templates/base/navbar.html b/pydis_site/templates/base/navbar.html index f51f7c53..1d30b8f0 100644 --- a/pydis_site/templates/base/navbar.html +++ b/pydis_site/templates/base/navbar.html @@ -1,3 +1,4 @@ +{% load socialaccount %} {% load static %}
{% endblock %} + -- cgit v1.2.3 From 8c7db873a967be46c5f65f4606a8c74ef5a05179 Mon Sep 17 00:00:00 2001 From: ByteCommander Date: Sat, 12 Oct 2019 00:27:43 +0200 Subject: Forgot to update base.html template with favicon changes --- pydis_site/templates/base/base.html | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'pydis_site/templates') diff --git a/pydis_site/templates/base/base.html b/pydis_site/templates/base/base.html index 6a0da0ae..4791aaaa 100644 --- a/pydis_site/templates/base/base.html +++ b/pydis_site/templates/base/base.html @@ -12,17 +12,15 @@ content="{% block meta-description %}We're a large, friendly community focused around the Python programming language. Our community is open to those who wish to learn the language, as well as those looking to help others.{% endblock %}"> {# Generated with https://realfavicongenerator.net/ #} - - - - - - - - - - - + + + + + + + + + Python Discord | {% block title %}Website{% endblock %} -- cgit v1.2.3 From 0d7d9e810251cf40dfac7ebe4ae529e7d81b2cb3 Mon Sep 17 00:00:00 2001 From: Gareth Coles Date: Mon, 14 Oct 2019 14:43:10 +0100 Subject: Wiki: Hide breadcrumbs bar if the user can't edit --- pydis_site/templates/wiki/includes/breadcrumbs.html | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'pydis_site/templates') diff --git a/pydis_site/templates/wiki/includes/breadcrumbs.html b/pydis_site/templates/wiki/includes/breadcrumbs.html index a2359f39..47da9bc2 100644 --- a/pydis_site/templates/wiki/includes/breadcrumbs.html +++ b/pydis_site/templates/wiki/includes/breadcrumbs.html @@ -1,4 +1,6 @@ -{% if urlpath and article and not user.is_anonymous %} +{% load wiki_tags %} + +{% if urlpath and article and article|can_write:user %}