Skip to content

Commit

Permalink
Update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
oliver-ni committed Sep 16, 2023
1 parent 0936c00 commit c0cc530
Show file tree
Hide file tree
Showing 17 changed files with 183 additions and 319 deletions.
2 changes: 1 addition & 1 deletion hknweb/academics/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@


class AcademicsConfig(AppConfig):
name = "academics"
name = "hknweb.academics"
2 changes: 1 addition & 1 deletion hknweb/candidate/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@


class CandidateConfig(AppConfig):
name = "candidate"
name = "hknweb.candidate"
2 changes: 1 addition & 1 deletion hknweb/course_surveys/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@


class CourseSurveysConfig(AppConfig):
name = "course_surveys"
name = "hknweb.course_surveys"
2 changes: 1 addition & 1 deletion hknweb/coursesemester/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@


class CoursesemesterConfig(AppConfig):
name = "coursesemester"
name = "hknweb.coursesemester"
2 changes: 1 addition & 1 deletion hknweb/events/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@


class EventsConfig(AppConfig):
name = "events"
name = "hknweb.events"
2 changes: 1 addition & 1 deletion hknweb/markdown_pages/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@


class MarkdownPagesConfig(AppConfig):
name = "markdown_pages"
name = "hknweb.markdown_pages"
34 changes: 5 additions & 29 deletions hknweb/settings/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
https://docs.djangoproject.com/en/2.0/ref/settings/
"""
import os

from django.conf.global_settings import DATETIME_INPUT_FORMATS

from hknweb.utils import DATETIME_12_HOUR_FORMAT

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
Expand Down Expand Up @@ -40,12 +42,10 @@
"django.contrib.messages",
"django.contrib.staticfiles",
"markdownx",
"social_django",
]

MIDDLEWARE = [
"django.middleware.security.SecurityMiddleware",
"whitenoise.middleware.WhiteNoiseMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
"django.middleware.common.CommonMiddleware",
"django.middleware.csrf.CsrfViewMiddleware",
Expand All @@ -56,17 +56,6 @@

ROOT_URLCONF = "hknweb.urls"

SOCIAL_AUTH_PIPELINE = (
"social_core.pipeline.social_auth.social_details",
"social_core.pipeline.social_auth.social_uid",
"social_core.pipeline.social_auth.auth_allowed",
"social_core.pipeline.social_auth.social_user",
"social_core.pipeline.social_auth.associate_by_email",
"social_core.pipeline.social_auth.associate_user",
"social_core.pipeline.social_auth.load_extra_data",
"social_core.pipeline.user.user_details",
)

TEMPLATES = [
{
"BACKEND": "django.template.backends.django.DjangoTemplates",
Expand All @@ -78,8 +67,6 @@
"django.template.context_processors.request",
"django.contrib.auth.context_processors.auth",
"django.contrib.messages.context_processors.messages",
"social_django.context_processors.backends",
"social_django.context_processors.login_redirect",
"hknweb.views.users.add_officer_context",
"hknweb.views.users.add_exec_context",
],
Expand All @@ -89,11 +76,9 @@

WSGI_APPLICATION = "hknweb.wsgi.application"

AUTHENTICATION_BACKENDS = (
"social_core.backends.open_id.OpenIdAuth", # for Google authentication
"social_core.backends.google.GoogleOAuth2", # for Google authentication
"django.contrib.auth.backends.ModelBackend",
)
AUTHENTICATION_BACKENDS = ("django.contrib.auth.backends.ModelBackend",)

DEFAULT_AUTO_FIELD = "django.db.models.AutoField"

# Database
# https://docs.djangoproject.com/en/2.0/ref/settings/#databases
Expand Down Expand Up @@ -185,18 +170,9 @@

MESSAGE_STORAGE = "django.contrib.messages.storage.session.SessionStorage"

# STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
# SOCIAL_AUTH_GOOGLE_OAUTH2_WHITELISTED_DOMAINS = ['hkn.eecs.berkeley.edu']

# Recaptcha: public and private key
RECAPTCHA_PUBLIC_KEY = "6LeYTKAUAAAAADooVC_FG9ua47PnwP_gGWOSwauK"

# python-social-auth: MySQL InnoDB index limits
# https://python-social-auth-docs.readthedocs.io/en/latest/configuration/settings.html#tweaking-some-fields-length
SOCIAL_AUTH_UID_LENGTH = 223
SOCIAL_AUTH_NONCE_SERVER_URL_LENGTH = 100
SOCIAL_AUTH_ASSOCIATION_SERVER_URL_LENGTH = 100

# Constants for backend code

# user groups
Expand Down
2 changes: 1 addition & 1 deletion hknweb/studentservices/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@


class StudentservicesConfig(AppConfig):
name = "studentservices"
name = "hknweb.studentservices"
2 changes: 1 addition & 1 deletion hknweb/templates/base.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% load static from staticfiles %}
{% load static %}
<!DOCTYPE html>
<html lang="en">
<head>
Expand Down
2 changes: 1 addition & 1 deletion hknweb/templates/home.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% extends "base.html" %}
{% load static from staticfiles %}
{% load static %}
<html>
<head>

Expand Down
1 change: 0 additions & 1 deletion hknweb/templates/registration/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@

<a href="{% url 'account-create' %}">Sign up</a>
<p><a href="{% url 'password_reset' %}">Forgot your password?</a></p>
<!-- <a href="{% url 'social:begin' 'google-oauth2' %}">Login with Google</a> -->
<br><br><br>
</div>
{% endblock %}
2 changes: 1 addition & 1 deletion hknweb/tutoring/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@


class TutoringConfig(AppConfig):
name = "tutoring"
name = "hknweb.tutoring"
2 changes: 1 addition & 1 deletion hknweb/tutoring/views/slots.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from django.http import JsonResponse
from django.utils import timezone
from django.contrib.auth.models import User
from django.contrib.staticfiles.templatetags.staticfiles import static
from django.templatetags.static import static

from hknweb.utils import allow_public_access

Expand Down
23 changes: 4 additions & 19 deletions hknweb/urls.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
import markdownx.views as markdownx_views
from django.contrib import admin
from django.urls import include, path
from django.conf.urls import url
from django.conf import settings
from django.conf.urls.static import static
from django.contrib import admin
from django.urls import include, path

from hknweb.views import landing, outreach, users, indrel, people
from hknweb.utils import method_login_and_permission
from hknweb.views import indrel, landing, outreach, people, users

__all__ = ["urlpatterns", "safe_urlpatterns"]

# DO NOT add urls here unless you know what you are doing
unsafe_urlpatterns = [
path("admin/", admin.site.urls),
path("accounts/", include("django.contrib.auth.urls")),
path("auth/", include("social_django.urls", namespace="social")),
]

app_urlpatterns = [
Expand All @@ -35,20 +33,7 @@
]

markdownx_urlpatterns = [
url(
r"^markdownx/upload/$",
method_login_and_permission("markdown_pages.add_markdownpage")(
markdownx_views.ImageUploadView
).as_view(),
name="markdownx_upload",
),
url(
r"^markdownx/markdownify/$",
method_login_and_permission("markdown_pages.add_markdownpage")(
markdownx_views.MarkdownifyView
).as_view(),
name="markdownx_markdownify",
),
path("markdownx/", include("markdownx.urls")),
]

safe_urlpatterns = [
Expand Down
36 changes: 12 additions & 24 deletions hknweb/utils.py
Original file line number Diff line number Diff line change
@@ -1,30 +1,22 @@
import csv
import re

from django.contrib.auth.decorators import (
login_required,
permission_required,
user_passes_test,
)
from django.core.exceptions import PermissionDenied
from django.http import HttpResponse
from django.utils.decorators import method_decorator
from django.contrib.staticfiles.finders import find

from functools import wraps
from random import randint
from datetime import datetime

from pytz import timezone

### For Markdownx Security Patch
from functools import partial
from functools import partial, wraps
from random import randint

import bleach
import markdown
from django.conf import settings
from django.contrib.auth.decorators import (login_required,
permission_required,
user_passes_test)
from django.contrib.staticfiles.finders import find
from django.core.exceptions import PermissionDenied
from django.http import HttpResponse
from django.utils.decorators import method_decorator
from django.utils.safestring import mark_safe

import markdown
import bleach
from pytz import timezone

###

Expand Down Expand Up @@ -173,9 +165,6 @@ def markdownify(text):
whitelist_attrs = getattr(
settings, "MARKDOWNIFY_WHITELIST_ATTRS", bleach.sanitizer.ALLOWED_ATTRIBUTES
)
whitelist_styles = getattr(
settings, "MARKDOWNIFY_WHITELIST_STYLES", bleach.sanitizer.ALLOWED_STYLES
)
whitelist_protocols = getattr(
settings, "MARKDOWNIFY_WHITELIST_PROTOCOLS", bleach.sanitizer.ALLOWED_PROTOCOLS
)
Expand Down Expand Up @@ -213,7 +202,6 @@ def markdownify(text):
cleaner = bleach.Cleaner(
tags=whitelist_tags,
attributes=whitelist_attrs,
styles=whitelist_styles,
protocols=whitelist_protocols,
strip=strip,
filters=linkify,
Expand Down
Loading

0 comments on commit c0cc530

Please sign in to comment.