Пример #1
0
def contents_stats(context, username=None, expanded=1):
    basecontents = get_contents(username, expanded)
    contents = [content for content in basecontents if not isinstance(content[0].get_real_instance(), BaseSection)]
    sections = [content for content in basecontents if isinstance(content[0].get_real_instance(), BaseSection)]
    return {'contents': contents,
            'sections': sections,
            'request': context.get('request')}
Пример #2
0
def contents_stats(context, user=None, expanded=1):
    basecontents = get_contents(user, expanded)
    contents = []
    sections = []
    section_classes = [BaseSection] + BaseSection.get_subclasses()
    section_class_names = [section_class._meta.module_name for section_class in section_classes]
    message = None
    if isinstance(basecontents, list):
        for content, visit in basecontents:
            if content.class_name in section_class_names:
                sections.append((content, visit))
            else:
                contents.append((content, visit))
    elif isinstance(basecontents, dict) and basecontents["result"] == "error":
        message = basecontents.get("message", basecontents["result"])
    return {"contents": contents, "sections": sections, "message": message, "request": context.get("request")}
Пример #3
0
def contents_stats(context, user=None, expanded=1):
    basecontents = get_contents(user, expanded)
    contents = []
    sections = []
    section_classes = [BaseSection] + BaseSection.get_subclasses()
    section_class_names = [
        section_class._meta.module_name for section_class in section_classes
    ]
    message = None
    if isinstance(basecontents, list):
        for content, visit in basecontents:
            if content.class_name in section_class_names:
                sections.append((content, visit))
            else:
                contents.append((content, visit))
    elif isinstance(basecontents, dict) and basecontents['result'] == 'error':
        message = basecontents.get('message', basecontents['result'])
    return {
        'contents': contents,
        'sections': sections,
        'message': message,
        'request': context.get('request')
    }