Commit 153fcaf7 by Kálmán Viktor

network: add rule button for host and host group views

parent 70d6e5f8
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
</div> </div>
<div class="col-sm-5 col-sm-offset-1"> <div class="col-sm-5 col-sm-offset-1">
<div class="page-header"> <div class="page-header">
<a href="{% url "network.rule_create" %}?hostgroup={{ group_pk }}" class="btn btn-success pull-right btn-xs"><i class="icon-plus-sign"></i> {% trans "Add new rule" %}</a>
<h3>{% trans "Rules" %}</h3> <h3>{% trans "Rules" %}</h3>
</div> </div>
{% if rule_list.data.data.count > 0 %} {% if rule_list.data.data.count > 0 %}
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
</div> </div>
<div class="col-sm-4"> <div class="col-sm-4">
<div class="page-header"> <div class="page-header">
<a href="{% url "network.rule_create" %}?host={{ host_pk }}" class="btn btn-success pull-right btn-xs"><i class="icon-plus-sign"></i> {% trans "Add new rule" %}</a>
<h3>{% trans "Rules" %}</h3> <h3>{% trans "Rules" %}</h3>
</div> </div>
{% if rule_list.data.data.count > 0 %} {% if rule_list.data.data.count > 0 %}
......
...@@ -246,6 +246,8 @@ class GroupDetail(UpdateView, SuccessMessageMixin): ...@@ -246,6 +246,8 @@ class GroupDetail(UpdateView, SuccessMessageMixin):
def get_context_data(self, *args, **kwargs): def get_context_data(self, *args, **kwargs):
context = super(GroupDetail, self).get_context_data(**kwargs) context = super(GroupDetail, self).get_context_data(**kwargs)
context['group_pk'] = self.object.pk
# records # records
q = Rule.objects.filter(hostgroup=self.object) q = Rule.objects.filter(hostgroup=self.object)
context['rule_list'] = SmallRuleTable(q) context['rule_list'] = SmallRuleTable(q)
...@@ -475,6 +477,13 @@ class RuleCreate(CreateView, SuccessMessageMixin): ...@@ -475,6 +477,13 @@ class RuleCreate(CreateView, SuccessMessageMixin):
form_class = RuleForm form_class = RuleForm
success_message = _(u'Successfully created rule!') success_message = _(u'Successfully created rule!')
def get_initial(self):
return {
# 'owner': 1,
'host': self.request.GET.get('host'),
'hostgroup': self.request.GET.get('hostgroup')
}
class RuleDelete(DeleteView): class RuleDelete(DeleteView):
model = Rule model = Rule
......
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 sign in to comment