Skip to content

Commit 618a348

Browse files
committed
update unitest
1 parent 3e781c1 commit 618a348

File tree

6 files changed

+30
-114
lines changed

6 files changed

+30
-114
lines changed

log_viewer/tests/tests.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44
class SimpleTest(TestCase):
55

66
def test_redirection(self):
7-
response = self.client.get('/admin/log_viewer/')
7+
response = self.client.get('/')
88
self.assertEqual(response.status_code, 302)

log_viewer/views.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ def render_to_response(self, context, **response_kwargs):
124124
resp['Content-Disposition'] = 'attachment; filename=%s' % file_name
125125
return resp
126126
else:
127-
raise Http404()
127+
raise Http404
128128

129129
else:
130130
zip_filename = 'log_%s.zip' % localtime().strftime("%Y%m%dT%H%M%S")

log_viewer_demo/log_viewer_demo/settings.py

+9-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
"""
32
Django settings for log_viewer_demo project.
43
@@ -12,29 +11,33 @@
1211
"""
1312

1413
import os
14+
from pathlib import Path
1515
from log_viewer_demo.logger import LOGGING
1616

17-
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
18-
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
17+
# Build paths inside the project like this: BASE_DIR / 'subdir'.
18+
BASE_DIR = Path(__file__).resolve(strict=True).parent.parent
1919

2020

2121
# Quick-start development settings - unsuitable for production
2222
# See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/
2323

2424
# SECURITY WARNING: keep the secret key used in production secret!
25-
SECRET_KEY = '8tjj-10%-%q^q1s^-#f4urf(n*%0jh-d-a81)#qo!j0@^om)%3'
25+
SECRET_KEY = 'j)s1pg_jhv22p(-38*r9d_@#sm+^k=+q29e0gis4ph(bioelc*'
2626

2727
# SECURITY WARNING: don't run with debug turned on in production!
2828
DEBUG = True
2929
ALLOWED_HOSTS = ['*']
30-
LOGIN_REDIRECT_URL = '/admin'
30+
LOGIN_URL = '/admin/login/'
31+
LOGIN_REDIRECT_URL = '/'
3132
LOGGING = LOGGING
3233

34+
3335
# Django log viewer
3436
LOG_VIEWER_FILES_DIR = 'logs'
3537
LOG_VIEWER_PAGE_LENGTH = 25
3638
LOG_VIEWER_MAX_READ_LINES = 1000
3739

40+
3841
# Application definition
3942

4043
INSTALLED_APPS = [
@@ -85,7 +88,7 @@
8588
DATABASES = {
8689
'default': {
8790
'ENGINE': 'django.db.backends.sqlite3',
88-
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
91+
'NAME': BASE_DIR / 'db.sqlite3',
8992
}
9093
}
9194

log_viewer_demo/static/admin/js/timeparse.js

-106
This file was deleted.

log_viewer_demo/static/log_viewer/css/log-viewer.css

+18
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,27 @@ https://github.com/agusmakmun/django-log-viewer
1414
.django__log__viewer .footer-action {
1515
margin: 1em 0
1616
}
17+
.django__log__viewer .pull-left {
18+
float: left;
19+
}
1720
.django__log__viewer .pull-right {
1821
float: right;
1922
}
23+
.django__log__viewer .btn-download {
24+
color: #fff;
25+
margin: .5em;
26+
font-size: 13px;
27+
text-align: center;
28+
padding: 8px 12px;
29+
border-radius: 15px;
30+
-webkit-border-radius: 15px;
31+
-moz-border-radius: 15px;
32+
-ms-border-radius: 15px;
33+
-o-border-radius: 15px;
34+
background-color: #79aec8;
35+
border-color: rgba(27,31,35,.15);
36+
box-shadow: 0 1px 0 rgba(27,31,35,.1), inset 0 1px 0 hsla(0,0%,100%,.03);
37+
}
2038
table#log-entries thead th {
2139
padding: 10px 18px;
2240
border-bottom: 1px solid #e1e1e1;

runtests.py

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
'ENGINE': 'django.db.backends.sqlite3',
1414
}
1515
},
16+
LOGIN_URL='/admin/login/',
1617
MIDDLEWARE=[
1718
'django.middleware.security.SecurityMiddleware',
1819
'django.contrib.sessions.middleware.SessionMiddleware',

0 commit comments

Comments
 (0)