# HG changeset patch # User Madhusudan.C.S # Date 1249594497 -19800 # Node ID 68454071934449b7087f7207fbac3f835aedf999 # Parent aac4944aca52532e6589a5e8d9384a6c393baed4 Added footer line. diff -r aac4944aca52 -r 684540719344 app/projrev/views/helpers/forms.py --- a/app/projrev/views/helpers/forms.py Fri Aug 07 01:03:56 2009 +0530 +++ b/app/projrev/views/helpers/forms.py Fri Aug 07 03:04:57 2009 +0530 @@ -16,7 +16,7 @@ """Creates a form for the project. """ - document = forms.FileField() + document = forms.FileField(required=False) class Meta: # We store most of the data in Project model. So even though the diff -r aac4944aca52 -r 684540719344 app/projrev/views/proposal.py --- a/app/projrev/views/proposal.py Fri Aug 07 01:03:56 2009 +0530 +++ b/app/projrev/views/proposal.py Fri Aug 07 03:04:57 2009 +0530 @@ -86,34 +86,43 @@ if prop_form.is_valid(): cleaned_data = prop_form.cleaned_data - # Generate MICR code - cleaned_data['micr_code'] = '%s%s%s%d' % ( - cleaned_data['state'], cleaned_data['district'], - cleaned_data['line_item'], - int(time.time() * 1000) % 1000000000) + if micr_code: + project = Project.objects.get(micr_code=micr_code) + project.line_item = Project.getLineItem(cleaned_data['line_item']) + project.institution = cleaned_data['institution'] + project.state = Project.getState(cleaned_data['state']) + project.district = Project.getDistrict(cleaned_data['district']) + else: + # Generate MICR code + cleaned_data['micr_code'] = '%s%s%s%d' % ( + cleaned_data['state'], cleaned_data['district'], + cleaned_data['line_item'], + int(time.time() * 1000) % 1000000000) - cleaned_data['line_item'] = Project.getLineItem(cleaned_data['line_item']) - cleaned_data['state'] = Project.getState(cleaned_data['state']) - cleaned_data['district'] = Project.getDistrict(cleaned_data['district']) + cleaned_data['line_item'] = Project.getLineItem(cleaned_data['line_item']) + cleaned_data['state'] = Project.getState(cleaned_data['state']) + cleaned_data['district'] = Project.getDistrict(cleaned_data['district']) + + prop_form.cleaned_data = cleaned_data - prop_form.cleaned_data = cleaned_data + # If the form is valid create a new project or update the project + # if it already exists from the form. + project = prop_form.save() - # If the form is valid create a new project or update the project - # if it already exists from the form. - project = prop_form.save() + project.micr_code = cleaned_data['micr_code'] project.status = 'new' - project.micr_code = cleaned_data['micr_code'] - micr_code = cleaned_data['micr_code'] + micr_code = project.micr_code project.save() - # Create a proposal for the project. - proposal = project.proposal_set.create( - document=prop_form.cleaned_data['document'], - submitted_by=request.user, rev_num = 0) + if prop_form.cleaned_data['document']: + # Create a proposal for the project. + proposal = project.proposal_set.create( + document=prop_form.cleaned_data['document'], + submitted_by=request.user, rev_num = 0) - proposal.save() + proposal.save() return HttpResponseRedirect( reverse('app.projrev.views.proposal.submit', args=(micr_code,))) @@ -139,13 +148,16 @@ prop_form = projrev_forms.ProposalForm( initial=initial_vals, instance=project) - proposal_path = str( - project.proposal_set.all().order_by('-submitted_on')[0].document) + proposal = project.proposal_set.all().order_by('-submitted_on')[0] + + if proposal: + proposal_path = str(proposal.document) - proposal_name = proposal_path.split('/')[-1] + proposal_name = proposal_path.split('/')[-1] - context['proposal_path'] = proposal_path - context['proposal_name'] = proposal_name + context['proposal_path'] = proposal_path + context['proposal_name'] = proposal_name + context['last_submitted'] = proposal.submitted_on if 'HTTP_REFERER' in request.META: referer = request.META['HTTP_REFERER'].split('/') @@ -158,6 +170,12 @@ context['created_now'] = True context['micr_code'] = project.micr_code + + reviews = project.review_set.all().order_by('-reviewed_on') + if reviews: + context['last_reviewed'] = reviews[0].reviewed_on + context['nr_reviews'] = len(reviews) + else: prop_form = projrev_forms.ProposalForm() @@ -221,7 +239,7 @@ if not micr_code: template = 'projrev/proposal/list.html' context = { - 'projects': Project.objects.all(), + 'projects': Project.objects.all().exclude(status__exact='invalid'), 'row_url': '/proposal/review/', } diff -r aac4944aca52 -r 684540719344 app/templates/projrev/proposal/submit.html --- a/app/templates/projrev/proposal/submit.html Fri Aug 07 01:03:56 2009 +0530 +++ b/app/templates/projrev/proposal/submit.html Fri Aug 07 03:04:57 2009 +0530 @@ -33,10 +33,28 @@

-

- Reviews (5) - Last reviewed: Nov 11, 2006 - Last submitted: Nov 11, 2006 +

+ Reviews: + {% if nr_reviews %} + {{ nr_reviews }} + {% else %} + (None) + {% endif %} + + Last reviewed: + {% if last_reviewed %} + {{ last_reviewed|date:"jS F Y H:i" }} + {% else %} + (Not Reviewed) + {% endif %} + + Last submitted: + {% if last_submitted %} + {{ last_submitted|date:"jS F Y H:i" }} + {% else %} + (New Submission) + {% endif %} +