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
995e297b
Commit
995e297b
authored
Jun 15, 2017
by
Vasyl Bodnaruk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add base view for new job
parent
e6410551
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
45 additions
and
19 deletions
+45
-19
service.py
esi/scraper/service.py
+11
-9
urls.py
esi/scraper/urls.py
+4
-2
views.py
esi/scraper/views.py
+19
-7
job_list.html
esi/templates/job_list.html
+6
-1
new_job.html
esi/templates/new_job.html
+5
-0
No files found.
esi/scraper/service.py
View file @
995e297b
...
...
@@ -4,6 +4,7 @@ from .models import Spider, Job
class
Service
:
def
update_jobs_status
(
self
,
jobs
):
try
:
finished
=
jobs
.
get
(
'finished'
)
if
finished
:
for
i
in
finished
:
...
...
@@ -12,4 +13,5 @@ class Service:
if
running
:
for
i
in
running
:
Job
.
objects
.
get
(
job_id
=
i
[
'id'
])
.
update
(
status
=
'RUN'
)
except
:
pass
esi/scraper/urls.py
View file @
995e297b
from
django.conf.urls
import
url
from
.views
import
JobListView
from
.views
import
JobListView
,
NewJobCreateView
urlpatterns
=
[
url
(
''
,
JobListView
.
as_view
(),
name
=
'job_list'
)
url
(
'^new$'
,
NewJobCreateView
.
as_view
(),
name
=
'new_job'
),
url
(
''
,
JobListView
.
as_view
(),
name
=
'job_list'
),
]
\ No newline at end of file
esi/scraper/views.py
View file @
995e297b
from
urllib.request
import
urlopen
,
Request
from
django.shortcuts
import
render
from
django.views.generic
import
ListView
from
django.shortcuts
import
render
,
HttpResponseRedirect
,
reverse
from
django.views.generic
import
ListView
,
CreateView
from
scrapyd_api
import
ScrapydAPI
from
.models
import
Spider
,
Job
...
...
@@ -17,10 +16,6 @@ class JobListView(ListView):
super
(
JobListView
,
self
)
.
__init__
()
def
get
(
self
,
request
,
*
args
,
**
kwargs
):
jobs
=
self
.
client
.
list_jobs
(
'exa'
)
print
(
jobs
)
self
.
service
.
update_jobs_status
(
jobs
)
jobs
=
{
'deleted'
:
Job
.
objects
.
deleted
(),
'running'
:
Job
.
objects
.
running
(),
...
...
@@ -37,4 +32,21 @@ class JobListView(ListView):
pass
if
action
==
'cancel'
:
pass
if
action
==
'update'
:
jobs
=
self
.
client
.
list_jobs
(
'exa'
)
self
.
service
.
update_jobs_status
(
jobs
)
if
action
==
'new'
:
return
HttpResponseRedirect
(
reverse
(
'new_job'
))
return
HttpResponseRedirect
(
reverse
(
'job_list'
))
class
NewJobCreateView
(
CreateView
):
template_name
=
'new_job.html'
def
get
(
self
,
request
,
*
args
,
**
kwargs
):
return
render
(
request
,
self
.
template_name
)
def
post
(
self
,
request
,
*
args
,
**
kwargs
):
pass
esi/templates/job_list.html
View file @
995e297b
{% extends 'base.html' %}
{% block content %}
{{ jobs }}
<form
name=
"jobs"
method=
"post"
>
{% csrf_token %}
<button
name=
"action"
value=
"new"
>
New job
</button>
<button
name=
"action"
value=
"update"
>
Update
</button>
<button
name=
"action"
value=
"cancel"
>
Cancel
</button>
</form>
{% endblock %}
\ No newline at end of file
esi/templates/new_job.html
0 → 100644
View file @
995e297b
{% extends 'base.html' %}
{% block content %}
new job
{% endblock %}
\ 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