Commits

Ralph Leyga committed 41a89d0

jobsboard pep8 code fix

  • Participants
  • Parent commits 834a6a8

Comments (0)

Files changed (5)

jobsboard/admin.py

 class Company_Admin(admin.ModelAdmin):
     fieldsets = (
               (None, {
-                      'fields': ('added_by', 'name', 
+                      'fields': ('added_by', 'name',
                                  'address', 'description',
-                                 ('telephone', 'fax'), 'tags',)
+                                 ('telephone', 'fax'), 'tags', )
                       }),
                         )
     list_display = ('added_by', 'name', 'telephone', 'fax', 'address', 'tags',)

jobsboard/forms.py

 from django.contrib.admin import widgets
 from django.forms.extras.widgets import SelectDateWidget
 
+
 class JobForm(forms.ModelForm):
 
-#    date_due = forms.DateField(widget=SelectDateWidget())
-
     class Meta:
         model = Job
-        exclude = ('posted_by','date_added','tags','title_slug',)
+        exclude = ('posted_by', 'date_added', 'tags', 'title_slug',)
 
-    #def __init__(self, user=None, *args, **kwargs):
-    #    self.user = user
-    #    super(JobForm, self).__init__(*args, **kwargs)
-    #    self.fields['company'] = forms.ModelChoiceField(queryset=Company.objects.filter(added_by=user))
 
 class CompanyForm(forms.ModelForm):
+
     class Meta:
         model = Company
-        exclude = ('added_by','name_slug',)
-        
+        exclude = ('added_by', 'name_slug',)
+
+
 class ApplicantForm(forms.ModelForm):
+
     class Meta:
         model = Applicant
         exclude = ('user', 'job', 'status', 'date_applied')

jobsboard/signals.py

 ##!/usr/bin/env python
+import django.dispatch
 
-import django.dispatch
 from jobsboard.models import *
 
-job_pre_status_changed = django.dispatch.Signal(providing_args=['old_job','new_job'])
-job_post_status_changed = django.dispatch.Signal(providing_args=['old_job','new_job'])
+job_pre_status_changed = django.dispatch.Signal(providing_args=['old_job', 'new_job'])
+job_post_status_changed = django.dispatch.Signal(providing_args=['old_job', 'new_job'])
 
+applicant_pre_status_changed = django.dispatch.Signal(providing_args=['job', 'applicant', 'old_status', 'new_status'])
+applicant_post_status_changed = django.dispatch.Signal(providing_args=['job', 'applicant', 'old_status', 'new_status'])
 
-applicant_pre_status_changed = django.dispatch.Signal(providing_args=['job','applicant','old_status','new_status'])
-applicant_post_status_changed = django.dispatch.Signal(providing_args=['job','applicant','old_status','new_status'])
-
-
-company_pre_edit = django.dispatch.Signal(providing_args=['name','added_by'])
-
-
-
+company_pre_edit = django.dispatch.Signal(providing_args=['name', 'added_by'])

jobsboard/templatetags/jobsboard_extras.py

     """
     def __init__(self, num, varname):
         self.num, self.varname = num, varname
-    
+
     def render(self, context):
         context[self.varname] = Job.objects.filter(status=1).order_by("?")[:self.num]
         return ''
     bits = token.contents.split()
     if len(bits) != 4:
         raise TemplateSyntaxError, "get_random_jobs tag takes exactly 2 arguments"
+
     if bits[2] != 'as':
         raise TemplateSyntaxError, "second argument to the get_random_jobs tag must be 'as'"
+
     return RandomLinksNode(bits[1], bits[3])
 get_random_jobs = register.tag(get_random_jobs)
 
     """
     def __init__(self, num, varname):
         self.num, self.varname = num, varname
-    
+
     def render(self, context):
         context[self.varname] = Job.objects.all().order_by('-date_added')[:self.num]
         return ''
         raise TemplateSyntaxError, "second argument to the get_latest_jobs tag must be 'as'"
     return LatestLinksNode(bits[1], bits[3])
 get_latest_jobs = register.tag(get_latest_jobs)
-
-            
-            
-

jobsboard/views.py

             is_me = True
         else:
             is_me = False
-            
+
     search_terms = request.GET.get('q', '')
     if search_terms:
         jobs = (jobs.filter(title_slug__icontains=search_terms)
-               |jobs.filter(title__icontains=search_terms)
-               |jobs.filter(description__icontains=search_terms)
-               |jobs.filter(status__icontains=search_terms)
-               |jobs.filter(date_added__icontains=search_terms)
-               |jobs.filter(date_updated__icontains=search_terms)
-               |jobs.filter(company__name__icontains=search_terms)
-               |jobs.filter(date_due__icontains=search_terms)
-               |jobs.filter(tags__icontains=search_terms))
+                   |jobs.filter(title__icontains=search_terms)
+                   |jobs.filter(description__icontains=search_terms)
+                   |jobs.filter(status__icontains=search_terms)
+                   |jobs.filter(date_added__icontains=search_terms)
+                   |jobs.filter(date_updated__icontains=search_terms)
+                   |jobs.filter(company__name__icontains=search_terms)
+                   |jobs.filter(date_due__icontains=search_terms)
+                   |jobs.filter(tags__icontains=search_terms))
     return render_to_response(template_name, dict({
-            "jobs":jobs,
-            "is_me":is_me,
+            "jobs": jobs,
+            "is_me": is_me,
         }), context_instance=RequestContext(request))
 
 
 
 
     return render_to_response(template_name, {
-        "job_form": job_form
-    }, context_instance=RequestContext(request))
+        "job_form" : job_form
+        }, context_instance=RequestContext(request))
 
 
 @login_required
-def job_edit(request,jobid,form_class=JobForm, template_name="jobsboard/job_form.html"):
+def job_edit(request, jobid, form_class=JobForm, template_name="jobsboard/job_form.html"):
     """
     edit job posted.  The user may able to set the status and update information about the job posted.
     """
     else:
         return HttpResponseRedirect(reverse("jobsboard.views.job_list"))
     return render_to_response(template_name, {
-        "job_form":job_form,
-        "job_obj":job_obj,
-        "is_edit":is_edit,
-        },context_instance=RequestContext(request))
+        "job_form": job_form,
+        "job_obj": job_obj,
+        "is_edit": is_edit,
+        }, context_instance=RequestContext(request))
 
 
-def job_detail(request,jobid, form_class=ApplicantForm, template_name="jobsboard/job_detail.html"):
+def job_detail(request, jobid, form_class=ApplicantForm, template_name="jobsboard/job_detail.html"):
     """
     display the job information and company.  the applicant may able to apply if he/she is a verified user
     """
+    job_obj = get_object_or_404(Job, id=jobid)
+    meapp = Applicant.objects.filter(user=request.user, job=job_obj)
+    app = Applicant.objects.filter(job=job_obj)
+    job_d = Job.objects.filter(id=jobid)
 
-
-    job_obj = get_object_or_404(Job, id = jobid)
-    meapp = Applicant.objects.filter(user=request.user, job=job_obj)
-    app = Applicant.objects.filter(job = job_obj)
-    job_d = Job.objects.filter(id = jobid)
-    
     if request.method == "POST":
         app_form = form_class(request.POST)
         if app_form.is_valid():
         app_form = form_class()
 
     return render_to_response(template_name, {
-        "job":job_obj,
-        "apps":app,
-        "app_form":app_form,
-        "jobstatus":jobstatus,
-        "meapp":meapp,
-        },context_instance=RequestContext(request))
+        "job": job_obj,
+        "apps": app,
+        "app_form": app_form,
+        "jobstatus": jobstatus,
+        "meapp": meapp,
+        }, context_instance=RequestContext(request))
 
 
 @login_required
         2 - Filled
         3 - Cancelled
         4 - Stale
-    
+
     the user who post the job is authorize to change the applicants status
     """
 
     applicant = Applicant.objects.get(pk=id)
-    job = get_object_or_404(Job, id = applicant.job.id)
-    
-    if job.posted_by==request.user:
+    job = get_object_or_404(Job, id=applicant.job.id)
+
+    if job.posted_by == request.user:
         applicant.status = status
         applicant.save()
         request.user.message_set.create(message=_("The applicant '%s' was changed successfully. ") % applicant.user)
     remove applicant from applied jobs
     """
 
-    apply = Applicant.objects.get(pk = id)
-    if apply.user==request.user:
+    apply = Applicant.objects.get(pk=id)
+    if apply.user == request.user:
         apply.delete()
         request.user.message_set.create(message=_("Successfully remove from '%s'") % apply.job)
     else:
         request.user.message_set.create(message=_("Not successfully remove from '%s'") % apply.job)
     return HttpResponseRedirect(reverse("jobsboard.views.job_list"))
 
+
 @login_required
 def apply_list(request, template_name='jobsboard/applied_jobs.html'):
     """
     """
 
     try:
-        apply = Applicant.objects.get(pk = id)
+        apply = Applicant.objects.get(pk=id)
     except Exception:
         return HttpResponseRedirect(reverse('jobsboard.views.apply_list'))
-    
+
     if apply.user==request.user:
         apply.delete()
         msg = "Your application has been successfully removed from '%s'" % (apply.job,)
     remove applicant by employers
     """
 
-    job = get_object_or_404(Job, id = jobid)
-    apply = Applicant.objects.get(pk = id)
-    if job.posted_by==request.user:
+    job = get_object_or_404(Job, id=jobid)
+    apply = Applicant.objects.get(pk=id)
+    if job.posted_by == request.user:
         apply.delete()
         request.user.message_set.create(message=_("Successfully remove from '%s'") % apply.job)
     else:
     remove job by the employer
     """
 
-    job = get_object_or_404(Job, id = id)
-    if job.posted_by==request.user:
+    job = get_object_or_404(Job, id=id)
+    if job.posted_by == request.user:
         job.delete()
         request.user.message_set.create(message=_("Successfully remove from '%s'") % job.title)
     else:
         request.user.message_set.create(message=_("Not successfully remove from '%s'") % job.title)
-        
+
     return HttpResponseRedirect(reverse('jobsboard.views.your_job_post'))
 
 
     employer change the status of applicant
     """
 
-    job = get_object_or_404(Job, id = id)
-    if job.posted_by==request.user:
-        job.status=status
+    job = get_object_or_404(Job, id=id)
+    if job.posted_by == request.user:
+        job.status = status
         job.save()
         request.user.message_set.create(message=_("Successfully update the '%s'") % job.title)
     else:
     remove the company by the user who added the company
     """
 
-    com = get_object_or_404(Company, id = id)
-    if com.added_by==request.user:
+    com = get_object_or_404(Company, id=id)
+    if com.added_by == request.user:
         com.delete()
         request.user.message_set.create(message=_("Successfully remove from '%s'") % com.name)
     else:
                |company.filter(date_added__icontains=search_terms)
                |company.filter(tags__icontains=search_terms))
     return render_to_response(template_name, dict({
-            "company":company,
-            "is_me":is_me,
+            "company": company,
+            "is_me": is_me,
         }), context_instance=RequestContext(request))
 
 
 
 #Modify the existing company
 @login_required
-def company_edit(request,comid,form_class=CompanyForm, template_name="jobsboard/company_form.html"):
+def company_edit(request, comid, form_class=CompanyForm, template_name="jobsboard/company_form.html"):
     """
     edit the company detail by verified user who added the company
     """
     else:
         return HttpResponseRedirect(reverse("jobsboard.views.company_list"))
     return render_to_response(template_name, {
-        "com_form":com_form,
-        "com_obj":com_obj,
-        },context_instance=RequestContext(request))
+        "com_form": com_form,
+        "com_obj": com_obj,
+        }, context_instance=RequestContext(request))
 
 
-def company_detail(request,comid, template_name="jobsboard/company_detail.html"):
+def company_detail(request, comid, template_name="jobsboard/company_detail.html"):
     """
     display the detail of the company
     """
 
-    com_d = get_object_or_404(Company,id = comid)
+    com_d = get_object_or_404(Company, id=comid)
     job_d = Job.objects.filter(company=com_d)
     return render_to_response(template_name, {
-        "com":com_d,
-        "jobs":job_d,
-        },context_instance=RequestContext(request))
+        "com": com_d,
+        "jobs": job_d,
+        }, context_instance=RequestContext(request))
+
 
 @login_required
 def your_job_post(request, template_name="jobsboard/your_job_post.html"):
     display the list of job posted by verified user
     """
 
-    job = Job.objects.filter(posted_by = request.user)
-    
+    job = Job.objects.filter(posted_by=request.user)
+
     search_terms = request.GET.get('q', '')
     if search_terms:
         job = (job.filter(title_slug__icontains=search_terms)
 
 
     return render_to_response(template_name, {
-        "jobs":job,
+        "jobs": job,
     }, context_instance=RequestContext(request))
 
 
                |company.filter(date_added__icontains=search_terms)
                |company.filter(tags__icontains=search_terms))
     return render_to_response(template_name, dict({
-            "company":company,
+            "company": company,
         }), context_instance=RequestContext(request))
-