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)
Exemple #2
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))
Exemple #3
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))
Exemple #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))
Exemple #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))
Exemple #6
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)
Exemple #7
0
def url(proposal, member=None, in_overlay=True, **kwargs):
    if proposal.is_amendment and member is None:
        base = u'page/%s/amendment' % proposal.selection.page.label
        if in_overlay:
            from adhocracy.lib.helpers import page_helper as page
            kwargs[u'format'] = u'overlay'
            query = {
                u'overlay_path': _url.build(proposal.instance, base,
                                            proposal.id, **kwargs),
                u'overlay_type': u'#overlay-url-big',
            }
            return page.url(proposal.selection.page, query=query)
        else:
            return _url.build(proposal.instance, base, proposal.id, **kwargs)
    else:
        ext = str(proposal.id) + '-' + label2url(proposal.title)
        return _url.build(proposal.instance, 'proposal', ext,
                          member=member, **kwargs)
def url(proposal, member=None, in_overlay=True, **kwargs):
    if proposal.is_amendment and member is None:
        base = u'page/%s/amendment' % proposal.selection.page.label
        if in_overlay:
            from adhocracy.lib.helpers import page_helper as page
            kwargs[u'format'] = u'overlay'
            query = {
                u'overlay_path':
                _url.build(proposal.instance, base, proposal.id, **kwargs),
                u'overlay_type':
                u'#overlay-url-big',
            }
            return page.url(proposal.selection.page, query=query)
        else:
            return _url.build(proposal.instance, base, proposal.id, **kwargs)
    else:
        ext = str(proposal.id) + '-' + label2url(proposal.title)
        return _url.build(proposal.instance,
                          'proposal',
                          ext,
                          member=member,
                          **kwargs)