Private
Public Access
1
0

half way through cleaning up and commenting the code

This commit is contained in:
Sander Roosendaal
2017-01-13 14:36:05 +01:00
parent 24364dcfb1
commit 220bc531dd
38 changed files with 140 additions and 2682 deletions

View File

@@ -1,6 +1,6 @@
from django import forms
from rowers.models import Workout
from rowsandall_app.rows import validate_file_extension,must_be_csv
from rowers.rows import validate_file_extension,must_be_csv
from django.contrib.auth.forms import UserCreationForm
from django.contrib.auth.models import User
from django.contrib.admin.widgets import AdminDateWidget
@@ -9,10 +9,12 @@ from django.utils import timezone,translation
import datetime
# login form
class LoginForm(forms.Form):
username = forms.CharField()
password = forms.CharField(widget=forms.PasswordInput())
# simple form for Contact page. Sends email to info@rowsandall.com
class EmailForm(forms.Form):
firstname = forms.CharField(max_length=255)
lastname = forms.CharField(max_length=255)
@@ -21,16 +23,21 @@ class EmailForm(forms.Form):
botcheck = forms.CharField(max_length=5)
message = forms.CharField()
# Upload the CrewNerd Summary CSV
class CNsummaryForm(forms.Form):
file = forms.FileField(required=True,validators=[must_be_csv])
# The little window to type '4x2000m/500m' to update the workout summary
class SummaryStringForm(forms.Form):
intervalstring = forms.CharField(max_length=255,label='Workout Description')
# Used for testing the POST API for StrokeData
class StrokeDataForm(forms.Form):
strokedata = forms.CharField(label='payload',
widget=forms.Textarea)
# The form used for uploading files
class DocumentsForm(forms.Form):
filetypechoices = (
('csv' , 'Painsled iOS CSV'),
@@ -50,9 +57,6 @@ class DocumentsForm(forms.Form):
workouttype = forms.ChoiceField(required=True,
choices=Workout.workouttypes,
initial='rower')
# fileformat = forms.ChoiceField(required=True,
# choices=filetypechoices,
# initial='csv')
notes = forms.CharField(required=False,
widget=forms.Textarea)
@@ -60,7 +64,8 @@ class DocumentsForm(forms.Form):
fields = ['title','file','workouttype','fileformat']
# The form to indicate additional actions to be performed immediately
# after a successful upload
class UploadOptionsForm(forms.Form):
plotchoices = (
('timeplot','Time Plot'),
@@ -76,6 +81,8 @@ class UploadOptionsForm(forms.Form):
class Meta:
fields = ['make_plot','plottype','upload_toc2']
# This form is used on the Analysis page to add a custom distance/time
# trial and predict the pace
class PredictedPieceForm(forms.Form):
unitchoices = (
('t','minutes'),
@@ -88,6 +95,7 @@ class PredictedPieceForm(forms.Form):
class Meta:
fields = ['value','pieceunit']
# On the Geeky side, to update stream information for river dwellers
class UpdateStreamForm(forms.Form):
unitchoices = (
('m','m/s'),
@@ -107,6 +115,7 @@ class UpdateStreamForm(forms.Form):
class Meta:
fields = ['dist1','dist2','stream1', 'stream2','streamunit']
# add wind information to your workout
class UpdateWindForm(forms.Form):
unitchoices = (
('m','m/s'),
@@ -134,8 +143,7 @@ class UpdateWindForm(forms.Form):
'windunit',
'winddirection1','winddirection2']
# Form to select a data range to show workouts from a certain time period
class DateRangeForm(forms.Form):
startdate = forms.DateField(initial=timezone.now()-datetime.timedelta(days=365),
widget=SelectDateWidget(years=range(1990,2050)),
@@ -147,6 +155,7 @@ class DateRangeForm(forms.Form):
class Meta:
fields = ['startdate','enddate']
# Form used to select workouts for the past N days
class DeltaDaysForm(forms.Form):
deltadays = forms.IntegerField(initial=0,required=False,label='')
@@ -191,13 +200,14 @@ class RegistrationFormUniqueEmail(RegistrationFormTermsOfService):
raise forms.ValidationError("This email address is already in use. Please supply a different email address.")
return self.cleaned_data['email']
# Time field supporting microseconds. Not used, I believe.
class MyTimeField(forms.TimeField):
def __init__(self, *args, **kwargs):
super(MyTimeField, self).__init__(*args, **kwargs)
supports_microseconds = True
# Form used to update interval stats
class IntervalUpdateForm(forms.Form):
def __init__(self, *args, **kwargs):