Commit de047352 authored by okhin's avatar okhin 🚴

Fixing the Factory for tags

parent 80cd52d3
import datetime
from random import choice
from random import choice, randint
import pytz
import factory
from factory.fuzzy import FuzzyDateTime, FuzzyChoice
from taggit.models import Tag
from .models import Article, STATUS_CHOICES
class TagFactory(factory.django.DjangoModelFactory):
class Meta:
model = Tag
name = factory.Faker("word")
class ArticleFactory(factory.django.DjangoModelFactory):
class Meta:
model = Article
......
from django.db import models
from django.utils.translation import ugettext_lazy as _
from django.core import files
from django.contrib.auth.decorators import permission_required
from taggit.managers import TaggableManager
from newspaper import Article as ArticleParser, ArticleException
......@@ -104,7 +103,7 @@ class Article(models.Model):
#: If the article is quoting something LQDN said or wrote
quote = models.BooleanField(_("Article directly quotes us"),
default=False)
default=False)
#: If the article speaks about something LQDN did or wrote
speak = models.BooleanField(_("Article speaks of us"), default=False)
......@@ -239,7 +238,8 @@ class Article(models.Model):
# Let's add the tags
if tags:
article.tags.add(','.join([t['name'] for t in tags if len(t) > 0]))
article.tags.set(*tags)
article.save()
try:
r = requests.get(url, timeout=0.5)
article.original_status = r.status_code
......
......@@ -20,6 +20,7 @@ CONTRIB_APPS = [
"rest_framework.authtoken",
"taggit",
"taggit_serializer",
"crispy_forms",
"django_markdown2",
"sorl.thumbnail",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment