Commit 0debf36d by Kálmán Viktor

network: add record table to host detail

parent 5383465a
...@@ -6,3 +6,8 @@ ...@@ -6,3 +6,8 @@
text-align: center; text-align: center;
} }
#host-detail-records-table td:first-child,
#host-detail-records-table th:first-child {
text-align: center;
width: 60px;
}
...@@ -15,6 +15,8 @@ ...@@ -15,6 +15,8 @@
# You should have received a copy of the GNU General Public License along # You should have received a copy of the GNU General Public License along
# with CIRCLE. If not, see <http://www.gnu.org/licenses/>. # with CIRCLE. If not, see <http://www.gnu.org/licenses/>.
from django.utils.translation import ugettext_lazy as _
from django_tables2 import Table, A from django_tables2 import Table, A
from django_tables2.columns import LinkColumn, TemplateColumn from django_tables2.columns import LinkColumn, TemplateColumn
...@@ -181,3 +183,20 @@ class VlanGroupTable(Table): ...@@ -181,3 +183,20 @@ class VlanGroupTable(Table):
attrs = {'class': 'table table-striped table-condensed'} attrs = {'class': 'table table-striped table-condensed'}
fields = ('name', 'vlans', 'description', 'owner', ) fields = ('name', 'vlans', 'description', 'owner', )
order_by = 'name' order_by = 'name'
class HostRecordsTable(Table):
fqdn = LinkColumn(
"network.record", args=[A("pk")],
order_by=("name", ),
)
class Meta:
model = Record
attrs = {
'class': "table table-striped table-bordered",
'id': "host-detail-records-table",
}
fields = ("type", "fqdn")
order_by = ("name", )
empty_text = _("No records.")
...@@ -45,7 +45,7 @@ ...@@ -45,7 +45,7 @@
{% endif %} {% endif %}
<div class="page-header"> <div class="page-header">
<h3>Add host group</h3> <h3>{% trans "Add host group" %}</h3>
</div> </div>
{% if not_used_groups|length == 0 %} {% if not_used_groups|length == 0 %}
No more groups to add! No more groups to add!
...@@ -64,7 +64,12 @@ ...@@ -64,7 +64,12 @@
</div><!-- input-group --> </div><!-- input-group -->
</form> </form>
{% endif %} {% endif %}
</div><!-- col-sm-4 --> <div class="page-header">
<h3>{% trans "Records" %}</h3>
</div>
{% render_table records_table %}
</div><!-- col-sm-5 -->
</div><!-- row --> </div><!-- row -->
{% endblock %} {% endblock %}
......
...@@ -399,6 +399,12 @@ class HostDetail(LoginRequiredMixin, SuperuserRequiredMixin, ...@@ -399,6 +399,12 @@ class HostDetail(LoginRequiredMixin, SuperuserRequiredMixin,
# set host pk (we need this for URL-s) # set host pk (we need this for URL-s)
context['host_pk'] = self.kwargs['pk'] context['host_pk'] = self.kwargs['pk']
from network.tables import HostRecordsTable
context['records_table'] = HostRecordsTable(
Record.objects.filter(host=self.get_object()),
request=self.request
)
return context return context
def get_success_url(self): def get_success_url(self):
......
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