Esempio n. 1
0
    def __init__(self, job, request):
        threading.Thread.__init__(self)
        plaintext = get_template('listings/emails/publish_to_admin.txt')
        html = get_template('listings/emails/publish_to_admin.html')
        template_vars = {}
        template_vars['job_url'] = 'http://%s%s' % (site_domain, job.get_absolute_url())
        template_vars['job_title'] = job.title
        template_vars['job_company'] = job.company
        template_vars['job_description'] = job.description
        template_vars['job_poster_email'] = job.poster_email
        job_info = {
                    'site_name': listings_settings.LISTINGS_SITE_NAME,
                    'job_title': job.title,
        }
        subject = listings_settings.LISTINGS_EDIT_POST_ADMIN_SUBJECT % job_info
        if not job.is_active():
            subject = listings_settings.LISTINGS_NEW_POST_ADMIN_SUBJECT % job_info
            template_vars['job_activate_url'] = 'http://%s%s' % (site_domain, job.get_activation_url())
        template_vars['job_edit_url'] = 'http://%s%s' % (site_domain, job.get_edit_url())
        template_vars['job_deactivate_url'] = 'http://%s%s' % (site_domain, job.get_deactivation_url())
        template_vars['job_poster_ip'] = getIP(request)
        template_vars['job_post_date'] = job.created_on
        d = Context(template_vars)

        from_email = listings_settings.LISTINGS_ADMIN_EMAIL
        to = listings_settings.LISTINGS_ADMIN_EMAIL
        text_content = plaintext.render(d)
        html_content = html.render(d)
        self.email = EmailMultiAlternatives(subject, text_content, from_email, [to])
        self.email.attach_alternative(html_content, "text/html")
Esempio n. 2
0
 def increment_view_count(self, request):  # TODO: Move to Posting
     lh = last_hour()
     ip = getIP(request)
     hits = JobStat.objects.filter(created_on__range=lh, ip=ip, stat_type='H', job=self).count()
     if hits < listings_settings.LISTINGS_MAX_VISITS_PER_HOUR:
         self.views_count = self.views_count + 1
         self.save()
         new_hit = JobStat(ip=ip, stat_type='H', job=self)
         new_hit.save()