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
54efae8a
Commit
54efae8a
authored
Jul 04, 2017
by
Vasyl Bodnaruk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added new template to edit job page
parent
730ea62f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
128 additions
and
39 deletions
+128
-39
views.py
esi/scraper/views.py
+1
-2
edit_job.html
esi/templates/edit_job.html
+127
-37
No files found.
esi/scraper/views.py
View file @
54efae8a
...
...
@@ -64,7 +64,6 @@ class NewJobCreateView(CreateView):
def
get
(
self
,
request
,
*
args
,
**
kwargs
):
spiders
=
Spider
.
objects
.
all
()
print
(
spiders
)
return
render
(
request
,
self
.
template_name
,
{
'spiders'
:
spiders
})
def
post
(
self
,
request
,
*
args
,
**
kwargs
):
...
...
@@ -82,7 +81,6 @@ class NewJobCreateView(CreateView):
}
job
.
schedule_job
=
make_periodic_task
(
job
.
id
,
data
)
job
.
save
()
print
(
request
.
POST
)
if
query
==
'j'
:
query
=
''
...
...
@@ -92,6 +90,7 @@ class NewJobCreateView(CreateView):
tp
=
date
[
-
3
:]
date
=
datetime
.
strptime
(
date
[:
-
3
],
"
%
m/
%
d/
%
Y
%
H:
%
M"
)
if
'PM'
in
tp
:
# TODO need make refactor, because here can be bug
h
=
date
.
hour
+
12
if
date
.
hour
<
12
else
0
return
date
.
replace
(
hour
=
h
)
return
date
...
...
esi/templates/edit_job.html
View file @
54efae8a
{% extends 'base.html' %}
{% load static %}
{% block style %}
<link
rel=
"stylesheet"
href=
"{% static 'css/bootstrap.css' %}"
>
<link
rel=
"stylesheet"
href=
"{% static 'css/datetime.css' %}"
>
<link
rel=
"stylesheet"
href=
"{% static 'css/font-awesome.min.css' %}"
>
{% endblock %}
{% block content %}
<main
class=
"pt-2 pb-5"
>
<div
class=
"container"
>
<form
class=
"form"
method=
"post"
>
{% csrf_token %}
<section
class=
"mb-5"
>
<h5
class=
"offset-1 display-5 mb-2"
>
Edit job
</h5>
<!-- Name -->
<main></main>
<div
class=
"container"
>
<h2
class=
"display-4"
>
Edit job
</h2>
<form
class=
"mb-5 mt-5"
method=
"post"
>
{% csrf_token %}
<!-- Name -->
<div
class=
"form-group row"
>
<label
for=
"name"
class=
"offset-1 col-2 col-form-label"
><strong>
Name:
</strong></label>
<div
class=
"col-6"
>
<input
class=
"form-control"
type=
"text"
placeholder=
"Name job..."
id=
"name"
name=
"name"
value=
"{{ job.name }}"
>
<input
type=
"hidden"
name=
"job"
value=
"{{ job.id }}"
>
</div>
</div>
<div
class=
"form-group row"
>
<label
for=
"spider"
class=
"offset-1 col-2 col-form-label"
>
Spider
</label>
<div
class=
"col-6"
>
<select
name=
"spider"
id=
"spider"
class=
"form-control"
>
<option
value=
"{{ job.spider.id }}"
>
{{ job.spider.name }}
</option>
{% for i in spiders %}
<option
value=
"{{ i.id }}"
>
{{ i.name }}
</option>
{% endfor %}
</select>
</div>
</div>
<div
class=
"form-group row"
>
<label
for=
"name"
class=
"offset-1 col-2 col-form-label"
><strong>
Date:
</strong></label>
<div
class=
"col-6"
>
<input
class=
"form-control"
type=
"text"
placeholder=
"Select date"
id=
"date"
name=
"date"
>
</div>
</div>
<div
class=
"form-group row"
>
<label
for=
"name"
class=
"offset-1 col-8 col-form-label"
><strong>
Interval:
</strong></label>
<div
class=
"offset-1 col-8 mt-4"
>
<div
class=
"form-group row"
>
<label
for=
"name"
class=
"offset-1 col-2 col-form-label"
>
Name
</label>
<div
class=
"col-6"
>
<input
class=
"form-control"
type=
"text"
id=
"name"
name=
"name"
value=
"{{ job.name }}"
>
<input
type=
"hidden"
name=
"job"
value=
"{{ job.id }}"
>
<div
class=
"col-md-3"
>
<label
class=
"custom-control custom-radio"
>
<input
id=
"radio1"
name=
"interval"
value=
"day"
type=
"radio"
class=
"custom-control-input"
>
<span
class=
"custom-control-indicator"
></span>
<span
class=
"custom-control-description"
>
Day
</span>
</label>
</div>
</div>
<div
class=
"form-group row"
>
<label
for=
"spider"
class=
"offset-1 col-2 col-form-label"
>
Spider
</label>
<div
class=
"col-6"
>
<select
name=
"spider"
id=
"spider"
class=
"form-control"
>
<option
value=
"{{ job.spider.id }}"
>
{{ job.spider.name }}
</option>
{% for i in spiders %}
<option
value=
"{{ i.id }}"
>
{{ i.name }}
</option>
{% endfor %}
</select>
<div
class=
"col-md-3"
>
<label
class=
"custom-control custom-radio"
>
<input
id=
"radio2"
name=
"interval"
value=
"week"
type=
"radio"
class=
"custom-control-input"
>
<span
class=
"custom-control-indicator"
></span>
<span
class=
"custom-control-description"
>
Week
</span>
</label>
</div>
<div
class=
"col-md-3"
>
<label
class=
"custom-control custom-radio"
>
<input
id=
"radio3"
name=
"interval"
value=
"month"
type=
"radio"
class=
"custom-control-input"
>
<span
class=
"custom-control-indicator"
></span>
<span
class=
"custom-control-description"
>
Month
</span>
</label>
</div>
<div
class=
"col-md-3"
>
<label
class=
"custom-control custom-radio"
>
<input
id=
"radio4"
name=
"interval"
value=
"finished"
type=
"radio"
class=
"custom-control-input"
>
<span
class=
"custom-control-indicator"
></span>
<span
class=
"custom-control-description"
>
After finish
</span>
</label>
</div>
</div>
<div
class=
"form-group row"
>
<label
for=
"name"
class=
"offset-1 col-2 col-form-label"
>
SQL query
</label>
<div
class=
"col-6"
>
<input
class=
"form-control"
type=
"text"
placeholder=
"Input query"
id=
"query"
name=
"query"
value=
"{{ job.query }}"
>
<div
class=
"offset-md-9 col-md-1"
>
<label
for=
"count"
class=
"col-form-label"
>
Every:
</label>
</div>
<div
class=
"col-md-2"
>
<input
class=
"form-control"
type=
"text"
placeholder=
"N"
id=
"count"
name=
"count"
>
</div>
</div>
</div>
</div>
<div
class=
"form-group row"
>
<div
class=
"offset-5 col-2"
>
<a
class=
"form-control btn btn-danger"
href=
"/job/"
>
Cancel
</a>
<div
class=
"form-group row"
>
<label
for=
"name"
class=
"offset-1 col-2 col-form-label"
>
SQL query
</label>
<div
class=
"col-6"
>
<input
class=
"form-control"
type=
"text"
placeholder=
"Input query"
id=
"query"
name=
"query"
value=
"{{ job.query }}"
>
</div>
</div>
</div>
<div
class=
"col-2 pull-right"
>
<button
type=
"submit"
class=
"form-control btn btn-primary"
>
Update
</button>
</div>
<div
class=
"form-group row"
>
<div
class=
"offset-5 col-2"
>
<button
type=
"submit"
class=
"form-control btn btn-primary"
>
Create
</button>
</div>
<div
class=
"col-2"
>
<a
class=
"form-control btn btn-danger"
href=
"/job/"
>
Cancel
</a>
</div>
</div>
</form>
</div>
<script
src=
"https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"
></script>
<script
src=
"https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment.min.js"
></script>
<script
src=
"{% static 'js/datetimepicker.js' %}"
></script>
<script>
$
(
'#date'
).
datetimepicker
();
$
(
'.custom-control'
).
on
(
'click'
,
function
()
{
var
input
=
$
(
this
).
find
(
'input'
);
if
(
input
.
prop
(
'id'
)
===
'radio4'
)
{
$
(
'#count'
).
val
(
''
).
prop
(
'disabled'
,
true
)
}
else
{
$
(
'#count'
).
val
(
''
).
prop
(
'disabled'
,
false
)
}
})
</div>
</section>
</form>
</div>
</main>
// Only numbers on count
$
(
"#count"
).
keydown
(
function
(
e
)
{
// Allow: backspace, delete, tab, escape, enter and .
if
(
$
.
inArray
(
e
.
keyCode
,
[
46
,
8
,
9
,
27
,
13
,
110
,
190
])
!==
-
1
||
// Allow: Ctrl+A, Command+A
(
e
.
keyCode
===
65
&&
(
e
.
ctrlKey
===
true
||
e
.
metaKey
===
true
))
||
// Allow: home, end, left, right, down, up
(
e
.
keyCode
>=
35
&&
e
.
keyCode
<=
40
))
{
// let it happen, don't do anything
return
;
}
// Ensure that it is a number and stop the keypress
if
((
e
.
shiftKey
||
(
e
.
keyCode
<
48
||
e
.
keyCode
>
57
))
&&
(
e
.
keyCode
<
96
||
e
.
keyCode
>
105
))
{
e
.
preventDefault
();
}
});
</script>
{% 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