very basic plannedsession view view
This commit is contained in:
6
rowers/templates/model_table.html
Normal file
6
rowers/templates/model_table.html
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
{% for row in rows %}
|
||||||
|
<tr>
|
||||||
|
<td class="name">{{ row.attr }}</td>
|
||||||
|
<td class="field">{{ row.value }}</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
29
rowers/templates/plannedsessionview.html
Normal file
29
rowers/templates/plannedsessionview.html
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
{% extends "base.html" %}
|
||||||
|
{% load staticfiles %}
|
||||||
|
|
||||||
|
{% block title %}Planned Session{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<div class="grid_12 alpha">
|
||||||
|
{% include "planningbuttons.html" %}
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div id="left" class="grid_6 alpha">
|
||||||
|
<h1>Session {{ psdict.name.1 }}</h1>
|
||||||
|
<table class="listtable shortpadded">
|
||||||
|
{% for header, value in psdict.items %}
|
||||||
|
{% if header in attrs %}
|
||||||
|
<tr>
|
||||||
|
<td><b>{{ value.0 }}</b></td><td>{{ value.1 }}</td>
|
||||||
|
</tr>
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<div id="right" class="grid_6 omega">
|
||||||
|
<p> </p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
@@ -151,3 +151,4 @@ def team_members(user):
|
|||||||
return []
|
return []
|
||||||
|
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
|||||||
@@ -398,6 +398,7 @@ urlpatterns = [
|
|||||||
url(r'^workout/(?P<id>\d+)/test\_strokedata$',views.strokedataform),
|
url(r'^workout/(?P<id>\d+)/test\_strokedata$',views.strokedataform),
|
||||||
url(r'^sessions/create$',views.plannedsession_create_view),
|
url(r'^sessions/create$',views.plannedsession_create_view),
|
||||||
url(r'^sessions/(?P<id>\d+)/edit$',views.plannedsession_edit_view),
|
url(r'^sessions/(?P<id>\d+)/edit$',views.plannedsession_edit_view),
|
||||||
|
url(r'^sessions/(?P<id>\d+)$',views.plannedsession_view),
|
||||||
]
|
]
|
||||||
|
|
||||||
if settings.DEBUG:
|
if settings.DEBUG:
|
||||||
|
|||||||
@@ -291,3 +291,16 @@ from datetime import date
|
|||||||
def calculate_age(born):
|
def calculate_age(born):
|
||||||
today = date.today()
|
today = date.today()
|
||||||
return today.year - born.year - ((today.month, today.day) < (born.month, born.day))
|
return today.year - born.year - ((today.month, today.day) < (born.month, born.day))
|
||||||
|
|
||||||
|
def my_dict_from_instance(instance,model):
|
||||||
|
thedict = {}
|
||||||
|
|
||||||
|
for attr, value in instance.__dict__.iteritems():
|
||||||
|
try:
|
||||||
|
verbose_name = model._meta.get_field(attr).verbose_name
|
||||||
|
except:
|
||||||
|
verbose_name = attr
|
||||||
|
|
||||||
|
thedict[attr] = (verbose_name,value)
|
||||||
|
|
||||||
|
return thedict
|
||||||
|
|||||||
@@ -741,7 +741,7 @@ from utils import (
|
|||||||
geo_distance,serialize_list,deserialize_list,uniqify,
|
geo_distance,serialize_list,deserialize_list,uniqify,
|
||||||
str2bool,range_to_color_hex,absolute,myqueue,get_call,
|
str2bool,range_to_color_hex,absolute,myqueue,get_call,
|
||||||
calculate_age,rankingdistances,rankingdurations,
|
calculate_age,rankingdistances,rankingdurations,
|
||||||
is_ranking_piece
|
is_ranking_piece,my_dict_from_instance
|
||||||
)
|
)
|
||||||
|
|
||||||
import datautils
|
import datautils
|
||||||
@@ -11801,3 +11801,24 @@ def plannedsession_edit_view(request,id=0):
|
|||||||
'plannedsessions':sps,
|
'plannedsessions':sps,
|
||||||
'thesession':ps,
|
'thesession':ps,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
def plannedsession_view(request,id=0):
|
||||||
|
|
||||||
|
r = getrower(request.user)
|
||||||
|
|
||||||
|
try:
|
||||||
|
ps = PlannedSession.objects.get(id=id)
|
||||||
|
except PlannedSession.DoesNotExist:
|
||||||
|
raise Http404("Planned Session does not exist")
|
||||||
|
|
||||||
|
|
||||||
|
psdict = {}
|
||||||
|
|
||||||
|
psdict = my_dict_from_instance(ps,PlannedSession)
|
||||||
|
|
||||||
|
return render(request,'plannedsessionview.html',
|
||||||
|
{
|
||||||
|
'psdict': psdict,
|
||||||
|
'attrs':['name','startdate']
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user