Private
Public Access
1
0

working, passing tests in django 3.2

This commit is contained in:
Sander Roosendaal
2021-12-14 16:36:22 +01:00
parent 3fc1c8905c
commit 1e2e6ae87a
21 changed files with 311 additions and 62 deletions

21
manage.py_old.py Normal file
View File

@@ -0,0 +1,21 @@
#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import os
import sys
def main():
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'rowsandall_app.settings_dev')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)
if __name__ == '__main__':
main()

240
requirements_django2.txt Normal file
View File

@@ -0,0 +1,240 @@
amqp==2.4.2
apipkg==1.5
appdirs==1.4.3
arcgis==1.6.0
arrow==1.0.2
asgiref==3.4.1
asn1crypto==0.24.0
atomicwrites==1.3.0
attrs==19.1.0
backcall==0.1.0
backports.zoneinfo==0.2.1
beautifulsoup4==4.7.1
billiard==3.6.0.0
bleach==3.1.0
bokeh==2.2.3
boto==2.49.0
boto3==1.17.45
botocore==1.20.45
bottle==0.12.18
braintree==3.55.0
cairocffi==1.0.2
celery==4.3.0
certifi==2019.3.9
cffi==1.14.0
chardet==3.0.4
Click==7.0
cloudpickle==1.2.2
colorama==0.4.1
colorclass==2.2.0
cookies==2.2.1
coreapi==2.3.3
coreschema==0.0.4
coverage==5.5
cryptography==3.4.7
cycler==0.10.0
Cython==0.29.21
dask==2.20.0
decorator==4.4.0
defusedxml==0.5.0
Django==2.1.7
django-analytical==2.5.0
django-async-messages==0.3.1
django-braces==1.13.0
django-classy-tags==0.8.0
django-cookie-law==2.0.1
django-cors-headers==2.5.2
django-countries==5.3.3
django-datetime-widget==0.9.3
django-debug-toolbar==2.0
django-extensions==2.1.6
django-htmlmin==0.11.0
django-leaflet==0.24.0
django-mailbox==4.8.0
django-oauth-toolkit==1.2.0
django-oauth2-provider==0.2.6.1
django-picklefield==2.1.1
django-redis==4.10.0
django-rest-framework==0.1.0
django-rest-swagger==2.2.0
django-rq==2.4.1
django-rq-dashboard==0.3.3
django-ses==2.0.0
django-shell-plus==1.1.7
django-social-share==1.3.2
django-suit==0.2.28
django-taggit==1.3.0
django-tz-detect==0.2.9
djangorestframework==3.9.2
docopt==0.6.2
docutils==0.14
entrypoints==0.3
execnet==1.5.0
factory-boy==2.11.1
Faker==1.0.4
fastparquet==0.5.0
fitparse==1.2.0
Flask==1.0.2
fonttools==4.28.2
fsspec==0.5.2
future==0.17.1
geocoder==1.38.1
geoip2==3.0.0
geos==0.2.1
grpcio==1.26.0
grpcio-tools==1.26.0
gunicorn==20.0.4
holoviews==1.13.5
html5lib==1.0.1
htmlmin==0.1.12
HTMLParser==0.0.2
httplib2==0.12.1
humanize==3.3.0
hvplot==0.4.0
icalendar==4.0.3
idna==2.8
image==1.5.27
importlib-resources==1.0.2
ipykernel==5.1.0
ipython==7.22.0
ipython-genutils==0.2.0
ipywidgets==7.4.2
iso8601==0.1.12
isodate==0.6.0
itsdangerous==1.1.0
itypes==1.1.0
jedi==0.18.0
jeepney==0.6.0
Jinja2==2.10
jmespath==0.10.0
json5==0.8.5
jsonschema==3.0.1
jupyter==1.0.0
jupyter-client==6.1.7
jupyter-console==6.2.0
jupyter-core==4.7.0
jupyterlab==0.35.6
jupyterlab-server==0.2.0
keyring==18.0.0
kiwisolver==1.0.1
kombu==4.5.0
llvmlite==0.36.0
lxml==4.7.1
Markdown==3.0.1
MarkupSafe==1.1.1
matplotlib==3.5.0
maxminddb==1.5.4
MiniMockTest==0.5
mistune==0.8.4
mock==2.0.0
more-itertools==6.0.0
mpld3==0.3
mysqlclient==1.4.2.post1
nbconvert==5.4.1
nbformat==4.4.0
newrelic==5.2.1.129
nose==1.3.7
nose-parameterized==0.6.0
notebook==5.7.6
numba==0.53.1
numpy==1.18.5
oauth2==1.9.0.post1
oauthlib==3.0.1
openapi-codec==1.3.2
packaging==21.3
pandas==1.2.4
pandocfilters==1.4.2
panel==0.10.1
param==1.10.0
parameterized==0.8.1
parso==0.8.2
pathspec==0.5.9
pbr==5.1.3
pendulum==2.1.2
pexpect==4.6.0
pickleshare==0.7.5
Pillow==8.0.1
pip-upgrader==1.4.6
pluggy==0.9.0
prometheus-client==0.6.0
prompt-toolkit==2.0.9
protobuf==3.11.1
psycopg2==2.8.1
ptyprocess==0.6.0
py==1.8.0
pyarrow==2.0.0
pycairo==1.19.0
pycparser==2.19
pyct==0.4.8
Pygments==2.3.1
PyJWT==2.1.0
pyOpenSSL==20.0.1
pyparsing==2.3.1
pyrsistent==0.14.11
pyshp==2.1.0
pytest==4.3.1
pytest-django==3.4.8
pytest-forked==1.0.2
pytest-runner==4.4
pytest-sugar==0.9.2
pytest-xdist==1.27.0
python-dateutil==2.8.0
python-memcached==1.59
python-twitter==3.5
pytz==2020.1
pytzdata==2020.1
pyviz-comms==0.7.6
pywin32-ctypes==0.2.0
PyYAML==5.1
pyzmq==18.0.1
qtconsole==4.4.3
ratelim==0.1.6
rauth==0.7.3
redis==3.5.3
requests==2.23.0
requests-oauthlib==1.2.0
rowingdata==3.4.9
rowingphysics==0.5.0
rq==1.8.0
rules==2.1
ruptures==1.1.3
s3transfer==0.3.4
scipy==1.5.4
SecretStorage==3.3.1
Send2Trash==1.5.0
setuptools-scm==6.3.2
shell==1.0.1
shortuuid==0.5.0
simplejson==3.17.2
six==1.12.0
soupsieve==1.8
SQLAlchemy==1.3.1
sqlparse==0.3.0
stravalib==0.10.4
termcolor==1.1.0
terminado==0.8.1
terminaltables==3.1.0
testpath==0.4.2
text-unidecode==1.2
thrift==0.11.0
timezonefinder==5.2.0
tk==0.1.0
tomli==1.2.2
toolz==0.10.0
tornado==6.0.1
tqdm==4.31.1
traitlets==4.3.2
typing-extensions==3.7.4.3
units==0.7
uritemplate==3.0.0
urllib3==1.25.9
VerbalExpressions==0.0.2
vine==1.3.0
wcwidth==0.1.7
webencodings==0.5.1
Werkzeug==0.15.1
widgetsnbextension==3.4.2
xlrd==1.2.0
xmltodict==0.12.0
yamjam==0.1.7
yamllint==1.15.0

View File

@@ -8,7 +8,6 @@ from django.urls import reverse
from django.http import HttpResponseRedirect
from django.core.exceptions import PermissionDenied
from django.utils.decorators import available_attrs
from django.contrib import messages
try:
@@ -28,7 +27,7 @@ def user_passes_test(test_func, message=default_message,login_url=None,redirect_
that takes the user object and returns True if the user passes.
"""
def decorator(view_func):
@wraps(view_func, assigned=available_attrs(view_func))
#@wraps(view_func, assigned=available_attrs(view_func))
def _wrapped_view(request, *args, **kwargs):
if request.user.is_anonymous:
url = reverse('login')+'?next='+request.path

View File

@@ -32,7 +32,6 @@ from uuid import uuid4
# Django
from django.shortcuts import render_to_response
from django.http import HttpResponseRedirect, HttpResponse,JsonResponse
from django.conf import settings
from django.contrib.auth import authenticate, login, logout

View File

@@ -4,7 +4,6 @@ from __future__ import print_function
from __future__ import unicode_literals
from __future__ import unicode_literals, absolute_import
import uuid
from django.utils.encoding import python_2_unicode_compatible
from django.db import models,IntegrityError
from django.contrib.auth.models import User
@@ -403,7 +402,7 @@ class PowerTimeFitnessMetric(models.Model):
class Meta:
db_table = 'powertimefitnessmetric'
@python_2_unicode_compatible
class C2WorldClassAgePerformance(models.Model):
weightcategories = mytypes.weightcategories
@@ -445,7 +444,7 @@ class C2WorldClassAgePerformance(models.Model):
return thestring
@python_2_unicode_compatible
class Team(models.Model):
choices = (
('private','private'),
@@ -742,7 +741,7 @@ paymentprocessors = (
('braintree','BrainTree')
)
@python_2_unicode_compatible
class PaidPlan(models.Model):
shortname = models.CharField(max_length=50,choices=plans)
name = models.CharField(max_length=200)
@@ -769,7 +768,7 @@ class PaidPlan(models.Model):
paymentprocessor = self.paymentprocessor,
)
@python_2_unicode_compatible
class CoachingGroup(models.Model):
name = models.CharField(default='group',max_length=30,null=True,blank=True)
@@ -787,7 +786,7 @@ class CoachingGroup(models.Model):
return Rower.objects.filter(mycoachgroup=self)
# Extension of User with rowing specific data
@python_2_unicode_compatible
class Rower(models.Model):
adaptivetypes = mytypes.adaptivetypes
stravatypes = (
@@ -1439,7 +1438,7 @@ timezones = (
# models related to geo data (points, polygon, courses)
@python_2_unicode_compatible
class GeoCourse(models.Model):
manager = models.ForeignKey(Rower,null=True,on_delete=models.SET_NULL)
distance = models.IntegerField(default=0)
@@ -1475,7 +1474,7 @@ class GeoCourseEditForm(ModelForm):
'notes': forms.Textarea,
}
@python_2_unicode_compatible
class GeoPolygon(models.Model):
name = models.CharField(max_length=150,blank=True)
course = models.ForeignKey(GeoCourse, blank=True,on_delete=models.CASCADE,related_name='polygons')
@@ -1630,7 +1629,7 @@ class InstantPlanForm(ModelForm):
'yaml',
]
@python_2_unicode_compatible
class TrainingPlan(models.Model):
statuschoices = (
@@ -2035,7 +2034,7 @@ def macrocyclecheckdates(plan): # pragma: no cover
pass
cycles = cycles[1:]
@python_2_unicode_compatible
class TrainingMacroCycle(models.Model):
plan = models.ForeignKey(TrainingPlan,on_delete=models.CASCADE)
name = models.CharField(max_length=150,blank=True)
@@ -2124,7 +2123,7 @@ class TrainingMacroCycleForm(ModelForm):
'enddate': AdminDateWidget()
}
@python_2_unicode_compatible
class TrainingMesoCycle(models.Model):
plan = models.ForeignKey(TrainingMacroCycle,on_delete=models.CASCADE)
name = models.CharField(max_length=150,blank=True)
@@ -2204,7 +2203,7 @@ class TrainingMesoCycle(models.Model):
createmicrofillers(self)
@python_2_unicode_compatible
class TrainingMicroCycle(models.Model):
plan = models.ForeignKey(TrainingMesoCycle,on_delete=models.CASCADE)
name = models.CharField(max_length=150,blank=True)
@@ -2301,7 +2300,7 @@ regularsessiontypechoices = (
)
# model for Planned Session (Workout, Challenge, Test)
@python_2_unicode_compatible
class PlannedSession(models.Model):
sessiontypechoices = (
@@ -2605,7 +2604,7 @@ registerchoices = (
('manual','Manual - select below'),
)
@python_2_unicode_compatible
class VirtualRace(PlannedSession):
# has_registration = models.BooleanField(default=False)
registration_form = models.CharField(
@@ -3187,7 +3186,7 @@ class Workout(models.Model):
starttime = models.TimeField(default=timezone.now)
startdatetime = models.DateTimeField(blank=True,null=True)
timezone = models.CharField(default='UTC',
choices=timezones,
#choices=timezones,
max_length=100)
distance = models.IntegerField(default=0)
duration = models.TimeField(blank=True)
@@ -3404,7 +3403,7 @@ class FollowerForm(ModelForm):
fields = ['emailaddress']
# Virtual Race results (for keeping results when workouts are deleted)
@python_2_unicode_compatible
class VirtualRaceResult(models.Model):
boatclasses = (type for type in mytypes.workouttypes if type[0] in mytypes.otwtypes)
userid = models.IntegerField(default=0)
@@ -3529,7 +3528,7 @@ class VirtualRaceResult(models.Model):
)
# Virtual Race results (for keeping results when workouts are deleted)
@python_2_unicode_compatible
class IndoorVirtualRaceResult(models.Model):
boatclasses = (type for type in mytypes.workouttypes if type[0] in mytypes.otetypes)
userid = models.IntegerField(default=0) # ID of rower object
@@ -3794,7 +3793,7 @@ class ergcpdata(models.Model):
app_label = 'rowers'
# A wrapper around the png files
@python_2_unicode_compatible
class GraphImage(models.Model):
filename = models.CharField(default='',max_length=150,blank=True,null=True)
creationdatetime = models.DateTimeField()
@@ -3856,7 +3855,9 @@ class WorkoutForm(ModelForm):
label='Private')
self.fields['timezone'] = forms.ChoiceField(
choices = [(x,x) for x in pytz.common_timezones]
choices = (
(x,x) for x in pytz.common_timezones
)
)
if 'instance' in kwargs:
@@ -4547,7 +4548,7 @@ class SiteAnnouncement(models.Model):
return super(SiteAnnouncement,self).save(*args, **kwargs)
# A comment by a user on a training
@python_2_unicode_compatible
class WorkoutComment(models.Model):
comment = models.TextField(max_length=300)
created = models.DateTimeField(default=timezone.now)
@@ -4573,7 +4574,7 @@ class WorkoutCommentForm(ModelForm):
}
# A comment by a user on a training
@python_2_unicode_compatible
class PlannedSessionComment(models.Model):
comment = models.TextField(max_length=300)
created = models.DateTimeField(default=timezone.now)

View File

@@ -23,7 +23,6 @@ import urllib
import rowers.c2stuff as c2stuff
# Django
from django.shortcuts import render_to_response
from django.http import HttpResponseRedirect, HttpResponse,JsonResponse
from django.conf import settings
from django.contrib.auth import authenticate, login, logout

View File

@@ -27,7 +27,6 @@ from uuid import uuid4
from requests import ConnectionError
# Django
from django.shortcuts import render_to_response
from django.http import HttpResponseRedirect, HttpResponse,JsonResponse
from django.conf import settings
from django.contrib.auth import authenticate, login, logout

View File

@@ -16,7 +16,7 @@ import re
from parameterized import parameterized
from django.test import TestCase, Client,override_settings
from django.core.management import call_command
from django.utils.six import StringIO
from django.test.client import RequestFactory
from rowers.views import c2_open
from rowers.models import Workout, User, Rower, WorkoutForm,RowerForm,GraphImage

View File

@@ -32,7 +32,9 @@ from django.test import TestCase, Client,override_settings, RequestFactory, Tran
from django.core.management import call_command
from django.core.files.uploadedfile import SimpleUploadedFile
from django.utils.six import StringIO
from io import StringIO
from django.test.client import RequestFactory
from rowers.views import c2_open, multi_compare_view

View File

@@ -9,7 +9,7 @@ from django.db import transaction
nu = datetime.datetime.now()
from django.core.files import File
from django.utils.six import BytesIO
from io import BytesIO
from PIL import Image
from io import StringIO

View File

@@ -11,7 +11,6 @@ from rowingdata import rowingdata
nu = datetime.datetime.now()
from django.core.files import File
from django.utils.six import BytesIO
from PIL import Image
from io import StringIO

View File

@@ -119,6 +119,7 @@ class ViewTest(TestCase):
'notes':'noot mies',
}
form = WorkoutForm(data=form_data)
self.assertTrue(form.is_valid())
response = self.c.post('/rowers/workout/'+encoded1+'/edit/', form_data, follow=True)
self.assertEqual(response.status_code, 200)

BIN
rowers/tests/testdata/testdata.tcx.gz vendored Normal file

Binary file not shown.

View File

@@ -1,6 +1,5 @@
from django.contrib.auth.tokens import PasswordResetTokenGenerator
from django.utils import six
import six
class AccountActivationTokenGenerator(PasswordResetTokenGenerator):
def _make_hash_value(self, user, timestamp):

View File

@@ -855,14 +855,14 @@ def rower_register_view(request):
d = {
'user': theuser,
'domain': current_site.domain,
'uid': urlsafe_base64_encode(force_bytes(theuser.id)).decode(),
'uid': urlsafe_base64_encode(force_bytes(theuser.id)),
'token': account_activation_token.make_token(theuser),
}
to_email = form.cleaned_data.get('email')
message = render_to_string('acc_activate_email.html', {
'user': theuser,
'domain': current_site.domain,
'uid': urlsafe_base64_encode(force_bytes(theuser.id)).decode(),
'uid': urlsafe_base64_encode(force_bytes(theuser.id)),
'token': account_activation_token.make_token(theuser),
})
to_email = form.cleaned_data.get('email')

View File

@@ -1617,9 +1617,7 @@ def plannedsessions_print_view(request,userid=0,startdatestring='',enddatestring
def plannedsessions_manage_view(request,userid=0,
initialsession=0):
is_ajax = False
if request.is_ajax(): # pragma: no cover
is_ajax = True
is_ajax = request.META.get('HTTP_X_REQUESTED_WITH') == 'XMLHttpRequest'
r = getrequestrower(request,userid=userid)

View File

@@ -414,9 +414,7 @@ def virtualevent_setlogo_view(request,id=0,logoid=0): # pragma: no cover
# Image upload to virtual event
@login_required()
def virtualevent_uploadimage_view(request,id=0): # pragma: no cover
is_ajax = False
if request.is_ajax():
is_ajax = True
is_ajax = request.META.get('HTTP_X_REQUESTED_WITH') == 'XMLHttpRequest'
r = getrower(request.user)
@@ -519,9 +517,7 @@ def virtualevent_uploadimage_view(request,id=0): # pragma: no cover
@login_required()
@permission_required('course.change_course',fn=get_course_by_pk,raise_exception=True)
def course_upload_replace_view(request,id=0):
is_ajax = False
if request.is_ajax(): # pragma: no cover
is_ajax = True
is_ajax = request.META.get('HTTP_X_REQUESTED_WITH') == 'XMLHttpRequest'
r = getrower(request.user)
@@ -649,9 +645,7 @@ def course_update_confirm(request,id=0,newid=0):
# Course upload
@login_required()
def course_upload_view(request):
is_ajax = False
if request.is_ajax(): # pragma: no cover
is_ajax = True
is_ajax = request.META.get('HTTP_X_REQUESTED_WITH') == 'XMLHttpRequest'
r = getrower(request.user)
@@ -715,9 +709,7 @@ def course_upload_view(request):
# Standards deactivate
@login_required()
def standard_deactivate_view(request,id=0):
is_ajax = False
if request.is_ajax(): # pragma: no cover
is_ajax = True
is_ajax = request.META.get('HTTP_X_REQUESTED_WITH') == 'XMLHttpRequest'
r = getrower(request.user)
@@ -762,10 +754,8 @@ def standards_download_view(request,id=0):
# Standards upload
@login_required()
def standards_upload_view(request,id=0):
is_ajax = False
if request.is_ajax(): # pragma: no cover
is_ajax = True
r = getrower(request.user)
is_ajax = request.META.get('HTTP_X_REQUESTED_WITH') == 'XMLHttpRequest'
r = getrower(request.user)
if id != 0: # pragma: no cover
collection = StandardCollection.objects.get(id=id)
@@ -833,9 +823,7 @@ def standards_upload_view(request,id=0):
def virtualevents_view(request):
is_ajax = False
if request.is_ajax(): # pragma: no cover
is_ajax = True
is_ajax = request.META.get('HTTP_X_REQUESTED_WITH') == 'XMLHttpRequest'
g = GeoIP2()
ip = request.META.get('HTTP_X_REAL_IP','1.1.1.1')

View File

@@ -4873,7 +4873,7 @@ def workout_map_view(request,id=0):
# Image upload
@permission_required('workout.change_workout',fn=get_workout_by_opaqueid,raise_exception=True)
def workout_uploadimage_view(request,id): # pragma: no cover
is_ajax = request_is_ajax(request)
is_ajax = request.META.get('HTTP_X_REQUESTED_WITH') == 'XMLHttpRequest'
r = getrower(request.user)
@@ -5013,7 +5013,7 @@ def workout_add_chart_view(request,id,plotnr=1):
@login_required
@permission_required('workout.change_workout',fn=get_workout_by_opaqueid,raise_exception=True)
def workout_toggle_ranking(request,id=0):
is_ajax = request_is_ajax(request)
is_ajax = request.META.get('HTTP_X_REQUESTED_WITH') == 'XMLHttpRequest'
row = get_workout_by_opaqueid(request,id)
@@ -5286,7 +5286,7 @@ def workout_upload_view(request,
},
raceid=0):
is_ajax = request_is_ajax(request)
is_ajax = request.META.get('HTTP_X_REQUESTED_WITH') == 'XMLHttpRequest'
if settings.TESTING:
is_ajax = False

View File

@@ -47,6 +47,7 @@ ALLOWED_HOSTS = CFG['allowed_hosts']
#OAUTH2_PROVIDER_REFRESH_TOKEN_MODEL = 'oauth2_provider.RefreshToken'
#OAUTH2_PROVIDER_ACCESS_TOKEN_EXPIRE_SECONDS = 3600
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
# Application definition
@@ -139,6 +140,9 @@ TEMPLATES = [
'context_processors.warning_message',
'rowers.context_processors.braintree_merchant',
],
'libraries' : {
'staticfiles': 'django.templatetags.static',
}
# 'loaders': [
# 'django.template.loaders.app_directories.Loader',
# ],

View File

@@ -1,4 +1,4 @@
from django.apps import AppConfig
class SurveyConfig(AppConfig):
name = 'app'
name = 'survey'

View File

@@ -49,7 +49,7 @@ class Response(models.Model):
video = models.BooleanField(default=False,verbose_name='Video Analysis')
interval = models.BooleanField(default=False,verbose_name='Interval editor')
capabilities = models.NullBooleanField(default=None,null=True,blank=True,
capabilities = models.BooleanField(default=None,null=True,blank=True,
verbose_name='Did you get the capabilities and features that you expected out of Rowsandall')
fallshort = models.TextField(max_length=500,blank=True,verbose_name='Where did Rowsandall fall short of your expectations?')