Beispiel #1
0
def find_intranets(context):
    # Find the community in the site with IIntranets
    site = find_site(context)
    for v in site.values():
        if IIntranets.providedBy(v):
            return v

    return []
Beispiel #2
0
def find_intranets(context):
    # Find the community in the site with IIntranets
    site = find_site(context)
    for v in site.values():
        if IIntranets.providedBy(v):
            return v

    return []
Beispiel #3
0
def _community_title(context):
    """find the title of a community

    offices also provide ICommunity, but we don't want to consider those
    here. offices explicitly provide IIntranets, so we'll discount those that
    way
    """
    obj = find_community(context)
    if obj is None or IIntranets.providedBy(obj):
        return None
    return obj.title
Beispiel #4
0
def collect_community_metrics(context, year, month):
    created = {}
    total = {}
    search = ICatalogSearch(context)
    begin, end = date_range(year, month)

    def make_type_counter(community):
        path = model_path(community)

        def count(content_type, creation_date):
            n, _, _ = search(path=path,
                             interfaces=[content_type],
                             creation_date=creation_date)
            return n

        def count_type(content_type):
            return (count(content_type,
                          (begin, end)), count(content_type, (None, end)))

        return count_type

    _, docids, resolver = search(interfaces=[ICommunity],
                                 creation_date=(None, end))
    for community in (resolver(docid) for docid in docids):

        if IIntranets.providedBy(community) or IIntranet.providedBy(community):
            # the offices container and the offices themselves provide
            # the ICommunity interface. we want to filter those out
            # from this list.
            continue

        communityid = community.__name__
        count_type = make_type_counter(community)

        # count created/totals (_c, _t suffix) for content types
        wikis_c, wikis_t = count_type(IWikiPage)
        blogs_c, blogs_t = count_type(IBlogEntry)
        comments_c, comments_t = count_type(IComment)
        files_c, files_t = count_type(ICommunityFile)
        events_c, events_t = count_type(ICalendarEvent)

        created[communityid] = dict(
            title=community.title,
            members=len(community.member_names),
            moderators=len(community.moderator_names),
            created=community.created,
            security_state=community.security_state,
            last_activity=community.content_modified,
            wikis=wikis_c,
            blogs=blogs_c,
            comments=comments_c,
            files=files_c,
            events=events_c,
            total=wikis_c + blogs_c + comments_c + files_c + events_c,
        )

        total[communityid] = dict(
            title=community.title,
            members=len(community.member_names),
            moderators=len(community.moderator_names),
            created=community.created,
            security_state=community.security_state,
            last_activity=community.content_modified,
            wikis=wikis_t,
            blogs=blogs_t,
            comments=comments_t,
            files=files_t,
            events=events_t,
            total=wikis_t + blogs_t + comments_t + files_t + events_t,
        )

    return dict(created=created, total=total)