race edit form
This commit is contained in:
@@ -1075,7 +1075,19 @@ class VirtualRace(PlannedSession):
|
|||||||
|
|
||||||
contact_email = models.EmailField(max_length=254,
|
contact_email = models.EmailField(max_length=254,
|
||||||
validators=[validate_email],blank=True)
|
validators=[validate_email],blank=True)
|
||||||
|
|
||||||
|
def __unicode__(self):
|
||||||
|
|
||||||
|
name = self.name
|
||||||
|
startdate = self.startdate
|
||||||
|
enddate = self.enddate
|
||||||
|
|
||||||
|
stri = u'Virtual Race {n}'.format(
|
||||||
|
n = name,
|
||||||
|
)
|
||||||
|
|
||||||
|
return stri
|
||||||
|
|
||||||
# Date input utility
|
# Date input utility
|
||||||
class DateInput(forms.DateInput):
|
class DateInput(forms.DateInput):
|
||||||
input_type = 'date'
|
input_type = 'date'
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import time
|
|||||||
from django.db import IntegrityError
|
from django.db import IntegrityError
|
||||||
import uuid
|
import uuid
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
import pytz
|
||||||
from utils import myqueue
|
from utils import myqueue
|
||||||
|
|
||||||
import django_rq
|
import django_rq
|
||||||
@@ -447,3 +447,37 @@ def update_plannedsession(ps,cd):
|
|||||||
ps.save()
|
ps.save()
|
||||||
|
|
||||||
return 1,'Planned Session Updated'
|
return 1,'Planned Session Updated'
|
||||||
|
|
||||||
|
def update_virtualrace(ps,cd):
|
||||||
|
for attr, value in cd.items():
|
||||||
|
if attr == 'comment':
|
||||||
|
value.replace("\r\n", "
");
|
||||||
|
value.replace("\n", "
");
|
||||||
|
setattr(ps, attr, value)
|
||||||
|
|
||||||
|
# correct times
|
||||||
|
|
||||||
|
course = cd['course']
|
||||||
|
geocourse = GeoCourse.objects.get(id= course.id)
|
||||||
|
timezone_str = courses.get_course_timezone(geocourse)
|
||||||
|
|
||||||
|
startdatetime = datetime.combine(cd['startdate'],cd['start_time'])
|
||||||
|
enddatetime = datetime.combine(cd['enddate'],cd['end_time'])
|
||||||
|
|
||||||
|
startdatetime = pytz.timezone(timezone_str).localize(
|
||||||
|
startdatetime
|
||||||
|
)
|
||||||
|
enddatetime = pytz.timezone(timezone_str).localize(
|
||||||
|
enddatetime
|
||||||
|
)
|
||||||
|
ps.evaluation_closure = pytz.timezone(timezone_str).localize(
|
||||||
|
ps.evaluation_closure.replace(tzinfo=None)
|
||||||
|
)
|
||||||
|
ps.registration_closure = pytz.timezone(timezone_str).localize(
|
||||||
|
ps.registration_closure.replace(tzinfo=None)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
ps.save()
|
||||||
|
|
||||||
|
return 1,'Virtual Race Updated'
|
||||||
|
|||||||
@@ -10,6 +10,12 @@
|
|||||||
|
|
||||||
<h1>{{ race.name }}</h1>
|
<h1>{{ race.name }}</h1>
|
||||||
|
|
||||||
|
{% if request.user == race.manager %}
|
||||||
|
<div class="grid_2 alpha">
|
||||||
|
<p>
|
||||||
|
<a href="/rowers/virtualevent/{{ race.id }}/edit" class="button gray small">Edit</a>
|
||||||
|
</p>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -40,6 +46,9 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<th>Contact Phone</th><td>{{ race.contact_phone }}</td>
|
<th>Contact Phone</th><td>{{ race.contact_phone }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th>Comment</th><td>{{ race.comment }}</td>
|
||||||
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</p>
|
</p>
|
||||||
|
|||||||
49
rowers/templates/virtualeventedit.html
Normal file
49
rowers/templates/virtualeventedit.html
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
{% extends "base.html" %}
|
||||||
|
{% load staticfiles %}
|
||||||
|
{% load rowerfilters %}
|
||||||
|
|
||||||
|
{% block title %}Edit Virtual Race{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
<div class="grid_12 alpha">
|
||||||
|
|
||||||
|
<h1>Edit Race {{ race.name }}</h1>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="grid_8 alpha">
|
||||||
|
<form enctype="multipart/form-data" action="{{ formloc }}" method="post">
|
||||||
|
{% if form.errors %}
|
||||||
|
<p style="color: red;">
|
||||||
|
Please correct the error{{ form.errors|pluralize }} below.
|
||||||
|
</p>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
<table>
|
||||||
|
{{ form.as_table }}
|
||||||
|
</table>
|
||||||
|
{% csrf_token %}
|
||||||
|
<div id="formbutton" class="grid_1 prefix_4 suffix_1">
|
||||||
|
<input class="button green" type="submit" value="Save">
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<div class="grid_4 omega">
|
||||||
|
<p>
|
||||||
|
<ul>
|
||||||
|
<li>All times are local times in the race course time zone</li>
|
||||||
|
<li>Adding a contact phone number and email is not mandatory, but we
|
||||||
|
strongly recommend it.</li>
|
||||||
|
<li>If your event has a registration closure deadline, participants
|
||||||
|
have to enter (and can withdraw) before the registration closure time.</li>
|
||||||
|
<li>Participants can submit results until the evaluation closure time.</li>
|
||||||
|
</ul>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block scripts %}
|
||||||
|
{% endblock %}
|
||||||
@@ -146,6 +146,7 @@ urlpatterns = [
|
|||||||
url(r'^virtualevents$',views.virtualevents_view),
|
url(r'^virtualevents$',views.virtualevents_view),
|
||||||
url(r'^virtualevent/create$',views.virtualevent_create_view),
|
url(r'^virtualevent/create$',views.virtualevent_create_view),
|
||||||
url(r'^virtualevent/(?P<id>\d+)$',views.virtualevent_view),
|
url(r'^virtualevent/(?P<id>\d+)$',views.virtualevent_view),
|
||||||
|
url(r'^virtualevent/(?P<id>\d+)/edit$',views.virtualevent_edit_view),
|
||||||
url(r'^list-workouts/$',views.workouts_view),
|
url(r'^list-workouts/$',views.workouts_view),
|
||||||
url(r'^list-courses/$',views.courses_view),
|
url(r'^list-courses/$',views.courses_view),
|
||||||
url(r'^courses/upload$',views.course_upload_view),
|
url(r'^courses/upload$',views.course_upload_view),
|
||||||
|
|||||||
@@ -13392,6 +13392,7 @@ def virtualevent_view(request,id=0):
|
|||||||
'rower':r
|
'rower':r
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@login_required()
|
||||||
def virtualevent_create_view(request):
|
def virtualevent_create_view(request):
|
||||||
r = getrower(request.user)
|
r = getrower(request.user)
|
||||||
|
|
||||||
@@ -13471,3 +13472,46 @@ def virtualevent_create_view(request):
|
|||||||
'rower':r,
|
'rower':r,
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@login_required()
|
||||||
|
def virtualevent_edit_view(request,id=0):
|
||||||
|
r = getrower(request.user)
|
||||||
|
|
||||||
|
try:
|
||||||
|
race = VirtualRace.objects.get(id=id)
|
||||||
|
if race.manager != request.user:
|
||||||
|
raise PermissionDenied("Access denied")
|
||||||
|
except VirtualRace.DoesNotExist:
|
||||||
|
raise Http404("Virtual Race does not exist")
|
||||||
|
|
||||||
|
if request.method == 'POST':
|
||||||
|
racecreateform = VirtualRaceForm(request.POST,instance=race)
|
||||||
|
if racecreateform.is_valid():
|
||||||
|
cd = racecreateform.cleaned_data
|
||||||
|
|
||||||
|
res, message = update_virtualrace(race,cd)
|
||||||
|
|
||||||
|
if res:
|
||||||
|
messages.info(request,message)
|
||||||
|
else:
|
||||||
|
messages.error(request,message)
|
||||||
|
|
||||||
|
url = reverse(virtualevent_view,
|
||||||
|
kwargs = {
|
||||||
|
'id':race.id
|
||||||
|
})
|
||||||
|
|
||||||
|
return HttpResponseRedirect(url)
|
||||||
|
|
||||||
|
else:
|
||||||
|
|
||||||
|
racecreateform = VirtualRaceForm(instance=race)
|
||||||
|
|
||||||
|
|
||||||
|
return render(request,'virtualeventedit.html',
|
||||||
|
{
|
||||||
|
'form':racecreateform,
|
||||||
|
'rower':r,
|
||||||
|
'race':race,
|
||||||
|
|
||||||
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user