Skip to content

Commit

Permalink
Merge pull request #327 from domino14/django-2.2
Browse files Browse the repository at this point in the history
upgrading to django 2.2
  • Loading branch information
domino14 authored Jun 13, 2019
2 parents 01e3995 + 3befcd0 commit 9eaa1b0
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 31 deletions.
5 changes: 0 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@ jobs:
INTERCOM_APP_SECRET_KEY: abcdefghijklmnopqrstuvwxyz
SECRET_KEY: csw*nc9gznwuz)(w9&u#h_b2dp1%hzf_w#)%yrzwas%+v8ck_q
WORD_DB_LOCATION: /opt/db
REDIS_HOST: localhost
docker:
- image: domino14/webolith-base-pkg:py3-latest
- image: redis:alpine
- image: postgres
steps:
- checkout # Into the webolith-base-pkg
Expand Down Expand Up @@ -45,9 +43,6 @@ jobs:
- run:
name: Wait for db
command: dockerize -wait tcp://localhost:5432 -timeout 1m
- run:
name: Wait for redis
command: dockerize -wait tcp://localhost:6379 -timeout 1m
- run:
name: Django tests
command: cd djAerolith && ./manage.py test -v2
Expand Down
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ node_modules
djAerolith/static/img/avatars/*
*.sublime-workspace
namedLists.json
djAerolith/static/build/*
djAerolith/static/built/*
*.mo
config/config.env
config/local_config.env
Expand Down
2 changes: 2 additions & 0 deletions base_pkg.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ RUN pip install --upgrade pip
RUN pip install -r /opt/prod_requirements.txt

# Prod image can import this image, and build on top of it.
# build like this:
# docker build --no-cache --pull -t domino14/webolith-base-pkg:py3-latest -f base_pkg.dockerfile .
4 changes: 2 additions & 2 deletions djAerolith/accounts/backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
logger = logging.getLogger(__name__)


class CaseInsensitiveModelBackend(object):
def authenticate(self, username=None, password=None):
class CaseInsensitiveModelBackend:
def authenticate(self, request=None, username=None, password=None):
try:
user = User.objects.get(username__iexact=username)
if user.check_password(password):
Expand Down
9 changes: 8 additions & 1 deletion djAerolith/djaerolith/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,9 @@ def tobool(val):
)

AUTHENTICATION_BACKENDS = (
'accounts.backends.CaseInsensitiveModelBackend',
'social_core.backends.google.GoogleOAuth2',
'social_core.backends.facebook.FacebookOAuth2',
'accounts.backends.CaseInsensitiveModelBackend',
)

SOCIAL_AUTH_PIPELINE = (
Expand Down Expand Up @@ -315,6 +315,11 @@ def tobool(val):
'level': 'ERROR',
'propagate': False,
},
'django.utils': {
'handlers': ['console', 'mail_admins'],
'level': 'INFO',
'propagate': False,
},
'django': {
'handlers': ['console', 'mail_admins'],
'level': 'DEBUG' if DEBUG else 'INFO',
Expand All @@ -334,6 +339,8 @@ def tobool(val):
# LOGGING config
USE_CAPTCHA = tobool(os.environ.get('USE_CAPTCHA', True))
NOCAPTCHA = True
# Don't complain about captcha in debug mode.
SILENCED_SYSTEM_CHECKS = ['captcha.recaptcha_test_key_error']

if os.environ.get('RECAPTCHA_PRIVATE_KEY'):
RECAPTCHA_PUBLIC_KEY = "6LctSMUSAAAAAAe-qMSIt5Y-iTw5hcFRsk2BPYl2"
Expand Down
17 changes: 7 additions & 10 deletions djAerolith/djaerolith/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
from django.conf.urls import url, include
# Uncomment the next two lines to enable the admin:
from django.contrib import admin
#from registration.forms import RegistrationFormUniqueEmail
from django.contrib.auth import views as auth_views
from django.views.generic import TemplateView
from registration.backends.simple.views import RegistrationView
Expand Down Expand Up @@ -63,25 +62,23 @@ def get_success_url(self, user):
url(r'^accounts/register/$', AerolithRegistrationView.as_view(
form_class=get_registration_form(settings.USE_CAPTCHA))),

#override the default registration urls
# override the default registration urls
url(r'^accounts/password/change/$',
auth_views.password_change,
name='password_change'),
auth_views.PasswordChangeView.as_view()),
url(r'^accounts/password/change/done/$',
auth_views.password_change_done,
auth_views.PasswordChangeDoneView.as_view(),
name='password_change_done'),
url(r'^accounts/password/reset/$',
auth_views.password_reset,
name='password_reset'),
auth_views.PasswordResetView.as_view()),
url(r'^accounts/password/reset/done/$',
auth_views.password_reset_done,
auth_views.PasswordResetDoneView.as_view(),
name='password_reset_done'),
url(r'^accounts/password/reset/complete/$',
auth_views.password_reset_complete,
auth_views.PasswordResetCompleteView.as_view(),
name='password_reset_complete'),
url(r'^accounts/password/reset/confirm/(?P<uidb64>[0-9A-Za-z]+)-'
'(?P<token>.+)/$',
auth_views.password_reset_confirm,
auth_views.PasswordResetConfirmView.as_view(),
name='password_reset_confirm'),

url(r'^accounts/username/change/$', username_change,
Expand Down
4 changes: 2 additions & 2 deletions djAerolith/prod_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# These are the requirements for the prod Docker file.

django>=2.0,<2.1
django>=2.2,<2.3
six >= 1.7
Markdown
django-registration-redux
gargoyle-yplan
requests
django-recaptcha
redis
# redis
jsonschema
social-auth-app-django
requests-oauthlib
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{# this is only here so that tests don't fail. it will get overwritten on prod #}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{# this is only here so that tests don't fail. it will get overwritten on prod #}
12 changes: 3 additions & 9 deletions djAerolith/wordwalls/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,14 +179,6 @@ def handle_table_post(request, tableid):
profile.customWordwallsStyle = request.POST['prefs']
profile.save()
return response({'success': True})
elif action == "getDcData":
# XXX XXX XXX Delete me after deploy.
wwg = WordwallsGame()
dcId = wwg.get_dc_id(tableid)
if dcId > 0:
leaderboardData = get_leaderboard_data_for_dc_instance(
DailyChallenge.objects.get(pk=dcId))
return response(leaderboardData)

return response({'success': False, 'error': _('Unhandled action.')},
status=StatusCode.BAD_REQUEST)
Expand All @@ -213,7 +205,9 @@ def ajax_upload(request):

filename = uploaded_file.name
try:
file_contents = uploaded_file.read().decode('utf-8')
# utf-8-sig will throw away the UTF8 BOM if found at the beginning of
# the file.
file_contents = uploaded_file.read().decode('utf-8-sig')
except UnicodeDecodeError:
return response(_('Please make sure your file is utf-8 encoded.'),
StatusCode.BAD_REQUEST)
Expand Down

0 comments on commit 9eaa1b0

Please sign in to comment.