mirror of
https://github.com/haiwen/seahub.git
synced 2025-08-25 02:00:06 +00:00
[sysadmin] Add virus scan records
This commit is contained in:
parent
57fb0066e3
commit
844dcf4a07
@ -677,6 +677,12 @@ textarea:-moz-placeholder {/* for FF */
|
|||||||
.side-tabnav-tabs .tab-cur .org {
|
.side-tabnav-tabs .tab-cur .org {
|
||||||
background-position: 11px -1247px;
|
background-position: 11px -1247px;
|
||||||
}
|
}
|
||||||
|
.side-tabnav-tabs .tab .security {
|
||||||
|
background-position: 10px -1285px;
|
||||||
|
}
|
||||||
|
.side-tabnav-tabs .tab-cur .security {
|
||||||
|
background-position: 10px -1322px;
|
||||||
|
}
|
||||||
.side-tabnav-tabs .tab a:hover {
|
.side-tabnav-tabs .tab a:hover {
|
||||||
background-color:#feefb8;
|
background-color:#feefb8;
|
||||||
text-decoration:none;
|
text-decoration:none;
|
||||||
|
BIN
media/img/bg.png
BIN
media/img/bg.png
Binary file not shown.
Before Width: | Height: | Size: 9.2 KiB After Width: | Height: | Size: 9.9 KiB |
@ -38,6 +38,11 @@
|
|||||||
<a href="{{ SITE_ROOT }}sys/loginadmin/" class="activity">{% trans "Logs" %}</a>
|
<a href="{{ SITE_ROOT }}sys/loginadmin/" class="activity">{% trans "Logs" %}</a>
|
||||||
</li>
|
</li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% if events_enabled %}
|
||||||
|
<li class="tab {% block cur_virus_scan %}{% endblock %}">
|
||||||
|
<a href="{{ SITE_ROOT }}sys/virus_scan_records/" class="security">{% trans "Virus Scan" %}</a>
|
||||||
|
</li>
|
||||||
|
{% endif %}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
40
seahub/templates/sysadmin/sys_virus_scan_records.html
Normal file
40
seahub/templates/sysadmin/sys_virus_scan_records.html
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
{% extends "sysadmin/base.html" %}
|
||||||
|
|
||||||
|
{% load seahub_tags i18n %}
|
||||||
|
|
||||||
|
{% block cur_virus_scan %}tab-cur{% endblock %}
|
||||||
|
|
||||||
|
{% block right_panel %}
|
||||||
|
<h3 class="hd">{% trans "Virus Scan Records" %}</h3>
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<th width="28%">{% trans "Library" %}</th>
|
||||||
|
<th width="28%">{% trans "Owner" %}</th>
|
||||||
|
<th width="29%">{% trans "Virus File" %}</th>
|
||||||
|
<th width="15%">{% trans "Operation" %}</th>
|
||||||
|
</tr>
|
||||||
|
{% for r in records %}
|
||||||
|
<tr>
|
||||||
|
<td>{{ r.repo.name }}</td>
|
||||||
|
<td><a href="{% url "user_info" r.repo.owner %}">{{ r.repo.owner }}</a></td>
|
||||||
|
<td>{{ r.file_path }}</td>
|
||||||
|
<td>
|
||||||
|
{% if not r.has_handle %}
|
||||||
|
<a href="{% url "sys_delete_virus_scan_records" r.vid %}">{% trans "Delete" %}</a>
|
||||||
|
{% else %}
|
||||||
|
<span style="color: green;">{% trans "Handled" %}</span>
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</table>
|
||||||
|
|
||||||
|
{% include "sysadmin/useradmin_paginator.html" %}
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block extra_script %}
|
||||||
|
<script>
|
||||||
|
|
||||||
|
</script>
|
||||||
|
{% endblock %}
|
@ -25,7 +25,8 @@ from seahub.views.ajax import *
|
|||||||
#from django.contrib import admin
|
#from django.contrib import admin
|
||||||
#admin.autodiscover()
|
#admin.autodiscover()
|
||||||
|
|
||||||
urlpatterns = patterns('',
|
urlpatterns = patterns(
|
||||||
|
'',
|
||||||
# Example:
|
# Example:
|
||||||
# (r'^seahub/', include('seahub.foo.urls')),
|
# (r'^seahub/', include('seahub.foo.urls')),
|
||||||
|
|
||||||
@ -248,8 +249,17 @@ urlpatterns = patterns('',
|
|||||||
url(r'^useradmin/batchadduser/$', batch_add_user, name='batch_add_user'),
|
url(r'^useradmin/batchadduser/$', batch_add_user, name='batch_add_user'),
|
||||||
|
|
||||||
url(r'^client-login/$', client_token_login, name='client_token_login'),
|
url(r'^client-login/$', client_token_login, name='client_token_login'),
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
from seahub.utils import EVENTS_ENABLED
|
||||||
|
if EVENTS_ENABLED:
|
||||||
|
urlpatterns += patterns(
|
||||||
|
'',
|
||||||
|
url(r'^sys/virus_scan_records/$', sys_virus_scan_records, name='sys_virus_scan_records'),
|
||||||
|
url(r'^sys/virus_scan_records/delete/(?P<vid>[\d+])/$', sys_delete_virus_scan_records, name='sys_delete_virus_scan_records'),
|
||||||
|
)
|
||||||
|
|
||||||
if settings.SERVE_STATIC:
|
if settings.SERVE_STATIC:
|
||||||
media_url = settings.MEDIA_URL.strip('/')
|
media_url = settings.MEDIA_URL.strip('/')
|
||||||
urlpatterns += patterns('',
|
urlpatterns += patterns('',
|
||||||
|
@ -683,6 +683,18 @@ if EVENTS_CONFIG_FILE:
|
|||||||
|
|
||||||
return events if events else None
|
return events if events else None
|
||||||
|
|
||||||
|
def get_virus_record(repo_id=None, start=-1, limit=-1):
|
||||||
|
with _get_seafevents_session() as session:
|
||||||
|
r = seafevents.get_virus_record(session, repo_id, start, limit)
|
||||||
|
return r if r else []
|
||||||
|
|
||||||
|
def handle_virus_record(vid):
|
||||||
|
with _get_seafevents_session() as session:
|
||||||
|
return True if seafevents.handle_virus_record(session, vid) == 0 else False
|
||||||
|
|
||||||
|
def get_virus_record_by_id(vid):
|
||||||
|
with _get_seafevents_session() as session:
|
||||||
|
return seafevents.get_virus_record_by_id(session, vid)
|
||||||
else:
|
else:
|
||||||
EVENTS_ENABLED = False
|
EVENTS_ENABLED = False
|
||||||
def get_user_events():
|
def get_user_events():
|
||||||
@ -695,6 +707,12 @@ else:
|
|||||||
pass
|
pass
|
||||||
def get_perm_audit_events():
|
def get_perm_audit_events():
|
||||||
pass
|
pass
|
||||||
|
def get_virus_record():
|
||||||
|
pass
|
||||||
|
def handle_virus_record():
|
||||||
|
pass
|
||||||
|
def get_virus_record_by_id(vid):
|
||||||
|
pass
|
||||||
|
|
||||||
def calc_file_path_hash(path, bits=12):
|
def calc_file_path_hash(path, bits=12):
|
||||||
if isinstance(path, unicode):
|
if isinstance(path, unicode):
|
||||||
|
@ -1449,6 +1449,66 @@ def sys_traffic_admin(request):
|
|||||||
},
|
},
|
||||||
context_instance=RequestContext(request))
|
context_instance=RequestContext(request))
|
||||||
|
|
||||||
|
@login_required
|
||||||
|
@sys_staff_required
|
||||||
|
def sys_virus_scan_records(request):
|
||||||
|
"""List virus scan records.
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
current_page = int(request.GET.get('page', '1'))
|
||||||
|
per_page = int(request.GET.get('per_page', '100'))
|
||||||
|
except ValueError:
|
||||||
|
current_page = 1
|
||||||
|
per_page = 100
|
||||||
|
|
||||||
|
from seahub.utils import get_virus_record
|
||||||
|
records_all = get_virus_record(start=per_page * (current_page - 1),
|
||||||
|
limit=per_page + 1)
|
||||||
|
if len(records_all) == per_page + 1:
|
||||||
|
page_next = True
|
||||||
|
else:
|
||||||
|
page_next = False
|
||||||
|
|
||||||
|
records = []
|
||||||
|
for r in records_all[:per_page]:
|
||||||
|
try:
|
||||||
|
r.repo = seafile_api.get_repo(r.repo_id)
|
||||||
|
except SearpcError:
|
||||||
|
continue
|
||||||
|
|
||||||
|
r.repo.owner = seafile_api.get_repo_owner(r.repo.repo_id)
|
||||||
|
records.append(r)
|
||||||
|
|
||||||
|
return render_to_response(
|
||||||
|
'sysadmin/sys_virus_scan_records.html', {
|
||||||
|
'records': records,
|
||||||
|
'current_page': current_page,
|
||||||
|
'prev_page': current_page - 1,
|
||||||
|
'next_page': current_page + 1,
|
||||||
|
'per_page': per_page,
|
||||||
|
'page_next': page_next,
|
||||||
|
}, context_instance=RequestContext(request))
|
||||||
|
|
||||||
|
@login_required
|
||||||
|
@sys_staff_required
|
||||||
|
def sys_delete_virus_scan_records(request, vid):
|
||||||
|
from seahub.utils import handle_virus_record, get_virus_record_by_id
|
||||||
|
|
||||||
|
r = get_virus_record_by_id(vid)
|
||||||
|
parent_dir = os.path.dirname(r.file_path)
|
||||||
|
dirent_name = os.path.basename(r.file_path)
|
||||||
|
|
||||||
|
try:
|
||||||
|
seafile_api.del_file(r.repo_id, parent_dir, dirent_name,
|
||||||
|
request.user.username)
|
||||||
|
handle_virus_record(vid)
|
||||||
|
messages.success(request, _('Successfully deleted.'))
|
||||||
|
except SearpcError as e:
|
||||||
|
logger.error(e)
|
||||||
|
messages.error(request, _('Failed to delete, please try again later.'))
|
||||||
|
|
||||||
|
return HttpResponseRedirect(reverse('sys_virus_scan_records'))
|
||||||
|
|
||||||
@login_required_ajax
|
@login_required_ajax
|
||||||
@sys_staff_required
|
@sys_staff_required
|
||||||
def batch_user_make_admin(request):
|
def batch_user_make_admin(request):
|
||||||
|
Loading…
Reference in New Issue
Block a user