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
ced2799c
Commit
ced2799c
authored
Jun 27, 2017
by
Vasyl Bodnaruk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add login functional
parent
4683f05c
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
44 additions
and
18 deletions
+44
-18
settings.py
esi/esi/settings.py
+3
-0
urls.py
esi/esi/urls.py
+4
-1
urls.py
esi/main/urls.py
+1
-1
views.py
esi/scraper/views.py
+4
-5
base.html
esi/templates/base.html
+32
-11
No files found.
esi/esi/settings.py
View file @
ced2799c
...
...
@@ -133,6 +133,9 @@ USE_L10N = True
USE_TZ
=
True
from
django.core.urlresolvers
import
reverse_lazy
LOGIN_URL
=
reverse_lazy
(
'login'
)
LOGIN_REDIRECT_URL
=
reverse_lazy
(
'home'
)
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.11/howto/static-files/
...
...
esi/esi/urls.py
View file @
ced2799c
...
...
@@ -15,10 +15,13 @@ Including another URLconf
"""
from
django.conf.urls
import
url
,
include
from
django.contrib
import
admin
from
django.contrib.auth
import
views
as
auth_views
urlpatterns
=
[
url
(
r'^admin/'
,
admin
.
site
.
urls
),
url
(
r'^news/'
,
include
(
'webapp.urls'
)),
url
(
r'^job/'
,
include
(
'scraper.urls'
)),
url
(
r'^$'
,
include
(
'main.urls'
))
url
(
r'^'
,
include
(
'main.urls'
)),
url
(
r'^login/$'
,
auth_views
.
login
,
name
=
'login'
),
url
(
r'^logout/$'
,
auth_views
.
logout
,
name
=
'logout'
),
]
esi/main/urls.py
View file @
ced2799c
...
...
@@ -3,5 +3,5 @@ from django.conf.urls import url
from
.views
import
MainView
urlpatterns
=
[
url
(
r'
'
,
MainView
.
as_view
(),
name
=
'index
'
)
url
(
r'
^$'
,
MainView
.
as_view
(),
name
=
'home
'
)
]
\ No newline at end of file
esi/scraper/views.py
View file @
ced2799c
from
django.shortcuts
import
render
,
HttpResponseRedirect
,
reverse
,
HttpResponse
from
django.http
import
JsonResponse
from
django.views.generic
import
ListView
,
CreateView
from
django.views.decorators.csrf
import
csrf_exempt
from
django.contrib.auth.decorators
import
login_required
,
permission_required
from
django.utils.decorators
import
method_decorator
from
.models
import
Spider
,
Job
from
.service
import
Service
...
...
@@ -18,10 +19,6 @@ class JobListView(ListView):
def
get
(
self
,
request
,
*
args
,
**
kwargs
):
self
.
service
.
update_jobs_status
()
j
=
Job
.
objects
.
all
()
.
order_by
(
'-create_time'
)
if
request
.
is_ajax
():
action
=
request
.
POST
.
get
(
'action'
)
job_id
=
request
.
POST
.
get
(
'id'
)
return
self
.
_logic
(
action
,
job_id
)
jobs
=
{
'deleted'
:
j
.
deleted
(),
'running'
:
j
.
running
(),
...
...
@@ -30,6 +27,7 @@ class JobListView(ListView):
}
return
render
(
request
,
self
.
template_name
,
{
'jobs'
:
jobs
})
@
method_decorator
(
login_required
)
def
post
(
self
,
request
,
*
args
,
**
kwargs
):
if
request
.
is_ajax
():
action
=
request
.
POST
.
get
(
'action'
)
...
...
@@ -57,6 +55,7 @@ class JobListView(ListView):
return
HttpResponse
(
log
,
content_type
=
'text/plain'
)
@
method_decorator
(
login_required
,
name
=
'post'
)
class
NewJobCreateView
(
CreateView
):
template_name
=
'new_job.html'
...
...
esi/templates/base.html
View file @
ced2799c
...
...
@@ -14,21 +14,42 @@
{% block title %}
<title>
Document
</title>
{% endblock %}
<style>
.navbar-header
{
display
:
flex
;
justify-content
:
space-between
;
width
:
100%
;
}
.nav-custom
{
display
:
flex
;
align-items
:
center
;
}
.nav-custom
>
*
:not
(
:first-child
)
{
margin-left
:
10px
;
}
</style>
</head>
<body>
<nav
class=
"navbar navbar-toggleable-md navbar-light bg-faded"
>
<div
class=
"navbar-header"
>
<a
class=
"navbar-brand"
href=
"#"
>
ESI
</a>
</div>
<ul
class=
"nav navbar-nav"
>
<li><a
href=
"{% url 'list_news' %}"
>
News
</a></li>
<li><a
href=
"{% url 'job_list' %}"
>
Run
&
Settings
</a></li>
<li><a
href=
"#"
>
Stat
</a></li>
</ul>
<nav
class=
"navbar"
>
<div
style=
"display: flex"
>
<div
class=
"navbar-header"
>
<div
class=
"nav-custom"
>
<a
class=
"navbar-brand"
href=
"/"
>
ESI
</a>
<ul
class=
"nav nav-custom"
>
<li><a
href=
"{% url 'list_news' %}"
>
News
</a></li>
<li><a
href=
"{% url 'job_list' %}"
>
Run
&
Settings
</a></li>
<li><a
href=
"#"
>
Stat
</a></li>
</ul>
</div>
<ul
class=
"nav nav-custom navbar-right"
>
<li><a
href=
"{% url 'login' %}"
><span
class=
"glyphicon glyphicon-log-in"
></span>
Login
</a></li>
<li><a
href=
"{% url 'logout' %}"
><span
class=
"glyphicon glyphicon-log-in"
></span>
Logout
</a></li>
</ul>
</div>
</div>
</nav>
{% block content %}
{% endblock %}
<script
src=
"https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"
></script>
...
...
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