All fixed for revising reviews and copying over reviews.
--- a/app/projrev/views/helpers/templatetags/review_helpers.py Wed Aug 12 22:41:21 2009 +0530
+++ b/app/projrev/views/helpers/templatetags/review_helpers.py Thu Aug 13 03:20:01 2009 +0530
@@ -59,7 +59,7 @@
"""
context['name'] = name
if 'prev_data' in context and name in context['prev_data']:
- context['value'] = context['prev_data'][name]
+ context['value'] = str(context['prev_data'][name])
else:
context['value'] = 0
--- a/app/projrev/views/proposal.py Wed Aug 12 22:41:21 2009 +0530
+++ b/app/projrev/views/proposal.py Thu Aug 13 03:20:01 2009 +0530
@@ -221,20 +221,24 @@
@access.register('reviewer')
@access.checkAccess
-def review(request, micr_code=None):
+def review(request, micr_code=None, review_id=None):
"""View for reviewing the proposal.
"""
if request.method == 'POST':
- return reviewPost(request, micr_code)
+ return reviewPost(request, micr_code, review_id)
else:
- return reviewGet(request, micr_code)
+ return reviewGet(request, micr_code, review_id)
-def reviewPost(request, micr_code=None):
+def reviewPost(request, micr_code=None, review_id=None):
"""
"""
- rev_form = projrev_forms.ReviewForm(request.POST)
+ if review_id:
+ review_instance = Review.objects.get(id=review_id)
+ rev_form = projrev_forms.ReviewForm(request.POST, instance=review_instance)
+ else:
+ rev_form = projrev_forms.ReviewForm(request.POST)
if rev_form.is_valid():
cleaned_data = rev_form.cleaned_data
@@ -252,9 +256,9 @@
return HttpResponseRedirect(
reverse('app.projrev.views.proposal.rank', args=(micr_code,)))
- return reviewGet(request, micr_code, rev_form)
+ return reviewGet(request, micr_code, review_id, rev_form)
-def reviewGet(request, micr_code=None, rev_form=None):
+def reviewGet(request, micr_code=None, review_id=None, rev_form=None):
"""
"""
@@ -262,27 +266,53 @@
if not micr_code:
template = 'projrev/proposal/list.html'
- context['projects'] = Project.objects.all().exclude(
+ context['projects'] = []
+ projects = Project.objects.all().exclude(
status__exact='invalid').order_by('-last_updated_on')
+
+ for project in projects:
+ user_reviews = project.review_set.all().filter(
+ reviewer__id__exact=request.user.id).order_by('-reviewed_on')
+
+ proposals = project.proposal_set.all().order_by('-submitted_on')
+
+ if user_reviews and proposals:
+ info = {
+ 'project': project,
+ }
+ proposal = proposals[0]
+ new_user_reviews = user_reviews.filter(proposal__id__exact=proposal.id)
+ if new_user_reviews:
+ info['user_review'] = new_user_reviews[0]
+ else:
+ info['not_this_proposal'] = True
+ info['user_review'] = user_reviews[0]
+
+ context['projects'].append(info)
+ elif proposals:
+ info = {
+ 'project': project,
+ }
+ proposal = proposals[0]
+ context['projects'].append(info)
+
context['row_url'] = '/proposal/review/'
return render_to_response(template, RequestContext(request, context))
- if not rev_form:
- rev_form = projrev_forms.ReviewForm()
- else:
- context['prev_data'] = rev_form.data
- import logging
- logging.error(rev_form.data)
-
project = Project.objects.get(micr_code=micr_code)
- context['form'] = rev_form
- context['project'] = project
proposals = project.proposal_set.all().order_by('-submitted_on')
+
if proposals:
proposal = proposals[0]
+ user_review = Review.objects.all().filter(
+ id__exact=review_id).order_by('-reviewed_on')
+
+ if user_review:
+ user_review = user_review[0]
+
if proposal:
proposal_path = str(proposal.document)
@@ -292,6 +322,18 @@
context['proposal_name'] = proposal_name
context['last_submitted'] = proposal.submitted_on
+ if not rev_form:
+ if user_review:
+ rev_form = projrev_forms.ReviewForm(instance=user_review)
+ context['prev_data'] = rev_form.initial
+ else:
+ rev_form = projrev_forms.ReviewForm()
+ else:
+ context['prev_data'] = rev_form.data
+
+ context['form'] = rev_form
+ context['project'] = project
+
reviews = project.review_set.all().order_by('reviewed_on')
if reviews:
context['reviews'] = reviews
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/app/site-content/proposals/2009/08/13/c.c Thu Aug 13 03:20:01 2009 +0530
@@ -0,0 +1,27 @@
+#include <stdio.h>
+
+main()
+{
+
+ int n, count = 1;
+ float x, sum = 0,average;
+ do {
+ printf("how many numbers? ");
+ scanf("%d", &n);
+ sum = 0;
+ count = 1;
+ while (count <= n) {
+ printf("x = ");
+ printf("\n(to end program, enter 0 for x): ");
+ scanf("%f", &x);
+ if (x == 0)
+ break;
+ sum += x;
+ ++count;
+ }
+ average = sum/n;
+ printf("\nthe average is %f\n", average);
+ } while (x != 0);
+}
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/app/site-content/proposals/2009/08/13/kaprekar.py Thu Aug 13 03:20:01 2009 +0530
@@ -0,0 +1,1 @@
+
--- a/app/templates/projrev/proposal/list.html Wed Aug 12 22:41:21 2009 +0530
+++ b/app/templates/projrev/proposal/list.html Thu Aug 13 03:20:01 2009 +0530
@@ -1,5 +1,7 @@
{% extends "projrev/base.html" %}
{% load review_helpers %}
+
+
{% block content %}
<div class="post">
<div class="list">
@@ -15,16 +17,35 @@
<th>Old Serial No.</th>
</tr>
{% for project in projects %}
- <tr class="row-a"><td><a href='{{ row_url }}{{ project.micr_code }}'>
- {{ project|serial_no:"new" }}
+ {% if project.not_this_proposal %}
+ <div class='hidden' style="display: none;">
+ <div id='message_{{ project.project|serial_no:"new" }}' style='padding:10px; background:#fff;'>
+ This proposal is revised after you submitted a review. You will have to submit a new review to the revised proposal. Press the relevant button.<br />
+ <a href='{{ row_url }}{{ project.project.micr_code }}/{{ project.user_review.id }}'>Start with my previous review</a>
+ <a href='{{ row_url }}{{ project.project.micr_code }}'>Start a fresh review</a>
+ </div>
+ </div>
+ <script type="text/javascript">
+ $(document).ready(function () {
+ $('#getredirect_{{ project.project|serial_no:"new" }}').colorbox({width:"50%", inline:true, href:"#message_{{ project.project|serial_no:"new" }}", title:"What do you want to do?"});
+ });
+ </script>
+ {% endif %}
+ <tr class="row-a"><td>
+ {% if project.user_review %}
+ <a id='getredirect_{{ project.project|serial_no:"new" }}' href='{{ row_url }}{{ project.project.micr_code }}/{{ project.user_review.id }}'>
+ {% else %}
+ <a id='getredirect_{{ project.project|serial_no:"new" }}' href='{{ row_url }}{{ project.project.micr_code }}'>
+ {% endif %}
+ {{ project.project|serial_no:"new" }}
</td>
- <td>{{ project.micr_code }}</td>
- <td>{{ project.title }}</td>
- <td>{{ project.line_item }}</td>
- <td>{{ project.institution }}</td>
- <td>{{ project.state }}</td>
- <td>{{ project.district }}</td>
- <td>{{ project|serial_no:"old" }}</td>
+ <td>{{ project.project.micr_code }}</td>
+ <td>{{ project.project.title }}</td>
+ <td>{{ project.project.line_item }}</td>
+ <td>{{ project.project.institution }}</td>
+ <td>{{ project.project.state }}</td>
+ <td>{{ project.project.district }}</td>
+ <td>{{ project.project|serial_no:"old" }}</td>
</a></tr>
{% endfor %}
</table>
--- a/app/templates/projrev/templatetags/_as_star_for_score.html Wed Aug 12 22:41:21 2009 +0530
+++ b/app/templates/projrev/templatetags/_as_star_for_score.html Thu Aug 13 03:20:01 2009 +0530
@@ -1,9 +1,4 @@
{% load review_helpers %}
-<script type="text/javascript">
-$(document).ready(function(){
-
-});
-</script>
<input id="{{ name }}" name="{{ name }}" type="radio" class="star" title="Poor" value="1" {% ifequal value "1" %} checked="checked" {% endifequal %} />
<input id="{{ name }}" name="{{ name }}" type="radio" class="star" title="Average" value="2" {% ifequal value "2" %} checked="checked" {% endifequal %} />
<input id="{{ name }}" name="{{ name }}" type="radio" class="star" title="Good" value="3" {% ifequal value "3" %} checked="checked" {% endifequal %} />
--- a/app/urls.py Wed Aug 12 22:41:21 2009 +0530
+++ b/app/urls.py Thu Aug 13 03:20:01 2009 +0530
@@ -35,6 +35,8 @@
(r'^proposal/review/$', 'app.projrev.views.proposal.review'),
(r'^proposal/review/(?P<micr_code>[A-Z]{6}\d{9})/$',
'app.projrev.views.proposal.review'),
+ (r'^proposal/review/(?P<micr_code>[A-Z]{6}\d{9})/(?P<review_id>\d+)/$',
+ 'app.projrev.views.proposal.review'),
(r'^proposal/rank/$', 'app.projrev.views.proposal.rank'),
(r'^proposal/rank/(?P<micr_code>[A-Z]{6}\d{9})/$',
'app.projrev.views.proposal.rank'),