prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Users should be able to edit expired 'careeropportunity' from Dashboard
  ## What kind of an issue is this?
  - Feature request
  
  ## What is the expected behaviour?
  
  You should be able to click to edit from the list of expired careeropportunities in the Dashboard.
  
  ## Other information
  
  This was requested by one of our users on email.
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `apps/careeropportunity/dashboard/views.py`
  Content:
  ```
  1 # -*- encoding: utf-8 -*-
  2 import logging
  3 
  4 from django.contrib import messages
  5 from django.contrib.auth.decorators import login_required
  6 from django.core.exceptions import PermissionDenied
  7 from django.shortcuts import get_object_or_404, redirect, render
  8 from django.utils import timezone
  9 from guardian.decorators import permission_required
  10 
  11 from apps.careeropportunity.forms import AddCareerOpportunityForm
  12 from apps.careeropportunity.models import CareerOpportunity
  13 from apps.dashboard.tools import get_base_context, has_access
  14 
  15 
  16 @login_required
  17 @permission_required('careeropportunity.view_careeropportunity', return_403=True)
  18 def index(request):
  19 
  20     if not has_access(request):
  21         raise PermissionDenied
  22 
  23     context = get_base_context(request)
  24 
  25     # "cops" is short for "careeropportunities" which is a fucking long word
  26     # "cop" is short for "careeropportunity" which also is a fucking long word
  27     cops = CareerOpportunity.objects.all()
  28     context['cops'] = cops.filter(end__gte=timezone.now()).order_by('end')
  29     context['archive'] = cops.filter(end__lte=timezone.now()).order_by('-id')
  30 
  31     return render(request, 'careeropportunity/dashboard/index.html', context)
  32 
  33 
  34 @login_required
  35 @permission_required('careeropportunity.change_careeropportunity', return_403=True)
  36 def detail(request, opportunity_id=None):
  37     logger = logging.getLogger(__name__)
  38     logger.debug('Editing careeropportunity with id: %s' % (opportunity_id))
  39 
  40     if not has_access(request):
  41         raise PermissionDenied
  42 
  43     context = get_base_context(request)
  44     cop = None
  45     if opportunity_id:
  46         cop = get_object_or_404(CareerOpportunity, pk=opportunity_id)
  47         context['cop'] = cop
  48         context['form'] = AddCareerOpportunityForm(instance=cop)
  49     else:
  50         context['form'] = AddCareerOpportunityForm()
  51 
  52     if request.method == 'POST':
  53         if cop:
  54             form = AddCareerOpportunityForm(data=request.POST, instance=cop)
  55         else:
  56             form = AddCareerOpportunityForm(data=request.POST)
  57 
  58         if form.is_valid():
  59             form.save()
  60             messages.success(request, 'La til ny karrieremulighet')
  61             return redirect(index)
  62         else:
  63             context['form'] = form
  64             messages.error(request,
  65                            'Skjemaet ble ikke korrekt utfylt. Se etter markerte felter for å se hva som gikk galt.')
  66 
  67     return render(request, 'careeropportunity/dashboard/detail.html', context)
  68 
  69 
  70 @login_required
  71 @permission_required('careeropportunity.change_careeropportunity', return_403=True)
  72 def delete(request, opportunity_id=None):
  73     logger = logging.getLogger(__name__)
  74     logger.debug('Deleting careeropportunitywith id: %s' % (opportunity_id))
  75     if not has_access(request):
  76         raise PermissionDenied
  77 
  78     cop = get_object_or_404(CareerOpportunity, pk=opportunity_id)
  79     cop.delete()
  80     messages.success(request, 'Slettet karrieremuligheten')
  81     return redirect(index)
  82
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/apps/careeropportunity/dashboard/views.py b/apps/careeropportunity/dashboard/views.py
  --- a/apps/careeropportunity/dashboard/views.py
  +++ b/apps/careeropportunity/dashboard/views.py
  @@ -27,7 +27,7 @@
       cops = CareerOpportunity.objects.all()
       context['cops'] = cops.filter(end__gte=timezone.now()).order_by('end')
       context['archive'] = cops.filter(end__lte=timezone.now()).order_by('-id')
  -
  +    context['all'] = cops
       return render(request, 'careeropportunity/dashboard/index.html', context)
  
verification_info: {"golden_diff": "diff --git a/apps/careeropportunity/dashboard/views.py b/apps/careeropportunity/dashboard/views.py\n--- a/apps/careeropportunity/dashboard/views.py\n+++ b/apps/careeropportunity/dashboard/views.py\n@@ -27,7 +27,7 @@\n     cops = CareerOpportunity.objects.all()\n     context['cops'] = cops.filter(end__gte=timezone.now()).order_by('end')\n     context['archive'] = cops.filter(end__lte=timezone.now()).order_by('-id')\n-\n+    context['all'] = cops\n     return render(request, 'careeropportunity/dashboard/index.html', context)\n", "issue": "Users should be able to edit expired 'careeropportunity' from Dashboard\n## What kind of an issue is this?\r\n- Feature request\r\n\r\n## What is the expected behaviour?\r\n\r\nYou should be able to click to edit from the list of expired careeropportunities in the Dashboard.\r\n\r\n## Other information\r\n\r\nThis was requested by one of our users on email.\r\n\n", "before_files": [{"content": "# -*- encoding: utf-8 -*-\nimport logging\n\nfrom django.contrib import messages\nfrom django.contrib.auth.decorators import login_required\nfrom django.core.exceptions import PermissionDenied\nfrom django.shortcuts import get_object_or_404, redirect, render\nfrom django.utils import timezone\nfrom guardian.decorators import permission_required\n\nfrom apps.careeropportunity.forms import AddCareerOpportunityForm\nfrom apps.careeropportunity.models import CareerOpportunity\nfrom apps.dashboard.tools import get_base_context, has_access\n\n\n@login_required\n@permission_required('careeropportunity.view_careeropportunity', return_403=True)\ndef index(request):\n\n    if not has_access(request):\n        raise PermissionDenied\n\n    context = get_base_context(request)\n\n    # \"cops\" is short for \"careeropportunities\" which is a fucking long word\n    # \"cop\" is short for \"careeropportunity\" which also is a fucking long word\n    cops = CareerOpportunity.objects.all()\n    context['cops'] = cops.filter(end__gte=timezone.now()).order_by('end')\n    context['archive'] = cops.filter(end__lte=timezone.now()).order_by('-id')\n\n    return render(request, 'careeropportunity/dashboard/index.html', context)\n\n\n@login_required\n@permission_required('careeropportunity.change_careeropportunity', return_403=True)\ndef detail(request, opportunity_id=None):\n    logger = logging.getLogger(__name__)\n    logger.debug('Editing careeropportunity with id: %s' % (opportunity_id))\n\n    if not has_access(request):\n        raise PermissionDenied\n\n    context = get_base_context(request)\n    cop = None\n    if opportunity_id:\n        cop = get_object_or_404(CareerOpportunity, pk=opportunity_id)\n        context['cop'] = cop\n        context['form'] = AddCareerOpportunityForm(instance=cop)\n    else:\n        context['form'] = AddCareerOpportunityForm()\n\n    if request.method == 'POST':\n        if cop:\n            form = AddCareerOpportunityForm(data=request.POST, instance=cop)\n        else:\n            form = AddCareerOpportunityForm(data=request.POST)\n\n        if form.is_valid():\n            form.save()\n            messages.success(request, 'La til ny karrieremulighet')\n            return redirect(index)\n        else:\n            context['form'] = form\n            messages.error(request,\n                           'Skjemaet ble ikke korrekt utfylt. Se etter markerte felter for \u00e5 se hva som gikk galt.')\n\n    return render(request, 'careeropportunity/dashboard/detail.html', context)\n\n\n@login_required\n@permission_required('careeropportunity.change_careeropportunity', return_403=True)\ndef delete(request, opportunity_id=None):\n    logger = logging.getLogger(__name__)\n    logger.debug('Deleting careeropportunitywith id: %s' % (opportunity_id))\n    if not has_access(request):\n        raise PermissionDenied\n\n    cop = get_object_or_404(CareerOpportunity, pk=opportunity_id)\n    cop.delete()\n    messages.success(request, 'Slettet karrieremuligheten')\n    return redirect(index)\n", "path": "apps/careeropportunity/dashboard/views.py"}], "after_files": [{"content": "# -*- encoding: utf-8 -*-\nimport logging\n\nfrom django.contrib import messages\nfrom django.contrib.auth.decorators import login_required\nfrom django.core.exceptions import PermissionDenied\nfrom django.shortcuts import get_object_or_404, redirect, render\nfrom django.utils import timezone\nfrom guardian.decorators import permission_required\n\nfrom apps.careeropportunity.forms import AddCareerOpportunityForm\nfrom apps.careeropportunity.models import CareerOpportunity\nfrom apps.dashboard.tools import get_base_context, has_access\n\n\n@login_required\n@permission_required('careeropportunity.view_careeropportunity', return_403=True)\ndef index(request):\n\n    if not has_access(request):\n        raise PermissionDenied\n\n    context = get_base_context(request)\n\n    # \"cops\" is short for \"careeropportunities\" which is a fucking long word\n    # \"cop\" is short for \"careeropportunity\" which also is a fucking long word\n    cops = CareerOpportunity.objects.all()\n    context['cops'] = cops.filter(end__gte=timezone.now()).order_by('end')\n    context['archive'] = cops.filter(end__lte=timezone.now()).order_by('-id')\n    context['all'] = cops\n    return render(request, 'careeropportunity/dashboard/index.html', context)\n\n\n@login_required\n@permission_required('careeropportunity.change_careeropportunity', return_403=True)\ndef detail(request, opportunity_id=None):\n    logger = logging.getLogger(__name__)\n    logger.debug('Editing careeropportunity with id: %s' % (opportunity_id))\n\n    if not has_access(request):\n        raise PermissionDenied\n\n    context = get_base_context(request)\n    cop = None\n    if opportunity_id:\n        cop = get_object_or_404(CareerOpportunity, pk=opportunity_id)\n        context['cop'] = cop\n        context['form'] = AddCareerOpportunityForm(instance=cop)\n    else:\n        context['form'] = AddCareerOpportunityForm()\n\n    if request.method == 'POST':\n        if cop:\n            form = AddCareerOpportunityForm(data=request.POST, instance=cop)\n        else:\n            form = AddCareerOpportunityForm(data=request.POST)\n\n        if form.is_valid():\n            form.save()\n            messages.success(request, 'La til ny karrieremulighet')\n            return redirect(index)\n        else:\n            context['form'] = form\n            messages.error(request,\n                           'Skjemaet ble ikke korrekt utfylt. Se etter markerte felter for \u00e5 se hva som gikk galt.')\n\n    return render(request, 'careeropportunity/dashboard/detail.html', context)\n\n\n@login_required\n@permission_required('careeropportunity.change_careeropportunity', return_403=True)\ndef delete(request, opportunity_id=None):\n    logger = logging.getLogger(__name__)\n    logger.debug('Deleting careeropportunitywith id: %s' % (opportunity_id))\n    if not has_access(request):\n        raise PermissionDenied\n\n    cop = get_object_or_404(CareerOpportunity, pk=opportunity_id)\n    cop.delete()\n    messages.success(request, 'Slettet karrieremuligheten')\n    return redirect(index)\n", "path": "apps/careeropportunity/dashboard/views.py"}]}