How to use the dispatch.apps.content.models.Article.objects.get function in dispatch

To help you get started, we’ve selected a few dispatch examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ubyssey / dispatch / dispatch / modules / auth / actions.py View on Github external
actions = Action.objects.all().order_by('-timestamp')[:count]

    results = []
    count = 0

    for n, action in enumerate(actions):
        count += 1

        if n < len(actions) - 1:
            next_action = actions[n+1]
            if action.person == next_action.person and action.object_type == next_action.object_type and action.object_id == next_action.object_id and action.action == next_action.action:
                continue

        if action.object_type == 'article':
            try:
                article = Article.objects.get(parent_id=action.object_id, head=True)
                meta = {
                    'id': action.object_id,
                    'author': action.person.full_name,
                    'headline': article.headline,
                    'count': count,
                    'action': SINGULAR[action.action] if count == 1 else PLURAL[action.action],
                }
            except:
                continue

            results.append({
                'icon': ICONS[action.action],
                'meta': meta,
                'timestamp': action.timestamp
            })