# Path: agora_site/agora_core/tasks/agora.py
# @task(ignore_result=True)
# def send_request_membership_mails(agora_id, user_id, is_secure, site_id, remote_addr):
#     user = User.objects.get(pk=user_id)
#     agora = Agora.objects.get(pk=agora_id)
# 
#     # Mail to the admins
#     context = get_base_email_context_task(is_secure, site_id)
#     context.update(dict(
#         agora=agora,
#         other_user=user,
#         notification_text=_('%(username)s has requested membership at '
#             '%(agora)s. Please review this pending request') % dict(
#                 username=user.username,
#                 agora=agora.get_full_name()
#             ),
#         extra_urls=(
#             (_('List of membership requests'),
#             reverse('agora-members',
#                 kwargs=dict(
#                     username=agora.creator,
#                     agoraname=agora.name,
#                     members_filter="membership_requests"
#                 ))
#             ),
#         ),
#     ))
#     for admin in agora.admins.all():
#         translation.activate(admin.get_profile().lang_code)
# 
#         if not admin.get_profile().has_perms('receive_email_updates'):
#             continue
# 
#         context['to'] = admin
# 
#         email = EmailMultiAlternatives(
#             subject=_('%(site)s - New membership request at %(agora)s') %\
#                 dict(
#                     site=Site.objects.get_current().domain,
#                     agora=agora.get_full_name()
#                 ),
#             body=render_to_string('agora_core/emails/agora_notification.txt',
#                 context),
#             to=[admin.email])
# 
#         email.attach_alternative(
#             render_to_string('agora_core/emails/agora_notification.html',
#                 context), "text/html")
#         email.send()
# 
#     translation.deactivate()


from common import (HTTP_OK,
                    HTTP_CREATED,
                    HTTP_ACCEPTED,
                    HTTP_NO_CONTENT,
                    HTTP_BAD_REQUEST,
                    HTTP_FORBIDDEN,
                    HTTP_NOT_FOUND,
                    HTTP_METHOD_NOT_ALLOWED)
from common import RootTestCase
from django.contrib.sites.models import Site
from django.contrib.markup.templatetags.markup import textile
from agora_site.agora_core.tasks.agora import send_request_membership_mails
        'description': "foo bar foo bar",
        'questions': [
            {
                'a': 'ballot/question',
                'tally_type': 'ONE_CHOICE',
                'max': 1,
                'min': 0,
                'question': 'Do you prefer foo or bar?',
                'randomize_answer_order': True,
                'answers': [
                    {
                        'a': 'ballot/answer',
                        'url': '',
                        'details': '',
                        'value': 'fo\"o'
                    },
                    {
                        'a': 'ballot/answer',
                        'url': '',
                        'details': '',
                        'value': 'bar'
                    }
                ]
            }
        ],
        'is_vote_secret': True,
        'from_date': '',
        'to_date': ''
    }


# Path: agora_site/agora_core/tasks/agora.py
# @task(ignore_result=True)
# def send_request_membership_mails(agora_id, user_id, is_secure, site_id, remote_addr):
#     user = User.objects.get(pk=user_id)
#     agora = Agora.objects.get(pk=agora_id)
# 
#     # Mail to the admins
#     context = get_base_email_context_task(is_secure, site_id)
#     context.update(dict(
#         agora=agora,
#         other_user=user,
#         notification_text=_('%(username)s has requested membership at '
#             '%(agora)s. Please review this pending request') % dict(
#                 username=user.username,
#                 agora=agora.get_full_name()
#             ),
#         extra_urls=(
#             (_('List of membership requests'),
#             reverse('agora-members',
#                 kwargs=dict(
#                     username=agora.creator,
#                     agoraname=agora.name,
#                     members_filter="membership_requests"
#                 ))
#             ),
#         ),
#     ))
#     for admin in agora.admins.all():
#         translation.activate(admin.get_profile().lang_code)
# 
#         if not admin.get_profile().has_perms('receive_email_updates'):
#             continue
# 
#         context['to'] = admin
# 
#         email = EmailMultiAlternatives(
#             subject=_('%(site)s - New membership request at %(agora)s') %\
#                 dict(
#                     site=Site.objects.get_current().domain,
#                     agora=agora.get_full_name()
#                 ),
#             body=render_to_string('agora_core/emails/agora_notification.txt',
#                 context),
#             to=[admin.email])
# 
#         email.attach_alternative(
#             render_to_string('agora_core/emails/agora_notification.html',
#                 context), "text/html")
#         email.send()
# 
#     translation.deactivate()


# Path: agora_site/agora_core/tests/agora.py
from common import (HTTP_OK,
                    HTTP_CREATED,
                    HTTP_ACCEPTED,
                    HTTP_NO_CONTENT,
                    HTTP_BAD_REQUEST,
                    HTTP_FORBIDDEN,
                    HTTP_NOT_FOUND,
                    HTTP_METHOD_NOT_ALLOWED)
from common import RootTestCase
from django.contrib.sites.models import Site
from django.contrib.markup.templatetags.markup import textile
from agora_site.agora_core.tasks.agora import send_request_membership_mails

        'description': "foo bar foo bar",
        'questions': [
            {
                'a': 'ballot/question',
                'tally_type': 'ONE_CHOICE',
                'max': 1,
                'min': 0,
                'question': 'Do you prefer foo or bar?',
                'randomize_answer_order': True,
                'answers': [
                    {
                        'a': 'ballot/answer',
                        'url': '',
                        'details': '',
                        'value': 'fo\"o'
                    },
                    {
                        'a': 'ballot/answer',
                        'url': '',
                        'details': '',
                        'value': 'bar'
                    }
                ]
            }
        ],
        'is_vote_secret': True,
        'from_date': '',
        'to_date': ''
    }


    def test_agora(self):