From 03143f22c0faea8801324d5e6ba403303701c0f9 Mon Sep 17 00:00:00 2001 From: Shreyas Satish Date: Mon, 3 Aug 2015 16:59:27 +0530 Subject: [PATCH] added ability to repost an archived job --- hasjob/forms.py | 28 +++++++++++++++++++++ hasjob/templates/detail.html | 5 ++++ hasjob/templates/postjob.html | 7 ++++++ hasjob/views/listing.py | 46 ++++++++++++----------------------- 4 files changed, 55 insertions(+), 31 deletions(-) diff --git a/hasjob/forms.py b/hasjob/forms.py index 9d8806500..d3301f483 100644 --- a/hasjob/forms.py +++ b/hasjob/forms.py @@ -354,6 +354,34 @@ def validate(self): self.send_signals() return success + def populate(self, post): + self.job_headline.data = post.headline + self.job_headlineb.data = post.headlineb + self.job_type.data = post.type_id + self.job_category.data = post.category_id + self.job_location.data = post.location + self.job_relocation_assist.data = post.relocation_assist + self.job_description.data = post.description + self.job_perks.data = True if post.perks else False + self.job_perks_description.data = post.perks + self.job_how_to_apply.data = post.how_to_apply + self.company_name.data = post.company_name + self.company_url.data = post.company_url + self.poster_email.data = post.email + self.twitter.data = post.twitter + self.hr_contact.data = int(post.hr_contact or False) + self.collaborators.data = post.admins + self.job_pay_type.data = post.pay_type + if post.pay_type is None: + # This kludge required because WTForms doesn't know how to handle None in forms + self.job_pay_type.data = -1 + self.job_pay_currency.data = post.pay_currency + self.job_pay_cash_min.data = post.pay_cash_min + self.job_pay_cash_max.data = post.pay_cash_max + self.job_pay_equity.data = bool(post.pay_equity_min and post.pay_equity_max) + self.job_pay_equity_min.data = post.pay_equity_min + self.job_pay_equity_max.data = post.pay_equity_max + class ApplicationForm(forms.Form): apply_email = forms.RadioField("Email", validators=[forms.validators.DataRequired("Pick an email address")], diff --git a/hasjob/templates/detail.html b/hasjob/templates/detail.html index f5e6c6cbb..25ba79917 100644 --- a/hasjob/templates/detail.html +++ b/hasjob/templates/detail.html @@ -133,6 +133,11 @@

What’s wrong with it?

   Edit this + {%- if post.is_old() %} + +    Repost this + + {%- endif %} {%- if post.is_public() %}    Withdraw this diff --git a/hasjob/templates/postjob.html b/hasjob/templates/postjob.html index d8b2c9b8e..4db4a4687 100644 --- a/hasjob/templates/postjob.html +++ b/hasjob/templates/postjob.html @@ -2,6 +2,13 @@ {% from "baseframe/forms.html" import renderfield, rendersubmit, widgetscripts %} {% block title %}List a job{% endblock %} {% block content %} + {%- if repost %} +
+

+ You're reposting {{archived_post.headline}}. +

+
+ {%- endif %}