Star values recalled.
--- a/app/projrev/models.py Wed Aug 12 19:30:12 2009 +0530
+++ b/app/projrev/models.py Wed Aug 12 22:41:21 2009 +0530
@@ -873,6 +873,9 @@
#: Field representing the relation to the corresponding project.
project = models.ForeignKey(Project)
+ #: Field representing the relation to the corresponding proposal.
+ proposal = models.ForeignKey(Proposal)
+
#: Field containing the comment entered along with the review.
comment = models.TextField()
comment.verbose_name = 'Overall Comment'
--- a/app/projrev/views/helpers/forms.py Wed Aug 12 19:30:12 2009 +0530
+++ b/app/projrev/views/helpers/forms.py Wed Aug 12 22:41:21 2009 +0530
@@ -11,8 +11,10 @@
from django.contrib.auth.models import User
from projrev.models import Project
+from projrev.models import Proposal
from projrev.models import Review
+
class ProposalForm(forms.ModelForm):
"""Creates a form for the project.
"""
@@ -38,6 +40,11 @@
project = forms.ModelChoiceField(queryset=Project.objects.all(),
widget=forms.HiddenInput(),
required=False)
+
+ proposal = forms.ModelChoiceField(queryset=Proposal.objects.all(),
+ widget=forms.HiddenInput(),
+ required=False)
+
reviewer = forms.ModelChoiceField(queryset=User.objects.all(),
widget=forms.HiddenInput(),
required=False)
--- a/app/projrev/views/helpers/templatetags/review_helpers.py Wed Aug 12 19:30:12 2009 +0530
+++ b/app/projrev/views/helpers/templatetags/review_helpers.py Wed Aug 12 22:41:21 2009 +0530
@@ -52,14 +52,26 @@
return review_context
+@register.inclusion_tag('projrev/templatetags/_as_star_for_score.html',
+ takes_context=True)
+def as_star_for_score(context, name):
+ """
+ """
+ context['name'] = name
+ if 'prev_data' in context and name in context['prev_data']:
+ context['value'] = context['prev_data'][name]
+ else:
+ context['value'] = 0
+
+ return context
+
@register.filter()
def serial_no(project, arg):
"""Returns the latest serial number of the project's proposal
"""
proposals = project.proposal_set.all().order_by('-submitted_on')
- import logging
- logging.error(proposals)
+
if proposals:
if arg == 'new':
proposal = proposals[0]
--- a/app/projrev/views/proposal.py Wed Aug 12 19:30:12 2009 +0530
+++ b/app/projrev/views/proposal.py Wed Aug 12 22:41:21 2009 +0530
@@ -239,7 +239,11 @@
if rev_form.is_valid():
cleaned_data = rev_form.cleaned_data
- cleaned_data['project'] = Project.objects.get(micr_code=micr_code)
+ project = Project.objects.get(micr_code=micr_code)
+ proposal = project.proposal_set.all().order_by('-submitted_on')[0]
+
+ cleaned_data['project'] = project
+ cleaned_data['proposal'] = proposal
cleaned_data['reviewer'] = request.user
# If the form is valid create a new project or update the project
@@ -266,6 +270,10 @@
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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/app/site-content/proposals/2009/08/10/arm.py Wed Aug 12 22:41:21 2009 +0530
@@ -0,0 +1,6 @@
+for i in range(100, 1000):
+ a = i % 10
+ b = (i / 10) % 10
+ c = (i / 100) % 10
+ if i == a ** 3 + b ** 3 + c ** 3:
+ print "Armstrong Number: ", i
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/app/site-content/proposals/2009/08/10/c.c Wed Aug 12 22:41:21 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/10/c_.c Wed Aug 12 22:41:21 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/10/c__.c Wed Aug 12 22:41:21 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/10/c___.c Wed Aug 12 22:41:21 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/10/c____.c Wed Aug 12 22:41:21 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/10/collatz.py Wed Aug 12 22:41:21 2009 +0530
@@ -0,0 +1,7 @@
+a = 343
+while a > 1:
+ print a
+ if a % 2:
+ a = a * 3 + 1
+ else:
+ a /= 2
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/app/site-content/proposals/2009/08/10/collatz_.py Wed Aug 12 22:41:21 2009 +0530
@@ -0,0 +1,7 @@
+a = 343
+while a > 1:
+ print a
+ if a % 2:
+ a = a * 3 + 1
+ else:
+ a /= 2
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/app/site-content/proposals/2009/08/10/gcd.py Wed Aug 12 22:41:21 2009 +0530
@@ -0,0 +1,6 @@
+def gcd(a, b):
+ if a % b == 0:
+ return b
+ return gcd(b, a %b)
+
+print gcd (10, 20)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/app/site-content/proposals/2009/08/11/arm.py Wed Aug 12 22:41:21 2009 +0530
@@ -0,0 +1,6 @@
+for i in range(100, 1000):
+ a = i % 10
+ b = (i / 10) % 10
+ c = (i / 100) % 10
+ if i == a ** 3 + b ** 3 + c ** 3:
+ print "Armstrong Number: ", i
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/app/site-content/proposals/2009/08/11/c.c Wed Aug 12 22:41:21 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);
+}
+
+
--- a/app/templates/projrev/proposal/review.html Wed Aug 12 19:30:12 2009 +0530
+++ b/app/templates/projrev/proposal/review.html Wed Aug 12 22:41:21 2009 +0530
@@ -1,15 +1,6 @@
{% extends "projrev/base.html" %}
{% load review_helpers %}
-{% block scripts %}
-{{ block.super }}
-<script type="text/javascript">
-$(document).ready(function () {
- alert($('#attribute1[value=1]').attr('checked', 'checked'));
-});
-</script>
-{% endblock scripts %}
-
{% block content %}
<div class="post">
@@ -97,11 +88,7 @@
<p>
{{ form.attribute1.errors }}
<strong>{{ form.attribute1.label }}</strong><br />
- <input name="attribute1" type="radio" class="star" title="Poor" value="1"/>
- <input name="attribute1" type="radio" class="star" title="Average" value="2"/>
- <input name="attribute1" type="radio" class="star" title="Good" value="3"/>
- <input name="attribute1" type="radio" class="star" title="Very Good" value="4" />
- <input name="attribute1" type="radio" class="star" title="Excellent" value="5"/>
+ {% as_star_for_score "attribute1" %}
{% if form.attribute1.field.required %}<span class="specialclass"> (required)</span>{% endif %}
</p>
<p>
@@ -111,11 +98,7 @@
<p>
{{ form.attribute2.errors }}
<strong>{{ form.attribute2.label }}</strong><br />
- <input name="attribute2" type="radio" class="star" title="Poor" value="1"/>
- <input name="attribute2" type="radio" class="star" title="Average" value="2"/>
- <input name="attribute2" type="radio" class="star" title="Good" value="3"/>
- <input name="attribute2" type="radio" class="star" title="Very Good" value="4"/>
- <input name="attribute2" type="radio" class="star" title="Excellent" value="5"/>
+ {% as_star_for_score "attribute2" %}
{% if form.attribute2.field.required %}<span class="specialclass"> (required)</span>{% endif %}
</p>
<p>
@@ -125,11 +108,7 @@
<p>
{{ form.attribute3.errors }}
<strong>{{ form.attribute3.label }}</strong><br />
- <input name="attribute3" type="radio" class="star" title="Poor" value="1"/>
- <input name="attribute3" type="radio" class="star" title="Average" value="2"/>
- <input name="attribute3" type="radio" class="star" title="Good" value="3"/>
- <input name="attribute3" type="radio" class="star" title="Very Good" value="4"/>
- <input name="attribute3" type="radio" class="star" title="Excellent" value="5"/>
+ {% as_star_for_score "attribute3" %}
{% if form.attribute3.field.required %}<span class="specialclass"> (required)</span>{% endif %}
</p>
<p>
@@ -139,11 +118,7 @@
<p>
{{ form.attribute4.errors }}
<strong>{{ form.attribute4.label }}</strong><br />
- <input name="attribute4" type="radio" class="star" title="Poor" value="1"/>
- <input name="attribute4" type="radio" class="star" title="Average" value="2"/>
- <input name="attribute4" type="radio" class="star" title="Good" value="3"/>
- <input name="attribute4" type="radio" class="star" title="Very Good" value="4"/>
- <input name="attribute4" type="radio" class="star" title="Excellent" value="5"/>
+ {% as_star_for_score "attribute4" %}
{% if form.attribute4.field.required %}<span class="specialclass"> (required)</span>{% endif %}
</p>
<p>
@@ -153,11 +128,7 @@
<p>
{{ form.attribute5.errors }}
<strong>{{ form.attribute5.label }}</strong><br />
- <input name="attribute5" type="radio" class="star" title="Poor" value="1"/>
- <input name="attribute5" type="radio" class="star" title="Average" value="2"/>
- <input name="attribute5" type="radio" class="star" title="Good" value="3"/>
- <input name="attribute5" type="radio" class="star" title="Very Good" value="4"/>
- <input name="attribute5" type="radio" class="star" title="Excellent" value="5"/>
+ {% as_star_for_score "attribute5" %}
{% if form.attribute5.field.required %}<span class="specialclass"> (required)</span>{% endif %}
</p>
<p>
@@ -167,11 +138,7 @@
<p>
{{ form.attribute6.errors }}
<strong>{{ form.attribute6.label }}</strong><br />
- <input name="attribute6" type="radio" class="star" title="Poor" value="1"/>
- <input name="attribute6" type="radio" class="star" title="Average" value="2"/>
- <input name="attribute6" type="radio" class="star" title="Good" value="3"/>
- <input name="attribute6" type="radio" class="star" title="Very Good" value="4"/>
- <input name="attribute6" type="radio" class="star" title="Excellent" value="5"/>
+ {% as_star_for_score "attribute6" %}
{% if form.attribute6.field.required %}<span class="specialclass"> (required)</span>{% endif %}
</p>
<p>
@@ -181,11 +148,7 @@
<p>
{{ form.attribute7.errors }}
<strong>{{ form.attribute7.label }}</strong><br />
- <input name="attribute7" type="radio" class="star" title="Poor" value="1"/>
- <input name="attribute7" type="radio" class="star" title="Average" value="2"/>
- <input name="attribute7" type="radio" class="star" title="Good" value="3"/>
- <input name="attribute7" type="radio" class="star" title="Very Good" value="4"/>
- <input name="attribute7" type="radio" class="star" title="Excellent" value="5"/>
+ {% as_star_for_score "attribute7" %}
{% if form.attribute7.field.required %}<span class="specialclass"> (required)</span>{% endif %}
</p>
<p>
@@ -195,11 +158,7 @@
<p>
{{ form.attribute8.errors }}
<strong>{{ form.attribute8.label }}</strong><br />
- <input name="attribute8" type="radio" class="star" title="Poor" value="1"/>
- <input name="attribute8" type="radio" class="star" title="Average" value="2"/>
- <input name="attribute8" type="radio" class="star" title="Good" value="3"/>
- <input name="attribute8" type="radio" class="star" title="Very Good" value="4"/>
- <input name="attribute8" type="radio" class="star" title="Excellent" value="5"/>
+ {% as_star_for_score "attribute8" %}
{% if form.attribute8.field.required %}<span class="specialclass"> (required)</span>{% endif %}
</p>
<p>
@@ -209,11 +168,7 @@
<p>
{{ form.attribute9.errors }}
<strong>{{ form.attribute9.label }}</strong><br />
- <input name="attribute9" type="radio" class="star" title="Poor" value="1"/>
- <input name="attribute9" type="radio" class="star" title="Average" value="2"/>
- <input name="attribute9" type="radio" class="star" title="Good" value="3"/>
- <input name="attribute9" type="radio" class="star" title="Very Good" value="4"/>
- <input name="attribute9" type="radio" class="star" title="Excellent" value="5"/>
+ {% as_star_for_score "attribute9" %}
{% if form.attribute9.field.required %}<span class="specialclass"> (required)</span>{% endif %}
</p>
<p>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/app/templates/projrev/templatetags/_as_star_for_score.html Wed Aug 12 22:41:21 2009 +0530
@@ -0,0 +1,11 @@
+{% 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 %} />
+<input id="{{ name }}" name="{{ name }}" type="radio" class="star" title="Very Good" value="4" {% ifequal value "4" %} checked="checked" {% endifequal %} />
+<input id="{{ name }}" name="{{ name }}" type="radio" class="star" title="Excellent" value="5" {% ifequal value "5" %} checked="checked" {% endifequal %} />
\ No newline at end of file