Exemplo n.º 1
0
def conference_view(**kwargs):
    meetings = []
    submissions = []
    for conf in Conference.find():
        query = (Q('tags', 'iexact', conf.endpoint)
                 & Q('is_public', 'eq', True)
                 & Q('is_deleted', 'eq', False))
        projects = Node.find(query)
        for idx, node in enumerate(projects):
            submissions.append(_render_conference_node(node, idx, conf))
        num_submissions = projects.count()
        if num_submissions < settings.CONFERNCE_MIN_COUNT:
            continue
        meetings.append({
            'name':
            conf.name,
            'active':
            conf.active,
            'url':
            web_url_for('conference_results', meeting=conf.endpoint),
            'count':
            num_submissions,
        })

    submissions.sort(key=lambda submission: submission['dateCreated'],
                     reverse=True)
    meetings.sort(key=lambda meeting: meeting['count'], reverse=True)

    return {'meetings': meetings, 'submissions': submissions}
Exemplo n.º 2
0
def conference_view(**kwargs):
    meetings = []
    submissions = []
    for conf in Conference.find():
        # For efficiency, we filter by tag first, then node
        # instead of doing a single Node query
        projects = set()
        for tag in Tag.find(Q('_id', 'iexact', conf.endpoint)):
            for node in tag.node__tagged:
                if not node:
                    continue
                if not node.is_public or node.is_deleted:
                    continue
                projects.add(node)

        for idx, node in enumerate(projects):
            submissions.append(_render_conference_node(node, idx, conf))
        num_submissions = len(projects)
        if num_submissions < settings.CONFERENCE_MIN_COUNT:
            continue
        meetings.append({
            'name': conf.name,
            'active': conf.active,
            'url': web_url_for('conference_results', meeting=conf.endpoint),
            'count': num_submissions,
        })

    submissions.sort(key=lambda submission: submission['dateCreated'], reverse=True)
    meetings.sort(key=lambda meeting: meeting['count'], reverse=True)

    return {'meetings': meetings, 'submissions': submissions}
Exemplo n.º 3
0
def conference_view(**kwargs):
    meetings = []
    submissions = []
    for conf in Conference.find():
        query = (
            Q('tags', 'iexact', conf.endpoint)
            & Q('is_public', 'eq', True)
            & Q('is_deleted', 'eq', False)
        )
        projects = Node.find(query)
        for idx, node in enumerate(projects):
            submissions.append(_render_conference_node(node, idx, conf))
        num_submissions = projects.count()
        if num_submissions < settings.CONFERNCE_MIN_COUNT:
            continue
        meetings.append({
            'name': conf.name,
            'active': conf.active,
            'url': web_url_for('conference_results', meeting=conf.endpoint),
            'count': num_submissions,
        })

    submissions.sort(key=lambda submission: submission['dateCreated'], reverse=True)
    meetings.sort(key=lambda meeting: meeting['count'], reverse=True)

    return {'meetings': meetings, 'submissions': submissions}
Exemplo n.º 4
0
def conference_submissions(**kwargs):
    """Return data for all OSF4M submissions.

    The total number of submissions for each meeting is calculated and cached
    in the Conference.num_submissions field.
    """
    submissions = []
    #  TODO: Revisit this loop, there has to be a way to optimize it
    for conf in Conference.find():
        # For efficiency, we filter by tag first, then node
        # instead of doing a single Node query
        projects = set()

        tags = Tag.find(Q('lower', 'eq', conf.endpoint.lower())).get_keys()
        nodes = Node.find(
            Q('tags', 'in', tags) &
            Q('is_public', 'eq', True) &
            Q('is_deleted', 'ne', True)
        )
        projects.update(list(nodes))

        for idx, node in enumerate(projects):
            submissions.append(_render_conference_node(node, idx, conf))
        num_submissions = len(projects)
        # Cache the number of submissions
        conf.num_submissions = num_submissions
        conf.save()
        if num_submissions < settings.CONFERENCE_MIN_COUNT:
            continue
    submissions.sort(key=lambda submission: submission['dateCreated'], reverse=True)
    return {'submissions': submissions}
Exemplo n.º 5
0
def conference_submissions(**kwargs):
    """Return data for all OSF4M submissions.

    The total number of submissions for each meeting is calculated and cached
    in the Conference.num_submissions field.
    """
    submissions = []
    for conf in Conference.find():
        # For efficiency, we filter by tag first, then node
        # instead of doing a single Node query
        projects = set()
        for tag in Tag.find(Q('lower', 'eq', conf.endpoint.lower())):
            for node in tag.node__tagged.find(Q('is_public', 'eq', True) & Q('is_deleted', 'eq', False)):
                projects.add(node)

        for idx, node in enumerate(projects):
            submissions.append(_render_conference_node(node, idx, conf))
        num_submissions = len(projects)
        # Cache the number of submissions
        conf.num_submissions = num_submissions
        conf.save()
        if num_submissions < settings.CONFERENCE_MIN_COUNT:
            continue
    submissions.sort(key=lambda submission: submission['dateCreated'], reverse=True)
    return {'submissions': submissions}
Exemplo n.º 6
0
 def test_form_valid(self):
     view = setup_form_view(self.view, self.request, self.form)
     view.form_valid(self.form)
     nt.assert_equal(
         Conference.find(Q('endpoint', 'iexact', data['endpoint'])).count(),
         1
     )
Exemplo n.º 7
0
def conference_submissions(**kwargs):
    """Return data for all OSF4M submissions.

    The total number of submissions for each meeting is calculated and cached
    in the Conference.num_submissions field.
    """
    conferences = Conference.find(Q('is_meeting', 'ne', False))
    #  TODO: Revisit this loop, there has to be a way to optimize it
    for conf in conferences:
        # For efficiency, we filter by tag first, then node
        # instead of doing a single Node query
        projects = set()

        tags = Tag.find(
            Q('system', 'eq', False)
            & Q('name', 'iexact', conf.endpoint.lower())).values_list(
                'pk', flat=True)
        nodes = Node.find(
            Q('tags', 'in', tags) & Q('is_public', 'eq', True)
            & Q('is_deleted', 'ne', True)).include('guids')
        projects.update(list(nodes))
        num_submissions = len(projects)
        # Cache the number of submissions
        conf.num_submissions = num_submissions
    bulk_update(conferences, update_fields=['num_submissions'])
    return {'success': True}
Exemplo n.º 8
0
def conference_submissions(**kwargs):
    """Return data for all OSF4M submissions.

    The total number of submissions for each meeting is calculated and cached
    in the Conference.num_submissions field.
    """
    submissions = []
    #  TODO: Revisit this loop, there has to be a way to optimize it
    for conf in Conference.find():
        if (hasattr(conf, 'is_meeting') and (conf.is_meeting is False)):
            break
        # For efficiency, we filter by tag first, then node
        # instead of doing a single Node query
        projects = set()

        tags = Tag.find(Q('lower', 'eq', conf.endpoint.lower())).get_keys()
        nodes = Node.find(
            Q('tags', 'in', tags) & Q('is_public', 'eq', True)
            & Q('is_deleted', 'ne', True))
        projects.update(list(nodes))

        for idx, node in enumerate(projects):
            submissions.append(_render_conference_node(node, idx, conf))
        num_submissions = len(projects)
        # Cache the number of submissions
        conf.num_submissions = num_submissions
        conf.save()
        if num_submissions < settings.CONFERENCE_MIN_COUNT:
            continue
    submissions.sort(key=lambda submission: submission['dateCreated'],
                     reverse=True)
    return {'submissions': submissions}
def main():
    init_app(set_backends=True, routes=False)
    dry = '--dry' in sys.argv
    if not dry:
        scripts_utils.add_file_logger(logger, __file__)

    for conf in Conference.find():
        if not conf.field_names.get('homepage_link_text'):
            logger.info('Setting conference {} field_names["homepage_link_text"] to default value: {}'.format(conf.endpoint, DEFAULT_FIELD_NAMES['homepage_link_text']))
            conf.field_names['homepage_link_text'] = DEFAULT_FIELD_NAMES['homepage_link_text']
            if not dry:
                conf.save()
    logger.info('Done.')
Exemplo n.º 10
0
def conference_view(**kwargs):
    meetings = []
    for conf in Conference.find():
        if conf.num_submissions < settings.CONFERENCE_MIN_COUNT:
            continue
        meetings.append({
            'name': conf.name,
            'active': conf.active,
            'url': web_url_for('conference_results', meeting=conf.endpoint),
            'count': conf.num_submissions,
        })

    meetings.sort(key=lambda meeting: meeting['count'], reverse=True)
    return {'meetings': meetings}
Exemplo n.º 11
0
def conference_view(**kwargs):
    meetings = []
    for conf in Conference.find():
        if conf.num_submissions < settings.CONFERENCE_MIN_COUNT:
            continue
        meetings.append({
            'name': conf.name,
            'location': conf.location,
            'end_date': conf.end_date.strftime("%b %d, %Y") if conf.end_date else None,
            'start_date': conf.start_date.strftime("%b %d, %Y") if conf.start_date else None,
            'url': web_url_for('conference_results', meeting=conf.endpoint),
            'count': conf.num_submissions,
        })

    meetings.sort(key=lambda meeting: meeting['count'], reverse=True)
    return {'meetings': meetings}
def main():
    init_app(set_backends=True, routes=False)
    dry = '--dry' in sys.argv
    if not dry:
        scripts_utils.add_file_logger(logger, __file__)

    for conf in Conference.find():
        if not conf.field_names.get('homepage_link_text'):
            logger.info(
                'Setting conference {} field_names["homepage_link_text"] to default value: {}'
                .format(conf.endpoint,
                        DEFAULT_FIELD_NAMES['homepage_link_text']))
            conf.field_names['homepage_link_text'] = DEFAULT_FIELD_NAMES[
                'homepage_link_text']
            if not dry:
                conf.save()
    logger.info('Done.')
Exemplo n.º 13
0
def meeting_hook():

    # Fail if not from Mailgun
    check_mailgun_headers()

    form = escape_html(request.form.to_dict())
    meeting, category = parse_mailgun_receiver(form)

    conf = Conference.find(Q('endpoint', 'iexact', meeting))
    if conf.count():
        conf = conf[0]
    else:
        raise HTTPError(http.NOT_FOUND)

    # Fail if not found or inactive
    # Note: Throw 406 to disable Mailgun retries
    try:
        if not conf.active:
            logger.error('Conference {0} is not active'.format(conf.endpoint))
            raise HTTPError(http.NOT_ACCEPTABLE)
    except KeyError:
        # TODO: Can this ever be reached?
        raise HTTPError(http.NOT_ACCEPTABLE)

    name, address = get_mailgun_from()

    # Add poster
    add_poster_by_email(
        conf=conf,
        recipient=form['recipient'],
        address=address,
        fullname=name,
        subject=get_mailgun_subject(form),
        message=form['stripped-text'],
        attachments=get_mailgun_attachments(),
        tags=[meeting],
        system_tags=[meeting],
        is_spam=check_mailgun_spam(),
    )
Exemplo n.º 14
0
def conference_view(**kwargs):

    meetings = []
    for conf in Conference.find():
        query = (
            Q('tags', 'iexact', conf.endpoint)
            & Q('is_public', 'eq', True)
            & Q('is_deleted', 'eq', False)
        )
        projects = Node.find(query)
        submissions = projects.count()
        if submissions < settings.CONFERNCE_MIN_COUNT:
            continue
        meetings.append({
            'name': conf.name,
            'active': conf.active,
            'url': web_url_for('conference_results', meeting=conf.endpoint),
            'submissions': submissions,
        })
    meetings.sort(key=lambda meeting: meeting['submissions'], reverse=True)

    return {'meetings': meetings}
Exemplo n.º 15
0
def conference_view(**kwargs):

    meetings = []
    for conf in Conference.find():
        query = (
            Q('tags', 'iexact', conf.endpoint)
            & Q('is_public', 'eq', True)
            & Q('is_deleted', 'eq', False)
        )
        projects = Node.find(query)
        submissions = projects.count()
        if submissions < settings.CONFERNCE_MIN_COUNT:
            continue
        meetings.append({
            'name': conf.name,
            'active': conf.active,
            'url': web_url_for('conference_results', meeting=conf.endpoint),
            'submissions': submissions,
        })
    meetings.sort(key=lambda meeting: meeting['submissions'], reverse=True)

    return {'meetings': meetings}
Exemplo n.º 16
0
def meeting_hook():

    # Fail if not from Mailgun
    check_mailgun_headers()

    form = escape_html(request.form.to_dict())
    meeting, category = parse_mailgun_receiver(form)

    conf = Conference.find(Q('endpoint', 'iexact', meeting))
    if conf.count():
        conf = conf[0]
    else:
        raise HTTPError(http.NOT_FOUND)

    # Fail if not found or inactive
    # Note: Throw 406 to disable Mailgun retries
    try:
        if not conf.active:
            raise HTTPError(http.NOT_ACCEPTABLE)
    except KeyError:
        raise HTTPError(http.NOT_ACCEPTABLE)

    name, address = get_mailgun_from()

    # Add poster
    add_poster_by_email(
        conf=conf,
        recipient=form['recipient'],
        address=address,
        fullname=name,
        subject=get_mailgun_subject(form),
        message=form['stripped-text'],
        attachments=get_mailgun_attachments(),
        tags=[meeting],
        system_tags=[meeting],
        is_spam=check_mailgun_spam(),
    )
Exemplo n.º 17
0
def conference_view(**kwargs):
    meetings = []
    submissions = []
    for conf in Conference.find():
        query = Q("tags", "iexact", conf.endpoint) & Q("is_public", "eq", True) & Q("is_deleted", "eq", False)
        projects = Node.find(query)
        for idx, node in enumerate(projects):
            submissions.append(_render_conference_node(node, idx, conf))
        num_submissions = projects.count()
        if num_submissions < settings.CONFERNCE_MIN_COUNT:
            continue
        meetings.append(
            {
                "name": conf.name,
                "active": conf.active,
                "url": web_url_for("conference_results", meeting=conf.endpoint),
                "count": num_submissions,
            }
        )

    submissions.sort(key=lambda submission: submission["dateCreated"], reverse=True)
    meetings.sort(key=lambda meeting: meeting["count"], reverse=True)

    return {"meetings": meetings, "submissions": submissions}
Exemplo n.º 18
0
 def get_queryset(self):
     return Conference.find()
Exemplo n.º 19
0
 def get_queryset(self):
     return Conference.find()