예제 #1
0
def save_item(item):
    if not item or item.get('link') is None:
        return

    time = datetime.datetime.now() + datetime.timedelta(days=-14)
    assert 'title' in item
    assert 'resource' in item
    assert 'link' in item

    if not Item.objects.filter(link=item.get('link'),
                               related_to_date__gt=time).exists():

        _a = Item(
            title=item.get('title'),
            resource=item.get('resource'),
            link=item.get('link'),
            description=item.get('description', ''),
            status=item.get('status', 'autoimport'),
            user_id=settings.BOT_USER_ID,
            section=item.get('section', None),
            additionally=item.get('additionally', None),
            language=item.get('language') if item.get('language') else 'en')

        _a.save()

        if item.get('tags'):
            _a.tags.add(*item.get('tags'))
            _a.save()
        elif item.get('status') == 'active':
            _a.save()
예제 #2
0
def save_item(item):
    assert 'title' in item
    assert 'resource' in item
    assert 'link' in item

    if not Item.objects.filter(title=item.get('title'),
                               link=item.get('link'),
                               description=item.get('description')).exists():
        _a = Item(
            title=item.get('title'),
            resource=item.get('resource'),
            link=item.get('link'),
            description=item.get('description', ''),
            status=item.get('status', 'autoimport'),
            user_id=settings.BOT_USER_ID,
            section=item.get('section', None),
            additionally=item.get('additionally', None),
            language=item.get('language') if item.get('language') else 'en')

        _a.save()

        if item.get('tags'):
            _a.tags.add(*item.get('tags'))
            _a.save()
        elif item.get('status') == 'active':
            _a.save()
예제 #3
0
def save_item(item):
    assert 'title' in item
    assert 'resource' in item
    assert 'link' in item

    if not Item.objects.filter(title=item.get('title'),
                               link=item.get('link'),
                               description=item.get('description')).exists():
        _a = Item(
            title=item.get('title'),
            resource=item.get('resource'),
            link=item.get('link'),
            description=item.get('description', ''),
            status=item.get('status', 'autoimport'),
            user_id=settings.BOT_USER_ID,
            section=item.get('section', None),
            language=item.get('language') if item.get('language') else 'en')

        _a.save()

        if item.get('tags'):
            _a.tags.add(*item.get('tags'))
            _a.save()
        elif item.get('status') == 'active':
            _a.save()
예제 #4
0
def save_item(item):
    if not item or item.get('link') is None:
        return

    time = datetime.datetime.now() + datetime.timedelta(days=-14)
    assert 'title' in item
    assert 'resource' in item
    assert 'link' in item

    if not Item.objects.filter(link=item.get('link'),
                               related_to_date__gt=time).exists():

        _a = Item(
            title=item.get('title'),
            resource=item.get('resource'),
            link=item.get('link'),
            description=item.get('description', ''),
            status=item.get('status', 'autoimport'),
            user_id=settings.BOT_USER_ID,
            section=item.get('section', None),
            additionally=item.get('additionally', None),
            language=item.get('language') if item.get('language') else 'en')

        _a.save()

        if item.get('tags'):
            _a.tags.add(*item.get('tags'))
            _a.save()
        elif item.get('status') == 'active':
            _a.save()
예제 #5
0
def save_item(item):
    if not item or item.get("link") is None:
        return

    time = datetime.datetime.now() + datetime.timedelta(days=-14)
    assert "title" in item
    assert "resource" in item
    assert "link" in item

    if not Item.objects.filter(link=item.get("link"), related_to_date__gt=time).exists():

        _a = Item(
            title=item.get("title"),
            resource=item.get("resource"),
            link=item.get("link"),
            description=item.get("description", ""),
            status=item.get("status", "autoimport"),
            user_id=settings.BOT_USER_ID,
            section=item.get("section", None),
            additionally=item.get("additionally", None),
            language=item.get("language") if item.get("language") else "en",
        )

        _a.save()

        if item.get("tags"):
            _a.tags.add(*item.get("tags"))
            _a.save()
        elif item.get("status") == "active":
            _a.save()