Пример #1
0
    def __init__(self, job, request):
        threading.Thread.__init__(self)
        plaintext = get_template('djobberbase/emails/publish_to_admin.txt')
        html = get_template('djobberbase/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': djobberbase_settings.DJOBBERBASE_SITE_NAME,
                    'job_title': job.title,
        }
        subject = djobberbase_settings.DJOBBERBASE_EDIT_POST_ADMIN_SUBJECT % job_info
        if not job.is_active():
            subject = djobberbase_settings.DJOBBERBASE_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 = djobberbase_settings.DJOBBERBASE_ADMIN_EMAIL
        to = djobberbase_settings.DJOBBERBASE_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")
Пример #2
0
 def increment_view_count(self, request):
     lh = last_hour()
     ip = getIP(request)
     hits = JobStat.objects.filter(created_on__range=lh,
                                     ip=ip, stat_type='H', job=self).count()
     if hits < djobberbase_settings.DJOBBERBASE_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()
Пример #3
0
 def increment_view_count(self, request):
     lh = last_hour()
     ip = getIP(request)
     hits = JobStat.objects.filter(created_on__range=lh,
                                   ip=ip,
                                   stat_type='H',
                                   job=self).count()
     if hits < djobberbase_settings.DJOBBERBASE_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()