Skip to content

Commit

Permalink
fix update member status in pool
Browse files Browse the repository at this point in the history
fix new and copy pool in vip
  • Loading branch information
edersonbrilhante committed Aug 24, 2016
1 parent effc55f commit e6a7d58
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 26 deletions.
11 changes: 6 additions & 5 deletions CadVlan/Pool/templates/pool/form.html
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@
<label for="{{ field.auto_id }}">{{ field.label_tag }}{% if field.field.required %}<span style="color: red;">*</span>{% endif %}</label>
</div>
{{ field }}
{% if field.errors %}
{% if field.errors %}
<p id="error">
{% for error in field.errors %}
{{ error|escape }}
Expand All @@ -307,7 +307,7 @@
<label for="{{ field.auto_id }}">{{ field.label_tag }}{% if field.field.required %}<span style="color: red;">*</span>{% endif %}</label>
</div>
{{ field }}
{% if field.errors %}
{% if field.errors %}
<p id="error">
{% for error in field.errors %}
{{ error|escape }}
Expand Down Expand Up @@ -376,6 +376,7 @@
{% else %}
<input type='hidden' name='id_pool_member' value='' />
{% endif %}
<input type='hidden' name='member_status' value='{{field.member_status}}' />
</td>
<td>
<span class='ui-icon ui-icon-closethick' style="cursor: pointer;"></span>
Expand All @@ -398,14 +399,14 @@
</div>
</div>
<br>

<div class="separator spacer"></div>

<div class="buttons-l ui-widget-header">
<button id="btn_sav" type="submit">Gravar</button>
<button id="btn_can" type="button" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-icon-primary">Cancelar</button>
</div>
</form>
</div>
</div>
{% endblock %}
{% endblock %}
65 changes: 44 additions & 21 deletions CadVlan/Pool/views.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# -*- coding:utf-8 -*-

# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
Expand All @@ -14,37 +13,59 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import json
import logging


from CadVlan.Auth.AuthSession import AuthSession
from CadVlan.forms import DeleteForm
from CadVlan.messages import error_messages, healthcheck_messages, pool_messages
from CadVlan.Pool import facade
from CadVlan.Pool.forms import SearchPoolForm, PoolHealthcheckForm, PoolFormV3
from CadVlan.permissions import POOL_MANAGEMENT, POOL_REMOVE_SCRIPT, POOL_CREATE_SCRIPT, POOL_ALTER_SCRIPT, \
HEALTH_CHECK_EXPECT, EQUIPMENT_MANAGEMENT, VIPS_REQUEST, ENVIRONMENT_MANAGEMENT
from CadVlan.templates import POOL_LIST, POOL_FORM, POOL_SPM_DATATABLE, \
POOL_DATATABLE, AJAX_IPLIST_EQUIPMENT_REAL_SERVER_HTML, POOL_REQVIP_DATATABLE, POOL_MEMBER_ITEMS, POOL_MANAGE_TAB1, \
POOL_MANAGE_TAB2, POOL_MANAGE_TAB3, POOL_MANAGE_TAB4
from CadVlan.Util.converters.util import split_to_array
from CadVlan.Util.Decorators import has_perm, has_perm_external, log, login_required
from CadVlan.Util.shortcuts import render_message_json
from CadVlan.Util.utility import DataTablePaginator, get_param_in_request

from django.contrib import messages
from django.core.urlresolvers import reverse
from django.http import HttpResponse, HttpResponseServerError
from django.shortcuts import redirect, render, render_to_response
from django.http import HttpResponse
from django.http import HttpResponseServerError
from django.shortcuts import redirect
from django.shortcuts import render
from django.shortcuts import render_to_response
from django.template import loader
from django.template.context import RequestContext
from django.views.decorators.csrf import csrf_exempt

from networkapiclient.exception import NetworkAPIClientError
from networkapiclient.Pagination import Pagination

from CadVlan.Auth.AuthSession import AuthSession
from CadVlan.forms import DeleteForm
from CadVlan.messages import error_messages
from CadVlan.messages import healthcheck_messages
from CadVlan.messages import pool_messages
from CadVlan.permissions import ENVIRONMENT_MANAGEMENT
from CadVlan.permissions import EQUIPMENT_MANAGEMENT
from CadVlan.permissions import HEALTH_CHECK_EXPECT
from CadVlan.permissions import POOL_ALTER_SCRIPT
from CadVlan.permissions import POOL_CREATE_SCRIPT
from CadVlan.permissions import POOL_MANAGEMENT
from CadVlan.permissions import POOL_REMOVE_SCRIPT
from CadVlan.permissions import VIPS_REQUEST
from CadVlan.Pool import facade
from CadVlan.Pool.forms import PoolFormV3
from CadVlan.Pool.forms import PoolHealthcheckForm
from CadVlan.Pool.forms import SearchPoolForm
from CadVlan.templates import AJAX_IPLIST_EQUIPMENT_REAL_SERVER_HTML
from CadVlan.templates import POOL_DATATABLE
from CadVlan.templates import POOL_FORM
from CadVlan.templates import POOL_LIST
from CadVlan.templates import POOL_MANAGE_TAB1
from CadVlan.templates import POOL_MANAGE_TAB2
from CadVlan.templates import POOL_MANAGE_TAB3
from CadVlan.templates import POOL_MANAGE_TAB4
from CadVlan.templates import POOL_MEMBER_ITEMS
from CadVlan.templates import POOL_REQVIP_DATATABLE
from CadVlan.templates import POOL_SPM_DATATABLE
from CadVlan.Util.converters.util import split_to_array
from CadVlan.Util.Decorators import has_perm
from CadVlan.Util.Decorators import has_perm_external
from CadVlan.Util.Decorators import log
from CadVlan.Util.Decorators import login_required
from CadVlan.Util.shortcuts import render_message_json
from CadVlan.Util.utility import DataTablePaginator
from CadVlan.Util.utility import get_param_in_request

logger = logging.getLogger(__name__)


Expand Down Expand Up @@ -366,6 +387,7 @@ def edit_form(request, id_server_pool):
'port_real': obj_member['port_real'],
'weight': obj_member['weight'],
'id_ip': ip_obj.get('id'),
'member_status': obj_member.get('member_status'),
'ip': ip_obj.get('ip_formated')
})

Expand Down Expand Up @@ -418,6 +440,7 @@ def edit_form(request, id_server_pool):
members["weight"] = request.POST.getlist('weight')
members["id_ips"] = request.POST.getlist('id_ip')
members["ips"] = request.POST.getlist('ip')
members["member_status"] = request.POST.getlist('member_status')
members["environment"] = environment_id

healthcheck_choices = facade.populate_healthcheck_choices(client)
Expand Down
6 changes: 6 additions & 0 deletions CadVlan/VipRequest/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,12 @@ def __init__(self, forms_aux, *args, **kwargs):
self.fields['trafficreturn'].choices = \
[(env['id'], env["nome_opcao_txt"]) for env in forms_aux["trafficreturn"]]

environment_vip = forms.IntegerField(
label="",
required=False,
widget=forms.HiddenInput(),
error_messages=error_messages)

timeout = forms.ChoiceField(
label="Timeout",
required=True,
Expand Down
3 changes: 3 additions & 0 deletions CadVlan/VipRequest/templates/vip-request/tab-vip-edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@

{% block tab-data %}
<div id="tabs-3">
<div id="dialog_pool">
<div id="content_pool"></div>
</div>
<form id="add_form" method="post" action="{{action}}">
{% csrf_token %}
<div style="margin-top:20px">
Expand Down
1 change: 1 addition & 0 deletions CadVlan/VipRequest/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ def tab_vip_edit(request, id_vip):
lists['form_option'] = forms.RequestVipOptionVipEditForm(
forms_aux,
initial={
"environment_vip": vip.get('environmentvip').get('id'),
"timeout": vip.get('options').get('timeout').get('id')
if vip.get('options').get('timeout') else None,
"persistence": vip.get('options').get('persistence').get('id')
Expand Down

0 comments on commit e6a7d58

Please sign in to comment.