Example #1
0
 def render_to_response(self, context):
     if self.render_json:
         jobs = []
         for job in context['object_list']:
             jobs.append({
                 'name': job.name,
                 'organization': job.organization.name,
                 'listed': dj_date(job.listing_start_date, 'F j, Y'),
             })
         return render_json_to_response(jobs)
     return super(JobList, self).render_to_response(context)
Example #2
0
 def render_to_response(self, context):
     if self.render_json:
         jobs = []
         for job in context['object_list']:
             jobs.append({
                 'name': job.name,
                 'organization': job.organization.name,
                 'description': job.description,
                 'location': job.location,
                 'contact_name': job.contact_name,
                 'email': job.email,
                 'listed': dj_date(job.listing_start_date, 'F j, Y'),
                 'url': job.url,
                 'source_url': job.get_list_page_url,
             })
         return render_json_to_response(jobs)
     return super(JobList, self).render_to_response(context)
Example #3
0
 def render_to_response(self, context):
     if self.render_json:
         jobs = []
         for job in context['object_list']:
             jobs.append({
                 'name': job.name,
                 'organization': job.organization.name,
                 'description': job.description,
                 'location': job.location,
                 'contact_name': job.contact_name,
                 'email': job.email,
                 'listed': dj_date(job.listing_start_date, 'F j, Y'),
                 'url': job.url,
                 'source_url': job.get_list_page_url,
             })
         return render_json_to_response(jobs)
     return super(JobList, self).render_to_response(context)
Example #4
0
    def post(self, request, *args, **kwargs):
        data = request.POST
        form_message = ''

        task = data['organization_task']
        organization = self.get_organization()

        if task == 'create':
            job = self.create_job(data, organization)
            form_message = 'Created'
        else:
            job = self.get_job(data['job'], organization, task)
            if task == 'update':
                form_message = self.process_form(job, data)
            elif task == 'remove':
                job.delete()
                expire_page_cache(reverse('job_list'))
                expire_page_cache(organization.get_absolute_url())
                form_message = 'Removed'

        if request.is_ajax():
            result = {
                'message': form_message,
                'job': {
                    'name': job.name,
                    'pk': job.pk,
                    'contact_name': job.contact_name,
                    'email': job.email,
                    'description': job.description,
                    'location': job.location,
                    'url': job.url,
                    'listing_end_date': job.listing_end_date
                }
            }
            return render_json_to_response(result)

        # if for some reason we're not hitting via ajax
        messages.success(request, form_message)
        return redirect(self.get_success_url())
Example #5
0
    def post(self, request, *args, **kwargs):
        data = request.POST
        form_message = ''
        
        task = data['organization_task']
        organization = self.get_organization()

        if task == 'create':
            job = self.create_job(data, organization)
            form_message = 'Created'
        else:
            job = self.get_job(data['job'], organization, task)
            if task == 'update':
                form_message = self.process_form(job, data)
            elif task == 'remove':
                job.delete()
                expire_page_cache(reverse('job_list'))
                expire_page_cache(organization.get_absolute_url())
                form_message = 'Removed'

        if request.is_ajax():
            result = {
                'message': form_message,
                'job': {
                    'name': job.name,
                    'pk': job.pk,
                    'contact_name': job.contact_name,
                    'email': job.email,
                    'description': job.description,
                    'location': job.location,
                    'url': job.url,
                    'listing_end_date': job.listing_end_date
                }
            }
            return render_json_to_response(result)

        # if for some reason we're not hitting via ajax
        messages.success(request, form_message)
        return redirect(self.get_success_url())