diff --git a/jumpserver/settings.py b/jumpserver/settings.py index 67e9bc776..5b991157f 100644 --- a/jumpserver/settings.py +++ b/jumpserver/settings.py @@ -46,6 +46,7 @@ INSTALLED_APPS = ( 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', + 'jumpserver', 'juser', 'jasset', 'jpermission', diff --git a/jumpserver/templatetags/__init__.py b/jumpserver/templatetags/__init__.py new file mode 100644 index 000000000..bfd53d39f --- /dev/null +++ b/jumpserver/templatetags/__init__.py @@ -0,0 +1 @@ +__author__ = 'Hudie' diff --git a/jumpserver/templatetags/mytags.py b/jumpserver/templatetags/mytags.py new file mode 100644 index 000000000..3ef015a5c --- /dev/null +++ b/jumpserver/templatetags/mytags.py @@ -0,0 +1,17 @@ +import time +from django import template + +register = template.Library() + + +@register.filter(name='stamp2str') +def stamp2str(value): + try: + return time.strftime('%Y/%m/%d %H:%M:%S', time.localtime(value)) + except AttributeError: + return '0000/00/00 00:00:00' + + +@register.filter(name='int2str') +def int2str(value): + return str(value) diff --git a/juser/views.py b/juser/views.py index 6f5c4803a..814a38ca4 100644 --- a/juser/views.py +++ b/juser/views.py @@ -126,7 +126,7 @@ def user_add(request): else: time_now = time.time() db_add_user(username=username, password=password, name=name, email=email, - groups=groups, role=role, ssh_pwd=ssh_pwd, ssh_key_pwd1=ssh_key_pwd1, + groups=groups, role=role_post, ssh_pwd=ssh_pwd, ssh_key_pwd1=ssh_key_pwd1, is_active=is_active, date_joined=time_now) msg = u'添加用户成功' return render_to_response('juser/user_add.html', diff --git a/templates/juser/user_add.html b/templates/juser/user_add.html index ac7730da9..4f1cc5531 100644 --- a/templates/juser/user_add.html +++ b/templates/juser/user_add.html @@ -1,4 +1,5 @@ {% extends 'base.html' %} +{% load mytags %} {% block content %} {% include 'nav_cat_bar.html' %} @@ -73,7 +74,7 @@