Private
Public Access
1
0

first version of race create form

This commit is contained in:
Sander Roosendaal
2018-04-13 15:18:57 +02:00
parent be1f17fde3
commit 0531ec0395
9 changed files with 161 additions and 8 deletions

View File

@@ -34,7 +34,7 @@ from rowers.forms import (
WorkFlowLeftPanelElement,WorkFlowMiddlePanelElement,
LandingPageForm,PlannedSessionSelectForm,WorkoutSessionSelectForm,
PlannedSessionTeamForm,PlannedSessionTeamMemberForm,
VirtualRaceSelectForm,
VirtualRaceSelectForm
)
from django.core.urlresolvers import reverse
from django.core.exceptions import PermissionDenied
@@ -67,6 +67,7 @@ from rowers.models import (
WorkoutComment,WorkoutCommentForm,RowerExportForm,
CalcAgePerformance,PowerTimeFitnessMetric,PlannedSessionForm,
PlannedSessionFormSmall,GeoCourseEditForm,VirtualRace,
VirtualRaceForm,
)
from rowers.models import (
FavoriteForm,BaseFavoriteFormSet,SiteAnnouncement,BasePlannedSessionFormSet
@@ -13302,3 +13303,62 @@ def virtualevents_view(request):
'form':form,
}
)
def virtualevent_create_view(request):
r = getrower(request.user)
if request.method == 'POST':
racecreateform = VirtualRaceForm(request.POST)
if racecreateform.is_valid():
cd = racecreateform.cleaned_data
startdate = cd['startdate']
start_time = cd['start_time']
enddate = cd['enddate']
end_time = cd['end_time']
comment = cd['comment']
course = cd['course']
name = cd['name']
has_registration = cd['has_registration']
registration_closure = cd['registration_closure']
evaluation_closure = cd['evaluation_closure']
contact_phone = cd['contact_phone']
contact_email = cd['contact_email']
geocourse = GeoCourse.objects.get(id= course.id)
vs = VirtualRace(
name=name,
startdate=startdate,
preferreddate = startdate,
start_time = start_time,
enddate=enddate,
end_time=end_time,
course=geocourse,
comment=comment,
sessiontype = 'coursetest',
has_registration=has_registration,
evaluation_closure=evaluation_closure,
registration_closure=registration_closure,
contact_phone=contact_phone,
contact_email=contact_email,
country = course.country,
manager=request.user,
)
vs.save()
url = reverse(virtualevents_view)
return HttpResponseRedirect(url)
else:
racecreateform = VirtualRaceForm()
return render(request,'virtualeventcreate.html',
{
'form':racecreateform,
'rower':r,
})