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
2ed8f4b5
Commit
2ed8f4b5
authored
Jul 03, 2017
by
Vasyl Bodnaruk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add form for making job
parent
29b4dd1a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
0 deletions
+27
-0
forms.py
esi/scraper/forms.py
+27
-0
No files found.
esi/scraper/forms.py
0 → 100644
View file @
2ed8f4b5
from
datetime
import
datetime
from
django
import
forms
from
.models
import
Job
,
Spider
class
CreateJobForm
(
forms
.
Form
):
name
=
forms
.
CharField
(
max_length
=
100
)
spider
=
forms
.
IntegerField
()
query
=
forms
.
CharField
(
max_length
=
255
)
date
=
forms
.
DateTimeField
()
interval
=
forms
.
CharField
(
max_length
=
100
)
count
=
forms
.
IntegerField
()
def
is_valid
(
self
):
if
self
.
data
.
get
(
'date'
):
if
self
.
data
.
get
(
'date'
)
<
datetime
.
now
()
.
date
():
raise
forms
.
ValidationError
(
'Date should be greater or equal'
)
def
create_job
(
self
):
job
=
Job
.
objects
.
create
(
name
=
self
.
cleaned_data
.
get
(
'name'
),
spider
=
Spider
.
objects
.
get
(
pk
=
self
.
cleaned_data
.
get
(
'spider'
)),
query
=
self
.
cleaned_data
.
get
(
'query'
)
)
print
(
'sdfsdfsdf'
)
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