prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Delete templates used in the old design, replace them with redesign-specific templates (like profile_redesign.html)
  
  
  --- 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/devmo/views.py`
  Content:
  ```
  1 from django.conf import settings
  2 from django.core.paginator import Paginator
  3 from django.shortcuts import get_object_or_404, render
  4 from django.http import (HttpResponseRedirect, HttpResponseForbidden)
  5 
  6 from devmo.urlresolvers import reverse
  7 
  8 import constance.config
  9 import basket
  10 from taggit.utils import parse_tags
  11 from waffle import flag_is_active
  12 
  13 from waffle import flag_is_active
  14 
  15 from access.decorators import login_required
  16 from demos.models import Submission
  17 from teamwork.models import Team
  18 
  19 from . import INTEREST_SUGGESTIONS
  20 from .models import Calendar, Event, UserProfile
  21 from .forms import (UserProfileEditForm, newsletter_subscribe,
  22                     get_subscription_details, subscribed_to_newsletter)
  23 
  24 
  25 DOCS_ACTIVITY_MAX_ITEMS = getattr(settings,
  26         'DOCS_ACTIVITY_MAX_ITEMS', 15)
  27 
  28 
  29 def events(request):
  30     """Developer Engagement Calendar"""
  31     cal = Calendar.objects.get(shortname='devengage_events')
  32     events = Event.objects.filter(calendar=cal)
  33     upcoming_events = events.filter(done=False)
  34     past_events = events.filter(done=True)
  35     google_maps_api_key = getattr(settings, 'GOOGLE_MAPS_API_KEY',
  36         "ABQIAAAAijZqBZcz-rowoXZC1tt9iRT5rHVQFKUGOHoyfP"
  37         "_4KyrflbHKcRTt9kQJVST5oKMRj8vKTQS2b7oNjQ")
  38 
  39     return render(request, 'devmo/calendar.html', {
  40         'upcoming_events': upcoming_events,
  41         'past_events': past_events,
  42         'google_maps_api_key': google_maps_api_key
  43     })
  44 
  45 
  46 def profile_view(request, username):
  47     profile = get_object_or_404(UserProfile, user__username=username)
  48     user = profile.user
  49 
  50     DEMOS_PAGE_SIZE = getattr(settings, 'DEMOS_PAGE_SIZE', 12)
  51     sort_order = request.GET.get('sort', 'created')
  52     try:
  53         page_number = int(request.GET.get('page', 1))
  54     except ValueError:
  55         page_number = 1
  56     show_hidden = (user == request.user) or user.is_superuser
  57 
  58     demos = Submission.objects.all_sorted(sort_order).filter(
  59                                                         creator=profile.user)
  60     if not show_hidden:
  61         demos = demos.exclude(hidden=True)
  62 
  63     demos_paginator = Paginator(demos, DEMOS_PAGE_SIZE, True)
  64     demos_page = demos_paginator.page(page_number)
  65 
  66     wiki_activity, docs_feed_items = None, None
  67     wiki_activity = profile.wiki_activity()
  68 
  69     if request.user.is_anonymous():
  70         show_manage_roles_button = False
  71     else:
  72         # TODO: This seems wasteful, just to decide whether to show the button
  73         roles_by_team = Team.objects.get_team_roles_managed_by(request.user,
  74                                                                user)
  75         show_manage_roles_button = (len(roles_by_team) > 0)
  76 
  77     template = 'devmo/profile.html'
  78     if flag_is_active(request, 'redesign'):
  79             template = 'devmo/profile_redesign.html'
  80 
  81     return render(request, template, dict(
  82         profile=profile, demos=demos, demos_paginator=demos_paginator,
  83         demos_page=demos_page, docs_feed_items=docs_feed_items,
  84         wiki_activity=wiki_activity,
  85         show_manage_roles_button=show_manage_roles_button,
  86     ))
  87 
  88 
  89 @login_required
  90 def my_profile(request):
  91     user = request.user
  92     return HttpResponseRedirect(reverse(
  93             'devmo.views.profile_view', args=(user.username,)))
  94 
  95 
  96 def profile_edit(request, username):
  97     """View and edit user profile"""
  98     profile = get_object_or_404(UserProfile, user__username=username)
  99     context = {'profile': profile}
  100     if not profile.allows_editing_by(request.user):
  101         return HttpResponseForbidden()
  102 
  103     # Map of form field names to tag namespaces
  104     field_to_tag_ns = (
  105         ('interests', 'profile:interest:'),
  106         ('expertise', 'profile:expertise:')
  107     )
  108 
  109 
  110     if request.method != 'POST':
  111         initial = dict(email=profile.user.email, beta=profile.beta_tester)
  112 
  113         # Load up initial websites with either user data or required base URL
  114         for name, meta in UserProfile.website_choices:
  115             initial['websites_%s' % name] = profile.websites.get(name, '')
  116 
  117         # Form fields to receive tags filtered by namespace.
  118         for field, ns in field_to_tag_ns:
  119             initial[field] = ', '.join(t.name.replace(ns, '')
  120                                        for t in profile.tags.all_ns(ns))
  121 
  122         subscription_details = get_subscription_details(profile.user.email)
  123         if subscribed_to_newsletter(subscription_details):
  124             initial['newsletter'] = True
  125             initial['agree'] = True
  126 
  127         # Finally, set up the forms.
  128         form = UserProfileEditForm(request.locale,
  129                                    instance=profile,
  130                                    initial=initial)
  131 
  132     else:
  133         form = UserProfileEditForm(request.locale,
  134                                    request.POST,
  135                                    request.FILES,
  136                                    instance=profile)
  137         if form.is_valid():
  138             profile_new = form.save(commit=False)
  139 
  140             # Gather up all websites defined by the model, save them.
  141             sites = dict()
  142             for name, meta in UserProfile.website_choices:
  143                 field_name = 'websites_%s' % name
  144                 field_value = form.cleaned_data.get(field_name, '')
  145                 if field_value and field_value != meta['prefix']:
  146                     sites[name] = field_value
  147             profile_new.websites = sites
  148 
  149             # Save the profile record now, since the rest of this deals with
  150             # related resources...
  151             profile_new.save()
  152 
  153             # Update tags from form fields
  154             for field, tag_ns in field_to_tag_ns:
  155                 tags = [t.lower() for t in parse_tags(
  156                                             form.cleaned_data.get(field, ''))]
  157                 profile_new.tags.set_ns(tag_ns, *tags)
  158 
  159             newsletter_subscribe(request, profile_new.user.email,
  160                                  form.cleaned_data)
  161             return HttpResponseRedirect(reverse(
  162                     'devmo.views.profile_view', args=(profile.user.username,)))
  163     context['form'] = form
  164     context['INTEREST_SUGGESTIONS'] = INTEREST_SUGGESTIONS
  165 
  166     return render(request, 'devmo/profile_edit.html', context)
  167 
  168 
  169 @login_required
  170 def my_profile_edit(request):
  171     user = request.user
  172     return HttpResponseRedirect(reverse(
  173             'devmo.views.profile_edit', args=(user.username,)))
  174
  ```
  --- 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/devmo/views.py b/apps/devmo/views.py
  --- a/apps/devmo/views.py
  +++ b/apps/devmo/views.py
  @@ -75,8 +75,6 @@
           show_manage_roles_button = (len(roles_by_team) > 0)
   
       template = 'devmo/profile.html'
  -    if flag_is_active(request, 'redesign'):
  -            template = 'devmo/profile_redesign.html'
   
       return render(request, template, dict(
           profile=profile, demos=demos, demos_paginator=demos_paginator,
  
verification_info: {"golden_diff": "diff --git a/apps/devmo/views.py b/apps/devmo/views.py\n--- a/apps/devmo/views.py\n+++ b/apps/devmo/views.py\n@@ -75,8 +75,6 @@\n         show_manage_roles_button = (len(roles_by_team) > 0)\n \n     template = 'devmo/profile.html'\n-    if flag_is_active(request, 'redesign'):\n-            template = 'devmo/profile_redesign.html'\n \n     return render(request, template, dict(\n         profile=profile, demos=demos, demos_paginator=demos_paginator,\n", "issue": "Delete templates used in the old design, replace them with redesign-specific templates (like profile_redesign.html)\n\n", "before_files": [{"content": "from django.conf import settings\nfrom django.core.paginator import Paginator\nfrom django.shortcuts import get_object_or_404, render\nfrom django.http import (HttpResponseRedirect, HttpResponseForbidden)\n\nfrom devmo.urlresolvers import reverse\n\nimport constance.config\nimport basket\nfrom taggit.utils import parse_tags\nfrom waffle import flag_is_active\n\nfrom waffle import flag_is_active\n\nfrom access.decorators import login_required\nfrom demos.models import Submission\nfrom teamwork.models import Team\n\nfrom . import INTEREST_SUGGESTIONS\nfrom .models import Calendar, Event, UserProfile\nfrom .forms import (UserProfileEditForm, newsletter_subscribe,\n                    get_subscription_details, subscribed_to_newsletter)\n\n\nDOCS_ACTIVITY_MAX_ITEMS = getattr(settings,\n        'DOCS_ACTIVITY_MAX_ITEMS', 15)\n\n\ndef events(request):\n    \"\"\"Developer Engagement Calendar\"\"\"\n    cal = Calendar.objects.get(shortname='devengage_events')\n    events = Event.objects.filter(calendar=cal)\n    upcoming_events = events.filter(done=False)\n    past_events = events.filter(done=True)\n    google_maps_api_key = getattr(settings, 'GOOGLE_MAPS_API_KEY',\n        \"ABQIAAAAijZqBZcz-rowoXZC1tt9iRT5rHVQFKUGOHoyfP\"\n        \"_4KyrflbHKcRTt9kQJVST5oKMRj8vKTQS2b7oNjQ\")\n\n    return render(request, 'devmo/calendar.html', {\n        'upcoming_events': upcoming_events,\n        'past_events': past_events,\n        'google_maps_api_key': google_maps_api_key\n    })\n\n\ndef profile_view(request, username):\n    profile = get_object_or_404(UserProfile, user__username=username)\n    user = profile.user\n\n    DEMOS_PAGE_SIZE = getattr(settings, 'DEMOS_PAGE_SIZE', 12)\n    sort_order = request.GET.get('sort', 'created')\n    try:\n        page_number = int(request.GET.get('page', 1))\n    except ValueError:\n        page_number = 1\n    show_hidden = (user == request.user) or user.is_superuser\n\n    demos = Submission.objects.all_sorted(sort_order).filter(\n                                                        creator=profile.user)\n    if not show_hidden:\n        demos = demos.exclude(hidden=True)\n\n    demos_paginator = Paginator(demos, DEMOS_PAGE_SIZE, True)\n    demos_page = demos_paginator.page(page_number)\n\n    wiki_activity, docs_feed_items = None, None\n    wiki_activity = profile.wiki_activity()\n\n    if request.user.is_anonymous():\n        show_manage_roles_button = False\n    else:\n        # TODO: This seems wasteful, just to decide whether to show the button\n        roles_by_team = Team.objects.get_team_roles_managed_by(request.user,\n                                                               user)\n        show_manage_roles_button = (len(roles_by_team) > 0)\n\n    template = 'devmo/profile.html'\n    if flag_is_active(request, 'redesign'):\n            template = 'devmo/profile_redesign.html'\n\n    return render(request, template, dict(\n        profile=profile, demos=demos, demos_paginator=demos_paginator,\n        demos_page=demos_page, docs_feed_items=docs_feed_items,\n        wiki_activity=wiki_activity,\n        show_manage_roles_button=show_manage_roles_button,\n    ))\n\n\n@login_required\ndef my_profile(request):\n    user = request.user\n    return HttpResponseRedirect(reverse(\n            'devmo.views.profile_view', args=(user.username,)))\n\n\ndef profile_edit(request, username):\n    \"\"\"View and edit user profile\"\"\"\n    profile = get_object_or_404(UserProfile, user__username=username)\n    context = {'profile': profile}\n    if not profile.allows_editing_by(request.user):\n        return HttpResponseForbidden()\n\n    # Map of form field names to tag namespaces\n    field_to_tag_ns = (\n        ('interests', 'profile:interest:'),\n        ('expertise', 'profile:expertise:')\n    )\n\n\n    if request.method != 'POST':\n        initial = dict(email=profile.user.email, beta=profile.beta_tester)\n\n        # Load up initial websites with either user data or required base URL\n        for name, meta in UserProfile.website_choices:\n            initial['websites_%s' % name] = profile.websites.get(name, '')\n\n        # Form fields to receive tags filtered by namespace.\n        for field, ns in field_to_tag_ns:\n            initial[field] = ', '.join(t.name.replace(ns, '')\n                                       for t in profile.tags.all_ns(ns))\n\n        subscription_details = get_subscription_details(profile.user.email)\n        if subscribed_to_newsletter(subscription_details):\n            initial['newsletter'] = True\n            initial['agree'] = True\n\n        # Finally, set up the forms.\n        form = UserProfileEditForm(request.locale,\n                                   instance=profile,\n                                   initial=initial)\n\n    else:\n        form = UserProfileEditForm(request.locale,\n                                   request.POST,\n                                   request.FILES,\n                                   instance=profile)\n        if form.is_valid():\n            profile_new = form.save(commit=False)\n\n            # Gather up all websites defined by the model, save them.\n            sites = dict()\n            for name, meta in UserProfile.website_choices:\n                field_name = 'websites_%s' % name\n                field_value = form.cleaned_data.get(field_name, '')\n                if field_value and field_value != meta['prefix']:\n                    sites[name] = field_value\n            profile_new.websites = sites\n\n            # Save the profile record now, since the rest of this deals with\n            # related resources...\n            profile_new.save()\n\n            # Update tags from form fields\n            for field, tag_ns in field_to_tag_ns:\n                tags = [t.lower() for t in parse_tags(\n                                            form.cleaned_data.get(field, ''))]\n                profile_new.tags.set_ns(tag_ns, *tags)\n\n            newsletter_subscribe(request, profile_new.user.email,\n                                 form.cleaned_data)\n            return HttpResponseRedirect(reverse(\n                    'devmo.views.profile_view', args=(profile.user.username,)))\n    context['form'] = form\n    context['INTEREST_SUGGESTIONS'] = INTEREST_SUGGESTIONS\n\n    return render(request, 'devmo/profile_edit.html', context)\n\n\n@login_required\ndef my_profile_edit(request):\n    user = request.user\n    return HttpResponseRedirect(reverse(\n            'devmo.views.profile_edit', args=(user.username,)))\n", "path": "apps/devmo/views.py"}], "after_files": [{"content": "from django.conf import settings\nfrom django.core.paginator import Paginator\nfrom django.shortcuts import get_object_or_404, render\nfrom django.http import (HttpResponseRedirect, HttpResponseForbidden)\n\nfrom devmo.urlresolvers import reverse\n\nimport constance.config\nimport basket\nfrom taggit.utils import parse_tags\nfrom waffle import flag_is_active\n\nfrom waffle import flag_is_active\n\nfrom access.decorators import login_required\nfrom demos.models import Submission\nfrom teamwork.models import Team\n\nfrom . import INTEREST_SUGGESTIONS\nfrom .models import Calendar, Event, UserProfile\nfrom .forms import (UserProfileEditForm, newsletter_subscribe,\n                    get_subscription_details, subscribed_to_newsletter)\n\n\nDOCS_ACTIVITY_MAX_ITEMS = getattr(settings,\n        'DOCS_ACTIVITY_MAX_ITEMS', 15)\n\n\ndef events(request):\n    \"\"\"Developer Engagement Calendar\"\"\"\n    cal = Calendar.objects.get(shortname='devengage_events')\n    events = Event.objects.filter(calendar=cal)\n    upcoming_events = events.filter(done=False)\n    past_events = events.filter(done=True)\n    google_maps_api_key = getattr(settings, 'GOOGLE_MAPS_API_KEY',\n        \"ABQIAAAAijZqBZcz-rowoXZC1tt9iRT5rHVQFKUGOHoyfP\"\n        \"_4KyrflbHKcRTt9kQJVST5oKMRj8vKTQS2b7oNjQ\")\n\n    return render(request, 'devmo/calendar.html', {\n        'upcoming_events': upcoming_events,\n        'past_events': past_events,\n        'google_maps_api_key': google_maps_api_key\n    })\n\n\ndef profile_view(request, username):\n    profile = get_object_or_404(UserProfile, user__username=username)\n    user = profile.user\n\n    DEMOS_PAGE_SIZE = getattr(settings, 'DEMOS_PAGE_SIZE', 12)\n    sort_order = request.GET.get('sort', 'created')\n    try:\n        page_number = int(request.GET.get('page', 1))\n    except ValueError:\n        page_number = 1\n    show_hidden = (user == request.user) or user.is_superuser\n\n    demos = Submission.objects.all_sorted(sort_order).filter(\n                                                        creator=profile.user)\n    if not show_hidden:\n        demos = demos.exclude(hidden=True)\n\n    demos_paginator = Paginator(demos, DEMOS_PAGE_SIZE, True)\n    demos_page = demos_paginator.page(page_number)\n\n    wiki_activity, docs_feed_items = None, None\n    wiki_activity = profile.wiki_activity()\n\n    if request.user.is_anonymous():\n        show_manage_roles_button = False\n    else:\n        # TODO: This seems wasteful, just to decide whether to show the button\n        roles_by_team = Team.objects.get_team_roles_managed_by(request.user,\n                                                               user)\n        show_manage_roles_button = (len(roles_by_team) > 0)\n\n    template = 'devmo/profile.html'\n\n    return render(request, template, dict(\n        profile=profile, demos=demos, demos_paginator=demos_paginator,\n        demos_page=demos_page, docs_feed_items=docs_feed_items,\n        wiki_activity=wiki_activity,\n        show_manage_roles_button=show_manage_roles_button,\n    ))\n\n\n@login_required\ndef my_profile(request):\n    user = request.user\n    return HttpResponseRedirect(reverse(\n            'devmo.views.profile_view', args=(user.username,)))\n\n\ndef profile_edit(request, username):\n    \"\"\"View and edit user profile\"\"\"\n    profile = get_object_or_404(UserProfile, user__username=username)\n    context = {'profile': profile}\n    if not profile.allows_editing_by(request.user):\n        return HttpResponseForbidden()\n\n    # Map of form field names to tag namespaces\n    field_to_tag_ns = (\n        ('interests', 'profile:interest:'),\n        ('expertise', 'profile:expertise:')\n    )\n\n\n    if request.method != 'POST':\n        initial = dict(email=profile.user.email, beta=profile.beta_tester)\n\n        # Load up initial websites with either user data or required base URL\n        for name, meta in UserProfile.website_choices:\n            initial['websites_%s' % name] = profile.websites.get(name, '')\n\n        # Form fields to receive tags filtered by namespace.\n        for field, ns in field_to_tag_ns:\n            initial[field] = ', '.join(t.name.replace(ns, '')\n                                       for t in profile.tags.all_ns(ns))\n\n        subscription_details = get_subscription_details(profile.user.email)\n        if subscribed_to_newsletter(subscription_details):\n            initial['newsletter'] = True\n            initial['agree'] = True\n\n        # Finally, set up the forms.\n        form = UserProfileEditForm(request.locale,\n                                   instance=profile,\n                                   initial=initial)\n\n    else:\n        form = UserProfileEditForm(request.locale,\n                                   request.POST,\n                                   request.FILES,\n                                   instance=profile)\n        if form.is_valid():\n            profile_new = form.save(commit=False)\n\n            # Gather up all websites defined by the model, save them.\n            sites = dict()\n            for name, meta in UserProfile.website_choices:\n                field_name = 'websites_%s' % name\n                field_value = form.cleaned_data.get(field_name, '')\n                if field_value and field_value != meta['prefix']:\n                    sites[name] = field_value\n            profile_new.websites = sites\n\n            # Save the profile record now, since the rest of this deals with\n            # related resources...\n            profile_new.save()\n\n            # Update tags from form fields\n            for field, tag_ns in field_to_tag_ns:\n                tags = [t.lower() for t in parse_tags(\n                                            form.cleaned_data.get(field, ''))]\n                profile_new.tags.set_ns(tag_ns, *tags)\n\n            newsletter_subscribe(request, profile_new.user.email,\n                                 form.cleaned_data)\n            return HttpResponseRedirect(reverse(\n                    'devmo.views.profile_view', args=(profile.user.username,)))\n    context['form'] = form\n    context['INTEREST_SUGGESTIONS'] = INTEREST_SUGGESTIONS\n\n    return render(request, 'devmo/profile_edit.html', context)\n\n\n@login_required\ndef my_profile_edit(request):\n    user = request.user\n    return HttpResponseRedirect(reverse(\n            'devmo.views.profile_edit', args=(user.username,)))\n", "path": "apps/devmo/views.py"}]}