def url(comment, member=None, format=None, comment_page=False,
        in_overlay=True, **kwargs):
    if member is None and format is None and not comment_page:
        if isinstance(comment.topic, model.Page):
            if comment.topic.function == model.Page.DESCRIPTION:
                return (proposal.url(comment.topic.proposal,
                                     anchor=u'c%i' % comment.id, **kwargs))
            if comment.topic.is_sectionpage():
                if not u'anchor' in kwargs:
                    kwargs[u'anchor'] = u'c%i' % comment.id
                if in_overlay:
                    kwargs[u'format'] = u'overlay'
                    query = {
                        u'overlay_path': page.url(comment.topic,
                                                  member=u'comments',
                                                  **kwargs),
                        u'overlay_type': u'#overlay-url',
                    }
                    return page.url(comment.topic.sectionpage_root(),
                                    query=query)
                else:
                    return page.url(comment.topic, member=u'comments',
                                    **kwargs),
            return (text.url(comment.topic.variant_head(comment.variant),
                             anchor=u'c%i' % comment.id, **kwargs))
        elif isinstance(comment.topic, model.Proposal):
            return (proposal.url(comment.topic, anchor=u'c%i' % comment.id,
                                 **kwargs))
    return _url.build(comment.topic.instance, 'comment',
                      comment.id, member=member, format=format, **kwargs)
Example #2
0
def url(selection, member=None, format='html', selection_page=False, **kwargs):
    if member is None and format == 'html' and not selection_page:
        anchor = "selection_%s" % selection.id
        return proposal.url(selection.proposal, anchor=anchor)
    url = proposal.url(selection.proposal, member='implementation')
    url += "/" + str(selection.id)
    return _url.append_member_and_format(url, member=member, format=format,
                                         **kwargs)
def url(comment, member=None, format=None, comment_page=False, **kwargs):
    if member is None and format is None and not comment_page:
        if isinstance(comment.topic, model.Page):
            if comment.topic.function == model.Page.DESCRIPTION:
                return (proposal.url(comment.topic.proposal) + '#c' +
                        str(comment.id))
            return (text.url(comment.topic.variant_head(comment.variant)) +
                    '#c' + str(comment.id))
        elif isinstance(comment.topic, model.Proposal):
            return proposal.url(comment.topic) + '#c' + str(comment.id)
    return _url.build(comment.topic.instance, 'comment',
                      comment.id, member=member, format=format, **kwargs)
Example #4
0
def entity_url(entity, **kwargs):
    if isinstance(entity, model.User):
        return user.url(entity, **kwargs)
    elif isinstance(entity, model.Proposal):
        return proposal.url(entity, **kwargs)
    elif isinstance(entity, model.Page):
        return page.url(entity, **kwargs)
    elif isinstance(entity, model.Text):
        return text.url(entity, **kwargs)
    elif isinstance(entity, model.Delegateable):
        return delegateable.url(entity, **kwargs)
    elif isinstance(entity, model.Poll):
        return poll.url(entity, **kwargs)
    elif isinstance(entity, model.Selection):
        return selection.url(entity, **kwargs)
    elif isinstance(entity, model.Comment):
        return comment.url(entity, **kwargs)
    elif isinstance(entity, model.Instance):
        return instance.url(entity, **kwargs)
    elif isinstance(entity, model.Delegation):
        return delegation.url(entity, **kwargs)
    elif isinstance(entity, model.Milestone):
        return milestone.url(entity, **kwargs)
    elif isinstance(entity, model.Tag):
        return tag.url(entity, **kwargs)
    elif isinstance(entity, model.StaticPage):
        return staticpage.url(entity, **kwargs)
    elif isinstance(entity, model.Treatment):
        return treatment.url(entity, **kwargs)
    elif isinstance(entity, model.Message):
        return message.url(entity, **kwargs)
    elif (isinstance(entity, model.CategoryBadge) and c.instance is not None
          and c.instance.display_category_pages):
        return category.url(entity, **kwargs)
    raise ValueError("No URL maker for: %s" % repr(entity))
Example #5
0
def entity_url(entity, **kwargs):
    if isinstance(entity, model.User):
        return user.url(entity, **kwargs)
    elif isinstance(entity, model.Proposal):
        return proposal.url(entity, **kwargs)
    elif isinstance(entity, model.Page):
        return page.url(entity, **kwargs)
    elif isinstance(entity, model.Text):
        return text.url(entity, **kwargs)
    elif isinstance(entity, model.Delegateable):
        return delegateable.url(entity, **kwargs)
    elif isinstance(entity, model.Poll):
        return poll.url(entity, **kwargs)
    elif isinstance(entity, model.Selection):
        return selection.url(entity, **kwargs)
    elif isinstance(entity, model.Comment):
        return comment.url(entity, **kwargs)
    elif isinstance(entity, model.Instance):
        return instance.url(entity, **kwargs)
    elif isinstance(entity, model.Delegation):
        return delegation.url(entity, **kwargs)
    elif isinstance(entity, model.Milestone):
        return milestone.url(entity, **kwargs)
    elif isinstance(entity, model.Tag):
        return tag.url(entity, **kwargs)
    raise ValueError("No URL maker for: %s" % repr(entity))
Example #6
0
def entity_url(entity, **kwargs):
    if isinstance(entity, model.User):
        return user.url(entity, **kwargs)
    elif isinstance(entity, model.Proposal):
        return proposal.url(entity, **kwargs)
    elif isinstance(entity, model.Page):
        return page.url(entity, **kwargs)
    elif isinstance(entity, model.Text):
        return text.url(entity, **kwargs)
    elif isinstance(entity, model.Delegateable):
        return delegateable.url(entity, **kwargs)
    elif isinstance(entity, model.Poll):
        return poll.url(entity, **kwargs)
    elif isinstance(entity, model.Selection):
        return selection.url(entity, **kwargs)
    elif isinstance(entity, model.Comment):
        return comment.url(entity, **kwargs)
    elif isinstance(entity, model.Instance):
        return instance.url(entity, **kwargs)
    elif isinstance(entity, model.Delegation):
        return delegation.url(entity, **kwargs)
    elif isinstance(entity, model.Milestone):
        return milestone.url(entity, **kwargs)
    elif isinstance(entity, model.Tag):
        return tag.url(entity, **kwargs)
    elif isinstance(entity, model.StaticPage):
        return staticpage.url(entity, **kwargs)
    elif isinstance(entity, model.Treatment):
        return treatment.url(entity, **kwargs)
    elif isinstance(entity, model.Message):
        return message.url(entity, **kwargs)
    elif (isinstance(entity, model.CategoryBadge) and c.instance is not None
          and c.instance.display_category_pages):
        return category.url(entity, **kwargs)
    raise ValueError("No URL maker for: %s" % repr(entity))
Example #7
0
def url(comment, member=None, format=None, comment_page=False, **kwargs):
    if member is None and format is None and not comment_page:
        if isinstance(comment.topic, model.Page):
            if comment.topic.function == model.Page.DESCRIPTION:
                return (proposal.url(comment.topic.proposal) + '#c' +
                        str(comment.id))
            return (text.url(comment.topic.variant_head(comment.variant)) +
                    '#c' + str(comment.id))
        elif isinstance(comment.topic, model.Proposal):
            return proposal.url(comment.topic) + '#c' + str(comment.id)
    return _url.build(comment.topic.instance,
                      'comment',
                      comment.id,
                      member=member,
                      format=format,
                      **kwargs)
Example #8
0
def entity_url(entity, **kwargs):
    if isinstance(entity, model.User):
        return user.url(entity, **kwargs)
    elif isinstance(entity, model.Proposal):
        return proposal.url(entity, **kwargs)
    elif isinstance(entity, model.Page):
        return page.url(entity, **kwargs)
    elif isinstance(entity, model.Text):
        return text.url(entity, **kwargs)
    elif isinstance(entity, model.Delegateable):
        return delegateable.url(entity, **kwargs)
    elif isinstance(entity, model.Poll):
        return poll.url(entity, **kwargs)
    elif isinstance(entity, model.Selection):
        return selection.url(entity, **kwargs)
    elif isinstance(entity, model.Comment):
        return comment.url(entity, **kwargs)
    elif isinstance(entity, model.Instance):
        return instance.url(entity, **kwargs)
    elif isinstance(entity, model.Delegation):
        return delegation.url(entity, **kwargs)
    elif isinstance(entity, model.Milestone):
        return milestone.url(entity, **kwargs)
    elif isinstance(entity, model.Tag):
        return tag.url(entity, **kwargs)
    raise ValueError("No URL maker for: %s" % repr(entity))
Example #9
0
def url(page, in_context=True, member=None, **kwargs):
    if in_context and page.proposal and not member:
        return proposal.url(page.proposal, **kwargs)
    if in_context and page.is_sectionpage() and page.parent and member is None:
        if u'anchor' not in kwargs:
            kwargs[u'anchor'] = u'subpage-%i' % page.id
        return url(page.root, in_context=False, **kwargs)
    label = urllib.quote(page.label.encode('utf-8'))
    return _url.build(page.instance, 'page', label, member=member, **kwargs)
Example #10
0
def url(page, in_context=True, member=None, **kwargs):
    if in_context and page.proposal and not member:
        return proposal.url(page.proposal, **kwargs)
    if (in_context and member is None and page.is_sectionpage() and
            page.sectionpage_root() != page):
        if u'anchor' not in kwargs:
            kwargs[u'anchor'] = u'subpage-%i' % page.id
        return url(page.sectionpage_root(), in_context=False, **kwargs)
    label = _url.quote(page.label)
    return _url.build(page.instance, 'page', label, member=member, **kwargs)
Example #11
0
def url(comment,
        member=None,
        format=None,
        comment_page=False,
        in_overlay=True,
        **kwargs):
    if member is None and format is None and not comment_page:
        if isinstance(comment.topic, model.Page):
            if comment.topic.function == model.Page.DESCRIPTION:
                return (proposal.url(comment.topic.proposal,
                                     anchor=u'c%i' % comment.id,
                                     **kwargs))
            if comment.topic.is_sectionpage():
                if u'anchor' not in kwargs:
                    kwargs[u'anchor'] = u'c%i' % comment.id
                if in_overlay:
                    kwargs[u'format'] = u'overlay'
                    query = {
                        u'overlay_path':
                        page.url(comment.topic, member=u'comments', **kwargs),
                        u'overlay_type':
                        u'#overlay-url',
                    }
                    return page.url(comment.topic.sectionpage_root(),
                                    query=query)
                else:
                    return page.url(comment.topic,
                                    member=u'comments',
                                    **kwargs),
            return (text.url(comment.topic.variant_head(comment.variant),
                             anchor=u'c%i' % comment.id,
                             **kwargs))
        elif isinstance(comment.topic, model.Proposal):
            return (proposal.url(comment.topic,
                                 anchor=u'c%i' % comment.id,
                                 **kwargs))
    return _url.build(comment.topic.instance,
                      'comment',
                      comment.id,
                      member=member,
                      format=format,
                      **kwargs)
Example #12
0
def bc_entity(selection):
    bc = _url.link(_("Implementation"),
                   proposal.url(selection.proposal,
                                member=u'/implementation'))
    bc += _url.BREAD_SEP + _url.link(selection.page.title, url(selection))
    return bc
Example #13
0
def url(page, in_context=True, member=None, **kwargs):
    if in_context and page.proposal and not member:
        return proposal.url(page.proposal, **kwargs)
    label = urllib.quote(page.label.encode('utf-8'))
    return _url.build(page.instance, 'page', label, member=member, **kwargs)
Example #14
0
def url(page, in_context=True, member=None, **kwargs):
    if in_context and page.proposal and not member:
        return proposal.url(page.proposal, **kwargs)
    label = urllib.quote(page.label.encode('utf-8'))
    return _url.build(page.instance, 'page', label, member=member, **kwargs)