from django.shortcuts import render_to_response
from django.shortcuts import get_object_or_404
from django.template import RequestContext
from apps.careeropportunity.models import CareerOpportunity

import datetime


def index(request):
    opportunities = CareerOpportunity.objects.all()
    
    return render_to_response('careeropportunity/index.html', \
            {'opportunities': opportunities}, \
            context_instance=RequestContext(request))

def details(request, opportunity_id):
    opportunity = get_object_or_404(CareerOpportunity, pk=opportunity_id)

    return render_to_response('careeropportunity/details.html', \
            {'opportunity': opportunity}, \
            context_instance=RequestContext(request))

from datetime import datetime
from django.shortcuts import render_to_response
from django.shortcuts import get_object_or_404
from django.template import RequestContext
from apps.careeropportunity.models import CareerOpportunity


def index(request):
    opportunities = CareerOpportunity.objects.filter(start__lte=datetime.now(), end__gte=datetime.now())
    
    return render_to_response('careeropportunity/index.html', \
            {'opportunities': opportunities}, \
            context_instance=RequestContext(request))

def details(request, opportunity_id):
    opportunity = get_object_or_404(CareerOpportunity, pk=opportunity_id)

    return render_to_response('careeropportunity/details.html', \
            {'opportunity': opportunity}, \
            context_instance=RequestContext(request))

Make careerop only display active ops
Make careerop only display active ops

+ from datetime import datetime
  from django.shortcuts import render_to_response
  from django.shortcuts import get_object_or_404
  from django.template import RequestContext
  from apps.careeropportunity.models import CareerOpportunity
  
- import datetime
- 
  
  def index(request):
-     opportunities = CareerOpportunity.objects.all()
+     opportunities = CareerOpportunity.objects.filter(start__lte=datetime.now(), end__gte=datetime.now())
      
      return render_to_response('careeropportunity/index.html', \
              {'opportunities': opportunities}, \
              context_instance=RequestContext(request))
  
  def details(request, opportunity_id):
      opportunity = get_object_or_404(CareerOpportunity, pk=opportunity_id)
  
      return render_to_response('careeropportunity/details.html', \
              {'opportunity': opportunity}, \
              context_instance=RequestContext(request))
  
Make careerop only display active ops
## Code Before:
from django.shortcuts import render_to_response
from django.shortcuts import get_object_or_404
from django.template import RequestContext
from apps.careeropportunity.models import CareerOpportunity

import datetime


def index(request):
    opportunities = CareerOpportunity.objects.all()
    
    return render_to_response('careeropportunity/index.html', \
            {'opportunities': opportunities}, \
            context_instance=RequestContext(request))

def details(request, opportunity_id):
    opportunity = get_object_or_404(CareerOpportunity, pk=opportunity_id)

    return render_to_response('careeropportunity/details.html', \
            {'opportunity': opportunity}, \
            context_instance=RequestContext(request))

## Instruction:
Make careerop only display active ops
## Code After:
from datetime import datetime
from django.shortcuts import render_to_response
from django.shortcuts import get_object_or_404
from django.template import RequestContext
from apps.careeropportunity.models import CareerOpportunity


def index(request):
    opportunities = CareerOpportunity.objects.filter(start__lte=datetime.now(), end__gte=datetime.now())
    
    return render_to_response('careeropportunity/index.html', \
            {'opportunities': opportunities}, \
            context_instance=RequestContext(request))

def details(request, opportunity_id):
    opportunity = get_object_or_404(CareerOpportunity, pk=opportunity_id)

    return render_to_response('careeropportunity/details.html', \
            {'opportunity': opportunity}, \
            context_instance=RequestContext(request))
