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
7f23cb75
Commit
7f23cb75
authored
May 31, 2017
by
Vasyl Bodnaruk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added functional for autocomplete for edit view
parent
c88860f3
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
50 additions
and
19 deletions
+50
-19
edit_news.html
esi/templates/edit_news.html
+9
-9
autocomplete.py
esi/webapp/autocomplete.py
+29
-0
news.py
esi/webapp/models/news.py
+7
-0
urls.py
esi/webapp/urls.py
+5
-2
views.py
esi/webapp/views.py
+0
-8
No files found.
esi/templates/edit_news.html
View file @
7f23cb75
...
...
@@ -61,9 +61,8 @@
<div
class=
"col-6"
>
<input
type=
"text"
multiple
id=
"radar"
data-url=
"{% url '
radar' news.id
%}"
data-url=
"{% url '
auto' slug='radar'
%}"
data-load-once=
"true"
class=
"multiselect"
name=
"radar"
/>
...
...
@@ -78,7 +77,7 @@
type=
"text"
id=
"industry"
class=
"multiselect"
data-url=
"
json/industry.json
"
data-url=
"
{% url 'auto' slug='industry' %}
"
data-load-once=
"true"
name=
"industry"
/>
</div>
...
...
@@ -92,7 +91,7 @@
type=
"text"
id=
"function"
class=
"multiselect"
data-url=
"
json/function.json
"
data-url=
"
{% url 'auto' slug='function' %}
"
data-load-once=
"true"
name=
"function"
/>
</div>
...
...
@@ -108,7 +107,7 @@
type=
"text"
id=
"media"
class=
"multiselect"
data-url=
"
json/media.json
"
data-url=
"
{% url 'auto' slug='media' %}
"
data-load-once=
"true"
name=
"media"
/>
</div>
...
...
@@ -127,7 +126,7 @@
type=
"text"
id=
"technology"
class=
"multiselect"
data-url=
"
json/technology.json
"
data-url=
"
{% url 'auto' slug='technology' %}
"
data-load-once=
"true"
name=
"technology"
/>
</div>
...
...
@@ -141,7 +140,7 @@
type=
"text"
id=
"type"
class=
"multiselect"
data-url=
"
json/type.json
"
data-url=
"
{% url 'auto' slug='type' %}
"
data-load-once=
"true"
name=
"type"
/>
</div>
...
...
@@ -155,7 +154,7 @@
type=
"text"
id=
"region"
class=
"multiselect"
data-url=
"
json/region.json
"
data-url=
"
{% url 'auto' slug='region' %}
"
data-load-once=
"true"
name=
"region"
/>
</div>
...
...
@@ -179,7 +178,8 @@
multiple
id=
"tag"
class=
"multiselect"
data-url=
"json/tags.json"
data-initial-value=
'[{"text": "Algeria", "value" : "Algeria"}, {"text": "Angola", "value" : "Angola"}]'
data-url=
"{% url 'auto' slug='tags' %}"
data-load-once=
"true"
name=
"tags"
/>
</div>
...
...
esi/webapp/autocomplete.py
0 → 100644
View file @
7f23cb75
import
json
from
django.http
import
JsonResponse
from
.models
import
WpEsiRadar
,
WpEsiIndustry
,
WpEsiFunction
,
WpEsiMedia
,
WpEsiTechnology
,
WpEsiType
,
WpEsiRegion
,
\
WpEsiTag
def
auto
(
request
,
slug
):
print
(
slug
)
if
slug
==
'radar'
:
return
select
(
WpEsiRadar
)
if
slug
==
'industry'
:
return
select
(
WpEsiIndustry
)
if
slug
==
'function'
:
return
select
(
WpEsiFunction
)
if
slug
==
'media'
:
return
select
(
WpEsiMedia
)
if
slug
==
'technology'
:
return
select
(
WpEsiTechnology
)
if
slug
==
'type'
:
return
select
(
WpEsiType
)
if
slug
==
'region'
:
return
select
(
WpEsiRegion
)
if
slug
==
'tags'
:
return
select
(
WpEsiTag
)
def
select
(
obj
):
d
=
[{
'text'
:
i
.
name
,
'value'
:
i
.
id
}
for
i
in
obj
.
objects
.
all
()]
return
JsonResponse
(
d
,
safe
=
False
)
\ No newline at end of file
esi/webapp/models/news.py
View file @
7f23cb75
from
django.db
import
models
from
.wp
import
WpEsiMedia
,
WpEsiEntity
,
WpEsiType
,
WpEsiRegion
,
WpEsiNewsEntity
,
WpEsiNews
class
News
(
models
.
Model
):
title
=
models
.
CharField
(
max_length
=
255
)
...
...
@@ -16,6 +17,12 @@ class News(models.Model):
company_id
=
models
.
BigIntegerField
()
is_accepted
=
models
.
BooleanField
(
default
=
False
)
radar_id
=
models
.
BigIntegerField
(
default
=
None
,
null
=
True
,
blank
=
True
)
industry_id
=
models
.
BigIntegerField
(
default
=
None
,
null
=
True
,
blank
=
True
)
function_id
=
models
.
BigIntegerField
(
default
=
None
,
null
=
True
,
blank
=
True
)
technology_id
=
models
.
BigIntegerField
(
default
=
None
,
null
=
True
,
blank
=
True
)
tags_id
=
models
.
CharField
(
max_length
=
255
,
default
=
None
,
null
=
True
,
blank
=
True
)
class
Meta
:
db_table
=
'wp_esi_news_accept'
...
...
esi/webapp/urls.py
View file @
7f23cb75
from
django.conf.urls
import
url
from
.views
import
ListNewsView
,
EditNewsView
,
ViewNewsView
,
radar
from
.views
import
ListNewsView
,
EditNewsView
,
ViewNewsView
from
.autocomplete
import
*
urlpatterns
=
[
url
(
r'^$'
,
ListNewsView
.
as_view
(),
name
=
'list_news'
),
url
(
r'^(?P<id>[0-9]+)$'
,
EditNewsView
.
as_view
(),
name
=
'edit_news'
),
url
(
r'^view/(?P<id>[0-9]+)$'
,
ViewNewsView
.
as_view
(),
name
=
'view_news'
),
url
(
r'^
radar/(?P<id>[0-9]+)$'
,
radar
,
name
=
'radar
'
)
url
(
r'^
auto/(?P<slug>\w+)$'
,
auto
,
name
=
'auto
'
)
]
\ No newline at end of file
esi/webapp/views.py
View file @
7f23cb75
...
...
@@ -104,11 +104,3 @@ class ViewNewsView(DetailView):
news
.
export_news
()
return
HttpResponseRedirect
(
reverse
(
'view_news'
,
kwargs
=
{
'id'
:
export_news
}))
def
radar
(
request
,
id
):
d
=
[{
"text"
:
"Algeria"
,
"value"
:
"Algeria"
},
{
"text"
:
"Angola"
,
"value"
:
"Angola"
},
{
"text"
:
"Angola"
,
"value"
:
"as"
},
{
"text"
:
"Angola"
,
"value"
:
"dsda"
},
{
"text"
:
"Angola"
,
"value"
:
"aasdadsd"
}]
return
JsonResponse
(
d
,
safe
=
False
)
\ No newline at end of file
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