From a71bcd24f5369895905204ffed1d6427ac6de9a5 Mon Sep 17 00:00:00 2001 From: Tyrel Souza Date: Sat, 1 Apr 2017 14:02:23 -0400 Subject: [PATCH] Make machine Details List show information --- .../migrations/0002_auto_20170401_1258.py | 20 +++++++++++++ stagestatus/apps/machines/models.py | 3 +- stagestatus/apps/machines/urls.py | 4 +-- stagestatus/apps/machines/views.py | 8 +++++- stagestatus/settings/base.py | 9 +++--- .../templates/{machines => }/index.html | 0 .../templates/machines/machine_list.html | 28 +++++++++++++++++++ stagestatus/urls.py | 4 ++- 8 files changed, 65 insertions(+), 11 deletions(-) create mode 100644 stagestatus/apps/machines/migrations/0002_auto_20170401_1258.py rename stagestatus/templates/{machines => }/index.html (100%) create mode 100644 stagestatus/templates/machines/machine_list.html diff --git a/stagestatus/apps/machines/migrations/0002_auto_20170401_1258.py b/stagestatus/apps/machines/migrations/0002_auto_20170401_1258.py new file mode 100644 index 0000000..f4feb51 --- /dev/null +++ b/stagestatus/apps/machines/migrations/0002_auto_20170401_1258.py @@ -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.'), + ), + ] diff --git a/stagestatus/apps/machines/models.py b/stagestatus/apps/machines/models.py index e7510d8..e14b659 100644 --- a/stagestatus/apps/machines/models.py +++ b/stagestatus/apps/machines/models.py @@ -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, diff --git a/stagestatus/apps/machines/urls.py b/stagestatus/apps/machines/urls.py index 8a7145d..1d40c87 100644 --- a/stagestatus/apps/machines/urls.py +++ b/stagestatus/apps/machines/urls.py @@ -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()), ] diff --git a/stagestatus/apps/machines/views.py b/stagestatus/apps/machines/views.py index 2536b37..4bde3c1 100644 --- a/stagestatus/apps/machines/views.py +++ b/stagestatus/apps/machines/views.py @@ -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() diff --git a/stagestatus/settings/base.py b/stagestatus/settings/base.py index 74ac2e6..97c583e 100644 --- a/stagestatus/settings/base.py +++ b/stagestatus/settings/base.py @@ -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', diff --git a/stagestatus/templates/machines/index.html b/stagestatus/templates/index.html similarity index 100% rename from stagestatus/templates/machines/index.html rename to stagestatus/templates/index.html diff --git a/stagestatus/templates/machines/machine_list.html b/stagestatus/templates/machines/machine_list.html new file mode 100644 index 0000000..ac97edd --- /dev/null +++ b/stagestatus/templates/machines/machine_list.html @@ -0,0 +1,28 @@ + + + + Staging Machines + + + + + diff --git a/stagestatus/urls.py b/stagestatus/urls.py index 53594e6..e629dcd 100644 --- a/stagestatus/urls.py +++ b/stagestatus/urls.py @@ -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')), ]