コード例 #1
0
ファイル: utils.py プロジェクト: Stephanie1125/personfinder
def send_confirmation_email_to_record_author(
    handler, person, action, confirm_url, record_id):
    """Send the author an email to confirm enabling/disabling notes
    of a record."""
    if not person.author_email:
        return handler.error(
            400, _('No author email for record %(id)s.') % {'id' : record_id})

    # i18n: Subject line of an e-mail message confirming the author
    # wants to disable notes for this record
    if action == 'enable':
        subject = _('[Person Finder] Enable notes on "%(full_name)s"?'
                ) % {'full_name': person.primary_full_name}
    elif action == 'disable':
        subject = _('[Person Finder] Disable notes on "%(full_name)s"?'
                ) % {'full_name': person.primary_full_name}
    else:
        raise ValueError('Unknown action: %s' % action)

    # send e-mail to record author confirming the lock of this record.
    template_name = '%s_notes_email.txt' % action
    handler.send_mail(
        subject=subject,
        to=person.author_email,
        body=handler.render_to_string(
            template_name,
            author_name=person.author_name,
            full_name=person.primary_full_name,
            site_url=handler.get_url('/'),
            confirm_url=confirm_url
        )
    )
コード例 #2
0
ファイル: utils.py プロジェクト: priestd09/personfinder
def send_confirmation_email_to_record_author(handler, person, action,
                                             confirm_url, record_id):
    """Send the author an email to confirm enabling/disabling notes
    of a record."""
    if not person.author_email:
        return handler.error(
            400,
            _('No author email for record %(id)s.') % {'id': record_id})

    # i18n: Subject line of an e-mail message confirming the author
    # wants to disable notes for this record
    if action == 'enable':
        subject = _('[Person Finder] Enable notes on "%(full_name)s"?') % {
            'full_name': person.primary_full_name
        }
    elif action == 'disable':
        subject = _('[Person Finder] Disable notes on "%(full_name)s"?') % {
            'full_name': person.primary_full_name
        }
    else:
        raise ValueError('Unknown action: %s' % action)

    # send e-mail to record author confirming the lock of this record.
    template_name = '%s_notes_email.txt' % action
    handler.send_mail(subject=subject,
                      to=person.author_email,
                      body=handler.render_to_string(
                          template_name,
                          author_name=person.author_name,
                          full_name=person.primary_full_name,
                          site_url=handler.get_url('/'),
                          confirm_url=confirm_url))
コード例 #3
0
    def get_captcha_html(self, error_code=None, use_ssl=False):
        """Generates the necessary HTML to display a CAPTCHA validation box."""

        # We use the 'custom_translations' parameter for UI messages, whereas
        # the 'lang' parameter controls the language of the challenge itself.
        # reCAPTCHA falls back to 'en' if this parameter isn't recognized.
        lang = self.env.lang.split('-')[0]

        return captcha.get_display_html(
            public_key=config.get('captcha_public_key'),
            use_ssl=use_ssl,
            error=error_code,
            lang=lang,
            custom_translations={
                # reCAPTCHA doesn't support all languages, so we treat its
                # messages as part of this app's usual translation workflow
                'instructions_visual': _('Type the two words:'),
                'instructions_audio': _('Type what you hear:'),
                'play_again': _('Play the sound again'),
                'cant_hear_this': _('Download the sound as MP3'),
                'visual_challenge': _('Get a visual challenge'),
                'audio_challenge': _('Get an audio challenge'),
                'refresh_btn': _('Get a new challenge'),
                'help_btn': _('Help'),
                'incorrect_try_again': _('Incorrect.  Try again.')
            })
コード例 #4
0
ファイル: utils.py プロジェクト: Jessie-Newman/personfinder
    def get_captcha_html(self, error_code=None, use_ssl=False):
        """Generates the necessary HTML to display a CAPTCHA validation box."""

        # We use the 'custom_translations' parameter for UI messages, whereas
        # the 'lang' parameter controls the language of the challenge itself.
        # reCAPTCHA falls back to 'en' if this parameter isn't recognized.
        lang = self.env.lang.split('-')[0]

        return captcha.get_display_html(
            public_key=config.get('captcha_public_key'),
            use_ssl=use_ssl, error=error_code, lang=lang,
            custom_translations={
                # reCAPTCHA doesn't support all languages, so we treat its
                # messages as part of this app's usual translation workflow
                'instructions_visual': _('Type the two words:'),
                'instructions_audio': _('Type what you hear:'),
                'play_again': _('Play the sound again'),
                'cant_hear_this': _('Download the sound as MP3'),
                'visual_challenge': _('Get a visual challenge'),
                'audio_challenge': _('Get an audio challenge'),
                'refresh_btn': _('Get a new challenge'),
                'help_btn': _('Help'),
                'incorrect_try_again': _('Incorrect.  Try again.')
            }
        )
コード例 #5
0
ファイル: utils.py プロジェクト: Stephanie1125/personfinder
 def handle_exception(self, exception, debug_mode):
     logging.error(traceback.format_exc())
     self.error(500, _(
         'There was an error processing your request.  Sorry for the '
         'inconvenience.  Our administrators will investigate the source '
         'of the problem, but please check that the format of your '
         'request is correct.'))
コード例 #6
0
ファイル: tos.py プロジェクト: tengle1080/personfinder
    def get(self):
        article_html = None

        # Fetches the ToS page and embed it in the page. We do this instead of
        # just redirecting to the ToS page because we need to host the content
        # in our domain in zero-rating mode. See "Zero-rating" section of the
        # admin page (app/resources/admin.html.template) for details of
        # zero-rating mode.
        try:
            if self.config.tos_url:
                url = self.config.tos_url % {'lang': self.env.lang}
                res = urllib2.urlopen(url)
                tos_html = res.read()
                doc = lxml.etree.HTML(tos_html)
                articles = doc.xpath("//div[@class='maia-article']")
                if articles:
                    article = articles[0]
                    for anchor in article.xpath('.//a'):
                        href = anchor.attrib.get('href')
                        if href and anchor.text:
                            # Converts relative URLs to absolute URLs.
                            anchor.attrib['href'] = urlparse.urljoin(
                                res.geturl(), href)
                            anchor.text += ' (%s)' % _(
                                'external site; '
                                'normal connection fee may apply')
                    article_html = lxml.etree.tostring(article, method='html')

        except:
            logging.error(
                'Error during fetching/parsing the ToS page from %s\n%s', url,
                traceback.format_exc())

        self.render('tos.html', article_html=article_html, tos_url=url)
コード例 #7
0
ファイル: utils.py プロジェクト: tanmoydeb07/personfinder
 def handle_exception(self, exception, debug_mode):
     logging.error(traceback.format_exc())
     self.error(500, _(
         'There was an error processing your request.  Sorry for the '
         'inconvenience.  Our administrators will investigate the source '
         'of the problem, but please check that the format of your '
         'request is correct.'))
コード例 #8
0
ファイル: tos.py プロジェクト: Reagankm/personfinder
    def get(self):
        article_html = None

        # Fetches the ToS page and embed it in the page. We do this instead of
        # just redirecting to the ToS page because we need to host the content
        # in our domain in zero-rating mode. See "Zero-rating" section of the
        # admin page (app/resources/admin.html.template) for details of
        # zero-rating mode.
        try:
            if self.config.tos_url:
                url = self.config.tos_url % {'lang': self.env.lang}
                res = urllib2.urlopen(url)
                tos_html = res.read()
                doc = lxml.etree.HTML(tos_html)
                articles = doc.xpath("//div[@class='maia-article']")
                if articles:
                    article = articles[0]
                    for anchor in article.xpath('.//a'):
                        href = anchor.attrib.get('href')
                        if href and anchor.text:
                            # Converts relative URLs to absolute URLs.
                            anchor.attrib['href'] = urlparse.urljoin(
                                    res.geturl(), href)
                            anchor.text += ' (%s)' % _(
                                'external site; '
                                'normal connection fee may apply')
                    article_html = lxml.etree.tostring(article, method='html')

        except:
            logging.error(
                'Error during fetching/parsing the ToS page from %s\n%s',
                url,
                traceback.format_exc())

        self.render(
                'tos.html',
                article_html=article_html,
                tos_url=url)
コード例 #9
0
ファイル: const.py プロジェクト: tengle1080/personfinder
LANGUAGES_BIDI = django_setup.LANGUAGES_BIDI + ['ps', 'prs']

# Mapping from language codes to the names of LayoutCode constants.  See:
# http://code.google.com/apis/ajaxlanguage/documentation/referenceKeyboard.html
VIRTUAL_KEYBOARD_LAYOUTS = {
    'ur': 'URDU'
}

# Charset string for UTF-8 used in env.charset.
CHARSET_UTF8 = 'utf-8'

# UI text for the sex field when displaying a person.
PERSON_SEX_TEXT = {
    # This dictionary must have an entry for '' that gives the default text.
    '': '',
    'female': _('female'),
    'male': _('male'),
    'other': _('other')
}

# UI text for the expiry field when displayinga person.
PERSON_EXPIRY_TEXT = {
    '30': _('About 1 month (30 days) from now'),
    '60': _('About 2 months (60 days) from now'),
    '90': _('About 3 months (90 days) from now'),
    '180': _('About 6 months (180 days) from now'),
    '360': _('About 1 year (360 days) from now'),
}

# UI text for the status field when posting or displaying a note.
NOTE_STATUS_TEXT = {