Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

redirect mod requests #548

Open
wants to merge 29 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
ab5328e
fix deprecation warnings
glbert-does Nov 17, 2023
86345bd
fix deprecated rexgexp
glbert-does Nov 17, 2023
57d4fd1
fix one test, temporarily turn failing test off
glbert-does Nov 21, 2023
a852a92
providing_args are documentational and are deprecated
glbert-does Nov 21, 2023
70d208e
add migration that was not done for 3rd alt option
glbert-does Nov 21, 2023
548ba3c
remove install_cacheops()
glbert-does Nov 21, 2023
d9cd10c
default_app_config in __init__.py is deprecated
glbert-does Nov 21, 2023
361460a
migrate deprecated fields
glbert-does Nov 22, 2023
4f8aa65
conf.urls.url() is deprecated in favour of urls.re_path()
glbert-does Nov 22, 2023
5c5e931
change some urls to paths
glbert-does Nov 22, 2023
0b49e75
change re_path to more readable path
glbert-does Nov 23, 2023
13f282c
ifequals is deprecated
glbert-does Nov 23, 2023
2b14357
update recaptcha to version 4
glbert-does Nov 23, 2023
a02c11a
update removed django.utils.http functions
glbert-does Nov 23, 2023
9ce14d4
re-enable cacheops, move to django 4.2
glbert-does Nov 23, 2023
f006834
the app is called tournament, not heltour
glbert-does Nov 23, 2023
89598e3
disable cacheops for testing
glbert-does Nov 23, 2023
5787737
add ad-hoc replacement for deactivated test
glbert-does Nov 23, 2023
f3a368d
enable cacheops in default settings
glbert-does Nov 23, 2023
5a5b9b0
fix django 5 deprecation warnings
glbert-does Nov 24, 2023
ae22207
fix broken url for webcal
glbert-does Nov 24, 2023
70a1edc
upgrade to python 3.9
glbert-does Jan 12, 2024
1fa17df
add missing map files for ManifestStaticFilesStorage
glbert-does Dec 4, 2024
99987b8
use regex string literals instead of escaping
glbert-does Dec 4, 2024
c45185d
remove superfluous comments
glbert-does Dec 4, 2024
2d83b28
be explicit about imports
glbert-does Dec 4, 2024
b57c6af
fill map files
glbert-does Dec 5, 2024
87dcf87
add helper for allowing static in debug mode
glbert-does Dec 16, 2024
dc63113
redirect rejected modrequests to the modrequest page
glbert-does Dec 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions heltour/api_worker/urls.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from django.conf.urls import url
from django.urls import path
from . import views

urlpatterns = [
url(r'^lichessapi/(?P<path>.+)$', views.lichess_api_call, name='lichess_api_call'),
url(r'^watch/$', views.watch, name='watch'),
url(r'^watch/add/$', views.watch_add, name='watch_add'),
path('lichessapi/<path:path>', views.lichess_api_call, name='lichess_api_call'),
path('watch/', views.watch, name='watch'),
path('watch/add/', views.watch_add, name='watch_add'),
]
2 changes: 1 addition & 1 deletion heltour/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
# Host-based settings overrides.
try:
hostname = platform.node().split('.')[0]
exec('from .local.%s import *' % re.sub('[^\w]', '_', hostname))
exec('from .local.%s import *' % re.sub('[^\\w]', '_', hostname))
except ImportError:
pass # ignore missing local settings

Expand Down
25 changes: 19 additions & 6 deletions heltour/settings_default.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False

DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'

ALLOWED_HOSTS = [
'www.lichess4545.tv',
'lichess4545.tv',
Expand All @@ -46,6 +48,7 @@
HELTOUR_APP = 'tournament'

INSTALLED_APPS = [
'cacheops',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
Expand All @@ -59,10 +62,9 @@
'ckeditor',
'ckeditor_uploader',
'debug_toolbar',
'cacheops',
'django_comments',
'heltour.comments',
'captcha',
'django_recaptcha',
'impersonate',
'static_precompiler',
]
Expand Down Expand Up @@ -166,8 +168,6 @@

USE_I18N = True

USE_L10N = True

USE_TZ = True

# Email
Expand Down Expand Up @@ -254,7 +254,11 @@
'output_style': 'compact'
}),
)
STATICFILES_STORAGE = 'django.contrib.staticfiles.storage.ManifestStaticFilesStorage'
STORAGES = {
'staticfiles': {
'BACKEND': 'django.contrib.staticfiles.storage.ManifestStaticFilesStorage'
},
}

BOOTSTRAP3 = {
'set_placeholder': False
Expand Down Expand Up @@ -289,10 +293,19 @@
'db': 1,
}
CACHEOPS_DEGRADE_ON_FAILURE = True
CACHEOPS_DEFAULTS = {
'timeout': 60*60
}
CACHEOPS = {
'*.*': {'ops': 'all', 'timeout': 60 * 60},
'admin.*': {'ops': 'all'},
'auth.*': {'ops': 'all'},
'heltour.*': {'ops': 'all'},
'tournament.*': {'ops': 'all'},
'*.*': {},
}

CACHEOPS_ENABLED = True

TEAMGEN_PROCESSES_NUMBER = 8

GOOGLE_SERVICE_ACCOUNT_KEYFILE_PATH = '/home/lichess4545/etc/heltour/gspread.conf'
Expand Down
11 changes: 9 additions & 2 deletions heltour/settings_testing.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
from .settings_default import *

CACHEOPS = {}
STATICFILES_STORAGE = 'django.contrib.staticfiles.storage.StaticFilesStorage'
CACHEOPS = {
'*.*': {'ops': ()},
}
CACHEOPS_ENABLED = False
STORAGES = {
'staticfiles': {
'BACKEND': 'django.contrib.staticfiles.storage.StaticFilesStorage'
},
}
1 change: 0 additions & 1 deletion heltour/tournament/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
default_app_config = 'heltour.tournament.apps.TournamentConfig'
61 changes: 30 additions & 31 deletions heltour/tournament/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from heltour.tournament import lichessapi, slackapi, views, forms, signals, simulation
from heltour.tournament.models import *
from reversion.admin import VersionAdmin
from django.conf.urls import url
from django.shortcuts import render, redirect, get_object_or_404
import reversion

Expand All @@ -17,9 +16,8 @@
from datetime import timedelta
from django_comments.models import Comment
from django.contrib.sites.models import Site
from django.urls import reverse
from django.urls import reverse, path
from django.http.response import HttpResponse
from django.utils.http import urlquote
from django.core.mail.message import EmailMultiAlternatives
from django.core import mail
from django.utils.html import format_html
Expand All @@ -29,10 +27,11 @@
from django.core.exceptions import PermissionDenied
from django.contrib.admin.filters import FieldListFilter, RelatedFieldListFilter, \
SimpleListFilter
from django.contrib.staticfiles.templatetags.staticfiles import static
from django.templatetags.static import static
from django.db.models.signals import post_save
from django.dispatch.dispatcher import receiver
from django.contrib.contenttypes.models import ContentType
from urllib.parse import quote as urlquote
from heltour.tournament.team_rating_utils import team_rating_range, team_rating_variance
from heltour.tournament import teamgen
import time
Expand Down Expand Up @@ -217,10 +216,10 @@ def get_readonly_fields(self, request, obj=None):
def get_urls(self):
urls = super(LeagueAdmin, self).get_urls()
my_urls = [
url(r'^(?P<object_id>[0-9]+)/import_season/$',
path('<int:object_id>/import_season/',
self.admin_site.admin_view(self.import_season_view),
name='import_season'),
url(r'^(?P<object_id>[0-9]+)/export_forfeit_data/$',
path('<int:object_id>/export_forfeit_data/',
self.admin_site.admin_view(self.export_forfeit_data_view),
name='export_forfeit_data'),
]
Expand Down Expand Up @@ -374,43 +373,43 @@ class SeasonAdmin(_BaseAdmin):
def get_urls(self):
urls = super(SeasonAdmin, self).get_urls()
my_urls = [
url(r'^(?P<object_id>[0-9]+)/manage_players/$',
path('<int:object_id>/manage_players/',
self.admin_site.admin_view(self.manage_players_view),
name='manage_players'),
url(r'^(?P<object_id>[0-9]+)/create_teams/$',
path('<int:object_id>/create_teams/',
self.admin_site.admin_view(self.create_teams_view),
name='create_teams'),
url(r'^(?P<object_id>[0-9]+)/player_info/(?P<player_name>[\w-]+)/$',
path('<int:object_id>/player_info/<slug:player_name>/',
self.admin_site.admin_view(self.player_info_view),
name='edit_rosters_player_info'),
url(r'^(?P<object_id>[0-9]+)/round_transition/$',
path('<int:object_id>/round_transition/',
self.admin_site.admin_view(self.round_transition_view),
name='round_transition'),
url(r'^(?P<object_id>[0-9]+)/review_nominated_games/$',
path('<int:object_id>/review_nominated_games/',
self.admin_site.admin_view(self.review_nominated_games_view),
name='review_nominated_games'),
url(r'^(?P<object_id>[0-9]+)/review_nominated_games/select/(?P<nom_id>[0-9]+)/$',
path('<int:object_id>/review_nominated_games/select/<int:nom_id>/',
self.admin_site.admin_view(self.review_nominated_games_select_view),
name='review_nominated_games_select'),
url(r'^(?P<object_id>[0-9]+)/review_nominated_games/deselect/(?P<sel_id>[0-9]+)/$',
path('<int:object_id>/review_nominated_games/deselect/<int:sel_id>/',
self.admin_site.admin_view(self.review_nominated_games_deselect_view),
name='review_nominated_games_deselect'),
url(r'^(?P<object_id>[0-9]+)/review_nominated_games/pgn/$',
path('<int:object_id>/review_nominated_games/pgn/',
self.admin_site.admin_view(self.review_nominated_games_pgn_view),
name='review_nominated_games_pgn'),
url(r'^(?P<object_id>[0-9]+)/bulk_email/$',
path('<int:object_id>/bulk_email/',
self.admin_site.admin_view(self.bulk_email_view),
name='bulk_email'),
url(r'^(?P<object_id>[0-9]+)/team_spam/$',
path('<int:object_id>/team_spam/',
self.admin_site.admin_view(self.team_spam_view),
name='team_spam'),
url(r'^(?P<object_id>[0-9]+)/mod_report/$',
path('<int:object_id>/mod_report/',
self.admin_site.admin_view(self.mod_report_view),
name='mod_report'),
url(r'^(?P<object_id>[0-9]+)/pre_round_report/$',
path('<int:object_id>/pre_round_report/',
self.admin_site.admin_view(self.pre_round_report_view),
name='pre_round_report'),
url(r'^(?P<object_id>[0-9]+)/export_players/$',
path('<int:object_id>/export_players/',
self.admin_site.admin_view(self.export_players_view),
name='export_players'),
]
Expand Down Expand Up @@ -544,7 +543,7 @@ def review_nominated_games_pgn_view(self, request, object_id):
pgn = lichessapi.get_pgn_with_cache(gameid, priority=10)

# Strip most tags for "blind" review
pgn = re.sub('\[[^R]\w+ ".*"\]\n', '', pgn)
pgn = re.sub(r'\[[^R]\w+ ".*"\]\n', '', pgn)

return HttpResponse(pgn)

Expand Down Expand Up @@ -1282,10 +1281,10 @@ class RoundAdmin(_BaseAdmin):
def get_urls(self):
urls = super(RoundAdmin, self).get_urls()
my_urls = [
url(r'^(?P<object_id>[0-9]+)/generate_pairings/$',
path('<int:object_id>/generate_pairings/',
self.admin_site.admin_view(self.generate_pairings_view),
name='generate_pairings'),
url(r'^(?P<object_id>[0-9]+)/review_pairings/$',
path('<int:object_id>/review_pairings/',
self.admin_site.admin_view(self.review_pairings_view),
name='review_pairings'),
]
Expand Down Expand Up @@ -1491,7 +1490,7 @@ class PlayerLateRegistrationAdmin(_BaseAdmin):
def get_urls(self):
urls = super(PlayerLateRegistrationAdmin, self).get_urls()
my_urls = [
url(r'^(?P<object_id>[0-9]+)/move_latereg/$',
path('<int:object_id>/move_latereg/',
self.admin_site.admin_view(self.move_latereg_view),
name='move_latereg'),
]
Expand Down Expand Up @@ -1956,13 +1955,13 @@ def valid(self, obj):
def get_urls(self):
urls = super(RegistrationAdmin, self).get_urls()
my_urls = [
url(r'^(?P<object_id>[0-9]+)/review/$',
path('<int:object_id>/review/',
self.admin_site.admin_view(self.review_registration),
name='review_registration'),
url(r'^(?P<object_id>[0-9]+)/approve/$',
path('<int:object_id>/approve/',
self.admin_site.admin_view(self.approve_registration),
name='approve_registration'),
url(r'^(?P<object_id>[0-9]+)/reject/$',
path('<int:object_id>/reject/',
self.admin_site.admin_view(self.reject_registration),
name='reject_registration')
]
Expand Down Expand Up @@ -2199,7 +2198,7 @@ def in_slack(self, sp):
def get_urls(self):
urls = super(SeasonPlayerAdmin, self).get_urls()
my_urls = [
url(r'^(?P<object_ids>[0-9,]+)/bulk_email/$',
path('<int:object_ids>/bulk_email/',
self.admin_site.admin_view(self.bulk_email_view),
name='bulk_email_by_players'),
]
Expand Down Expand Up @@ -2508,13 +2507,13 @@ def edit(self, obj):
def get_urls(self):
urls = super(ModRequestAdmin, self).get_urls()
my_urls = [
url(r'^(?P<object_id>[0-9]+)/review/$',
path('<int:object_id>/review/',
self.admin_site.admin_view(self.review_request),
name='tournament_modrequest_review'),
url(r'^(?P<object_id>[0-9]+)/approve/$',
path('<int:object_id>/approve/',
self.admin_site.admin_view(self.approve_request),
name='tournament_modrequest_approve'),
url(r'^(?P<object_id>[0-9]+)/reject/$',
path('<int:object_id>/reject/',
self.admin_site.admin_view(self.reject_request),
name='tournament_modrequest_reject')
]
Expand Down Expand Up @@ -2610,7 +2609,7 @@ def reject_request(self, request, object_id):
if 'confirm' in form.data:
obj.reject(request.user.username, form.cleaned_data['response'])
self.message_user(request, 'Request rejected.', messages.INFO)
return redirect_with_params('admin:tournament_registration_changelist',
return redirect_with_params('admin:tournament_modrequest_changelist',
params='?' + changelist_filters)
else:
return redirect_with_params('admin:tournament_modrequest_review', object_id,
Expand Down
25 changes: 0 additions & 25 deletions heltour/tournament/decorators.py

This file was deleted.

5 changes: 2 additions & 3 deletions heltour/tournament/forms.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
from django import forms
from django.utils.translation import ugettext_lazy as _
from captcha.fields import ReCaptchaField
from django.utils.translation import gettext_lazy as _
from django_recaptcha.fields import ReCaptchaField
from ckeditor_uploader.widgets import CKEditorUploadingWidget

from .models import *
from django.core.exceptions import ValidationError
from heltour import settings
import captcha
from django.urls import reverse
from heltour.tournament.workflows import ApproveRegistrationWorkflow
from heltour import gdpr
Expand Down
28 changes: 28 additions & 0 deletions heltour/tournament/migrations/0195_auto_20231118_2130.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Generated by Django 2.2.28 on 2023-11-18 21:30

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('tournament', '0194_playerpairing_last_time_player_changed'),
]

operations = [
migrations.AlterField(
model_name='registration',
name='alternate_preference',
field=models.CharField(blank=True, choices=[('alternate', 'Alternate'), ('full_time', 'Full Time'), ('either', 'Either is fine for me.')], max_length=255),
),
migrations.AlterField(
model_name='player',
name='profile',
field=models.JSONField(blank=True, null=True),
),
migrations.AlterField(
model_name='registration',
name='validation_ok',
field=models.BooleanField(blank=True, default=None, null=True),
),
]
Loading