mirror of https://github.com/jumpserver/jumpserver
添加自定义tag
parent
fbde8d42fe
commit
9304a911ea
|
@ -46,6 +46,7 @@ INSTALLED_APPS = (
|
||||||
'django.contrib.sessions',
|
'django.contrib.sessions',
|
||||||
'django.contrib.messages',
|
'django.contrib.messages',
|
||||||
'django.contrib.staticfiles',
|
'django.contrib.staticfiles',
|
||||||
|
'jumpserver',
|
||||||
'juser',
|
'juser',
|
||||||
'jasset',
|
'jasset',
|
||||||
'jpermission',
|
'jpermission',
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
__author__ = 'Hudie'
|
|
@ -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)
|
|
@ -126,7 +126,7 @@ def user_add(request):
|
||||||
else:
|
else:
|
||||||
time_now = time.time()
|
time_now = time.time()
|
||||||
db_add_user(username=username, password=password, name=name, email=email,
|
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)
|
is_active=is_active, date_joined=time_now)
|
||||||
msg = u'添加用户成功'
|
msg = u'添加用户成功'
|
||||||
return render_to_response('juser/user_add.html',
|
return render_to_response('juser/user_add.html',
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
{% extends 'base.html' %}
|
{% extends 'base.html' %}
|
||||||
|
{% load mytags %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
{% include 'nav_cat_bar.html' %}
|
{% include 'nav_cat_bar.html' %}
|
||||||
|
@ -73,7 +74,7 @@
|
||||||
<div class="col-sm-8">
|
<div class="col-sm-8">
|
||||||
<select id="groups" name="groups" class="form-control m-b" multiple>
|
<select id="groups" name="groups" class="form-control m-b" multiple>
|
||||||
{% for group in all_group %}
|
{% for group in all_group %}
|
||||||
{% if group.id in groups_str %}
|
{% if group.id|int2str in groups_str %}
|
||||||
<option value="{{ group.id }}" selected>{{ group.name }}</option>
|
<option value="{{ group.id }}" selected>{{ group.name }}</option>
|
||||||
{% else %}
|
{% else %}
|
||||||
{% if forloop.first %}
|
{% if forloop.first %}
|
||||||
|
|
Loading…
Reference in New Issue