Exemple #1
0
def editEvent(request,eventid):
    eventid = int(eventid)
    event = Event.objects.get(id=eventid)
    originaltags = event.tags
    if request.user.id == event.user.id :
        if request.method == "GET" :
            mlogger.debug("the person who posted the event is editing")
            form = EventForm(instance=event,initial={'tags':' '.join(event.tags.values_list('name',flat=True))},user=request.user)            
            return render_to_response('events/create_event.html',{'form':form,'editmode':True},RequestContext(request))
        elif request.method == "POST":            
            form = EventForm(request.POST,instance=event,user=request.user)
            if form.is_valid() :
                   newevent = form.save(commit=False)
                   newevent.save()                   
                   removeUserTagWeights(originaltags,request.user,settings.CONTRIBUTION_WEIGHT)
                   newevent.tags = form.cleaned_data['tags']
                   assignUserTagWeights(newevent.tags,request.user,settings.CONTRIBUTION_WEIGHT)               
                   if event.sendemail is not None :
                        emaillist = event.sendemail.getEmailList(request.institute)                          
                        deliverEmail('event_created_subject.html','event_created.html',{'institute':request.institute,'event':event,'edit':True,'site':settings.SITE_URL},emaillist)
                    
                   create_message(request,"Successfuly edited the event")
                   return HttpResponseRedirect(reverse('agendaviewurl')) 
            else:      
                   return render_to_response('events/create_event.html',{'form':form,'editmode':True},RequestContext(request))  
            
    else :
        create_message(request,"You are not authorized to edit this event")
        return HttpResponseRedirect(reverse('agendaviewurl'))
Exemple #2
0
def postAJob(request):
    mlogger.debug("posting a job.......................")    
    if request.method == "GET":
        form  = JobForm(user=request.user)        
        return render_to_response('jobs/postjob.html',{'form':form},RequestContext(request))
    elif request.method =="POST":
        form =  JobForm(request.POST,user=request.user)
        if form.is_valid() :
            j=form.save(commit=False)                        
            j.postedby = request.user
            j.institute = request.institute
            j.save()
            
            if j.sendemail is not None :
                emaillist = j.sendemail.getEmailList(request.institute)
                fullurl = j.getfullurl(request.institute)
                deliverEmail('new_job_subject.html','new_job_message.html',{'institute':request.institute,'job':j,'fullurl':fullurl},emaillist)
                
            #Assign tags to jobs    
            j.tags = form.cleaned_data['tags']
            assignUserTagWeights(j.tags,request.user,settings.CONTRIBUTION_WEIGHT)          
            create_message(request,"Successfuly posted your job")
            return HttpResponseRedirect(reverse('displayjoburl'))            
        else:
           return render_to_response('jobs/postjob.html',{'form':form},RequestContext(request))
Exemple #3
0
def postAJob(request):
    mlogger.debug("posting a job.......................")
    if request.method == "GET":
        form = JobForm(user=request.user)
        return render_to_response('jobs/postjob.html', {'form': form},
                                  RequestContext(request))
    elif request.method == "POST":
        form = JobForm(request.POST, user=request.user)
        if form.is_valid():
            j = form.save(commit=False)
            j.postedby = request.user
            j.institute = request.institute
            j.save()

            if j.sendemail is not None:
                emaillist = j.sendemail.getEmailList(request.institute)
                fullurl = j.getfullurl(request.institute)
                deliverEmail('new_job_subject.html', 'new_job_message.html', {
                    'institute': request.institute,
                    'job': j,
                    'fullurl': fullurl
                }, emaillist)

            #Assign tags to jobs
            j.tags = form.cleaned_data['tags']
            assignUserTagWeights(j.tags, request.user,
                                 settings.CONTRIBUTION_WEIGHT)
            create_message(request, "Successfuly posted your job")
            return HttpResponseRedirect(reverse('displayjoburl'))
        else:
            return render_to_response('jobs/postjob.html', {'form': form},
                                      RequestContext(request))
Exemple #4
0
def publishNewsLetter(request,entry_id=None):
    mlogger.debug("publish new newsletters")
    if request.method == "GET" :
        if entry_id is None :
               form = PublishForm(user=request.user)
        else :
               entry=Entry.objects.get(pk=entry_id)
               form = PublishForm(instance=entry,user=request.user)
        return render_to_response('publish/institute_create_new.html',{'form':form},RequestContext(request))
    elif request.method == "POST" :        
        form = PublishForm(request.POST,user=request.user)
        if form.is_valid() :
            entry = form.save(commit=False)
            entry.institute = request.institute
            entry.user = request.user
            entry.save()
            if request.POST['whichbutton'] == "save" :                
                create_message(request,"saved your news letter")           
                return HttpResponseRedirect(reverse('publishnewurl2',kwargs={'entry_id':entry.id})+"?backto=publishhome")
            else:
                if entry.sendemail is not None :                    
                    emaillist = entry.sendemail.getEmailList(request.institute)
                    fullurl = entry.getfullurl(request.institute)
                    deliverEmail('new_newsletter_subject.html','new_newsletter.html',{'institute':request.institute,'entry':entry,'fullurl':fullurl},emaillist)
                
                entry.tags = form.cleaned_data['tags']
                assignUserTagWeights(entry.tags,request.user,settings.CONTRIBUTION_WEIGHT)
                create_message(request,"Successfully created blog post")
                return HttpResponseRedirect(reverse('newsletterurl'))               
        else:
            return render_to_response('publish/institute_create_new.html',{'form':form},RequestContext(request))            
Exemple #5
0
def browseByCountry(request,ncountryname):    
    country = ncountryname.replace("-"," ")
    if request.method == "POST" :        
        d={}
        try:
                message = request.POST['text']
                message = convertToProperHTML(message)
                #emails of all people living inthis country are
                emails =  UserProfile.objects.filter(isadmin=False,institutes__in=[request.institute.id],country__name__iexact=country).values_list('user__email', flat=True).distinct()                
                deliverEmail('country_wide_subject.html','country_wide_message.html',{'institute':request.institute,'message':message,'sourceuser':request.user,'countrywide':True,'statewide':False},list(emails))
        except :
                d['error'] = "oops........some problem at the server end"
                
        json = simplejson.dumps(d)
        return HttpResponse(json)                
        #return HttpResponseRedirect(reverse('countryurl',kwargs={'ncountryname':ncountryname}))
    else :    
        mlogger.debug("country name = %s "% (country,))
        mlogger.debug("getting the state details....................")
        states = UserProfile.objects.filter(isadmin=False,institutes__in=[request.institute.id],country__name__iexact=country).values_list('state', flat=True).distinct()
          
        noofpeople = []
        for state in states :
            noofpeople.append(len(UserProfile.objects.filter(isadmin=False,institutes__in=[request.institute.id],country__name__iexact=country,state__iexact=state)))
        
        statezip = zip(states,noofpeople)
        peoplezip = getPeople(request.institute,country)
        level = "state"
        address = country
        count =  UserProfile.objects.filter(isadmin=False,institutes__in=[request.institute.id],country__name__iexact=country).count()
        return render_to_response("location/locate.html",{'peoplezip':peoplezip,'statezip':statezip,'level':level,'address':address,'country':country,'count':count},RequestContext(request))
Exemple #6
0
def registerInstitution(request):
    ''' method which display and registration an institution'''
     #for now display the question
    mlogger.debug("Registering an institute................")    
    if request.method == 'GET':
        #display form
        form = IRegForm(0)            
    else:       
        form = IRegForm(0,request.POST,request.FILES)        
        if form.is_valid() :
            inst = form.save(commit=False)
            inst.admin = createAdmin(form.cleaned_data['adminemail'],form.cleaned_data['password1'],form.cleaned_data['adminname'])            
            inst.save()
            inst.admin.get_profile().institutes.add(inst)
            mlogger.debug("Creating an institution %s" %(inst.name,))
            #associate institute logo as avatar of admin            
            createAdminAvatar(request,inst.admin,'logo')
            fullactivationurl = inst.admin.get_profile().get_full_activation_url(inst)
            deliverEmail('newinstitute_subject.html','newinstitute_message.html',{'institute':inst,'fullactivationurl':fullactivationurl,'user':inst.admin,'password':form.cleaned_data['password1']},inst.admin.email)
            #Tell ALumclub admin about new registration
            emails = getALumClubAdminUrls()
            deliverEmail('tell_new_institute_registration.html','tell_new_institute_registration_message.html',{'institute':inst,'fullactivationurl':fullactivationurl,'user':inst.admin,'password':form.cleaned_data['password1']},emails)
            #redirect
            return HttpResponseRedirect("http://%s%s/"%(inst.subdomain,settings.DOMAIN_NAME))
        else :            
            pass

    return render_to_response("institution/register.html",{'form':form},RequestContext(request))  
Exemple #7
0
def approveMemebers(request):
    mlogger.debug('admin approving %s .............')
    if request.method == "GET" :
        if not  request.user.get_profile().isadmin :
             create_message(request,"Your are not authorized to do this operation............")
             return HttpResponseRedirect(reverse('dashboardurl'))
        
       
        paginator =  Paginator(Faculty.objects.filter(institutes__in=[request.institute.id],profile__approved=0).order_by('-createddate'),1)
        toapprove = paginator.page(1)
        if toapprove.object_list :
            fi = FacultyInstitute.objects.get(faculty__id = toapprove.object_list[0].id,institute__id = request.institute.id)
            return render_to_response("institution/approve_member.html",{'institute':request.institute,'toapprove':toapprove.object_list[0],'entity':'faculty','fi':fi},RequestContext(request))
        else :            
            si = None
            paginator = Paginator(Student.objects.filter(institutes__in=[request.institute.id],profile__approved=0).order_by('-createddate'),1)
            toapprove = paginator.page(1)
            
            if toapprove.object_list :                
                toapprove = toapprove.object_list[0]
                si = StudentInstitute.objects.get(student__id = toapprove.id,institute__id=request.institute.id)
            else :
                toapprove = None
            return render_to_response("institution/approve_member.html",{'toapprove':toapprove,'entity':'student','si':si},RequestContext(request))
    elif request.method == "POST":
         d = {}
         id = int(request.POST['id'])
         entity = request.POST['entity']
         flag = int(request.POST['flag'])
         
         k = None
        
         if entity == "student":
            k = Student.objects.get(pk=id)            
         else :
            k = Faculty.objects.get(pk=id)
        
         profile = k.profile
         #approve
         if flag :
            profile.approved = 1
            d['message'] = "Sucessfully approved..........."
         #Reject the member ship
         else:
             profile.approved = -1
             d['message'] = "Successfully rejected .................."
         
         profile.save()
         #deliver mail
         if entity =="student":
            deliverEmail('studentapproved_subject.html','studentapproved_message.html',{'user':request.user,'approved':profile.approved},profile.user.email)
         else :
            deliverEmail('facultyapproved_subject.html','facultyapproved_message.html',{'user':request.user,'approved':profile.approved},profile.user.email)
            
         
         d['success'] = "yes"      
         json = simplejson.dumps(d)         
         return HttpResponse(json)    
Exemple #8
0
def paymentReview(request,fundid):
    pp = paypal.PayPal()
    fund = Fund.objects.get(pk=int(fundid))      
    if request.method == 'GET':
        token = request.GET.get('token')
        payerid = request.GET['PayerID']        
        paypal_details = pp.GetExpressCheckoutDetails(token,return_all = True)
        payload = {}
        payload['fund'] = fund
        if 'Success' in paypal_details['ACK']:            
            payload['ack'] = True
            payload['amount'] = paypal_details['AMT'][0]
            payload['currency'] = paypal_details['CURRENCYCODE'][0]
            payload['token'] = token
            payload['payerid'] = payerid            
            return render_to_response('payments/review.html', payload, RequestContext(request))
        else :
            create_message(request,"Some problem with the payment.Please try again............")
            return HttpResponseRedirect(reverse('displayfundsurl'))            
    if request.method == 'POST':        
        token = request.POST['token']
        payerid = request.POST['payerid']
        amount = request.POST['amount']        
        payment_details  = pp.DoExpressCheckoutPayment(token,payerid,amount)
       
        if 'Success' in payment_details['ACK']:        
            str = "Successfully donated the amount  %s to %s"%(amount,fund.fundname,)
            create_message(request,str)
            #note down this donation
            d = Donation()
            d.user = request.user
            d.fund = fund
            d.institute = request.institute
            d.donationamount = amount
            d.paypaltransactionid = payment_details['TRANSACTIONID']
            d.correlationid = payment_details['CORRELATIONID']
            d.save()
            fund.totaldonations = fund.totaldonations+float(amount)
            fund.save()
            
            # send mail to admin  of institute and the user about the donation ........................
            # and the admin of the site about the details of the donation            
            deliverEmail('amount_donated_subject.html','amount_donated.html',{'institute':request.institute,'fund':fund,'user':request.user,'amount':amount,'transactionid':payment_details['TRANSACTIONID']},request.user.email)
            adminemail = getInstituteAdminEmail()
            siteadmin = getAlumClubAdminEmail()            
            mainlist = adminemail+siteadmin
            mlogger.debug("Main email list = %s"%(unicode(mainlist)))
            deliverEmail('reference_donation_subject.html','reference_donation.html',{'institute':request.institute,'fund':fund,'user':request.user,'amount':amount,'transactionid':payment_details['TRANSACTIONID']},mainlist)
            return HttpResponseRedirect(reverse('displayfundsurl'))        
        else :
            create_message(request,"Some problem with the payment.Please try again............")
            return HttpResponseRedirect(reverse('displayfundsurl'))        
Exemple #9
0
def browseByState(request,ncountryname,nstatename,pageno=None):
       
    mlogger.debug("Browsing the people by state,.......................")
    country = ncountryname.replace("-"," ")
    state = nstatename.replace("-"," ")
    if request.method == "POST" :        
        d={}
        try:
                message = request.POST['text']
                message = convertToProperHTML(message)
                #emails of all people living inthis country are
                emails =  UserProfile.objects.filter(isadmin=False,institutes__in=[request.institute.id],country__name__iexact=country,state__iexact=state).values_list('user__email', flat=True).distinct()                
                deliverEmail('country_wide_subject.html','country_wide_message.html',{'institute':request.institute,'message':message,'sourceuser':request.user,'statewide':True,'countrywide':False},list(emails))
        except :
                d['error'] = "oops........some problem at the server end"
                
        json = simplejson.dumps(d)
        return HttpResponse(json)                
    else:
    
            if pageno is None :
                  pageno = 1
            
            #for  map purposes
            peoplezip = getPeople(request.institute,country,state)
           
            #for display purposes
            paginator = Paginator(UserProfile.objects.filter(isadmin=False,institutes__in=[request.institute.id],country__name__iexact=country,state__iexact=state).order_by("-createddate"),settings.PEOPLE_PER_PAGE)        
            apage = paginator.page(pageno)
            
            #get the corresponding entities for Student Institute ,Faculty Institute
            entities =[]
            for p in apage.object_list :
                profile = p
                if p.isFaculty :
                    f = Faculty.objects.get(profile__id = profile.id )
                    fi = FacultyInstitute.objects.get(faculty__id = f.id,institute__id = request.institute.id)
                    entities.append(fi)
                else:
                    s = Student.objects.get(profile__id = profile.id )
                    si = StudentInstitute.objects.get(student__id = s.id,institute__id=request.institute.id)
                    entities.append(si)
            
            
            peopledisplayzip = zip(apage.object_list,entities)    
            address =  "%s , %s" %(state,country)
            level =  "city"
            count =  UserProfile.objects.filter(isadmin=False,institutes__in=[request.institute.id],country__name__iexact=country,state__iexact=state).count()
            return render_to_response("location/locate.html",{'peopledisplayzip':peopledisplayzip,'peoplezip':peoplezip,'level':level,'address':address,'country':country,'state':state,'pagedetail':apage,'count':count},RequestContext(request))
Exemple #10
0
def submitFeedback(request):
    d = {}
   

    try:
            if request.method == "POST" :                 
                f = Feedback()
                f.email = request.POST['email']
                f.username = request.POST['name']
                f.message = request.POST['body']
                f.save()
                deliverEmail("feedbacksubject.html","feedbackmessage.html",{'f':f},getAlumClubAdminEmail())
               
    except:
        d['error'] = "oops........some problem at the server end"
    
    json = simplejson.dumps(d)
    return HttpResponse(json)  
Exemple #11
0
def submitFeedback(request):
    d = {}

    try:
        if request.method == "POST":
            f = Feedback()
            f.email = request.POST['email']
            f.username = request.POST['name']
            f.message = request.POST['body']
            f.save()
            deliverEmail("feedbacksubject.html", "feedbackmessage.html",
                         {'f': f}, getAlumClubAdminEmail())

    except:
        d['error'] = "oops........some problem at the server end"

    json = simplejson.dumps(d)
    return HttpResponse(json)
Exemple #12
0
def addConnection(request,touserid):    
    d={}
    try: 
        mlogger.debug("Add new connections...................")
        touserid = int(touserid)
        profile = User.objects.get(pk=int(touserid)).get_profile()
        try :
            Connection.objects.get(initiator__id=request.user.get_profile().id,reciever__id=profile.id)
        except Connection.DoesNotExist :    
            c = Connection()
            c.initiator = request.user.get_profile()
            c.reciever = profile
            c.save()
            #send email to the ereciever
            fullpendingurl = c.getfullurl(request.institute)
            deliverEmail('new_connection_subject.html','new_connection_message.html',{'institute':request.institute,'initiator':c.initiator,'reciever':c.reciever,'fullpendingurl':fullpendingurl},[c.reciever.user.email])
    except :
        d['error'] = "Oops...........some problem at the server"    
    
    json = simplejson.dumps(d)
    return HttpResponse(json)  
Exemple #13
0
def createEvent(request):
    mlogger.debug("Create new event ..........................")
    if request.method == "GET":
        form = EventForm(user=request.user)
        return render_to_response('events/create_event.html',{'form':form},RequestContext(request))        
    elif request.method == "POST" :
        form = EventForm(request.POST,user=request.user)        
        if form.is_valid() :
            event = form.save(commit=False)
            event.user = request.user
            event.institute = request.institute
            event.save()
            
            event.tags = form.cleaned_data['tags']
            assignUserTagWeights(event.tags,request.user,settings.CONTRIBUTION_WEIGHT)
            
            if event.sendemail is not None :
                emaillist = event.sendemail.getEmailList(request.institute)                
                deliverEmail('event_created_subject.html','event_created.html',{'institute':request.institute,'event':event,'edit':False,'site':settings.SITE_URL},emaillist)
                
            create_message(request,"Succesfully created the event ...............")
            return HttpResponseRedirect(reverse('agendaviewurl'))               
    return render_to_response('events/create_event.html',{'form':form},RequestContext(request))                
Exemple #14
0
def browseByState(request, ncountryname, nstatename, pageno=None):

    mlogger.debug("Browsing the people by state,.......................")
    country = ncountryname.replace("-", " ")
    state = nstatename.replace("-", " ")
    if request.method == "POST":
        d = {}
        try:
            message = request.POST['text']
            message = convertToProperHTML(message)
            #emails of all people living inthis country are
            emails = UserProfile.objects.filter(
                isadmin=False,
                institutes__in=[request.institute.id],
                country__name__iexact=country,
                state__iexact=state).values_list('user__email',
                                                 flat=True).distinct()
            deliverEmail(
                'country_wide_subject.html', 'country_wide_message.html', {
                    'institute': request.institute,
                    'message': message,
                    'sourceuser': request.user,
                    'statewide': True,
                    'countrywide': False
                }, list(emails))
        except:
            d['error'] = "oops........some problem at the server end"

        json = simplejson.dumps(d)
        return HttpResponse(json)
    else:

        if pageno is None:
            pageno = 1

        #for  map purposes
        peoplezip = getPeople(request.institute, country, state)

        #for display purposes
        paginator = Paginator(
            UserProfile.objects.filter(
                isadmin=False,
                institutes__in=[request.institute.id],
                country__name__iexact=country,
                state__iexact=state).order_by("-createddate"),
            settings.PEOPLE_PER_PAGE)
        apage = paginator.page(pageno)

        #get the corresponding entities for Student Institute ,Faculty Institute
        entities = []
        for p in apage.object_list:
            profile = p
            if p.isFaculty:
                f = Faculty.objects.get(profile__id=profile.id)
                fi = FacultyInstitute.objects.get(
                    faculty__id=f.id, institute__id=request.institute.id)
                entities.append(fi)
            else:
                s = Student.objects.get(profile__id=profile.id)
                si = StudentInstitute.objects.get(
                    student__id=s.id, institute__id=request.institute.id)
                entities.append(si)

        peopledisplayzip = zip(apage.object_list, entities)
        address = "%s , %s" % (state, country)
        level = "city"
        count = UserProfile.objects.filter(
            isadmin=False,
            institutes__in=[request.institute.id],
            country__name__iexact=country,
            state__iexact=state).count()
        return render_to_response(
            "location/locate.html", {
                'peopledisplayzip': peopledisplayzip,
                'peoplezip': peoplezip,
                'level': level,
                'address': address,
                'country': country,
                'state': state,
                'pagedetail': apage,
                'count': count
            }, RequestContext(request))
Exemple #15
0
def browseByCountry(request, ncountryname):
    country = ncountryname.replace("-", " ")
    if request.method == "POST":
        d = {}
        try:
            message = request.POST['text']
            message = convertToProperHTML(message)
            #emails of all people living inthis country are
            emails = UserProfile.objects.filter(
                isadmin=False,
                institutes__in=[request.institute.id],
                country__name__iexact=country).values_list(
                    'user__email', flat=True).distinct()
            deliverEmail(
                'country_wide_subject.html', 'country_wide_message.html', {
                    'institute': request.institute,
                    'message': message,
                    'sourceuser': request.user,
                    'countrywide': True,
                    'statewide': False
                }, list(emails))
        except:
            d['error'] = "oops........some problem at the server end"

        json = simplejson.dumps(d)
        return HttpResponse(json)
        #return HttpResponseRedirect(reverse('countryurl',kwargs={'ncountryname':ncountryname}))
    else:
        mlogger.debug("country name = %s " % (country, ))
        mlogger.debug("getting the state details....................")
        states = UserProfile.objects.filter(
            isadmin=False,
            institutes__in=[request.institute.id],
            country__name__iexact=country).values_list('state',
                                                       flat=True).distinct()

        noofpeople = []
        for state in states:
            noofpeople.append(
                len(
                    UserProfile.objects.filter(
                        isadmin=False,
                        institutes__in=[request.institute.id],
                        country__name__iexact=country,
                        state__iexact=state)))

        statezip = zip(states, noofpeople)
        peoplezip = getPeople(request.institute, country)
        level = "state"
        address = country
        count = UserProfile.objects.filter(
            isadmin=False,
            institutes__in=[request.institute.id],
            country__name__iexact=country).count()
        return render_to_response(
            "location/locate.html", {
                'peoplezip': peoplezip,
                'statezip': statezip,
                'level': level,
                'address': address,
                'country': country,
                'count': count
            }, RequestContext(request))
Exemple #16
0
def paymentReview(request, fundid):
    pp = paypal.PayPal()
    fund = Fund.objects.get(pk=int(fundid))
    if request.method == 'GET':
        token = request.GET.get('token')
        payerid = request.GET['PayerID']
        paypal_details = pp.GetExpressCheckoutDetails(token, return_all=True)
        payload = {}
        payload['fund'] = fund
        if 'Success' in paypal_details['ACK']:
            payload['ack'] = True
            payload['amount'] = paypal_details['AMT'][0]
            payload['currency'] = paypal_details['CURRENCYCODE'][0]
            payload['token'] = token
            payload['payerid'] = payerid
            return render_to_response('payments/review.html', payload,
                                      RequestContext(request))
        else:
            create_message(
                request,
                "Some problem with the payment.Please try again............")
            return HttpResponseRedirect(reverse('displayfundsurl'))
    if request.method == 'POST':
        token = request.POST['token']
        payerid = request.POST['payerid']
        amount = request.POST['amount']
        payment_details = pp.DoExpressCheckoutPayment(token, payerid, amount)

        if 'Success' in payment_details['ACK']:
            str = "Successfully donated the amount  %s to %s" % (
                amount,
                fund.fundname,
            )
            create_message(request, str)
            #note down this donation
            d = Donation()
            d.user = request.user
            d.fund = fund
            d.institute = request.institute
            d.donationamount = amount
            d.paypaltransactionid = payment_details['TRANSACTIONID']
            d.correlationid = payment_details['CORRELATIONID']
            d.save()
            fund.totaldonations = fund.totaldonations + float(amount)
            fund.save()

            # send mail to admin  of institute and the user about the donation ........................
            # and the admin of the site about the details of the donation
            deliverEmail(
                'amount_donated_subject.html', 'amount_donated.html', {
                    'institute': request.institute,
                    'fund': fund,
                    'user': request.user,
                    'amount': amount,
                    'transactionid': payment_details['TRANSACTIONID']
                }, request.user.email)
            adminemail = getInstituteAdminEmail()
            siteadmin = getAlumClubAdminEmail()
            mainlist = adminemail + siteadmin
            mlogger.debug("Main email list = %s" % (unicode(mainlist)))
            deliverEmail(
                'reference_donation_subject.html', 'reference_donation.html', {
                    'institute': request.institute,
                    'fund': fund,
                    'user': request.user,
                    'amount': amount,
                    'transactionid': payment_details['TRANSACTIONID']
                }, mainlist)
            return HttpResponseRedirect(reverse('displayfundsurl'))
        else:
            create_message(
                request,
                "Some problem with the payment.Please try again............")
            return HttpResponseRedirect(reverse('displayfundsurl'))
Exemple #17
0
def registerMember(request):
    ''' register new member it may be student or faculty'''
    mlogger.debug("Institution %s" %(str(request.institute)))
    mlogger.debug("Registering a new member it can either student or Faculty")
    
    if request.institute is not None :
        if request.method == "GET" :        
            fform = FacultyForm(request.institute.id,False)
            sform = StudentForm(request.institute.id,False)            
            states = State.objects.all().order_by("id")
            industries = Industry.objects.all()
            return render_to_response("institution/newmember.html",{'industries':industries,'fform':fform,'sform':sform,'states':states,'form_default':'student'},RequestContext(request))
        elif request.method == "POST":
            if request.POST['whichform'] == "student" :
                whichform = "student"
                sform = StudentForm(request.institute.id,0,request.POST)
                fform = FacultyForm(request.institute.id,0)
                if sform.is_valid() :                    
                    #give him the success message
                    student = sform.save(commit=False)
                    up = createMember(sform.cleaned_data['name'],sform.cleaned_data['email'],sform.cleaned_data['password'],whichform,sform,request.institute)
                    student.profile = up              
                    student.save()              
                    #Student Institute                    
                    si = StudentInstitute()
                    si.institute = request.institute
                    si.student = student
                    si.fromyear = sform.cleaned_data['fromyear']                  
                    if len(sform.cleaned_data['toyear'].strip()) > 0 :
                        si.toyear = sform.cleaned_data['toyear']                  
                    si.course = sform.cleaned_data['course']
                    si.department = sform.cleaned_data['department']
                    si.degree = sform.cleaned_data['degree']                    
                    si.save()                   
                    #Create message
                    
                    fullactivationurl = student.profile.get_full_activation_url(request.institute)                    
                    deliverEmail('newstudent_subject.html','newstudent_message.html',{'fullactivationurl':fullactivationurl,'institute':request.institute,'user':up.user,'password':sform.cleaned_data['password']},up.user.email)
                    
                    # TEll alumclub admin and institute admin about regitration
                    emails = getALumClubAdminUrls()
                    emails.append(request.institute.admin.email)
                    deliverEmail('tell_new_alumini_registration.html','tell_new_alumini_registration_message.html',{'fullactivationurl':fullactivationurl,'institute':request.institute,'user':up.user,'password':sform.cleaned_data['password']},emails)
                    #Tell institute admin about new registration                    
                    
                    create_message(request,"Successfully Registered.Your will be able to login once your account is  verified by the Insitute admin.")
                    return HttpResponseRedirect("/")                       
                else :
                    return render_to_response("institution/newmember.html",{'fform':fform,'sform':sform,'form_default':whichform},RequestContext(request))                        
            elif request.POST['whichform'] == "faculty" :
                whichform = "faculty"           
                sform = StudentForm(request.institute.id,0)
                fform = FacultyForm(request.institute.id,0,request.POST)
                if fform.is_valid() :
                    #give him the success message
                    faculty = fform.save(commit=False)
                    up = createMember(fform.cleaned_data['name'],fform.cleaned_data['email'],fform.cleaned_data['password'],whichform,fform,request.institute)
                    faculty.profile = up
                    faculty.save()                    
                    #save faculty institute relationship
                    fi = FacultyInstitute()
                    fi.institute = request.institute
                    fi.faculty = faculty                
                    fi.department = fform.cleaned_data['department']
                    fi.save()
                    #Create message
                    
                    fullactivationurl = faculty.profile.get_full_activation_url(request.institute)                    
                    deliverEmail('newfaculty_subject.html','newfaculty_message.html',{'fullactivationurl':fullactivationurl,'institute':request.institute,'user':up.user,'password':fform.cleaned_data['password']},up.user.email)
                    
                    # TEll alumclub admin and institute admin about regitration
                    emails = getALumClubAdminUrls()
                    emails.append(request.institute.admin.email)
                    deliverEmail('tell_new_alumini_registration.html','tell_new_alumini_registration_message.html',{'fullactivationurl':fullactivationurl,'institute':request.institute,'user':up.user,'password':fform.cleaned_data['password']},emails)
                    
                    create_message(request,"Successfully Registered.Your will be able to login once your account is  verified by the Insitute admin.")
                    
                    #Redirect to institute home
                    return HttpResponseRedirect("/")                          
                    
                else :
                    return render_to_response("institution/newmember.html",{'fform':fform,'sform':sform,'form_default':whichform},RequestContext(request))