Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
J
jumpserver
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ops
jumpserver
Commits
f51c6efd
Unverified
Commit
f51c6efd
authored
Jul 30, 2019
by
老广
Committed by
GitHub
Jul 30, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3054 from jumpserver/dev
获取子节点资产时 使用 in
parents
be59bff3
bb235f3e
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
149 additions
and
57 deletions
+149
-57
.dockerignore
.dockerignore
+4
-2
.gitignore
.gitignore
+3
-0
Vagrantfile
Vagrantfile
+56
-0
asset_user.py
apps/assets/api/asset_user.py
+1
-1
asset.py
apps/assets/models/asset.py
+1
-1
user.py
apps/assets/models/user.py
+16
-0
signals_handler.py
apps/assets/signals_handler.py
+10
-10
tasks.py
apps/assets/tasks.py
+31
-23
utils.py
apps/assets/utils.py
+2
-2
django.mo
apps/locale/zh/LC_MESSAGES/django.mo
+0
-0
django.po
apps/locale/zh/LC_MESSAGES/django.po
+0
-0
asset_permission_list.html
apps/perms/templates/perms/asset_permission_list.html
+2
-1
asset_permission.py
apps/perms/utils/asset_permission.py
+8
-5
terminal_list.html
apps/terminal/templates/terminal/terminal_list.html
+3
-2
user.py
apps/users/models/user.py
+1
-1
tasks.py
apps/users/tasks.py
+4
-4
_granted_assets.html
apps/users/templates/users/_granted_assets.html
+1
-1
user_group_list.html
apps/users/templates/users/user_group_list.html
+2
-1
user_list.html
apps/users/templates/users/user_list.html
+3
-2
jms
jms
+1
-1
No files found.
.dockerignore
View file @
f51c6efd
...
@@ -4,4 +4,6 @@ data/*
...
@@ -4,4 +4,6 @@ data/*
.github
.github
tmp/*
tmp/*
django.db
django.db
celerybeat.pid
celerybeat.pid
\ No newline at end of file
### Vagrant ###
.vagrant/
\ No newline at end of file
.gitignore
View file @
f51c6efd
...
@@ -34,3 +34,5 @@ data/static
...
@@ -34,3 +34,5 @@ data/static
docs/_build/
docs/_build/
xpack
xpack
logs/*
logs/*
### Vagrant ###
.vagrant/
\ No newline at end of file
Vagrantfile
0 → 100644
View file @
f51c6efd
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant
.
configure
(
"2"
)
do
|
config
|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at
# https://docs.vagrantup.com.
# Every Vagrant development environment requires a box. You can search for
# boxes at https://vagrantcloud.com/search.
config
.
vm
.
box_check_update
=
false
config
.
vm
.
box
=
"centos/7"
config
.
vm
.
hostname
=
"jumpserver"
config
.
vm
.
network
"private_network"
,
ip:
"172.17.8.101"
config
.
vm
.
provider
"virtualbox"
do
|
vb
|
vb
.
memory
=
"4096"
vb
.
cpus
=
2
vb
.
name
=
"jumpserver"
end
config
.
vm
.
synced_folder
"."
,
"/vagrant"
,
type:
"rsync"
,
rsync__verbose:
true
,
rsync__exclude:
[
'.git*'
,
'node_modules*'
,
'*.log'
,
'*.box'
,
'Vagrantfile'
]
config
.
vm
.
provision
"shell"
,
inline:
<<-
SHELL
## 设置yum的阿里云源
sudo curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
sudo sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo
sudo curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
sudo yum makecache
## 安装依赖包
sudo yum install -y python36 python36-devel python36-pip \
libtiff-devel libjpeg-devel libzip-devel freetype-devel \
lcms2-devel libwebp-devel tcl-devel tk-devel sshpass \
openldap-devel mariadb-devel mysql-devel libffi-devel \
openssh-clients telnet openldap-clients gcc
## 配置pip阿里云源
mkdir /home/vagrant/.pip
cat << EOF | sudo tee -a /home/vagrant/.pip/pip.conf
[global]
timeout = 6000
index-url = https://mirrors.aliyun.com/pypi/simple/
[install]
use-mirrors = true
mirrors = https://mirrors.aliyun.com/pypi/simple/
trusted-host=mirrors.aliyun.com
EOF
python3.6 -m venv /home/vagrant/venv
source /home/vagrant/venv/bin/activate
echo 'source /home/vagrant/venv/bin/activate' >> /home/vagrant/.bash_profile
SHELL
end
apps/assets/api/asset_user.py
View file @
f51c6efd
...
@@ -81,7 +81,7 @@ class AssetUserViewSet(IDInCacheFilterMixin, BulkModelViewSet):
...
@@ -81,7 +81,7 @@ class AssetUserViewSet(IDInCacheFilterMixin, BulkModelViewSet):
manager
=
AssetUserManager
()
manager
=
AssetUserManager
()
if
system_user_id
:
if
system_user_id
:
system_user
=
get_object_or_404
(
SystemUser
,
id
=
system_user_id
)
system_user
=
get_object_or_404
(
SystemUser
,
id
=
system_user_id
)
assets
=
system_user
.
assets
.
all
()
assets
=
system_user
.
get_all_assets
()
username
=
system_user
.
username
username
=
system_user
.
username
elif
admin_user_id
:
elif
admin_user_id
:
admin_user
=
get_object_or_404
(
AdminUser
,
id
=
admin_user_id
)
admin_user
=
get_object_or_404
(
AdminUser
,
id
=
admin_user_id
)
...
...
apps/assets/models/asset.py
View file @
f51c6efd
...
@@ -12,7 +12,6 @@ from django.core.cache import cache
...
@@ -12,7 +12,6 @@ from django.core.cache import cache
from
django.db
import
models
from
django.db
import
models
from
django.utils.translation
import
ugettext_lazy
as
_
from
django.utils.translation
import
ugettext_lazy
as
_
from
.user
import
AdminUser
,
SystemUser
from
.utils
import
Connectivity
from
.utils
import
Connectivity
from
orgs.mixins
import
OrgModelMixin
,
OrgManager
from
orgs.mixins
import
OrgModelMixin
,
OrgManager
...
@@ -320,6 +319,7 @@ class Asset(ProtocolsMixin, NodesRelationMixin, OrgModelMixin):
...
@@ -320,6 +319,7 @@ class Asset(ProtocolsMixin, NodesRelationMixin, OrgModelMixin):
@classmethod
@classmethod
def
generate_fake
(
cls
,
count
=
100
):
def
generate_fake
(
cls
,
count
=
100
):
from
.user
import
AdminUser
,
SystemUser
from
random
import
seed
,
choice
from
random
import
seed
,
choice
from
django.db
import
IntegrityError
from
django.db
import
IntegrityError
from
.node
import
Node
from
.node
import
Node
...
...
apps/assets/models/user.py
View file @
f51c6efd
...
@@ -4,12 +4,15 @@
...
@@ -4,12 +4,15 @@
import
logging
import
logging
from
functools
import
reduce
from
django.db
import
models
from
django.db
import
models
from
django.db.models
import
Q
from
django.utils.translation
import
ugettext_lazy
as
_
from
django.utils.translation
import
ugettext_lazy
as
_
from
django.core.validators
import
MinValueValidator
,
MaxValueValidator
from
django.core.validators
import
MinValueValidator
,
MaxValueValidator
from
common.utils
import
get_signer
from
common.utils
import
get_signer
from
.base
import
AssetUser
from
.base
import
AssetUser
from
.asset
import
Asset
__all__
=
[
'AdminUser'
,
'SystemUser'
]
__all__
=
[
'AdminUser'
,
'SystemUser'
]
...
@@ -144,6 +147,19 @@ class SystemUser(AssetUser):
...
@@ -144,6 +147,19 @@ class SystemUser(AssetUser):
return
False
,
matched_cmd
return
False
,
matched_cmd
return
True
,
None
return
True
,
None
def
get_all_assets
(
self
):
args
=
[
Q
(
systemuser
=
self
)]
pattern
=
set
()
nodes_keys
=
self
.
nodes
.
all
()
.
values_list
(
'key'
,
flat
=
True
)
for
key
in
nodes_keys
:
pattern
.
add
(
r'^{0}$|^{0}:'
.
format
(
key
))
pattern
=
'|'
.
join
(
list
(
pattern
))
if
pattern
:
args
.
append
(
Q
(
nodes__key__regex
=
pattern
))
args
=
reduce
(
lambda
x
,
y
:
x
|
y
,
args
)
assets
=
Asset
.
objects
.
filter
(
args
)
.
distinct
()
return
assets
class
Meta
:
class
Meta
:
ordering
=
[
'name'
]
ordering
=
[
'name'
]
unique_together
=
[(
'name'
,
'org_id'
)]
unique_together
=
[(
'name'
,
'org_id'
)]
...
...
apps/assets/signals_handler.py
View file @
f51c6efd
...
@@ -57,16 +57,16 @@ def on_system_user_update(sender, instance=None, created=True, **kwargs):
...
@@ -57,16 +57,16 @@ def on_system_user_update(sender, instance=None, created=True, **kwargs):
push_system_user_to_assets
.
delay
(
instance
,
assets
)
push_system_user_to_assets
.
delay
(
instance
,
assets
)
@receiver
(
m2m_changed
,
sender
=
SystemUser
.
nodes
.
through
)
#
@receiver(m2m_changed, sender=SystemUser.nodes.through)
def
on_system_user_nodes_change
(
sender
,
instance
=
None
,
**
kwargs
):
#
def on_system_user_nodes_change(sender, instance=None, **kwargs):
if
instance
and
kwargs
[
"action"
]
==
"post_add"
:
#
if instance and kwargs["action"] == "post_add":
logger
.
info
(
"System user `{}` nodes update signal received"
.
format
(
instance
))
#
logger.info("System user `{}` nodes update signal received".format(instance))
assets
=
set
()
#
assets = set()
nodes
=
kwargs
[
'model'
]
.
objects
.
filter
(
pk__in
=
kwargs
[
'pk_set'
])
#
nodes = kwargs['model'].objects.filter(pk__in=kwargs['pk_set'])
for
node
in
nodes
:
#
for node in nodes:
assets
.
update
(
set
(
node
.
get_all_assets
()))
#
assets.update(set(node.get_all_assets()))
instance
.
assets
.
add
(
*
tuple
(
assets
))
#
instance.assets.add(*tuple(assets))
#
@receiver
(
m2m_changed
,
sender
=
SystemUser
.
assets
.
through
)
@receiver
(
m2m_changed
,
sender
=
SystemUser
.
assets
.
through
)
def
on_system_user_assets_change
(
sender
,
instance
=
None
,
**
kwargs
):
def
on_system_user_assets_change
(
sender
,
instance
=
None
,
**
kwargs
):
...
...
apps/assets/tasks.py
View file @
f51c6efd
...
@@ -347,7 +347,7 @@ def test_system_user_connectivity_util(system_user, assets, task_name):
...
@@ -347,7 +347,7 @@ def test_system_user_connectivity_util(system_user, assets, task_name):
@shared_task
@shared_task
def
test_system_user_connectivity_manual
(
system_user
):
def
test_system_user_connectivity_manual
(
system_user
):
task_name
=
_
(
"Test system user connectivity: {}"
)
.
format
(
system_user
)
task_name
=
_
(
"Test system user connectivity: {}"
)
.
format
(
system_user
)
assets
=
system_user
.
get_
related
_assets
()
assets
=
system_user
.
get_
all
_assets
()
return
test_system_user_connectivity_util
(
system_user
,
assets
,
task_name
)
return
test_system_user_connectivity_util
(
system_user
,
assets
,
task_name
)
...
@@ -367,17 +367,43 @@ def test_system_user_connectivity_period():
...
@@ -367,17 +367,43 @@ def test_system_user_connectivity_period():
system_users
=
SystemUser
.
objects
.
all
()
system_users
=
SystemUser
.
objects
.
all
()
for
system_user
in
system_users
:
for
system_user
in
system_users
:
task_name
=
_
(
"Test system user connectivity period: {}"
)
.
format
(
system_user
)
task_name
=
_
(
"Test system user connectivity period: {}"
)
.
format
(
system_user
)
assets
=
system_user
.
get_
related
_assets
()
assets
=
system_user
.
get_
all
_assets
()
test_system_user_connectivity_util
(
system_user
,
assets
,
task_name
)
test_system_user_connectivity_util
(
system_user
,
assets
,
task_name
)
#### Push system user tasks ####
#### Push system user tasks ####
def
get_push_linux_system_user_tasks
(
system_user
):
def
get_push_linux_system_user_tasks
(
system_user
):
tasks
=
[]
tasks
=
[
{
'name'
:
'Add user {}'
.
format
(
system_user
.
username
),
'action'
:
{
'module'
:
'user'
,
'args'
:
'name={} shell={} state=present'
.
format
(
system_user
.
username
,
system_user
.
shell
,
),
}
},
{
'name'
:
'Check home dir exists'
,
'action'
:
{
'module'
:
'stat'
,
'args'
:
'path=/home/{}'
.
format
(
system_user
.
username
)
},
'register'
:
'home_existed'
},
{
'name'
:
"Set home dir permission"
,
'action'
:
{
'module'
:
'file'
,
'args'
:
"path=/home/{0} owner={0} group={0} mode=700"
.
format
(
system_user
.
username
)
},
'when'
:
'home_existed.stat.exists == true'
}
]
if
system_user
.
password
:
if
system_user
.
password
:
tasks
.
append
({
tasks
.
append
({
'name'
:
'
Add user {}
'
.
format
(
system_user
.
username
),
'name'
:
'
Set {} password
'
.
format
(
system_user
.
username
),
'action'
:
{
'action'
:
{
'module'
:
'user'
,
'module'
:
'user'
,
'args'
:
'name={} shell={} state=present password={}'
.
format
(
'args'
:
'name={} shell={} state=present password={}'
.
format
(
...
@@ -386,24 +412,6 @@ def get_push_linux_system_user_tasks(system_user):
...
@@ -386,24 +412,6 @@ def get_push_linux_system_user_tasks(system_user):
),
),
}
}
})
})
tasks
.
extend
([
{
'name'
:
'Check home dir exists'
,
'action'
:
{
'module'
:
'stat'
,
'args'
:
'path=/home/{}'
.
format
(
system_user
.
username
)
},
'register'
:
'home_existed'
},
{
'name'
:
"Set home dir permission"
,
'action'
:
{
'module'
:
'file'
,
'args'
:
"path=/home/{0} owner={0} group={0} mode=700"
.
format
(
system_user
.
username
)
},
'when'
:
'home_existed.stat.exists == true'
}
])
if
system_user
.
public_key
:
if
system_user
.
public_key
:
tasks
.
append
({
tasks
.
append
({
'name'
:
'Set {} authorized key'
.
format
(
system_user
.
username
),
'name'
:
'Set {} authorized key'
.
format
(
system_user
.
username
),
...
@@ -513,7 +521,7 @@ def push_system_user_util(system_user, assets, task_name):
...
@@ -513,7 +521,7 @@ def push_system_user_util(system_user, assets, task_name):
@shared_task
@shared_task
def
push_system_user_to_assets_manual
(
system_user
):
def
push_system_user_to_assets_manual
(
system_user
):
assets
=
system_user
.
get_
related
_assets
()
assets
=
system_user
.
get_
all
_assets
()
task_name
=
_
(
"Push system users to assets: {}"
)
.
format
(
system_user
.
name
)
task_name
=
_
(
"Push system users to assets: {}"
)
.
format
(
system_user
.
name
)
return
push_system_user_util
(
system_user
,
assets
,
task_name
=
task_name
)
return
push_system_user_util
(
system_user
,
assets
,
task_name
=
task_name
)
...
...
apps/assets/utils.py
View file @
f51c6efd
...
@@ -213,10 +213,10 @@ class NodeUtil:
...
@@ -213,10 +213,10 @@ class NodeUtil:
children
.
add
(
node
)
children
.
add
(
node
)
return
list
(
children
)
return
list
(
children
)
def
get_children
(
self
,
node
,
with_self
=
True
):
def
get_
all_
children
(
self
,
node
,
with_self
=
True
):
return
self
.
get_all_children_by_key
(
node
.
key
,
with_self
=
with_self
)
return
self
.
get_all_children_by_key
(
node
.
key
,
with_self
=
with_self
)
def
get_children_keys_by_key
(
self
,
key
,
with_self
=
True
):
def
get_
all_
children_keys_by_key
(
self
,
key
,
with_self
=
True
):
nodes
=
self
.
get_all_children_by_key
(
key
,
with_self
=
with_self
)
nodes
=
self
.
get_all_children_by_key
(
key
,
with_self
=
with_self
)
return
[
n
.
key
for
n
in
nodes
]
return
[
n
.
key
for
n
in
nodes
]
...
...
apps/locale/zh/LC_MESSAGES/django.mo
View file @
f51c6efd
No preview for this file type
apps/locale/zh/LC_MESSAGES/django.po
View file @
f51c6efd
This diff is collapsed.
Click to expand it.
apps/perms/templates/perms/asset_permission_list.html
View file @
f51c6efd
...
@@ -174,10 +174,11 @@ function initTable() {
...
@@ -174,10 +174,11 @@ function initTable() {
}
}
}},
}},
{
targets
:
8
,
createdCell
:
function
(
td
,
cellData
,
rowData
)
{
{
targets
:
8
,
createdCell
:
function
(
td
,
cellData
,
rowData
)
{
var
name
=
htmlEscape
(
rowData
.
name
);
var
update_btn
=
'<a href="{% url "perms:asset-permission-update" pk=DEFAULT_PK %}" class="btn btn-xs m-l-xs btn-info">{% trans "Update" %}</a>'
.
replace
(
'{{ DEFAULT_PK }}'
,
cellData
);
var
update_btn
=
'<a href="{% url "perms:asset-permission-update" pk=DEFAULT_PK %}" class="btn btn-xs m-l-xs btn-info">{% trans "Update" %}</a>'
.
replace
(
'{{ DEFAULT_PK }}'
,
cellData
);
var
del_btn
=
'<a class="btn btn-xs btn-danger m-l-xs btn-del" data-uid="{{ DEFAULT_PK }}" mark=1 data-name="99991938">{% trans "Delete" %}</a>'
var
del_btn
=
'<a class="btn btn-xs btn-danger m-l-xs btn-del" data-uid="{{ DEFAULT_PK }}" mark=1 data-name="99991938">{% trans "Delete" %}</a>'
.
replace
(
'{{ DEFAULT_PK }}'
,
cellData
)
.
replace
(
'{{ DEFAULT_PK }}'
,
cellData
)
.
replace
(
'99991938'
,
rowData
.
name
);
.
replace
(
'99991938'
,
name
);
if
(
rowData
.
inherit
)
{
if
(
rowData
.
inherit
)
{
del_btn
=
del_btn
.
replace
(
"mark"
,
"disabled"
)
del_btn
=
del_btn
.
replace
(
"mark"
,
"disabled"
)
}
}
...
...
apps/perms/utils/asset_permission.py
View file @
f51c6efd
...
@@ -449,6 +449,8 @@ class AssetPermissionUtil(AssetPermissionCacheMixin):
...
@@ -449,6 +449,8 @@ class AssetPermissionUtil(AssetPermissionCacheMixin):
self
.
_nodes
=
None
self
.
_nodes
=
None
self
.
_assets_direct
=
None
self
.
_assets_direct
=
None
self
.
_nodes_direct
=
None
self
.
_nodes_direct
=
None
self
.
node_util
=
NodeUtil
()
self
.
tree
.
_node_util
=
self
.
node_util
@staticmethod
@staticmethod
def
change_org_if_need
():
def
change_org_if_need
():
...
@@ -491,13 +493,14 @@ class AssetPermissionUtil(AssetPermissionCacheMixin):
...
@@ -491,13 +493,14 @@ class AssetPermissionUtil(AssetPermissionCacheMixin):
self
.
tree
.
add_nodes
(
nodes_keys
)
self
.
tree
.
add_nodes
(
nodes_keys
)
pattern
=
set
()
all_nodes_keys
=
set
()
for
key
in
nodes_keys
:
for
key
in
nodes_keys
:
pattern
.
add
(
r'^{0}$|^{0}:'
.
format
(
key
))
children_keys
=
self
.
node_util
.
get_all_children_keys_by_key
(
key
)
pattern
=
'|'
.
join
(
list
(
pattern
))
all_nodes_keys
.
update
(
set
(
children_keys
))
if
pattern
:
if
all_nodes_keys
:
assets_ids
=
Asset
.
objects
.
filter
(
assets_ids
=
Asset
.
objects
.
filter
(
nodes__key__
regex
=
pattern
nodes__key__
in
=
all_nodes_keys
)
.
valid
()
.
values_list
(
"id"
,
flat
=
True
)
.
distinct
()
)
.
valid
()
.
values_list
(
"id"
,
flat
=
True
)
.
distinct
()
else
:
else
:
assets_ids
=
[]
assets_ids
=
[]
...
...
apps/terminal/templates/terminal/terminal_list.html
View file @
f51c6efd
...
@@ -69,16 +69,17 @@ function initTable() {
...
@@ -69,16 +69,17 @@ function initTable() {
}
}
}},
}},
{
targets
:
6
,
createdCell
:
function
(
td
,
cellData
,
rowData
)
{
{
targets
:
6
,
createdCell
:
function
(
td
,
cellData
,
rowData
)
{
var
name
=
htmlEscape
(
rowData
.
name
);
var
update_btn
=
'<a href="{% url "terminal:terminal-update" pk=DEFAULT_PK %}" class="btn btn-xs btn-info">{% trans "Update" %}</a>'
var
update_btn
=
'<a href="{% url "terminal:terminal-update" pk=DEFAULT_PK %}" class="btn btn-xs btn-info">{% trans "Update" %}</a>'
.
replace
(
'{{ DEFAULT_PK }}'
,
cellData
);
.
replace
(
'{{ DEFAULT_PK }}'
,
cellData
);
var
delete_btn
=
'<a class="btn btn-xs btn-danger m-l-xs btn-del" data-id="{{ DEFAULT_PK }}" data-name="99991938">{% trans "Delete" %}</a>'
var
delete_btn
=
'<a class="btn btn-xs btn-danger m-l-xs btn-del" data-id="{{ DEFAULT_PK }}" data-name="99991938">{% trans "Delete" %}</a>'
.
replace
(
'{{ DEFAULT_PK }}'
,
cellData
)
.
replace
(
'{{ DEFAULT_PK }}'
,
cellData
)
.
replace
(
'99991938'
,
rowData
.
name
);
.
replace
(
'99991938'
,
name
);
var
accept_btn
=
'<a class="btn btn-xs btn-primary btn-accept" data-id="{{ DEFAULT_PK }}">{% trans "Accept" %}</a> '
var
accept_btn
=
'<a class="btn btn-xs btn-primary btn-accept" data-id="{{ DEFAULT_PK }}">{% trans "Accept" %}</a> '
.
replace
(
'{{ DEFAULT_PK }}'
,
cellData
);
.
replace
(
'{{ DEFAULT_PK }}'
,
cellData
);
var
reject_btn
=
'<a class="btn btn-xs btn-danger m-l-xs btn-del" data-id="{{ DEFAULT_PK }}" data-name="99991938">{% trans "Reject" %}</a>'
var
reject_btn
=
'<a class="btn btn-xs btn-danger m-l-xs btn-del" data-id="{{ DEFAULT_PK }}" data-name="99991938">{% trans "Reject" %}</a>'
.
replace
(
'{{ DEFAULT_PK }}'
,
cellData
)
.
replace
(
'{{ DEFAULT_PK }}'
,
cellData
)
.
replace
(
'99991938'
,
rowData
.
name
);
.
replace
(
'99991938'
,
name
);
if
(
rowData
.
is_accepted
)
{
if
(
rowData
.
is_accepted
)
{
$
(
td
).
html
(
update_btn
+
delete_btn
);
$
(
td
).
html
(
update_btn
+
delete_btn
);
}
else
{
}
else
{
...
...
apps/users/models/user.py
View file @
f51c6efd
...
@@ -111,7 +111,7 @@ class AuthMixin:
...
@@ -111,7 +111,7 @@ class AuthMixin:
@property
@property
def
password_will_expired
(
self
):
def
password_will_expired
(
self
):
if
self
.
is_local
and
self
.
password_expired_remain_days
<
5
:
if
self
.
is_local
and
0
<=
self
.
password_expired_remain_days
<
5
:
return
True
return
True
return
False
return
False
...
...
apps/users/tasks.py
View file @
f51c6efd
...
@@ -20,13 +20,13 @@ logger = get_logger(__file__)
...
@@ -20,13 +20,13 @@ logger = get_logger(__file__)
def
check_password_expired
():
def
check_password_expired
():
users
=
User
.
objects
.
exclude
(
role
=
User
.
ROLE_APP
)
users
=
User
.
objects
.
exclude
(
role
=
User
.
ROLE_APP
)
for
user
in
users
:
for
user
in
users
:
if
not
user
.
is_valid
:
continue
if
not
user
.
password_will_expired
:
if
not
user
.
password_will_expired
:
continue
continue
send_password_expiration_reminder_mail
(
user
)
send_password_expiration_reminder_mail
(
user
)
logger
.
info
(
"The user {} password expires in {} days"
.
format
(
msg
=
"The user {} password expires in {} days"
user
,
user
.
password_expired_remain_days
)
logger
.
info
(
msg
.
format
(
user
,
user
.
password_expired_remain_days
))
)
@shared_task
@shared_task
...
...
apps/users/templates/users/_granted_assets.html
View file @
f51c6efd
...
@@ -156,7 +156,7 @@ function loadLabels() {
...
@@ -156,7 +156,7 @@ function loadLabels() {
}
}
$
(
document
).
ready
(
function
()
{
$
(
document
).
ready
(
function
()
{
loadLabels
()
{
#
loadLabels
()
#
}
}).
on
(
'click'
,
'.labels-menu li'
,
function
()
{
}).
on
(
'click'
,
'.labels-menu li'
,
function
()
{
var
val
=
$
(
this
).
text
();
var
val
=
$
(
this
).
text
();
$
(
"#user_assets_table_filter input"
).
val
(
val
);
$
(
"#user_assets_table_filter input"
).
val
(
val
);
...
...
apps/users/templates/users/user_group_list.html
View file @
f51c6efd
...
@@ -67,11 +67,12 @@ function initTable() {
...
@@ -67,11 +67,12 @@ function initTable() {
$
(
td
).
html
(
'<span href="javascript:void(0);" data-toggle="tooltip" title="'
+
cellData
+
'">'
+
innerHtml
+
'</span>'
);
$
(
td
).
html
(
'<span href="javascript:void(0);" data-toggle="tooltip" title="'
+
cellData
+
'">'
+
innerHtml
+
'</span>'
);
}},
}},
{
targets
:
4
,
createdCell
:
function
(
td
,
cellData
,
rowData
)
{
{
targets
:
4
,
createdCell
:
function
(
td
,
cellData
,
rowData
)
{
var
name
=
htmlEscape
(
rowData
.
name
);
var
update_btn
=
'<a href="{% url "users:user-group-update" pk=DEFAULT_PK %}" class="btn btn-xs btn-info">{% trans "Update" %}</a>'
var
update_btn
=
'<a href="{% url "users:user-group-update" pk=DEFAULT_PK %}" class="btn btn-xs btn-info">{% trans "Update" %}</a>'
.
replace
(
'{{ DEFAULT_PK }}'
,
cellData
);
.
replace
(
'{{ DEFAULT_PK }}'
,
cellData
);
var
del_btn
=
'<a class="btn btn-xs btn-danger m-l-xs btn_delete_user_group" data-gid="{{ DEFAULT_PK }}" data-name="99991938">{% trans "Delete" %}</a>'
var
del_btn
=
'<a class="btn btn-xs btn-danger m-l-xs btn_delete_user_group" data-gid="{{ DEFAULT_PK }}" data-name="99991938">{% trans "Delete" %}</a>'
.
replace
(
'{{ DEFAULT_PK }}'
,
cellData
)
.
replace
(
'{{ DEFAULT_PK }}'
,
cellData
)
.
replace
(
'99991938'
,
rowData
.
name
);
.
replace
(
'99991938'
,
name
);
if
(
rowData
.
id
===
1
)
{
if
(
rowData
.
id
===
1
)
{
$
(
td
).
html
(
update_btn
)
$
(
td
).
html
(
update_btn
)
}
else
{
}
else
{
...
...
apps/users/templates/users/user_list.html
View file @
f51c6efd
...
@@ -97,6 +97,7 @@ function initTable() {
...
@@ -97,6 +97,7 @@ function initTable() {
}
}
}},
}},
{
targets
:
7
,
createdCell
:
function
(
td
,
cellData
,
rowData
)
{
{
targets
:
7
,
createdCell
:
function
(
td
,
cellData
,
rowData
)
{
var
name
=
htmlEscape
(
rowData
.
name
);
var
update_btn
=
""
;
var
update_btn
=
""
;
if
(
rowData
.
role
===
'Admin'
&&
(
'{{ request.user.role }}'
!==
'Admin'
))
{
if
(
rowData
.
role
===
'Admin'
&&
(
'{{ request.user.role }}'
!==
'Admin'
))
{
update_btn
=
'<a class="btn btn-xs disabled btn-info">{% trans "Update" %}</a>'
;
update_btn
=
'<a class="btn btn-xs disabled btn-info">{% trans "Update" %}</a>'
;
...
@@ -109,11 +110,11 @@ function initTable() {
...
@@ -109,11 +110,11 @@ function initTable() {
if
(
rowData
.
id
===
1
||
rowData
.
username
===
"admin"
||
rowData
.
username
===
"{{ request.user.username }}"
||
(
rowData
.
role
===
'Admin'
&&
(
'{{ request.user.role }}'
!==
'Admin'
)))
{
if
(
rowData
.
id
===
1
||
rowData
.
username
===
"admin"
||
rowData
.
username
===
"{{ request.user.username }}"
||
(
rowData
.
role
===
'Admin'
&&
(
'{{ request.user.role }}'
!==
'Admin'
)))
{
del_btn
=
'<a class="btn btn-xs btn-danger m-l-xs" disabled>{% trans "Delete" %}</a>'
del_btn
=
'<a class="btn btn-xs btn-danger m-l-xs" disabled>{% trans "Delete" %}</a>'
.
replace
(
'{{ DEFAULT_PK }}'
,
cellData
)
.
replace
(
'{{ DEFAULT_PK }}'
,
cellData
)
.
replace
(
'99991938'
,
rowData
.
name
);
.
replace
(
'99991938'
,
name
);
}
else
{
}
else
{
del_btn
=
'<a class="btn btn-xs btn-danger m-l-xs btn_user_delete" data-uid="{{ DEFAULT_PK }}" data-name="99991938">{% trans "Delete" %}</a>'
del_btn
=
'<a class="btn btn-xs btn-danger m-l-xs btn_user_delete" data-uid="{{ DEFAULT_PK }}" data-name="99991938">{% trans "Delete" %}</a>'
.
replace
(
'{{ DEFAULT_PK }}'
,
cellData
)
.
replace
(
'{{ DEFAULT_PK }}'
,
cellData
)
.
replace
(
'99991938'
,
rowData
.
name
);
.
replace
(
'99991938'
,
name
);
}
}
$
(
td
).
html
(
update_btn
+
del_btn
)
$
(
td
).
html
(
update_btn
+
del_btn
)
}}],
}}],
...
...
jms
View file @
f51c6efd
...
@@ -81,7 +81,7 @@ def make_migrations():
...
@@ -81,7 +81,7 @@ def make_migrations():
def
collect_static
():
def
collect_static
():
print
(
"Collect static files"
)
print
(
"Collect static files"
)
os
.
chdir
(
os
.
path
.
join
(
BASE_DIR
,
'apps'
))
os
.
chdir
(
os
.
path
.
join
(
BASE_DIR
,
'apps'
))
subprocess
.
call
(
'python3 manage.py collectstatic --no-input'
,
shell
=
True
)
subprocess
.
call
(
'python3 manage.py collectstatic --no-input
-c &> /dev/null && echo "Collect static file done"
'
,
shell
=
True
)
def
prepare
():
def
prepare
():
...
...
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