Exemple #1
0
    def save(self):
        import sys, datetime
        sys.path.append('/websites/jobhuntin')
        from utils import mailer, eventnotifier
        if not self.id:
            eventnotifier.sendEventNotification(
                'New User: %s posted on: %s' %
                (self.doc_filename,
                 datetime.datetime.utcnow().strftime('%d/%m/%Y %H:%M:%S %p')))

        if self.name and self.email and self.tags and self.pref_location:
            if not self.tagged:
                self.tagged = True
                from datetime import datetime
                self.tagged_on = datetime.utcnow()

        if self.account.account_type == 'FU' and self.id > 0 and self.tagged:
            user_old = User.objects.get(id=self.id)
            if user_old and not user_old.email:
                params = {'user_key': self.key}
                usrs = User.objects.filter(email=self.email,
                                           account__account_state='A',
                                           id__lt=self.id)
                if usrs:
                    if usrs.filter(account__account_type='PU'):
                        mailer.sendPremiumUserLoginToUpdateAlert(
                            self.email, by_mail=bool(self.mail_ref))
                        self.delete()
                        return
                    else:
                        for usr in usrs.all():
                            usr.account.account_state = 'I'
                            usr.account.save()
                            IndexDelta(user_id=usr.id, index_type='D').save()

                        mailer.sendResumeUpdatedMail(self.email, params)
                else:
                    mailer.sendResumeAddedMail(self.email, params)

        super(User, self).save()

        #If he is tagged and is job hunting, he has to be indexed
        if self.tagged and self.is_job_hunting == 'yes':
            IndexDelta(user_id=self.id, index_type='U').save()
def verifyAndSendMail(user_email, user_id, user_key, by_mail, cursor):
    stmt = "SELECT U.id, A.id, A.account_type FROM website_user U INNER JOIN website_account A ON U.account_id = A.id WHERE A.account_state = 'A' AND U.email = %(user_email)s AND U.id <> %(user_id)s;"
    cursor.execute(stmt, {'user_email':user_email, 'user_id':user_id})
    results = cursor.fetchall()
    params = {'user_key': user_key }
    if results:
        ids = []
        for row in results:
            ids.append((row[0], row[1]))
            if row[2] == 'PU':
                mailer.sendPremiumUserLoginToUpdateAlert(user_email, by_mail = by_mail)
                return

        stmt = "UPDATE website_account SET account_state = 'I' WHERE id IN (" + string.join([str(x[1]) for x in ids], ',') + ");"
        cursor.execute(stmt)

        for idx in ids:
            cursor.execute("INSERT INTO website_indexdelta (user_id, index_type, marked_at) VALUES (%(user_id)s, 'D', CURRENT_TIMESTAMP);", {'user_id':idx[0]})

        mailer.sendResumeUpdatedMail(user_email, params)
    else:
        mailer.sendResumeAddedMail(user_email, params)
Exemple #3
0
    def save(self):
        import sys, datetime
        sys.path.append('/websites/jobhuntin')
        from utils import mailer, eventnotifier
        if not self.id:
            eventnotifier.sendEventNotification('New User: %s posted on: %s' % (self.doc_filename, datetime.datetime.utcnow().strftime('%d/%m/%Y %H:%M:%S %p')))

        if self.name and self.email and self.tags and self.pref_location:
            if not self.tagged:
                self.tagged = True
                from datetime import datetime
                self.tagged_on = datetime.utcnow()

        if self.account.account_type == 'FU' and self.id > 0 and self.tagged:
            user_old = User.objects.get(id=self.id)
            if user_old and not user_old.email:
                params = {'user_key': self.key }
                usrs = User.objects.filter(email=self.email, account__account_state='A', id__lt=self.id)
                if usrs:
                    if usrs.filter(account__account_type = 'PU'):
                        mailer.sendPremiumUserLoginToUpdateAlert(self.email, by_mail = bool(self.mail_ref))
                        self.delete()
                        return
                    else:
                        for usr in usrs.all():
                            usr.account.account_state = 'I'
                            usr.account.save()
                            IndexDelta(user_id=usr.id, index_type='D').save()

                        mailer.sendResumeUpdatedMail(self.email, params)
                else:
                    mailer.sendResumeAddedMail(self.email, params)

        super(User, self).save()
        
        #If he is tagged and is job hunting, he has to be indexed
        if self.tagged and self.is_job_hunting == 'yes':    IndexDelta(user_id=self.id, index_type='U').save()