-
Notifications
You must be signed in to change notification settings - Fork 38
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
update django to 4.2 #527
base: master
Are you sure you want to change the base?
update django to 4.2 #527
Conversation
just noticed that django 5 was released in the meantime. will soon work on upgrading. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, a few minor cosmetic things @lakinwecker can we get this merged?
heltour/tournament/admin.py
Outdated
@@ -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]\\w+ ".*"\\]\n', '', pgn) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but I think the pythonic way of doing this is using a regrex string literal:
pgn = re.sub('\\[[^R]\\w+ ".*"\\]\n', '', pgn) | |
pgn = re.sub(r'\[[^R]\w+ ".*"\]\n', '', pgn) |
The solution is to use Python’s raw string notation for regular expression patterns; backslashes are not handled in any special way in a string literal prefixed with 'r'. So r"\n" is a two-character string containing '' and 'n', while "\n" is a one-character string containing a newline. Usually patterns will be expressed in Python code using this raw string notation.
heltour/tournament/models.py
Outdated
@@ -732,7 +731,7 @@ def __str__(self): | |||
return self.account_username | |||
|
|||
|
|||
username_validator = RegexValidator('^[\w-]+$') | |||
username_validator = RegexValidator('^[\\w-]+$') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see above on regexp litrals
heltour/tournament/signals.py
Outdated
do_pairings_published = Signal(providing_args=['round_id']) | ||
do_validate_registration = Signal(providing_args=['reg_id']) | ||
do_create_team_channel = Signal(providing_args=['team_ids']) | ||
do_generate_pairings = Signal() # providing_args=['round_id', 'overwrite'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delete comments, we have version control.
@@ -3,7 +3,8 @@ | |||
from django.test import TestCase | |||
from unittest.mock import patch | |||
from heltour.tournament import oauth | |||
from .testutils import * | |||
from .testutils import *# |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
generally speaking it's worth being explicit about your imports. from a practical perspective it helps static analysis because when you have import *
the program (it it's not like a LSP or something) really struggles to know what variables/functions etc are on the stack.
Additionally relative imports are the devil, prefere absolute imports if possible.
@@ -20,13 +21,18 @@ def test_encode_decode_state(self, *args): | |||
@patch('heltour.tournament.oauth._encode_state', return_value='encodedstate') | |||
def test_oauth_redirect(self, *args): | |||
response = self.client.get(league_url('team', 'login')) | |||
expected_oauth_url = 'https://oauth.lichess.org/oauth/authorize' + \ | |||
url = re.sub("&code_challenge=[0-9A-z-]{43}", "", response.url) | |||
expected_oauth_url = 'https://lichess.org/oauth' + \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expected_oauth_url = 'https://lichess.org/oauth' + \ | |
expected_oauth_url = ('https://lichess.org/oauth' | |
'?response_type=code' | |
'&client_id=clientid' | |
'&redirect_uri=http://testserver/auth/lichess/' | |
'&scope=email:read%20challenge:read%20challenge:write' | |
'&code_challenge_method=S256' | |
'&state=encodedstate') |
python will concat this strings for you.
I would also make an argument to use https://docs.python.org/3/library/urllib.parse.html#module-urllib.parse as you are looking at a URL. but not the end of the world
i'll fix the minor stuff on tuesday/wednesday. |
I trust you all more than I trust myself on this stuff at the moment. I won't have time to review it in depth, anytime soon. Do you need me to mash the merge button? Or does one of you have the perms to do that? I can deploy whenever you are ready |
I ran into an error testing this locally so don't merge yet. Django 4.1 upgraded the adding the missing map files appears to fix the problem locally for me. |
i wonder why i did not have that local error. i will fix this tomorrow/day after tomorrow as well. also, i will try to see why i didn't have the error locally. PS: lakin, you gave me the merge perm. but the only way for me to use it responsibly is to not use it. |
no. I'm suggesting that some of the current files are missing maps for their minified content but are still referencing them. The old version of I'm not sure what settings you are running locally but if you change the staticfiles storage to |
it's also entirely possible that I have broken something in my branch and I might be projecting :D |
@nicwest fixed all the minor issues you commented about above. i also tried to read up on the |
you can grab the files from here: |
right. i added those map files, but this is some dark magic. locally, the empty files did not lead to an error for me already, so i am not convinced i fixed it. i turned debug on and off again, and switched around some folders and STATIC*-settings, and in the end i did manage to break everything. doesn't seem related to those map files though, so i am still in the dark. |
you may need to to run |
CACHEOPS_ENABLED = False
in your settings now.i don't really see where we even use select2, so i simply removed it.removing it is not possible, unless we squash migrations.edit: this will also close #525