app/projrev/views/proposal.py
changeset 40 7f6f4b8525b8
parent 39 e7880a8f7e04
child 43 55e650bb9dbe
equal deleted inserted replaced
39:e7880a8f7e04 40:7f6f4b8525b8
    10 
    10 
    11 import json
    11 import json
    12 import os
    12 import os
    13 import time
    13 import time
    14 
    14 
       
    15 from django.contrib.auth.models import User
    15 from django.core.urlresolvers import reverse
    16 from django.core.urlresolvers import reverse
    16 from django.http import HttpResponse
    17 from django.http import HttpResponse
    17 from django.http import HttpResponseRedirect
    18 from django.http import HttpResponseRedirect
    18 from django.shortcuts import render_to_response
    19 from django.shortcuts import render_to_response
    19 from django.template import RequestContext
    20 from django.template import RequestContext
   116       # if it already exists from the form.
   117       # if it already exists from the form.
   117       project = prop_form.save()
   118       project = prop_form.save()
   118 
   119 
   119       project.micr_code = cleaned_data['micr_code']
   120       project.micr_code = cleaned_data['micr_code']
   120 
   121 
   121       subject = "[Sakshath] MICR Code of the new proposal submitted"
   122       send_mails(request, project)
   122       message = """Hi,
       
   123    We have received a new proposal for National Mission on education from your, 
       
   124 email address "%s", to the http://sakshath.ac.in portal. The MICR Code of the
       
   125 submitted proposal is: 
       
   126   MICR Code: %s
       
   127 
       
   128 Please remember this code for all future references.
       
   129 
       
   130 
       
   131 --  
       
   132 Regards,
       
   133 Saksath admin""" % (request.user.username, project.micr_code)
       
   134 
       
   135       request.user.email_user(subject=subject, message=message)
       
   136 
   123 
   137     project.status = 'new'
   124     project.status = 'new'
   138     micr_code = project.micr_code
   125     micr_code = project.micr_code
   139 
   126 
   140     project.save()
   127     project.save()
   454     context['nr_reviews'] = nr_reviews
   441     context['nr_reviews'] = nr_reviews
   455   
   442   
   456   template = 'projrev/proposal/myreviews.html'
   443   template = 'projrev/proposal/myreviews.html'
   457 
   444 
   458   return render_to_response(template, RequestContext(request, context))
   445   return render_to_response(template, RequestContext(request, context))
       
   446 
       
   447 def send_mails(request, project):
       
   448   """Send mails to the user and all the reviewers after the project is created.
       
   449   """
       
   450   pass
       
   451 
       
   452   subject = '[Sakshath] MICR Code of the new proposal submitted'
       
   453 
       
   454   message = """Hi,
       
   455    We have received a new proposal for National Mission on education from your, 
       
   456 email address "%s", to the http://sakshath.ac.in portal. The MICR Code of the
       
   457 submitted proposal is: 
       
   458   MICR Code: %s
       
   459 
       
   460 Please remember this code for all future references.
       
   461 
       
   462 
       
   463 --  
       
   464 Regards,
       
   465 Saksath admin""" % (request.user.username, project.micr_code)
       
   466 
       
   467   request.user.email_user(subject=subject, message=message)
       
   468 
       
   469   subject = '[Sakshath] A new proposal has been submitted for review'
       
   470 
       
   471   message_template = """Dear %(user)s,
       
   472 
       
   473   A new project proposal has been uploaded on the site for reviewing. The details are as follows:
       
   474 
       
   475 *Title:* %(title)s
       
   476 *Institution:* %(institution)s
       
   477 *Address:* %(address)s
       
   478 *City:* %(city)s
       
   479 *State:* %(state)s
       
   480 *Phone Number:* %(ph_no)s
       
   481 *Email ID:* %(email)s
       
   482 
       
   483 To review the proposal please logon to: <a href="">some website</a>
       
   484 """
       
   485 
       
   486   reviewers = User.objects.all().filter(is_staff__exact='1')
       
   487 
       
   488   for reviewer in reviewers:
       
   489     message = message_template % {
       
   490         'user': reviewer.username,
       
   491         'title': project.title,
       
   492         'institution': project.institution,
       
   493         'address': project.address,
       
   494         'city': project.city,
       
   495         'state': project.state,
       
   496         'ph_no': project.phone_num,
       
   497         'email': request.user.email,
       
   498         }
       
   499 
       
   500     reviewer.email_user(subject=subject, message=message)