Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add rule break support #73

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion www/rule/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class RulesTable(tables.Table):
id = columns.Column(verbose_name=_(u"规则ID"), orderable=False)
title = columns.Column(verbose_name=_(u"规则名称"), orderable=False)
status = columns.Column(verbose_name=_(u"状态"), orderable=False)
allow_break = columns.Column(verbose_name=_(u"允许策略短路"), orderable=False)
allow_break = columns.Column(verbose_name=_(u"允许策略短路"), orderable=False, default=False)
update_time = columns.Column(verbose_name=_(u"更新时间"), orderable=False)
user = columns.Column(verbose_name=_(u"更新人"), orderable=False)
action = columns.TemplateColumn("""
Expand Down
6 changes: 4 additions & 2 deletions www/rule/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ def get_rule(self):
d = client.hgetall(name)
if not d:
raise Http404
for key in ('status', 'allow_break', 'title', 'describe', 'end_time', 'id', 'uuid'):
for key in ('status', 'title', 'describe', 'end_time', 'id', 'uuid'):
data[key] = d[key]
try:
rule_list = json.loads(d["strategys"])
Expand All @@ -265,6 +265,7 @@ def get_rule(self):
x[2] for x in rule['strategy_list'] if len(x) == 3)
rule['strategy_list_str'] = json.dumps(rule['strategy_list'])
data['rule_list'] = rule_list
data['allow_break'] = d['allow_break'] if 'allow_break' in d else False
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这种也是,使用 d.get('auto_break', False) 更简略一些, 保险起见也可以d.get('auto_break') or False

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

包括下面的一些地方

return data


Expand Down Expand Up @@ -460,7 +461,7 @@ def get_rule(self):
raise Http404

data = {}
for key in ('status', 'allow_break', 'title', 'describe', 'end_time', 'id', 'uuid'):
for key in ('status', 'title', 'describe', 'end_time', 'id', 'uuid'):
data[key] = d[key]

try:
Expand All @@ -476,6 +477,7 @@ def get_rule(self):
x[2] for x in rule['strategy_list'] if len(x) == 3)
rule['strategy_list_str'] = json.dumps(rule['strategy_list'])
data['rule_list'] = rule_list
data['allow_break'] = d['allow_break'] if 'allow_break' in d else False
return data

@classmethod
Expand Down