Unverified Commit cc67fcb5 authored by 老广's avatar 老广 Committed by GitHub

Merge pull request #1269 from jumpserver/dev

Dev
parents 43c13355 b074bd8f
...@@ -108,18 +108,18 @@ class NodeChildrenApi(mixins.ListModelMixin, generics.CreateAPIView): ...@@ -108,18 +108,18 @@ class NodeChildrenApi(mixins.ListModelMixin, generics.CreateAPIView):
return node return node
def get_queryset(self): def get_queryset(self):
queryset = set() queryset = []
query_all = self.request.query_params.get("all") query_all = self.request.query_params.get("all")
query_assets = self.request.query_params.get('assets') query_assets = self.request.query_params.get('assets')
node = self.get_object() node = self.get_object()
if node == Node.root(): if node == Node.root():
queryset.add(node) queryset.append(node)
if query_all: if query_all:
children = node.get_all_children() children = node.get_all_children()
else: else:
children = node.get_children() children = node.get_children()
queryset.update(set(children)) queryset.extend(list(children))
if query_assets: if query_assets:
assets = node.get_assets() assets = node.get_assets()
for asset in assets: for asset in assets:
...@@ -128,7 +128,7 @@ class NodeChildrenApi(mixins.ListModelMixin, generics.CreateAPIView): ...@@ -128,7 +128,7 @@ class NodeChildrenApi(mixins.ListModelMixin, generics.CreateAPIView):
node_fake.parent = node node_fake.parent = node
node_fake.value = asset.hostname node_fake.value = asset.hostname
node_fake.is_node = False node_fake.is_node = False
queryset.add(node_fake) queryset.append(node_fake)
queryset = sorted(queryset, key=lambda x: x.is_node, reverse=True) queryset = sorted(queryset, key=lambda x: x.is_node, reverse=True)
return queryset return queryset
......
...@@ -18,8 +18,7 @@ class NodeTMPSerializer(serializers.ModelSerializer): ...@@ -18,8 +18,7 @@ class NodeTMPSerializer(serializers.ModelSerializer):
class Meta: class Meta:
model = Node model = Node
fields = ['id', 'key', 'value', 'parent', 'assets_amount', fields = ['id', 'key', 'value', 'parent', 'assets_amount', 'is_node']
'is_asset']
list_serializer_class = BulkListSerializer list_serializer_class = BulkListSerializer
@staticmethod @staticmethod
......
This diff is collapsed.
...@@ -70,6 +70,7 @@ ...@@ -70,6 +70,7 @@
<br> <br>
<input type="checkbox" id="acceptTerms"> <input type="checkbox" id="acceptTerms">
<label for="acceptTerms" style="margin-top:20px">{% trans "I agree with the terms and conditions." %}</label> <label for="acceptTerms" style="margin-top:20px">{% trans "I agree with the terms and conditions." %}</label>
<p id="noTerms" class="red-fonts" style="visibility: hidden; font-size: 10px; margin-top: 10px;">* {% trans 'Please choose the terms and conditions.' %}</p>
{% endif %} {% endif %}
{% bootstrap_form wizard.form %} {% bootstrap_form wizard.form %}
...@@ -99,11 +100,7 @@ ...@@ -99,11 +100,7 @@
{% if wizard.steps.prev %} {% if wizard.steps.prev %}
<li><a class="fl_goto" name="wizard_goto_step" data-goto="{{ wizard.steps.prev }}">{% trans "Previous" %}</a></li> <li><a class="fl_goto" name="wizard_goto_step" data-goto="{{ wizard.steps.prev }}">{% trans "Previous" %}</a></li>
{% endif %} {% endif %}
{#{% if wizard.steps.next %}#}
{#<li><a class="fl_goto" name="wizard_goto_step" data-goto="{{ wizard.steps.next }}">{% trans "Next" %}</a></li>#}
{#{% endif %}#}
{#<li><a id="fl_submit">{% trans "Submit" %}</a></li>#}
{#将原来的下一页-替换为提交;修复 每页都提交,最后才能成功问题#}
{% if wizard.steps.next %} {% if wizard.steps.next %}
<li><a id="fl_submit" >{% trans "Next" %}</a></li> <li><a id="fl_submit" >{% trans "Next" %}</a></li>
{% else %} {% else %}
...@@ -124,16 +121,21 @@ ...@@ -124,16 +121,21 @@
{% block custom_foot_js %} {% block custom_foot_js %}
<script> <script>
$('#id_2-otp_level div').eq(2).css('display', 'none');
$(document).on('click', ".fl_goto", function(){ $(document).on('click', ".fl_goto", function(){
var $form = $('#fl_form'); var $form = $('#fl_form');
$('<input />', {'name': 'wizard_goto_step', 'value': $(this).data('goto'), 'type': 'hidden'}).appendTo($form); $('<input />', {'name': 'wizard_goto_step', 'value': $(this).data('goto'), 'type': 'hidden'}).appendTo($form);
$form.submit(); $form.submit();
return false; return false;
}).on('click', '#fl_submit', function(){ }).on('click', '#fl_submit', function(){
$('#fl_form').submit(); var isFinish = $('#fl_submit').html() === "{% trans 'Finish' %}";
return false; var noChecked = !$('#acceptTerms').prop('checked');
if ( isFinish && noChecked){
$('#noTerms').css('visibility', 'visible');
}
else{
$('#fl_form').submit();
return false;
}
}).on('click', '#btn-reset-pubkey', function () { }).on('click', '#btn-reset-pubkey', function () {
var the_url = '{% url "users:user-pubkey-generate" %}'; var the_url = '{% url "users:user-pubkey-generate" %}';
window.open(the_url, "_blank") window.open(the_url, "_blank")
......
...@@ -278,6 +278,16 @@ class UserFirstLoginView(LoginRequiredMixin, SessionWizardView): ...@@ -278,6 +278,16 @@ class UserFirstLoginView(LoginRequiredMixin, SessionWizardView):
def get_form(self, step=None, data=None, files=None): def get_form(self, step=None, data=None, files=None):
form = super().get_form(step, data, files) form = super().get_form(step, data, files)
form.instance = self.request.user form.instance = self.request.user
if isinstance(form, forms.UserMFAForm):
choices = form.fields["otp_level"].choices
if self.request.user.otp_force_enabled:
choices = [(k, v) for k, v in choices if k == 2]
else:
choices = [(k, v) for k, v in choices if k in [0, 1]]
form.fields["otp_level"].choices = choices
form.fields["otp_level"].initial = self.request.user.otp_level
return form return form
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment