def contact(request): meta_desc = "Questions? Comments? Good or bad, we'd love to hear from you!" title = 'Contact Us' if request.method == 'POST': form = ContactForm(request.POST) if form.is_valid(): site = get_current_site(request) cd = form.cleaned_data # re-tag subject to make it more identifiable cd['subject'] = "[%s] %s" % (site.name.upper(), cd['subject']) send_mail_with_helper( cd['subject'], cd['message'], cd['email'], [site.siteconfig.admin_email] ) messages.success( request, "Thank you for your message, " "we'll be back in touch as soon as possible" ) return HttpResponseRedirect(reverse('jobs_index')) else: form = ContactForm() context = {'meta_desc': meta_desc, 'title': title, 'form': form} return render(request, "job_board/contact.html", context)
def contact(request): if request.method == 'POST': form = ContactForm(request.POST) if form.is_valid(): site = get_current_site(request) cd = form.cleaned_data # re-tag subject to make it more identifiable cd['subject'] = "[%s] %s" % (site.name.upper(), cd['subject']) send_mail_with_helper( cd['subject'], cd['message'], cd['email'], [site.siteconfig.admin_email] ) messages.success( request, "Thank you for your message, " "we'll be back in touch as soon as possible" ) return HttpResponseRedirect(reverse('jobs_index')) else: form = ContactForm() title = 'Contact Us' return render(request, "job_board/contact.html", { 'form': form, 'title': title, })
def jobs_new(request): title = 'Add a Job' site = get_current_site(request) msg = 'Your job has been successfully added' if request.method == 'POST': if site.siteconfig.remote: form = JobRemoteForm(request.POST) else: form = JobForm(request.POST) company_form = CompanyForm(initial={'site': site}) if form.is_valid(): job = form.save(commit=False) if site.siteconfig.remote: job.remote = True job.site_id = site.id job.user_id = request.user.id job.save() context = {'job': job, 'protocol': site.siteconfig.protocol} send_mail_with_helper( '[%s] New job posting' % site.name.upper(), render_to_string('job_board/emails/new_job_notification.txt', context), site.siteconfig.admin_email, [site.siteconfig.admin_email]) if site.siteconfig.price == 0: msg += ', however it does require verification ' \ 'before being activated' messages.success(request, msg) return HttpResponseRedirect(job.get_absolute_url()) else: if site.siteconfig.remote: form = JobRemoteForm() else: form = JobForm() company_form = CompanyForm(initial={'site': site}) # NOTE: By default, the company and category dropdowns will contain all # instances across all sites, and the following limits this to # the site in question. form.fields['company'].queryset = Company.objects.filter(site_id=site.id) form.fields['category'].queryset = Category.objects.filter(site_id=site.id) context = { 'form': form, 'company_form': company_form, 'title': title, 'protocol': site.siteconfig.protocol } return render(request, 'job_board/jobs_new.html', context)
def expire(self): if self.paid_at is not None and self.expired_at is None: context = {'job': self, 'protocol': self.site.siteconfig.protocol} self.expired_at = timezone.now() self.save() send_mail_with_helper( 'Your %s job has expired' % self.site.name, render_to_string('job_board/emails/expired.txt', context), self.site.siteconfig.admin_email, [self.email]) return True else: return False
def jobs_new(request): title = 'Add a Job' site = get_current_site(request) msg = 'Your job has been successfully added' if request.method == 'POST': if site.siteconfig.remote: form = JobRemoteForm(request.POST) else: form = JobForm(request.POST) company_form = CompanyForm(initial={'site': site}) if form.is_valid(): job = form.save(commit=False) if site.siteconfig.remote: job.remote = True job.site_id = site.id job.user_id = request.user.id job.save() context = {'job': job, 'protocol': site.siteconfig.protocol} send_mail_with_helper( '[%s] New job posting' % site.name.upper(), render_to_string( 'job_board/emails/new_job_notification.txt', context ), site.siteconfig.admin_email, [site.siteconfig.admin_email] ) if site.siteconfig.price == 0: msg += ', however it does require verification ' \ 'before being activated' messages.success(request, msg) return HttpResponseRedirect(job.get_absolute_url()) else: if site.siteconfig.remote: form = JobRemoteForm() else: form = JobForm() company_form = CompanyForm(initial={'site': site}) # NOTE: By default, the company and category dropdowns will contain all # instances across all sites, and the following limits this to # the site in question. form.fields['company'].queryset = Company.objects.filter( site_id=site.id ) form.fields['category'].queryset = Category.objects.filter( site_id=site.id ) context = {'form': form, 'company_form': company_form, 'title': title, 'protocol': site.siteconfig.protocol} return render(request, 'job_board/jobs_new.html', context)