Make machine Details List show information

This commit is contained in:
Tyrel Souza 2017-04-01 14:02:23 -04:00
parent 23b8cce692
commit a71bcd24f5
No known key found for this signature in database
GPG Key ID: 2EECB5087209E6A5
8 changed files with 65 additions and 11 deletions

View File

@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.6 on 2017-04-01 17:58
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('machines', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='machinenote',
name='notes',
field=models.TextField(help_text='Reason you are checking out the server.'),
),
]

View File

@ -52,8 +52,7 @@ class MachineNote(models.Model):
"""
machine = models.OneToOneField('Machine')
notes = models.CharField(
max_length=256,
notes = models.TextField(
help_text='Reason you are checking out the server.')
user = models.ForeignKey(
User,

View File

@ -1,6 +1,6 @@
from django.conf.urls import url
from django.views.generic import TemplateView
from machines.views import MachineList
urlpatterns = [
url(r'^', TemplateView.as_view(template_name='machines/index.html')),
url(r'^$', MachineList.as_view()),
]

View File

@ -1 +1,7 @@
from django.shortcuts import render
from django.views.generic import ListView
from machines.models import Machine
class MachineList(ListView):
context_object_name = 'machines'
queryset = Machine.objects.all()

View File

@ -18,7 +18,6 @@ DEBUG = True
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
@ -26,15 +25,15 @@ INSTALLED_APPS = [
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
# Third Party apps
'rest_framework',
]
PROJECT_APPS = [
'machines',
]
THIRD_PARTY_APPS = [
'rest_framework',
]
INSTALLED_APPS += PROJECT_APPS
INSTALLED_APPS += THIRD_PARTY_APPS
MIDDLEWARE_CLASSES = [
'django.middleware.security.SecurityMiddleware',

View File

@ -0,0 +1,28 @@
<!DOCTYPE html>
<html>
<head>
<title>Staging Machines</title>
</head>
<body>
<ul>
{% for machine in machines %}
<li>
<span>{{machine.hostname}}</span>
<ul>
<li>DB Server: {{ machine.db_server }}</li>
<li>DB Refresh: {{machine.machinestatus.last_db_refresh }}</li>
<li>Git Branch: {{ machine.machinestatus.git_branch }}</li>
<li>Git Version: {{ machine.machinestatus.git_version }}</li>
{% if machine.machinenote %}
<li>User: {{ machine.machinenote.user }}</li>
<li>Notes: <br>
<span>{{ machine.machinenote.notes|linebreaksbr }}</span>
</li>
{% endif %}
</ul>
</li>
{% endfor %}
</ul>
</body>
</html>

View File

@ -1,7 +1,9 @@
from django.conf.urls import url, include
from django.contrib import admin
from django.views.generic import TemplateView
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^$', include('machines.urls')),
url(r'^machines/', include('machines.urls')),
url(r'^', TemplateView.as_view(template_name='index.html')),
]