Пример #1
0
 def save(self):
     if self.verified and not self.sent:
         import sys
         sys.path.append('/websites/jobhuntin')
         from utils import mailer
         mailer.sendInviteFriend(self)
         self.sent = True
     super(TellFriend, self).save()
Пример #2
0
 def save(self):
     if self.verified and not self.sent:
         import sys
         sys.path.append('/websites/jobhuntin')
         from utils import mailer
         mailer.sendInviteFriend(self)
         self.sent = True
     super(TellFriend, self).save()
Пример #3
0
def handle(request):    
    if request.method == 'GET':         
        return codejar.actions.render(request, 'tellfriends.htm')
        
    elif request.method == 'POST':
        sender_name = dataplus.dictGetSafeVal(request.REQUEST, 'name')
        emails = []
        emails[len(emails):] = dataplus.dictGetSafeVal(request.REQUEST, 'email1', '').split(',')
        emails[len(emails):] = dataplus.dictGetSafeVal(request.REQUEST, 'email2', '').split(',')
        emails[len(emails):] = dataplus.dictGetSafeVal(request.REQUEST, 'email3', '').split(',')
        message = dataplus.dictGetSafeVal(request.REQUEST, 'messageBox')
        
        valid_emails = [eml for eml in emails if eml != '']
        if sender_name and valid_emails and message:
            ip_address = request.META['REMOTE_ADDR']
            sent_count = getSentRequestCount(ip_address)
            send_max = 6 - sent_count
            if send_max < 0:    send_max = 0
            
            requests = []
            for email_id in valid_emails:
                fr = models.TellFriend(sender_name=sender_name, 
                                        receiver_email=email_id, 
                                        message=message,
                                        ip_address=ip_address)
                fr.save()
                requests.append(fr)
            
            subject = 'New Tell Friends Request'
            if send_max < len(valid_emails):    subject += ": Require verification"
            event_desc = "Sender: %s\nReceiver(s): %s\nMessage: %s" % (sender_name, string.join(valid_emails, ','), message)
            eventnotifier.sendEventNotification(subject, event_desc)
            
            for req in requests[:send_max]:
                mailer.sendInviteFriend(req)
                req.sent = True
                req.save()
            
            return HttpResponseRedirect('toldfriends.html')
        else:
            return HttpResponse('Gimme some valid data :(')