Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
E
esi-table-data
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
esi-data-scrapping
esi-table-data
Commits
01c40a7b
Commit
01c40a7b
authored
Jul 11, 2017
by
Vasyl Bodnaruk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add export news with tag, technology, industry if exist
parent
5aa75670
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
5 deletions
+25
-5
news.py
esi/webapp/models/news.py
+25
-5
No files found.
esi/webapp/models/news.py
View file @
01c40a7b
import
json
import
json
from
datetime
import
datetime
from
datetime
import
datetime
from
django.db
import
models
from
django.db
import
models
# from esi.webapp.models.wp import WpEsiTagNews
from
.wp
import
WpEsiMedia
,
WpEsiEntity
,
WpEsiType
,
WpEsiRegion
,
WpEsiNewsEntity
,
WpEsiNews
,
WpEsiRadar
,
WpEsiIndustry
,
\
from
.wp
import
WpEsiMedia
,
WpEsiEntity
,
WpEsiType
,
WpEsiRegion
,
WpEsiNewsEntity
,
WpEsiNews
,
WpEsiRadar
,
WpEsiIndustry
,
\
WpEsiFunction
,
WpEsiTechnology
,
WpEsiTag
WpEsiFunction
,
WpEsiTechnology
,
WpEsiTag
,
WpEsiNewsFunction
,
WpEsiNewsIndustry
,
WpEsiNewsRadar
,
\
WpEsiTechnologyNews
,
WpEsiTagNews
class
News
(
models
.
Model
):
class
News
(
models
.
Model
):
title
=
models
.
CharField
(
max_length
=
255
,
default
=
None
,
null
=
True
,
blank
=
True
)
title
=
models
.
CharField
(
max_length
=
255
,
default
=
None
,
null
=
True
,
blank
=
True
)
url
=
models
.
TextField
(
max_length
=
2083
,
default
=
None
,
null
=
True
,
blank
=
True
)
url
=
models
.
TextField
(
max_length
=
2083
,
default
=
None
,
null
=
True
,
blank
=
True
)
description
=
models
.
TextField
(
default
=
None
,
null
=
True
,
blank
=
True
)
description
=
models
.
TextField
(
default
=
None
,
null
=
True
,
blank
=
True
)
...
@@ -21,9 +23,9 @@ class News(models.Model):
...
@@ -21,9 +23,9 @@ class News(models.Model):
is_accepted
=
models
.
BooleanField
(
default
=
False
)
is_accepted
=
models
.
BooleanField
(
default
=
False
)
radar_id
=
models
.
BigIntegerField
(
default
=
None
,
null
=
True
,
blank
=
True
)
radar_id
=
models
.
BigIntegerField
(
default
=
None
,
null
=
True
,
blank
=
True
)
industry_id
=
models
.
CharField
(
max_length
=
255
,
default
=
None
,
null
=
True
,
blank
=
True
)
industry_id
=
models
.
CharField
(
max_length
=
255
,
default
=
None
,
null
=
True
,
blank
=
True
)
function_id
=
models
.
CharField
(
max_length
=
255
,
default
=
None
,
null
=
True
,
blank
=
True
)
function_id
=
models
.
CharField
(
max_length
=
255
,
default
=
None
,
null
=
True
,
blank
=
True
)
technology_id
=
models
.
CharField
(
max_length
=
255
,
default
=
None
,
null
=
True
,
blank
=
True
)
technology_id
=
models
.
CharField
(
max_length
=
255
,
default
=
None
,
null
=
True
,
blank
=
True
)
tags_id
=
models
.
CharField
(
max_length
=
255
,
default
=
None
,
null
=
True
,
blank
=
True
)
tags_id
=
models
.
CharField
(
max_length
=
255
,
default
=
None
,
null
=
True
,
blank
=
True
)
class
Meta
:
class
Meta
:
...
@@ -115,3 +117,21 @@ class News(models.Model):
...
@@ -115,3 +117,21 @@ class News(models.Model):
)
)
self
.
is_accepted
=
True
self
.
is_accepted
=
True
self
.
save
()
self
.
save
()
if
self
.
radar_id
:
WpEsiNewsRadar
.
objects
.
create
(
news_id
=
esi
.
id
,
radar_id
=
self
.
radar_id
)
if
self
.
industry_id
:
industry
=
json
.
loads
(
self
.
industry_id
)
WpEsiNewsIndustry
.
objects
.
bulk_create
([
WpEsiNewsIndustry
(
news_id
=
esi
.
id
,
industry_id
=
i
)
for
i
in
industry
])
if
self
.
function_id
:
func
=
json
.
loads
(
self
.
function_id
)
WpEsiNewsFunction
.
objects
.
bulk_create
([
WpEsiNewsFunction
(
news_id
=
esi
.
id
,
function_id
=
i
)
for
i
in
func
])
if
self
.
technology_id
:
technology
=
json
.
loads
(
self
.
technology_id
)
WpEsiTechnologyNews
.
objects
.
bulk_create
(
WpEsiTechnologyNews
(
news_id
=
esi
.
id
,
technology_id
=
i
)
for
i
in
technology
)
if
self
.
tags_id
:
tags
=
json
.
loads
(
self
.
tags_id
)
WpEsiTagNews
.
objects
.
bulk_create
(
WpEsiTagNews
(
news_id
=
esi
.
id
,
tag_id
=
i
)
for
i
in
tags
)
Write
Preview
Markdown
is supported
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