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
piphone
campaign
Commits
c3984fb3
Commit
c3984fb3
authored
Sep 05, 2017
by
Okhin
Browse files
Let's try to guess the file kind
parent
e4250010
Pipeline
#1238
failed with stage
in 3 seconds
Changes
2
Pipelines
2
Show whitespace changes
Inline
Side-by-side
picampaign/importer/models.py
View file @
c3984fb3
...
...
@@ -31,10 +31,10 @@ class Importer(models.Model):
def
kind
(
self
):
if
self
.
url
is
None
and
self
.
file
.
name
is
None
:
return
None
if
self
.
url
is
not
''
and
self
.
url
is
not
None
:
return
'url'
else
:
if
self
.
file
.
name
is
not
None
:
return
'file'
else
:
return
'url'
def
representative
(
self
,
import_data
):
"""
...
...
picampaign/importer/tests.py
View file @
c3984fb3
...
...
@@ -134,6 +134,7 @@ class ImporterTest(TestCase):
importer
.
file
=
'a'
importer
.
url
=
''
self
.
assertEqual
(
importer
.
kind
(),
'file'
)
importer
.
file
=
None
importer
.
url
=
'http://www.example.com/'
self
.
assertEqual
(
importer
.
kind
(),
'url'
)
...
...
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