Yes, of course, should have read the question properly. Anyhow, I
haven't found a readymade generic view to do the job for me so here's
the sample I use:

-------------- view: ----------------------------
@login_required
def projects(request):
  """Get list of projects and project details for logged in manager."""

  users = [ttime.auth.users.get_object(fullname__exact =
request.user).id]
  project_list = [(0, '')]
  start_date  = ''
  end_date   = ''
  summary   = False

  for p in ttime.projects.get_managed_by(users):
    project_list.append((p.id, p.project))

  if request.POST:
    for key, value in request.POST.items():
      if key == 'project'   : project    = int(value)
      if key == 'start_date': start_date = value
      if key == 'end_date' : end_date  = value
      if key == 'summary' : summary  = bool(value)

    proj_list = ttime.projects.get_project_items(
      users, project, start_date, end_date)

    return render_to_response('ttime/projects',
      {'title': 'Project report', 'project': project,
       'start_date': start_date, 'end_date': end_date})

----------- template 'ttime/projects':----------------
{% extends "base_site" %}
{% block content %}<div id="content-main" class="module">
<form action="" method=post>
<fieldset class="module aligned">
<h2>Selections</h2>
<table width=100%>
<thead>
<tr>
  <th class=optional>Project</th>
  <th class=optional>Start date</th>
  <th class=optional>End date</th>
  <th style=tex-align:centre>
      <input type=submit name=summary value=Summary />
  </th>
</tr>
</thead>
<tr class=row1>
<td>
  <select id=id_project class=vSelectField name=project size=1>
    {% for proj in project_list %}
       <option {% ifequal proj.0 project %}selected{% endifequal %}
          value={{proj.0}}>{{proj.1}}</option>
    {% endfor %}
  </select>
</td>
<td>
  <input type=text id=id_start_date class=vDateField name=start_date
            size=10 value="{{start_date}}" maxlength=10 />
</td>
<td>
  <input type=text id=id_end_date class=vDateField name=end_date
            size=10 value="{{end_date}}" maxlength=10 />
</td>
</tr></table></fieldset></form>

<h2>Projects - detailed</h2>
<table width=100%>
<thead>
  <th>Project / Subproject / Activity</th>
</thead>
{% for p in proj_list %}
<tr>
  <td><h3>{{p.project}} - {{p.name}}</h3></td>
</tr>
</table>
------------------------------------------
The end result is that the user(s) get presented with some selection
items, including a project popup selection box, hit the summary button,
and the resulting batch of records get displayed below the selection
box, maintaining the selections made.

Hope this helps.
/LarS

Reply via email to