app/projrev/views/proposal.py
changeset 14 9d720dfded68
parent 13 684540719344
child 15 8c9e6c98de82
equal deleted inserted replaced
13:684540719344 14:9d720dfded68
   155 
   155 
   156       proposal_name = proposal_path.split('/')[-1]
   156       proposal_name = proposal_path.split('/')[-1]
   157 
   157 
   158       context['proposal_path'] = proposal_path
   158       context['proposal_path'] = proposal_path
   159       context['proposal_name'] = proposal_name
   159       context['proposal_name'] = proposal_name
   160       context['last_submitted'] = proposal.submitted_on 
   160       context['last_submitted'] = proposal.submitted_on
   161 
   161 
   162     if 'HTTP_REFERER' in request.META:
   162     if 'HTTP_REFERER' in request.META:
   163       referer = request.META['HTTP_REFERER'].split('/')
   163       referer = request.META['HTTP_REFERER'].split('/')
   164       if referer[-1]:
   164       if referer[-1]:
   165         ref = referer[-1]
   165         ref = referer[-1]
   234 
   234 
   235 def reviewGet(request, micr_code=None, rev_form=None):
   235 def reviewGet(request, micr_code=None, rev_form=None):
   236   """
   236   """
   237   """
   237   """
   238 
   238 
       
   239   context = {}
       
   240 
   239   if not micr_code:
   241   if not micr_code:
   240     template = 'projrev/proposal/list.html'
   242     template = 'projrev/proposal/list.html'
   241     context = {
   243     context['projects'] = Project.objects.all().exclude(status__exact='invalid')
   242         'projects': Project.objects.all().exclude(status__exact='invalid'),
   244     context['row_url'] = '/proposal/review/'
   243         'row_url': '/proposal/review/',
       
   244         }
       
   245 
   245 
   246     return render_to_response(template, RequestContext(request, context))
   246     return render_to_response(template, RequestContext(request, context))
   247 
   247 
   248   if not rev_form:
   248   if not rev_form:
   249     rev_form = projrev_forms.ReviewForm()
   249     rev_form = projrev_forms.ReviewForm()
   250 
   250 
   251   proposal_path = str(Project.objects.get(
   251   project = Project.objects.get(micr_code=micr_code)
   252           micr_code=micr_code).proposal_set.all().order_by(
   252   context['form'] = rev_form
   253               '-submitted_on')[0].document)
   253   context['project'] = project
   254 
   254 
   255   proposal_name = proposal_path.split('/')[-1]
   255   proposal = project.proposal_set.all().order_by('-submitted_on')[0]
   256 
   256 
   257   context = {
   257   if proposal:
   258       'form': rev_form,
   258     proposal_path = str(proposal.document)
   259       'project': Project.objects.get(micr_code=micr_code),
   259 
   260       'proposal_path': proposal_path,
   260     proposal_name = proposal_path.split('/')[-1]
   261       'proposal_name': proposal_name,
   261 
   262       }
   262     context['proposal_path'] = proposal_path
       
   263     context['proposal_name'] = proposal_name
       
   264     context['last_submitted'] = proposal.submitted_on
       
   265 
       
   266   reviews = project.review_set.all().order_by('-reviewed_on')
       
   267   if reviews:
       
   268     context['last_reviewed'] = reviews[0].reviewed_on
       
   269     context['nr_reviews'] = len(reviews)
   263 
   270 
   264   template = 'projrev/proposal/review.html'
   271   template = 'projrev/proposal/review.html'
   265 
   272 
   266   return render_to_response(template, RequestContext(request, context))
   273   return render_to_response(template, RequestContext(request, context))
   267 
   274