def get_map_title(self):
     region = self.get_region()
     d = {
         'map_url': reverse('maps:global', kwargs={'region' : region.slug}),
         'tag_url': reverse('tags:list', kwargs={'region': region.slug}),
         'page_tag_url': reverse('tags:tagged',
             kwargs={'slug': self.tag.slug, 'region': region.slug}),
         'tag_name': escape(self.tag.name)
     }
     return (
         _('<a href="%(map_url)s">Map</a> for tag "<a href="%(page_tag_url)s">%(tag_name)s</a>"') % d
     )
 def get_success_url(self):
     # Redirect back to the map.
     return reverse('maps:show',
                    kwargs={
                        'region': self.get_region().slug,
                        'slug': self.kwargs.get('slug')
                    })
 def success_msg(self):
     return (_(
         'Map saved! You should probably go <a href="%s">edit the page that was created</a>, too.'
     ) % reverse('pages:edit',
                 kwargs={
                     'region': self.get_region().slug,
                     'slug': self.object.page.name
                 }))
 def get_map_title(self):
     d = {
         'page_tag_url':
         reverse('tags:global-tagged', kwargs={'slug': self.tag_slug}),
         'tag_name':
         escape(self.tag_slug)
     }
     return (
         _('Map for tag "<a href="%(page_tag_url)s">%(tag_name)s</a>"') % d)
 def get_map_title(self):
     d = {
         'page_tag_url': reverse('tags:global-tagged',
             kwargs={'slug': self.tag_slug}),
         'tag_name': escape(self.tag_slug)
     }
     return (
         _('Map for tag "<a href="%(page_tag_url)s">%(tag_name)s</a>"') % d
     )
 def get_map_title(self):
     region = self.get_region()
     d = {
         'map_url':
         reverse('maps:global', kwargs={'region': region.slug}),
         'tag_url':
         reverse('tags:list', kwargs={'region': region.slug}),
         'page_tag_url':
         reverse('tags:tagged',
                 kwargs={
                     'slug': self.tag.slug,
                     'region': region.slug
                 }),
         'tag_name':
         escape(self.tag.name)
     }
     return (_(
         '<a href="%(map_url)s">Map</a> for tag "<a href="%(page_tag_url)s">%(tag_name)s</a>"'
     ) % d)
def notify_page_edited(user, page, notification_type=None):
    if notification_type == OWN_USER_PAGE:
        template_name = 'stars/own_userpage_edited'
    else:
        template_name = 'stars/page_edited'

    page_hist = page.versions.most_recent()

    diff_url = reverse('pages:compare-dates',
                       kwargs={
                           'slug': page.pretty_slug,
                           'region': page.region.slug,
                           'date1': page_hist.version_info.date,
                       })
    # In plaintext email, we want the period escaped
    # because some clients don't include it in the URL.
    diff_url_plaintext = diff_url.replace('.', '%2E')

    if page_hist.version_info.user:
        username = page_hist.version_info.user.username
        user_url = page_hist.version_info.user.get_absolute_url()
        user_with_link = '<a href="%s%s">%s</a>' % (get_base_uri(), user_url,
                                                    username)
    else:
        username = page_hist.version_info.user_ip
        user_with_link = username

    comment_text = page_hist.version_info.comment
    if comment_text:
        comment_text = ' ' + _('Their edit comment was "%s".' % comment_text)

    send_templated_mail(
        template_name=template_name,
        from_email=settings.DEFAULT_FROM_EMAIL,
        recipient_list=[user.email],
        headers=get_headers(page),
        context={
            'page': page,
            'pagename': page.name,
            'page_url': page.get_absolute_url(),
            'comment_text': comment_text,
            'user_with_link': user_with_link,
            'region_name': page.region.full_name,
            'region_url': page.region.get_absolute_url(),
            'diff_url': diff_url,
            'username': username,
            'diff_url_plaintext': diff_url_plaintext,
            'page_hist': page_hist,
            'base_uri': get_base_uri(),
        },
    )
def notify_page_edited(user, page, notification_type=None):
    if notification_type == OWN_USER_PAGE:
        template_name = "stars/own_userpage_edited"
    else:
        template_name = "stars/page_edited"

    page_hist = page.versions.most_recent()

    diff_url = reverse(
        "pages:compare-dates",
        kwargs={"slug": page.pretty_slug, "region": page.region.slug, "date1": page_hist.version_info.date},
    )
    # In plaintext email, we want the period escaped
    # because some clients don't include it in the URL.
    diff_url_plaintext = diff_url.replace(".", "%2E")

    if page_hist.version_info.user:
        username = page_hist.version_info.user.username
        user_url = page_hist.version_info.user.get_absolute_url()
        user_with_link = '<a href="%s%s">%s</a>' % (get_base_uri(), user_url, username)
    else:
        username = page_hist.version_info.user_ip
        user_with_link = username

    comment_text = page_hist.version_info.comment
    if comment_text:
        comment_text = " " + _('Their edit comment was "%s".' % comment_text)

    send_templated_mail(
        template_name=template_name,
        from_email=settings.DEFAULT_FROM_EMAIL,
        recipient_list=[user.email],
        headers=get_headers(page),
        context={
            "page": page,
            "pagename": page.name,
            "page_url": page.get_absolute_url(),
            "comment_text": comment_text,
            "user_with_link": user_with_link,
            "region_name": page.region.full_name,
            "region_url": page.region.get_absolute_url(),
            "diff_url": diff_url,
            "username": username,
            "diff_url_plaintext": diff_url_plaintext,
            "page_hist": page_hist,
            "base_uri": get_base_uri(),
        },
    )
def notify_page_deleted(user, page, notification_type=None):
    if notification_type == OWN_USER_PAGE:
        template_name = 'stars/own_userpage_deleted'
    else:
        template_name = 'stars/page_deleted'

    page_hist = page.versions.most_recent()

    if page_hist.version_info.user:
        username = page_hist.version_info.user.username
        user_url = page_hist.version_info.user.get_absolute_url()
        user_with_link = '<a href="%s">%s</a>' % (user_url, username)
    else:
        username = page_hist.version_info.user_ip
        user_with_link = username

    comment_text = page_hist.version_info.comment
    if comment_text:
        comment_text = ' ' + _('Their edit comment was "%s".' % comment_text)

    history_url = reverse('pages:history',
                          kwargs={
                              'slug': page.pretty_slug,
                              'region': page.region.slug,
                          })

    send_templated_mail(
        template_name=template_name,
        from_email=settings.DEFAULT_FROM_EMAIL,
        recipient_list=[user.email],
        headers=get_headers(page),
        context={
            'page': page,
            'pagename': page.name,
            'page_url': page.get_absolute_url(),
            'comment_text': comment_text,
            'user_with_link': user_with_link,
            'region_name': page.region.full_name,
            'region_url': page.region.get_absolute_url(),
            'history_url': history_url,
            'username': username,
            'page_hist': page_hist,
            'base_uri': get_base_uri(),
        },
    )
def notify_page_deleted(user, page, notification_type=None):
    if notification_type == OWN_USER_PAGE:
        template_name = "stars/own_userpage_deleted"
    else:
        template_name = "stars/page_deleted"

    page_hist = page.versions.most_recent()

    if page_hist.version_info.user:
        username = page_hist.version_info.user.username
        user_url = page_hist.version_info.user.get_absolute_url()
        user_with_link = '<a href="%s">%s</a>' % (user_url, username)
    else:
        username = page_hist.version_info.user_ip
        user_with_link = username

    comment_text = page_hist.version_info.comment
    if comment_text:
        comment_text = " " + _('Their edit comment was "%s".' % comment_text)

    history_url = reverse("pages:history", kwargs={"slug": page.pretty_slug, "region": page.region.slug})

    send_templated_mail(
        template_name=template_name,
        from_email=settings.DEFAULT_FROM_EMAIL,
        recipient_list=[user.email],
        headers=get_headers(page),
        context={
            "page": page,
            "pagename": page.name,
            "page_url": page.get_absolute_url(),
            "comment_text": comment_text,
            "user_with_link": user_with_link,
            "region_name": page.region.full_name,
            "region_url": page.region.get_absolute_url(),
            "history_url": history_url,
            "username": username,
            "page_hist": page_hist,
            "base_uri": get_base_uri(),
        },
    )
 def get_success_url(self):
     return reverse('maps:show',
                    kwargs={
                        'region': self.object.region.slug,
                        'slug': self.object.page.pretty_slug
                    })
 def get_success_url(self):
     # Redirect back to the map.
     return reverse('maps:show',
         kwargs={'region': self.get_region().slug, 'slug': self.kwargs.get('slug')})
 def success_msg(self):
     return (
         _('Map saved! You should probably go <a href="%s">edit the page that was created</a>, too.') %
         reverse('pages:edit', kwargs={'region': self.get_region().slug, 'slug': self.object.page.name})
     )
 def get_success_url(self):
     return reverse('maps:show',
         kwargs={'region': self.object.region.slug, 'slug': self.object.page.pretty_slug})