예제 #1
0
def show_community_view(context, request):
    assert ICommunity.providedBy(context), str(type(context))

    user = authenticated_userid(request)
    page_title = _(u'View Community ${title}',
                    mapping={'title': context.title})
    api = TemplateAPI(context, request, page_title)

    # provide client data for rendering current tags in the tagbox
    tagquery = getMultiAdapter((context, request), ITagQuery)
    client_json_data = {'tagbox': {'docid': tagquery.docid,
                                   'records': tagquery.tagswithcounts,
                                  },
                       }

    # Filter the actions based on permission
    actions = []
    if has_permission(MODERATE, context, request):
        actions.append((_(u'Edit'), 'edit.html'))

    # If user has permission to see this view then has permission to join.
    if not(user in context.member_names or user in context.moderator_names):
        actions.append((_(u'Join'), 'join.html'))

    if has_permission(DELETE_COMMUNITY, context, request):
        actions.append((_(u'Delete'), 'delete.html'))

    if has_permission(ADMINISTER, context, request):
        actions.append((_(u'Advanced'), 'advanced.html'))

    recent_items = []
    recent_items_batch = get_recent_items_batch(context, request)
    for item in recent_items_batch["entries"]:
        adapted = getMultiAdapter((item, request), IGridEntryInfo)
        recent_items.append(adapted)

    feed_url = resource_url(context, request, "atom.xml")

    return {'api': api,
            'actions': actions,
            'recent_items': recent_items,
            'batch_info': recent_items_batch,
            'head_data': convert_to_script(client_json_data),
            'feed_url': feed_url,
           }
예제 #2
0
 def _entry_models(self):
     batch = get_recent_items_batch(self.context, self.request, size=20)
     return batch["entries"]
예제 #3
0
파일: atom.py 프로젝트: lslaz1/karl
 def _entry_models(self):
     batch = get_recent_items_batch(self.context, self.request, size=20)
     return batch["entries"]