diff --git a/chipy_org/apps/job_board/templates/job_board/delete_job_post.html b/chipy_org/apps/job_board/templates/job_board/delete_job_post.html
index b9f7e7b8..a51c070e 100644
--- a/chipy_org/apps/job_board/templates/job_board/delete_job_post.html
+++ b/chipy_org/apps/job_board/templates/job_board/delete_job_post.html
@@ -7,10 +7,9 @@
Are you sure you want to delete the job post for {{job_post.position}} at {{
- Cancel
-
{% endblock body %}
\ No newline at end of file
diff --git a/chipy_org/apps/job_board/views.py b/chipy_org/apps/job_board/views.py
index 4bc0abdc..99107314 100755
--- a/chipy_org/apps/job_board/views.py
+++ b/chipy_org/apps/job_board/views.py
@@ -1,5 +1,4 @@
import datetime
-import urllib
from django.conf import settings
from django.contrib import messages
@@ -40,10 +39,23 @@ def create_job_post(request):
send_email_to_admin_after_create_job_post(position, company, recipients)
- return HttpResponseRedirect(
- url_with_query_string(reverse("after-submit-job-post"), action="create")
+ messages.success(
+ request,
+ (
+ "Thank you for submitting a job posting!\n"
+ "It will have to be approved by an admin in order"
+ " to show up on the job board.\n"
+ " \n"
+ "You can check back on the decision status in the future.\n"
+ "To do so:\n"
+ "1. Log into chipy.org\n"
+ "2. In the top main menu, click on 'my jobs'.\n"
+ "3. It will take you to this page."
+ ),
)
+ return HttpResponseRedirect(reverse("after-submit-job-post"))
+
job_post = JobPost(contact=request.user)
job_post_form = JobPostForm(instance=job_post)
job_user_form = JobUserForm(instance=request.user)
@@ -76,10 +88,8 @@ def update_job_post(request, pk): # pylint: disable=invalid-name
job_post_form.save()
job_user_form.save()
-
- return HttpResponseRedirect(
- url_with_query_string(reverse("after-submit-job-post"), action="update")
- )
+ messages.success(request, "Your job post has been successfully updated.")
+ return HttpResponseRedirect(reverse("after-submit-job-post"))
else:
@@ -112,7 +122,6 @@ def delete_job_post(request, pk): # pylint: disable=invalid-name
if job_post.contact == request.user:
if request.method == "POST":
-
# If the user deletes the job post before the admin approves/rejects it, send an
# email to the admin telling them this.
if job_post.status == "SU":
@@ -121,11 +130,14 @@ def delete_job_post(request, pk): # pylint: disable=invalid-name
recipients = getattr(settings, "CHICAGO_ORGANIZER_EMAILS", [])
send_email_to_admin_after_user_deletes_job_post(position, company, recipients)
- job_post.delete()
+ if "delete" in request.POST:
+ job_post.delete()
+ messages.success(request, "Your job post has been successfully deleted.")
- return HttpResponseRedirect(
- url_with_query_string(reverse("after-submit-job-post"), action="delete")
- )
+ else:
+ messages.info(request, "The job post was not deleted.")
+
+ return HttpResponseRedirect(reverse("after-submit-job-post"))
else:
@@ -145,34 +157,6 @@ class AfterSubmitJobPost(LoginRequiredMixin, ListView):
template_name = "job_board/after_submit_job_post.html"
paginate_by = 6
- def get(self, request, *args, **kwargs):
-
- action = request.GET.get("action")
-
- if action == "create":
- messages.success(
- request,
- (
- "Thank you for submitting a job posting!\n"
- "It will have to be approved by an admin in order"
- " to show up on the job board.\n"
- " \n"
- "You can check back on the decision status in the future.\n"
- "To do so:\n"
- "1. Log into chipy.org\n"
- "2. In the top main menu, click on 'my jobs'.\n"
- "3. It will take you to this page."
- ),
- )
-
- elif action == "update":
- messages.success(request, "Your job post has been successfully updated.")
-
- elif action == "delete":
- messages.success(request, "Your job post has been successfully deleted.")
-
- return super().get(request, *args, **kwargs)
-
def get_queryset(self):
job_posts = JobPost.objects.filter(contact=self.request.user).order_by("-created")
return job_posts
@@ -206,18 +190,3 @@ def get(self, request, *args, **kwargs):
return super().get(request, *args, **kwargs)
else:
raise Http404("Post doesn't have a status of 'approved' OR it has expired.")
-
-
-def url_with_query_string(path, **kwargs):
-
- # This function is meant to be used with reverse() and kwargs
- # to create url with query string parameters.
- # For example,
- # url_with_query_string(reverse('example'), action='create', num=1, msg="well done!")
- # yields https://www.chipy.org/job-board/example/?action=create&num=1&msg=well+done%21 .
-
- # Code is from user 'geekQ' from
- # https://stackoverflow.com/questions/2778247/how-do-i-construct-a-django-reverse-url-using-query-args
-
- encoded_url = path + "?" + urllib.parse.urlencode(kwargs)
- return encoded_url