diff --git a/django_project/settings.py b/django_project/settings.py index 4961555..8076f32 100644 --- a/django_project/settings.py +++ b/django_project/settings.py @@ -76,8 +76,8 @@ django_apps= [ third_party_apps = [ 'allauth', 'allauth.account', - 'allauth.socialaccount', - 'allauth.socialaccount.providers.oauth2', # required for github + 'allauth.socialaccount', + 'allauth.socialaccount.providers.oauth2', # required for github 'allauth.socialaccount.providers.github', 'allauth.socialaccount.providers.google', 'allauth.socialaccount.providers.openid', diff --git a/django_project/urls.py b/django_project/urls.py index 09af0ed..5b7d066 100644 --- a/django_project/urls.py +++ b/django_project/urls.py @@ -20,7 +20,7 @@ from django.conf import settings urlpatterns = [ path('',include("tinywiki.urls")), path("user/",include("user.urls")), - path('admin/', admin.site.urls), + path("admin/", admin.site.urls), path('accounts/',include('allauth.urls')), ] diff --git a/poetry.lock b/poetry.lock index 06ca481..45ff9a9 100644 --- a/poetry.lock +++ b/poetry.lock @@ -422,13 +422,13 @@ bcrypt = ["bcrypt"] [[package]] name = "django-allauth" -version = "65.11.2" +version = "65.12.0" description = "Integrated set of Django applications addressing authentication, registration, account management as well as 3rd party (social) account authentication." optional = false python-versions = ">=3.8" groups = ["main"] files = [ - {file = "django_allauth-65.11.2.tar.gz", hash = "sha256:7b7e771d3384d0e247d0d6aef31b0cb589f92305b7e975e70056a513525906e7"}, + {file = "django_allauth-65.12.0.tar.gz", hash = "sha256:a76ec55935354a1455753601a0a814a4ded368242e8969323480a2810b349183"}, ] [package.dependencies] @@ -436,7 +436,7 @@ asgiref = ">=3.8.1" Django = ">=4.2.16" oauthlib = {version = ">=3.3.0,<4", optional = true, markers = "extra == \"socialaccount\""} pyjwt = {version = ">=2.0,<3", extras = ["crypto"], optional = true, markers = "extra == \"socialaccount\""} -python3-openid = {version = ">=3.0.8,<4", optional = true, markers = "extra == \"steam\""} +python3-openid = {version = ">=3.0.8,<4", optional = true, markers = "extra == \"openid\" or extra == \"steam\""} requests = {version = ">=2.0.0,<3", optional = true, markers = "extra == \"socialaccount\""} [package.extras] @@ -1084,4 +1084,4 @@ testing = ["coverage[toml]", "zope.event", "zope.testing"] [metadata] lock-version = "2.1" python-versions = ">=3.12,<3.14" -content-hash = "cdc572d2076797697db50f74bfecc2a67620b6a7bcc8eb3a799e816848c0c261" +content-hash = "98e621f617ddd42f730009c747e8e771e95e2a5260bcca3409e6f0edbcef6b17" diff --git a/pyproject.toml b/pyproject.toml index b00bd84..ed0144b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,7 +10,7 @@ dependencies = [ "django-extensions (>=4.1,<5.0)", "django-widget-tweaks (>=1.5.0,<2.0.0)", "django-environ (>=0.12.0,<0.13.0)", - "django-allauth[socialaccount,steam] (>=65.11.2,<66.0.0)", + "django-allauth[oauth2,openid,saml2,socialaccount,steam] (>=65.12.0,<66.0.0)", "django-browser-reload (>=1.19.0,<2.0.0)", "pillow (>=11.3.0,<12.0.0)", "bbcode (>=1.1.0,<2.0.0)", diff --git a/tinywiki/views/home.py b/tinywiki/views/home.py index d884a9a..b91f73a 100644 --- a/tinywiki/views/home.py +++ b/tinywiki/views/home.py @@ -1,4 +1,3 @@ -from curses.ascii import isalpha from django.shortcuts import render from django.utils.safestring import mark_safe from django.urls import reverse @@ -6,7 +5,7 @@ from django.urls import reverse from django_project.settings import STATIC_URL from tinywiki import settings from .base import View -from django.http import HttpRequest,HttpResponse +from django.http import HttpRequest, HttpResponse from django.db.models.functions import Lower import string from ..models import Page @@ -17,15 +16,15 @@ from django.utils.translation import ngettext, gettext as _ class HomeView(View): template_name = "tinywiki/home/home.html" - + def get(self,request): try: page = Page.objects.get(slug='tw-home') if (not Page.status == WikiPageStatus.PUBLISHED - and not request.user.is_staff + and not request.user.is_staff and not request.user.has_perm('page.view-all')): page = None - + except Page.DoesNotExist: page = None if self.user_can_create_system_pages: @@ -35,7 +34,7 @@ class HomeView(View): create_tw_home = f"{_('create a new page with the slug tw-home')}" else: create_tw_home = "create a new page with the slug tw-home" - + if settings.USE_BOOTSTRAP: markdown_guide = f"{_('Guide for markdown used by TinyWiki')}" bbcode_guide = f"{_('Guide for BBCode used by TinyWiki')}" @@ -53,26 +52,26 @@ class HomeView(View): class TocView(View): template_name = "tinywiki/home/wiki-content.html" bs_template_name = "tinywiki/home/bs-wiki-content.html" - + @classmethod def get_template_name(cls): if settings.USE_BOOTSTRAP: return cls.bs_template_name return cls.template_name - + def get(self,request): def mkdict(page:Page): return {'slug':page.slug,'title':page.title, 'is_system':page.slug.startswith('tw-')} - + user = self.request.user if (user.is_staff or user.has_perm('page.read_all')): pages = Page.objects.all() else: pages = Page.objects.filter(status_data=WikiPageStatus.PUBLISHED.value) - + toc_mapping = {} - - + + for page in pages: first_char = page.title.lstrip()[0].upper() if first_char.isdigit(): @@ -90,8 +89,8 @@ class TocView(View): toc_mapping[first_char] = [mkdict(page)] else: toc_mapping[first_char].append(mkdict(page)) - - toc = [] + + toc = [] for key in sorted(toc_mapping.keys()): toc_entries = toc_mapping[key] count = len(toc_mapping[key]) @@ -101,19 +100,19 @@ class TocView(View): pages_1 = [] else: pages_1 = toc_entries[split:] - - + + if (key.startswith('0') or key == '#'): toc_section = key else: toc_section = f"{key}..." - + toc_section = ngettext("{toc_section} ({n} page)","{toc_section} ({n} pages)", count).format( toc_section=toc_section, n=count, ) toc.append((toc_section,pages_0,pages_1)) - + return render(request, self.get_template_name(), self.get_context_data(toc=toc,subtitle=_("Table of Contents"))) \ No newline at end of file