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
154e9605
Commit
154e9605
authored
Jun 07, 2017
by
Vasyl Bodnaruk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add multiple choice to edit view
parent
89a110c5
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
41 additions
and
16 deletions
+41
-16
edit_news.html
esi/templates/edit_news.html
+9
-6
list_news.html
esi/templates/list_news.html
+1
-1
forms.py
esi/webapp/forms.py
+7
-3
news.py
esi/webapp/models/news.py
+24
-6
No files found.
esi/templates/edit_news.html
View file @
154e9605
...
@@ -81,8 +81,9 @@
...
@@ -81,8 +81,9 @@
type=
"text"
type=
"text"
id=
"industry"
id=
"industry"
class=
"multiselect"
class=
"multiselect"
{%
if
news
.
get_industry
%}
multiple
data-initial-value=
'[{"text": "{{ news.get_industry }}", "value" : "{{ news.get_industry.id }}"}]'
{%
if
news
.
get_industry_json
%}
data-initial-value=
'{{ news.get_industry_json }}'
{%
endif
%}
{%
endif
%}
data-url=
"{% url 'auto' slug='industry' %}"
data-url=
"{% url 'auto' slug='industry' %}"
data-load-once=
"true"
data-load-once=
"true"
...
@@ -98,8 +99,9 @@
...
@@ -98,8 +99,9 @@
type=
"text"
type=
"text"
id=
"function"
id=
"function"
class=
"multiselect"
class=
"multiselect"
{%
if
news
.
get_function
%}
multiple
data-initial-value=
'[{"text": "{{ news.get_function }}", "value" : "{{ news.get_function.id }}"}]'
{%
if
news
.
get_function_json
%}
data-initial-value=
'{{ news.get_function_json }}'
{%
endif
%}
{%
endif
%}
data-url=
"{% url 'auto' slug='function' %}"
data-url=
"{% url 'auto' slug='function' %}"
data-load-once=
"true"
data-load-once=
"true"
...
@@ -139,8 +141,9 @@
...
@@ -139,8 +141,9 @@
type=
"text"
type=
"text"
id=
"technology"
id=
"technology"
class=
"multiselect"
class=
"multiselect"
{%
if
news
.
get_technology
%}
multiple
data-initial-value=
'[{"text": "{{ news.get_technology }}", "value" : "{{ news.get_technology.id }}"}]'
{%
if
news
.
get_technology_json
%}
data-initial-value=
'{{ news.get_technology_json }}'
{%
endif
%}
{%
endif
%}
data-url=
"{% url 'auto' slug='technology' %}"
data-url=
"{% url 'auto' slug='technology' %}"
data-load-once=
"true"
data-load-once=
"true"
...
...
esi/templates/list_news.html
View file @
154e9605
...
@@ -45,7 +45,7 @@
...
@@ -45,7 +45,7 @@
{% paginate news %}
{% paginate news %}
{{ request.get_full_path }}
<form
class=
"form"
>
<form
class=
"form"
>
<table
class=
"table table-hover"
>
<table
class=
"table table-hover"
>
<thead
class=
"thead-inverse"
>
<thead
class=
"thead-inverse"
>
...
...
esi/webapp/forms.py
View file @
154e9605
...
@@ -10,6 +10,7 @@ class NewsForm(forms.Form):
...
@@ -10,6 +10,7 @@ class NewsForm(forms.Form):
news
=
News
.
objects
.
get
(
pk
=
self
.
data
[
'news_id'
])
news
=
News
.
objects
.
get
(
pk
=
self
.
data
[
'news_id'
])
news
=
self
.
_make
(
news
)
news
=
self
.
_make
(
news
)
news
.
save
()
news
.
save
()
print
(
news
.
technology_id
)
def
create
(
self
):
def
create
(
self
):
news
=
News
()
news
=
News
()
...
@@ -28,13 +29,15 @@ class NewsForm(forms.Form):
...
@@ -28,13 +29,15 @@ class NewsForm(forms.Form):
if
self
.
data
[
'radar'
]:
if
self
.
data
[
'radar'
]:
news
.
radar_id
=
self
.
data
[
'radar'
]
news
.
radar_id
=
self
.
data
[
'radar'
]
if
self
.
data
[
'industry'
]:
if
self
.
data
[
'industry'
]:
news
.
industry_id
=
self
.
data
[
'industry'
]
print
(
'fdgdfgdfg'
,
self
.
data
[
'industry'
])
news
.
industry_id
=
[
int
(
i
)
for
i
in
self
.
data
[
'industry'
]
.
split
(
','
)]
if
self
.
data
[
'function'
]:
if
self
.
data
[
'function'
]:
news
.
function_id
=
self
.
data
[
'function'
]
news
.
function_id
=
[
int
(
i
)
for
i
in
self
.
data
[
'function'
]
.
split
(
','
)
]
if
self
.
data
[
'media'
]:
if
self
.
data
[
'media'
]:
news
.
media_id
=
self
.
data
[
'media'
]
news
.
media_id
=
self
.
data
[
'media'
]
if
self
.
data
[
'technology'
]:
if
self
.
data
[
'technology'
]:
news
.
technology_id
=
self
.
data
[
'technology'
]
news
.
technology_id
=
[
int
(
i
)
for
i
in
self
.
data
[
'technology'
]
.
split
(
','
)]
print
(
news
.
technology_id
)
if
self
.
data
[
'type'
]:
if
self
.
data
[
'type'
]:
news
.
type_id
=
self
.
data
[
'type'
]
news
.
type_id
=
self
.
data
[
'type'
]
if
self
.
data
[
'region'
]:
if
self
.
data
[
'region'
]:
...
@@ -43,6 +46,7 @@ class NewsForm(forms.Form):
...
@@ -43,6 +46,7 @@ class NewsForm(forms.Form):
news
.
publish_date
=
datetime
.
strptime
(
self
.
data
[
'date'
],
'
%
Y-
%
m-
%
d'
)
news
.
publish_date
=
datetime
.
strptime
(
self
.
data
[
'date'
],
'
%
Y-
%
m-
%
d'
)
if
self
.
data
[
'tags'
]:
if
self
.
data
[
'tags'
]:
print
(
self
.
data
[
'tags'
])
news
.
tags_id
=
[
int
(
i
)
for
i
in
self
.
data
[
'tags'
]
.
split
(
','
)]
news
.
tags_id
=
[
int
(
i
)
for
i
in
self
.
data
[
'tags'
]
.
split
(
','
)]
return
news
return
news
esi/webapp/models/news.py
View file @
154e9605
...
@@ -21,9 +21,9 @@ class News(models.Model):
...
@@ -21,9 +21,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
.
BigIntegerField
(
default
=
None
,
null
=
True
,
blank
=
True
)
industry_id
=
models
.
CharField
(
max_length
=
255
,
default
=
None
,
null
=
True
,
blank
=
True
)
function_id
=
models
.
BigIntegerField
(
default
=
None
,
null
=
True
,
blank
=
True
)
function_id
=
models
.
CharField
(
max_length
=
255
,
default
=
None
,
null
=
True
,
blank
=
True
)
technology_id
=
models
.
BigIntegerField
(
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
:
...
@@ -49,17 +49,35 @@ class News(models.Model):
...
@@ -49,17 +49,35 @@ class News(models.Model):
def
get_technology
(
self
):
def
get_technology
(
self
):
if
self
.
technology_id
:
if
self
.
technology_id
:
return
WpEsiTechnology
.
objects
.
get
(
id
=
self
.
technology_id
)
return
WpEsiTechnology
.
objects
.
filter
(
id__in
=
json
.
loads
(
self
.
technology_id
))
return
None
def
get_technology_json
(
self
):
tech
=
self
.
get_technology
()
if
tech
:
return
json
.
dumps
([{
'text'
:
i
.
name
,
'value'
:
i
.
id
}
for
i
in
tech
])
return
None
return
None
def
get_function
(
self
):
def
get_function
(
self
):
if
self
.
function_id
:
if
self
.
function_id
:
return
WpEsiFunction
.
objects
.
get
(
id
=
self
.
function_id
)
return
WpEsiFunction
.
objects
.
filter
(
id__in
=
json
.
loads
(
self
.
function_id
))
return
None
def
get_function_json
(
self
):
func
=
self
.
get_function
()
if
func
:
return
json
.
dumps
([{
'text'
:
i
.
name
,
'value'
:
i
.
id
}
for
i
in
func
])
return
None
return
None
def
get_industry
(
self
):
def
get_industry
(
self
):
if
self
.
industry_id
:
if
self
.
industry_id
:
return
WpEsiIndustry
.
objects
.
get
(
id
=
self
.
industry_id
)
return
WpEsiIndustry
.
objects
.
filter
(
id__in
=
json
.
loads
(
self
.
industry_id
))
return
None
def
get_industry_json
(
self
):
ind
=
self
.
get_industry
()
if
ind
:
return
json
.
dumps
([{
'text'
:
i
.
name
,
'value'
:
i
.
id
}
for
i
in
ind
])
return
None
return
None
def
get_radar
(
self
):
def
get_radar
(
self
):
...
...
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