コード例 #1
0
def directors_choice(node, kw):
    context = node.bindings['context']
    request = node.bindings['request']
    root = getSite()
    values = []
    if context is not root:
        values = [(a.get_id(), a.title) for a in context.directors]

    ajax_url = request.resource_url(context,
                                    '@@creationculturelapi',
                                    query={'op': 'find_directors'})

    def title_getter(id):
        try:
            obj = get_obj(int(id), None)
            if obj:
                return obj.title
            else:
                return id
        except Exception as e:
            log.warning(e)
            return id

    return AjaxSelect2Widget(values=values,
                             ajax_url=ajax_url,
                             css_class="directors-container review-directors",
                             multiple=True,
                             create=True,
                             title_getter=title_getter,
                             ajax_item_template="artist_item_template",
                             ajax_selection_template='formatDirector')
コード例 #2
0
def announcement_choice(node, kw):
    context = node.bindings['context']
    request = node.bindings['request']
    root = getSite()
    values = []
    if context is not root:
        announcement = context.announcement
        if announcement:
            values = [(get_oid(announcement), announcement.title)]

    ajax_url = request.resource_url(context,
                                    '@@creationculturelapi',
                                    query={'op': 'find_cultural_events'})

    def title_getter(id):
        try:
            obj = get_obj(int(id), None)
            if obj:
                return obj.title
            else:
                return id
        except Exception as e:
            log.warning(e)
            return id

    return AjaxSelect2Widget(values=values,
                             ajax_url=ajax_url,
                             multiple=False,
                             title_getter=title_getter)
コード例 #3
0
def relatedcontents_choice(node, kw):
    request = node.bindings['request']
    context = node.bindings['context']
    root = request.root
    values = []
    if isinstance(context, SmartFolder):
        values = [(get_oid(t), t.title) for t in context.contents]

    def title_getter(id):
        try:
            obj = get_obj(int(id), None)
            if obj:
                return obj.title
            else:
                return id
        except Exception as e:
            log.warning(e)
            return id

    ajax_url = request.resource_url(root,
                                    '@@novaideoapi',
                                    query={'op': 'find_smart_folder_contents'})
    return AjaxSelect2Widget(
        values=values,
        ajax_url=ajax_url,
        ajax_item_template="related_item_template",
        title_getter=title_getter,
        multiple=True,
        page_limit=50,
    )
コード例 #4
0
def challenge_choice(node, kw):
    request = node.bindings['request']
    root = getSite()
    values = [('', _('- Select -'))]

    def title_getter(id):
        try:
            obj = get_obj(int(id), None)
            if obj:
                return obj.title
            else:
                return id
        except Exception as e:
            log.warning(e)
            return id

    ajax_url = request.resource_url(
        root, '@@novaideoapi',
        query={'op': 'find_challenges'})
    return AjaxSelect2Widget(
        values=values,
        ajax_url=ajax_url,
        ajax_item_template="related_item_template",
        title_getter=title_getter,
        multiple=False,
        page_limit=20,
        add_clear=True,
        item_css_class='challenge-input')
コード例 #5
0
def members_choice(node, kw):
    context = node.bindings['context']
    request = node.bindings['request']
    values = []
    ajax_url = request.resource_url(context,
                                    '@@novaideoapi',
                                    query={'op': 'find_user'})

    def title_getter(oid):
        try:
            obj = get_obj(int(oid), None)
            if obj:
                return obj.title
            else:
                return oid
        except Exception as e:
            log.warning(e)
            return oid

    return AjaxSelect2Widget(
        values=values,
        ajax_url=ajax_url,
        multiple=True,
        create=False,
        ajax_item_template="user_item_template",
        title_getter=title_getter,
        item_css_class='publish-proposal-opt'
        )
コード例 #6
0
def ideas_choice(node, kw):
    context = node.bindings['context']
    request = node.bindings['request']
    values = []
    ajax_url = request.resource_url(context,
                                    '@@novaideoapi',
                                    query={'op': 'find_ideas'})

    def title_getter(oid):
        try:
            obj = get_obj(int(oid), None)
            if obj:
                return obj.title
            else:
                return oid
        except Exception as e:
            log.warning(e)
            return oid

    return AjaxSelect2Widget(
        values=values,
        ajax_url=ajax_url,
        multiple=True,
        add_clear=True,
        title_getter=title_getter,
        )
コード例 #7
0
ファイル: comment.py プロジェクト: middlestate/nova-ideo
def relatedcontents_choice(node, kw):
    request = node.bindings['request']
    context = node.bindings['context']
    root = getSite()
    values = []
    if isinstance(context, Comment) and\
       context.related_correlation:
        values = [(get_oid(t), t.title) for t in context.associated_contents]

    def title_getter(id):
        try:
            obj = get_obj(int(id), None)
            if obj:
                return obj.title
            else:
                return id
        except Exception as e:
            log.warning(e)
            return id

    ajax_url = request.resource_url(root,
                                    '@@novaideoapi',
                                    query={'op': 'find_correlable_entity'})
    return AjaxSelect2Widget(
        values=values,
        ajax_url=ajax_url,
        ajax_item_template="related_item_template",
        css_class="search-idea-form",
        title_getter=title_getter,
        multiple=True,
        page_limit=50,
        item_css_class="comment-form-group comment-related-form")
コード例 #8
0
def review_choice(node, kw):
    context = node.bindings['context']
    request = node.bindings['request']
    root = getSite()
    values = []
    if context is not root:
        review = context.review
        if review:
            values = [(get_oid(review), review.title)]

    ajax_url = request.resource_url(context,
                                    '@@creationculturelapi',
                                    query={'op': 'find_base_review'})

    def title_getter(id):
        try:
            obj = get_obj(int(id), None)
            if obj:
                return obj.title
            else:
                return id
        except Exception as e:
            log.warning(e)
            return id

    return AjaxSelect2Widget(
        values=values,
        ajax_url=ajax_url,
        css_class="artists-container review-artists",
        multiple=False,
        title_getter=title_getter,
        ajax_item_template='formatReview'
        )
コード例 #9
0
ファイル: __init__.py プロジェクト: ecreall/lagendacommun
def venue_choice(node, kw):
    context = node.bindings['context']
    request = node.bindings['request']
    venues = node.bindings.get('venues', [])
    venues = [(context, context.title)]
    venues.insert(0, ('', _('- Select -')))
    ajax_url = request.resource_url(context,
                                    '@@cinemaapi',
                                    query={'op': 'find_cinema_venue'})

    def title_getter(obj):
        if not isinstance(obj, str):
            return getattr(obj, 'title', obj)
        else:
            try:
                obj = get_obj(int(obj), None)
                if obj:
                    return obj.title
                else:
                    return obj
            except Exception as e:
                log.warning(e)
                return obj

    return AjaxSelect2Widget(values=venues,
                             ajax_url=ajax_url,
                             title_getter=title_getter,
                             ajax_item_template="venue_item_template",
                             css_class="venue-title")
コード例 #10
0
ファイル: core.py プロジェクト: ecreall/lagendacommun
def labels_choices(node, kw):
    """Country must be in the select tag for the initialization"""
    context = node.bindings['context']
    request = node.bindings['request']
    values = []
    ajax_url = request.resource_url(context,
                                    '@@creationculturelapi',
                                    query={'op': 'find_labels'})

    def title_getter(oid):
        try:
            obj = get_obj(int(oid), None)
            if obj:
                return obj.title
            else:
                return oid
        except Exception as e:
            log.warning(e)
            return oid

    return AjaxSelect2Widget(
        values=values,
        ajax_url=ajax_url,
        multiple=True,
        title_getter=title_getter,
        ajax_item_template='formatLabel'
        )
コード例 #11
0
def target_choice(node, kw):
    context = node.bindings['context']
    request = node.bindings['request']
    values = []
    ajax_url = request.resource_url(context,
                                    '@@creationculturelapi',
                                    query={'op': 'find_artists'})
    return AjaxSelect2Widget(values=values,
                             ajax_url=ajax_url,
                             css_class="artists-container review-artists",
                             title_getter=title_getter)
コード例 #12
0
def idea_choice(node, kw):
    request = node.bindings['request']
    root = getSite()
    values = []
    values.insert(0, ('', _('- Select -')))
    ajax_url = request.resource_url(root, '@@novaideoapi',
                                    query={'op': 'find_ideas'})
    return AjaxSelect2Widget(
        values=values,
        ajax_url=ajax_url,
        css_class="search-idea-form")
コード例 #13
0
def target_choice(node, kw):
    context = node.bindings['context']
    request = node.bindings['request']
    venues = []
    ajax_url = request.resource_url(context,
                                    '@@culturaleventmanagement',
                                    query={'op': 'find_venues'})
    return AjaxSelect2Widget(values=venues,
                             ajax_url=ajax_url,
                             title_getter=title_getter,
                             ajax_item_template="venue_item_template",
                             css_class="venue-title",
                             multiple=False)
コード例 #14
0
def relatedideas_choice(node, kw):
    context = node.bindings['context']
    request = node.bindings['request']
    used_ideas = context.get_used_ideas()
    root = getSite()
    ideas = context.proposal.related_ideas
    ideas.extend(used_ideas)
    ideas = set(ideas)
    values = [(i, i.title) for i in ideas]
    ajax_url = request.resource_url(root,
                                    '@@novaideoapi',
                                    query={'op': 'find_ideas'})
    return AjaxSelect2Widget(values=values,
                             ajax_url=ajax_url,
                             css_class="search-idea-form",
                             multiple=True)
コード例 #15
0
ファイル: venue.py プロジェクト: ecreall/lagendacommun
def department_widget(node, kw):
    """Department must be in the select tag for the initialization"""
    context = node.bindings['context']
    request = node.bindings['request']
    departments = get_initialization_data('department', node)
    values = [(d, d) for d in departments]
    values.insert(0, ('', _('- Select -')))
    ajax_url = request.resource_url(context,
                                    '@@culturaleventmanagement',
                                    query={'op': 'find_cities'})
    return AjaxSelect2Widget(
        values=values,
        ajax_url=ajax_url,
        dependencies=['country', 'city', 'zipcode'],
        css_class="address-entry address-department-entry select2-preload",
        create=True,
        add_clear=True,
        clear_title=_('Clear'))
コード例 #16
0
ファイル: idea.py プロジェクト: ecreall/KuneAgi
def challenge_choice(node, kw):
    request = node.bindings['request']
    is_home_form = node.bindings.get('is_home_form', False)
    request_context = request.context
    challenge = getattr(request_context, 'challenge', None)
    root = getSite()
    values = [('', _('- Select -'))]
    if challenge is not None and challenge.can_add_content:
        values = [(get_oid(challenge), challenge.title)]

    def title_getter(id):
        try:
            obj = get_obj(int(id), None)
            if obj:
                return obj.title
            else:
                return id
        except Exception as e:
            log.warning(e)
            return id

    ajax_url = request.resource_url(
        root, '@@novaideoapi',
        query={'op': 'find_challenges'})
    item_css_class = 'challenge-input'
    is_challenge_content = is_home_form and challenge
    if is_challenge_content:
        item_css_class += ' challenge-content'

    return AjaxSelect2Widget(
        template='novaideo:views/idea_management/templates/ajax_select2.pt',
        values=values,
        ajax_url=ajax_url,
        ajax_item_template="related_item_template",
        title_getter=title_getter,
        challenge=challenge,
        is_challenge_content=is_challenge_content,
        multiple=False,
        add_clear=True,
        page_limit=20,
        item_css_class=item_css_class)
コード例 #17
0
ファイル: organization.py プロジェクト: middlestate/nova-ideo
def managers_choice(node, kw):
    """"""
    context = node.bindings['context']
    request = node.bindings['request']
    values = []

    def title_getter(oid):
        author = None
        try:
            author = get_obj(int(oid))
        except Exception:
            return oid

        title = getattr(author, 'title', author.__name__)
        return title

    ajax_url = request.resource_url(context,
                                    '@@novaideoapi',
                                    query={'op': 'find_organization_user'})
    return AjaxSelect2Widget(values=values,
                             ajax_url=ajax_url,
                             multiple=True,
                             title_getter=title_getter)
コード例 #18
0
ファイル: venue.py プロジェクト: ecreall/lagendacommun
def venue_choice(node, kw):
    context = node.bindings['context']
    request = node.bindings['request']
    default_venues = node.bindings.get('venues', [])
    default_venues = [(v.get_id(), v.title) for v in default_venues]
    root = getSite()
    venues = []
    if hasattr(context, 'schedules') and context is not root:
        venues = [(s.venue.get_id(), s.venue.title)
                  for s in context.schedules if s.venue]

    venues.extend(default_venues)
    venues.insert(0, ('', _('- Select -')))
    ajax_url = request.resource_url(context,
                                    '@@culturaleventmanagement',
                                    query={'op': 'find_venues'})

    def title_getter(id):
        try:
            obj = get_obj(int(id), None)
            if obj:
                return obj.title
            else:
                return id
        except Exception as e:
            log.warning(e)
            return id

    return AjaxSelect2Widget(
        values=venues,
        ajax_url=ajax_url,
        dependencies=['venue_history'],
        title_getter=title_getter,
        ajax_item_template="venue_item_template",
        css_class="venue-title select2-preload",
        create_message=_("Create a new venue"),
        create=True)
コード例 #19
0
ファイル: challenge.py プロジェクト: middlestate/nova-ideo
def users_to_invite(node, kw):
    request = node.bindings['request']
    context = node.bindings['context']
    state = 'closed'
    if request.POST and json.loads(request.POST.get('is_restricted', 'false')):
        state = ''

    root = getSite()
    values = []
    if isinstance(context, Challenge) and\
       context.invited_users:
        values = [(get_oid(t), t.title) for t in context.invited_users]

    def title_getter(id):
        try:
            obj = get_obj(int(id), None)
            if obj:
                return obj.title
            else:
                return id
        except Exception as e:
            log.warning(e)
            return id

    ajax_url = request.resource_url(root,
                                    '@@novaideoapi',
                                    query={'op': 'find_groups'})
    return AjaxSelect2Widget(
        values=values,
        ajax_url=ajax_url,
        ajax_item_template="related_item_template",
        item_css_class='invitedusers-input ' + state,
        title_getter=title_getter,
        multiple=True,
        page_limit=50,
    )