Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
La Quadrature du Net
rpteam
Revue de Press
Commits
de047352
Commit
de047352
authored
Jul 04, 2019
by
Okhin
Browse files
Fixing the Factory for tags
parent
80cd52d3
Changes
3
Hide whitespace changes
Inline
Side-by-side
apps/rp/factories.py
View file @
de047352
import
datetime
import
datetime
from
random
import
choice
from
random
import
choice
,
randint
import
pytz
import
pytz
import
factory
import
factory
from
factory.fuzzy
import
FuzzyDateTime
,
FuzzyChoice
from
factory.fuzzy
import
FuzzyDateTime
,
FuzzyChoice
from
taggit.models
import
Tag
from
.models
import
Article
,
STATUS_CHOICES
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
ArticleFactory
(
factory
.
django
.
DjangoModelFactory
):
class
Meta
:
class
Meta
:
model
=
Article
model
=
Article
...
...
apps/rp/models.py
View file @
de047352
from
django.db
import
models
from
django.db
import
models
from
django.utils.translation
import
ugettext_lazy
as
_
from
django.utils.translation
import
ugettext_lazy
as
_
from
django.core
import
files
from
django.core
import
files
from
django.contrib.auth.decorators
import
permission_required
from
taggit.managers
import
TaggableManager
from
taggit.managers
import
TaggableManager
from
newspaper
import
Article
as
ArticleParser
,
ArticleException
from
newspaper
import
Article
as
ArticleParser
,
ArticleException
...
@@ -104,7 +103,7 @@ class Article(models.Model):
...
@@ -104,7 +103,7 @@ class Article(models.Model):
#: If the article is quoting something LQDN said or wrote
#: If the article is quoting something LQDN said or wrote
quote
=
models
.
BooleanField
(
_
(
"Article directly quotes us"
),
quote
=
models
.
BooleanField
(
_
(
"Article directly quotes us"
),
default
=
False
)
default
=
False
)
#: If the article speaks about something LQDN did or wrote
#: If the article speaks about something LQDN did or wrote
speak
=
models
.
BooleanField
(
_
(
"Article speaks of us"
),
default
=
False
)
speak
=
models
.
BooleanField
(
_
(
"Article speaks of us"
),
default
=
False
)
...
@@ -239,7 +238,8 @@ class Article(models.Model):
...
@@ -239,7 +238,8 @@ class Article(models.Model):
# Let's add the tags
# Let's add the tags
if
tags
:
if
tags
:
article
.
tags
.
add
(
','
.
join
([
t
[
'name'
]
for
t
in
tags
if
len
(
t
)
>
0
]))
article
.
tags
.
set
(
*
tags
)
article
.
save
()
try
:
try
:
r
=
requests
.
get
(
url
,
timeout
=
0.5
)
r
=
requests
.
get
(
url
,
timeout
=
0.5
)
article
.
original_status
=
r
.
status_code
article
.
original_status
=
r
.
status_code
...
...
project/settings/apps.py
View file @
de047352
...
@@ -20,6 +20,7 @@ CONTRIB_APPS = [
...
@@ -20,6 +20,7 @@ CONTRIB_APPS = [
"rest_framework.authtoken"
,
"rest_framework.authtoken"
,
"taggit"
,
"taggit"
,
"taggit_serializer"
,
"crispy_forms"
,
"crispy_forms"
,
"django_markdown2"
,
"django_markdown2"
,
"sorl.thumbnail"
,
"sorl.thumbnail"
,
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment