Ejemplo n.º 1
0
 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
     )
Ejemplo n.º 2
0
 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')
                    })
Ejemplo n.º 3
0
 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
                 }))
Ejemplo n.º 4
0
 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)
Ejemplo n.º 5
0
 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
     )
Ejemplo n.º 6
0
 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)
Ejemplo n.º 7
0
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(),
        },
    )
Ejemplo n.º 8
0
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(),
        },
    )
Ejemplo n.º 9
0
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(),
        },
    )
Ejemplo n.º 10
0
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(),
        },
    )
Ejemplo n.º 11
0
 def get_success_url(self):
     return reverse('maps:show',
                    kwargs={
                        'region': self.object.region.slug,
                        'slug': self.object.page.pretty_slug
                    })
Ejemplo n.º 12
0
 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')})
Ejemplo n.º 13
0
 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})
     )
Ejemplo n.º 14
0
 def get_success_url(self):
     return reverse('maps:show',
         kwargs={'region': self.object.region.slug, 'slug': self.object.page.pretty_slug})