prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Membership application uses email object instead of email-address
  Same as #2219
  
  https://sentry.io/organizations/dotkom/issues/890887549/?project=204971&referrer=github_plugin
  
  ```
  TypeError: object of type 'Email' has no len()
  (16 additional frame(s) were not displayed)
  ...
    File "guardian/decorators.py", line 126, in _wrapped_view
      return view_func(request, *args, **kwargs)
    File "apps/approval/dashboard/views.py", line 105, in approve_application
      app.save()
    File "apps/approval/signals.py", line 50, in notify_membership_applicant_handler
      send_approval_status_update(instance)
    File "apps/approval/tasks.py", line 45, in send_approval_status_update
      [approval.applicant.get_email()],
  
  TypeError: object of type 'Email' has no len()
  ```
  Membership application uses email object instead of email-address
  Same as #2219
  
  https://sentry.io/organizations/dotkom/issues/890887549/?project=204971&referrer=github_plugin
  
  ```
  TypeError: object of type 'Email' has no len()
  (16 additional frame(s) were not displayed)
  ...
    File "guardian/decorators.py", line 126, in _wrapped_view
      return view_func(request, *args, **kwargs)
    File "apps/approval/dashboard/views.py", line 105, in approve_application
      app.save()
    File "apps/approval/signals.py", line 50, in notify_membership_applicant_handler
      send_approval_status_update(instance)
    File "apps/approval/tasks.py", line 45, in send_approval_status_update
      [approval.applicant.get_email()],
  
  TypeError: object of type 'Email' has no len()
  ```
  
  --- 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/approval/signals.py`
  Content:
  ```
  1 from django.conf import settings
  2 from django.db.models.signals import post_save
  3 from django.dispatch import receiver
  4 
  5 from apps.approval.models import CommitteeApplication, MembershipApproval
  6 
  7 from .tasks import (send_approval_notification, send_approval_status_update,
  8                     send_committee_application_notification)
  9 
  10 
  11 @receiver(post_save, sender=MembershipApproval)
  12 def new_membership_approval_handler(sender, instance, created, **kwargs):
  13     """
  14 
  15     :param sender: The sending model.
  16     :type sender: MembershipApproval
  17     :param instance: The MembershipApproval instance
  18     :type instance: MembershipApproval
  19     :param created: True or False, whether this instance is new or not.
  20     :type created: bool
  21     :param kwargs: Other parameters.
  22     :type kwargs: dict
  23     :return: Nothing
  24     :rtype: None
  25     """
  26 
  27     if created and not instance.processed:
  28         if settings.APPROVAL_SETTINGS.get('SEND_APPROVER_NOTIFICATION_EMAIL', False):
  29             send_approval_notification(instance)
  30 
  31 
  32 @receiver(post_save, sender=MembershipApproval)
  33 def notify_membership_applicant_handler(sender, instance, created, **kwargs):
  34     """
  35 
  36        :param sender: The sending model.
  37        :type sender: Approval
  38        :param instance: The Approval instance
  39        :type instance: Approval
  40        :param approved: True or False, whether this instance is new or not.
  41        :type created: bool
  42        :param kwargs: Other parameters.
  43        :type kwargs: dict
  44        :return: Nothing
  45        :rtype: None
  46     """
  47 
  48     if not created and instance.processed and instance.applicant.get_email():
  49         if settings.APPROVAL_SETTINGS.get('SEND_APPLICANT_NOTIFICATION_EMAIL', False):
  50             send_approval_status_update(instance)
  51 
  52 
  53 @receiver(post_save, sender=CommitteeApplication)
  54 def notify_new_committee_application(sender, instance, created, **kwargs):
  55     if created:
  56         send_committee_application_notification(instance, [settings.EMAIL_OPPTAK], link_to_admin=True)
  57         if settings.APPROVAL_SETTINGS.get('SEND_COMMITTEEAPPLICATION_APPLICANT_EMAIL', False):
  58             send_committee_application_notification(instance, [instance.get_email()], link_to_admin=False)
  59
  ```
  
  Path: `apps/approval/tasks.py`
  Content:
  ```
  1 import logging
  2 
  3 from django.conf import settings
  4 from django.core.exceptions import ImproperlyConfigured
  5 from django.core.mail import EmailMessage, send_mail
  6 from django.template.loader import render_to_string
  7 from django.urls import reverse
  8 
  9 
  10 def send_approval_notification(approval):
  11     logger = logging.getLogger(__name__)
  12     d = {
  13         'approval': approval,
  14         'approval_url': settings.BASE_URL + reverse('approvals')
  15     }
  16 
  17     to_emails = [settings.EMAIL_HS]
  18     content = render_to_string('approval/email/approval_notification.txt', d)
  19 
  20     try:
  21         EmailMessage("[Medlemskapssøknad] %s" % approval.applicant.get_full_name(),
  22                      content, settings.DEFAULT_FROM_EMAIL, to_emails).send()
  23     except ImproperlyConfigured:
  24         logger.warn('Failed to send approval approver notification email for approval#{pk}.'.format(
  25             {'pk': approval.pk}))
  26 
  27 
  28 def send_approval_status_update(approval):
  29     logger = logging.getLogger(__name__)
  30 
  31     accepted = approval.approved
  32     message = "Ditt medlemskap i Online er "
  33     if accepted:
  34         message += "godkjent."
  35     else:
  36         message += "ikke godkjent."
  37         if len(approval.message) == 0:
  38             message += " Ta kontakt med Online for begrunnelse."
  39         else:
  40             message += approval.message
  41     try:
  42         EmailMessage("Soknad om medlemskap i Online er vurdert",
  43                      message,
  44                      settings.DEFAULT_FROM_EMAIL,
  45                      [approval.applicant.get_email()],
  46                      ).send()
  47     except ImproperlyConfigured:
  48         logger.warn('Failed to notify applicant about updated status on membership for approval#{pk}.'.format(
  49             {'pk': approval.pk}))
  50 
  51 
  52 def send_committee_application_notification(application, to_emails, link_to_admin=False):
  53     context = {
  54         'link_to_admin': link_to_admin,
  55         'absolute_url': settings.BASE_URL + application.get_absolute_url(),
  56         'applicant_name': application.get_name(),
  57     }
  58     message = render_to_string('approval/email/committeeapplication_notification.txt', context)
  59     send_mail('[opptak] Bekreftelse på komitesøknad', message, settings.DEFAULT_FROM_EMAIL, to_emails)
  60
  ```
  --- 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/approval/signals.py b/apps/approval/signals.py
  --- a/apps/approval/signals.py
  +++ b/apps/approval/signals.py
  @@ -55,4 +55,4 @@
       if created:
           send_committee_application_notification(instance, [settings.EMAIL_OPPTAK], link_to_admin=True)
           if settings.APPROVAL_SETTINGS.get('SEND_COMMITTEEAPPLICATION_APPLICANT_EMAIL', False):
  -            send_committee_application_notification(instance, [instance.get_email()], link_to_admin=False)
  +            send_committee_application_notification(instance, [instance.get_email().email], link_to_admin=False)
  diff --git a/apps/approval/tasks.py b/apps/approval/tasks.py
  --- a/apps/approval/tasks.py
  +++ b/apps/approval/tasks.py
  @@ -42,7 +42,7 @@
           EmailMessage("Soknad om medlemskap i Online er vurdert",
                        message,
                        settings.DEFAULT_FROM_EMAIL,
  -                     [approval.applicant.get_email()],
  +                     [approval.applicant.get_email().email],
                        ).send()
       except ImproperlyConfigured:
           logger.warn('Failed to notify applicant about updated status on membership for approval#{pk}.'.format(
  
verification_info: {"golden_diff": "diff --git a/apps/approval/signals.py b/apps/approval/signals.py\n--- a/apps/approval/signals.py\n+++ b/apps/approval/signals.py\n@@ -55,4 +55,4 @@\n     if created:\n         send_committee_application_notification(instance, [settings.EMAIL_OPPTAK], link_to_admin=True)\n         if settings.APPROVAL_SETTINGS.get('SEND_COMMITTEEAPPLICATION_APPLICANT_EMAIL', False):\n-            send_committee_application_notification(instance, [instance.get_email()], link_to_admin=False)\n+            send_committee_application_notification(instance, [instance.get_email().email], link_to_admin=False)\ndiff --git a/apps/approval/tasks.py b/apps/approval/tasks.py\n--- a/apps/approval/tasks.py\n+++ b/apps/approval/tasks.py\n@@ -42,7 +42,7 @@\n         EmailMessage(\"Soknad om medlemskap i Online er vurdert\",\n                      message,\n                      settings.DEFAULT_FROM_EMAIL,\n-                     [approval.applicant.get_email()],\n+                     [approval.applicant.get_email().email],\n                      ).send()\n     except ImproperlyConfigured:\n         logger.warn('Failed to notify applicant about updated status on membership for approval#{pk}.'.format(\n", "issue": "Membership application uses email object instead of email-address\nSame as #2219\n\nhttps://sentry.io/organizations/dotkom/issues/890887549/?project=204971&referrer=github_plugin\n\n```\nTypeError: object of type 'Email' has no len()\n(16 additional frame(s) were not displayed)\n...\n  File \"guardian/decorators.py\", line 126, in _wrapped_view\n    return view_func(request, *args, **kwargs)\n  File \"apps/approval/dashboard/views.py\", line 105, in approve_application\n    app.save()\n  File \"apps/approval/signals.py\", line 50, in notify_membership_applicant_handler\n    send_approval_status_update(instance)\n  File \"apps/approval/tasks.py\", line 45, in send_approval_status_update\n    [approval.applicant.get_email()],\n\nTypeError: object of type 'Email' has no len()\n```\nMembership application uses email object instead of email-address\nSame as #2219\n\nhttps://sentry.io/organizations/dotkom/issues/890887549/?project=204971&referrer=github_plugin\n\n```\nTypeError: object of type 'Email' has no len()\n(16 additional frame(s) were not displayed)\n...\n  File \"guardian/decorators.py\", line 126, in _wrapped_view\n    return view_func(request, *args, **kwargs)\n  File \"apps/approval/dashboard/views.py\", line 105, in approve_application\n    app.save()\n  File \"apps/approval/signals.py\", line 50, in notify_membership_applicant_handler\n    send_approval_status_update(instance)\n  File \"apps/approval/tasks.py\", line 45, in send_approval_status_update\n    [approval.applicant.get_email()],\n\nTypeError: object of type 'Email' has no len()\n```\n", "before_files": [{"content": "from django.conf import settings\nfrom django.db.models.signals import post_save\nfrom django.dispatch import receiver\n\nfrom apps.approval.models import CommitteeApplication, MembershipApproval\n\nfrom .tasks import (send_approval_notification, send_approval_status_update,\n                    send_committee_application_notification)\n\n\n@receiver(post_save, sender=MembershipApproval)\ndef new_membership_approval_handler(sender, instance, created, **kwargs):\n    \"\"\"\n\n    :param sender: The sending model.\n    :type sender: MembershipApproval\n    :param instance: The MembershipApproval instance\n    :type instance: MembershipApproval\n    :param created: True or False, whether this instance is new or not.\n    :type created: bool\n    :param kwargs: Other parameters.\n    :type kwargs: dict\n    :return: Nothing\n    :rtype: None\n    \"\"\"\n\n    if created and not instance.processed:\n        if settings.APPROVAL_SETTINGS.get('SEND_APPROVER_NOTIFICATION_EMAIL', False):\n            send_approval_notification(instance)\n\n\n@receiver(post_save, sender=MembershipApproval)\ndef notify_membership_applicant_handler(sender, instance, created, **kwargs):\n    \"\"\"\n\n       :param sender: The sending model.\n       :type sender: Approval\n       :param instance: The Approval instance\n       :type instance: Approval\n       :param approved: True or False, whether this instance is new or not.\n       :type created: bool\n       :param kwargs: Other parameters.\n       :type kwargs: dict\n       :return: Nothing\n       :rtype: None\n    \"\"\"\n\n    if not created and instance.processed and instance.applicant.get_email():\n        if settings.APPROVAL_SETTINGS.get('SEND_APPLICANT_NOTIFICATION_EMAIL', False):\n            send_approval_status_update(instance)\n\n\n@receiver(post_save, sender=CommitteeApplication)\ndef notify_new_committee_application(sender, instance, created, **kwargs):\n    if created:\n        send_committee_application_notification(instance, [settings.EMAIL_OPPTAK], link_to_admin=True)\n        if settings.APPROVAL_SETTINGS.get('SEND_COMMITTEEAPPLICATION_APPLICANT_EMAIL', False):\n            send_committee_application_notification(instance, [instance.get_email()], link_to_admin=False)\n", "path": "apps/approval/signals.py"}, {"content": "import logging\n\nfrom django.conf import settings\nfrom django.core.exceptions import ImproperlyConfigured\nfrom django.core.mail import EmailMessage, send_mail\nfrom django.template.loader import render_to_string\nfrom django.urls import reverse\n\n\ndef send_approval_notification(approval):\n    logger = logging.getLogger(__name__)\n    d = {\n        'approval': approval,\n        'approval_url': settings.BASE_URL + reverse('approvals')\n    }\n\n    to_emails = [settings.EMAIL_HS]\n    content = render_to_string('approval/email/approval_notification.txt', d)\n\n    try:\n        EmailMessage(\"[Medlemskapss\u00f8knad] %s\" % approval.applicant.get_full_name(),\n                     content, settings.DEFAULT_FROM_EMAIL, to_emails).send()\n    except ImproperlyConfigured:\n        logger.warn('Failed to send approval approver notification email for approval#{pk}.'.format(\n            {'pk': approval.pk}))\n\n\ndef send_approval_status_update(approval):\n    logger = logging.getLogger(__name__)\n\n    accepted = approval.approved\n    message = \"Ditt medlemskap i Online er \"\n    if accepted:\n        message += \"godkjent.\"\n    else:\n        message += \"ikke godkjent.\"\n        if len(approval.message) == 0:\n            message += \" Ta kontakt med Online for begrunnelse.\"\n        else:\n            message += approval.message\n    try:\n        EmailMessage(\"Soknad om medlemskap i Online er vurdert\",\n                     message,\n                     settings.DEFAULT_FROM_EMAIL,\n                     [approval.applicant.get_email()],\n                     ).send()\n    except ImproperlyConfigured:\n        logger.warn('Failed to notify applicant about updated status on membership for approval#{pk}.'.format(\n            {'pk': approval.pk}))\n\n\ndef send_committee_application_notification(application, to_emails, link_to_admin=False):\n    context = {\n        'link_to_admin': link_to_admin,\n        'absolute_url': settings.BASE_URL + application.get_absolute_url(),\n        'applicant_name': application.get_name(),\n    }\n    message = render_to_string('approval/email/committeeapplication_notification.txt', context)\n    send_mail('[opptak] Bekreftelse p\u00e5 komites\u00f8knad', message, settings.DEFAULT_FROM_EMAIL, to_emails)\n", "path": "apps/approval/tasks.py"}], "after_files": [{"content": "from django.conf import settings\nfrom django.db.models.signals import post_save\nfrom django.dispatch import receiver\n\nfrom apps.approval.models import CommitteeApplication, MembershipApproval\n\nfrom .tasks import (send_approval_notification, send_approval_status_update,\n                    send_committee_application_notification)\n\n\n@receiver(post_save, sender=MembershipApproval)\ndef new_membership_approval_handler(sender, instance, created, **kwargs):\n    \"\"\"\n\n    :param sender: The sending model.\n    :type sender: MembershipApproval\n    :param instance: The MembershipApproval instance\n    :type instance: MembershipApproval\n    :param created: True or False, whether this instance is new or not.\n    :type created: bool\n    :param kwargs: Other parameters.\n    :type kwargs: dict\n    :return: Nothing\n    :rtype: None\n    \"\"\"\n\n    if created and not instance.processed:\n        if settings.APPROVAL_SETTINGS.get('SEND_APPROVER_NOTIFICATION_EMAIL', False):\n            send_approval_notification(instance)\n\n\n@receiver(post_save, sender=MembershipApproval)\ndef notify_membership_applicant_handler(sender, instance, created, **kwargs):\n    \"\"\"\n\n       :param sender: The sending model.\n       :type sender: Approval\n       :param instance: The Approval instance\n       :type instance: Approval\n       :param approved: True or False, whether this instance is new or not.\n       :type created: bool\n       :param kwargs: Other parameters.\n       :type kwargs: dict\n       :return: Nothing\n       :rtype: None\n    \"\"\"\n\n    if not created and instance.processed and instance.applicant.get_email():\n        if settings.APPROVAL_SETTINGS.get('SEND_APPLICANT_NOTIFICATION_EMAIL', False):\n            send_approval_status_update(instance)\n\n\n@receiver(post_save, sender=CommitteeApplication)\ndef notify_new_committee_application(sender, instance, created, **kwargs):\n    if created:\n        send_committee_application_notification(instance, [settings.EMAIL_OPPTAK], link_to_admin=True)\n        if settings.APPROVAL_SETTINGS.get('SEND_COMMITTEEAPPLICATION_APPLICANT_EMAIL', False):\n            send_committee_application_notification(instance, [instance.get_email().email], link_to_admin=False)\n", "path": "apps/approval/signals.py"}, {"content": "import logging\n\nfrom django.conf import settings\nfrom django.core.exceptions import ImproperlyConfigured\nfrom django.core.mail import EmailMessage, send_mail\nfrom django.template.loader import render_to_string\nfrom django.urls import reverse\n\n\ndef send_approval_notification(approval):\n    logger = logging.getLogger(__name__)\n    d = {\n        'approval': approval,\n        'approval_url': settings.BASE_URL + reverse('approvals')\n    }\n\n    to_emails = [settings.EMAIL_HS]\n    content = render_to_string('approval/email/approval_notification.txt', d)\n\n    try:\n        EmailMessage(\"[Medlemskapss\u00f8knad] %s\" % approval.applicant.get_full_name(),\n                     content, settings.DEFAULT_FROM_EMAIL, to_emails).send()\n    except ImproperlyConfigured:\n        logger.warn('Failed to send approval approver notification email for approval#{pk}.'.format(\n            {'pk': approval.pk}))\n\n\ndef send_approval_status_update(approval):\n    logger = logging.getLogger(__name__)\n\n    accepted = approval.approved\n    message = \"Ditt medlemskap i Online er \"\n    if accepted:\n        message += \"godkjent.\"\n    else:\n        message += \"ikke godkjent.\"\n        if len(approval.message) == 0:\n            message += \" Ta kontakt med Online for begrunnelse.\"\n        else:\n            message += approval.message\n    try:\n        EmailMessage(\"Soknad om medlemskap i Online er vurdert\",\n                     message,\n                     settings.DEFAULT_FROM_EMAIL,\n                     [approval.applicant.get_email().email],\n                     ).send()\n    except ImproperlyConfigured:\n        logger.warn('Failed to notify applicant about updated status on membership for approval#{pk}.'.format(\n            {'pk': approval.pk}))\n\n\ndef send_committee_application_notification(application, to_emails, link_to_admin=False):\n    context = {\n        'link_to_admin': link_to_admin,\n        'absolute_url': settings.BASE_URL + application.get_absolute_url(),\n        'applicant_name': application.get_name(),\n    }\n    message = render_to_string('approval/email/committeeapplication_notification.txt', context)\n    send_mail('[opptak] Bekreftelse p\u00e5 komites\u00f8knad', message, settings.DEFAULT_FROM_EMAIL, to_emails)\n", "path": "apps/approval/tasks.py"}]}