add default prod and local confs
+x manage.py, add .env to gitignore initial page, tests, change settings
This commit is contained in:
parent
1bce26be09
commit
e8261ef423
2
.gitignore
vendored
2
.gitignore
vendored
@ -12,7 +12,6 @@ dist
|
||||
build
|
||||
eggs
|
||||
parts
|
||||
bin
|
||||
var
|
||||
sdist
|
||||
develop-eggs
|
||||
@ -49,6 +48,7 @@ docs/_build
|
||||
env
|
||||
env*
|
||||
venv
|
||||
.env
|
||||
|
||||
# intellij
|
||||
*.ipr
|
||||
|
@ -1,3 +1,5 @@
|
||||
-r testing.txt
|
||||
|
||||
Sphinx
|
||||
pdir2
|
||||
ipython
|
||||
|
@ -0,0 +1 @@
|
||||
default_app_config = 'machines.apps.MachinesConfig'
|
@ -1,13 +1,22 @@
|
||||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
||||
from .models import Machine, MachineStatus
|
||||
from .models import Machine, MachineStatus, MachineNote
|
||||
|
||||
class MachineAdmnin(admin.ModelAdmin):
|
||||
list_display = ('hostname',)
|
||||
admin.site.register(Machine, MachineAdmnin)
|
||||
|
||||
class MachineAdmin(admin.ModelAdmin):
|
||||
list_display = ('hostname', 'db_server')
|
||||
|
||||
|
||||
class MachineStatusAdmin(admin.ModelAdmin):
|
||||
list_display = ('machine', 'git_branch', 'notes', 'user')
|
||||
admin.site.register(MachineStatus, MachineStatusAdmin)
|
||||
list_display = ('machine', 'last_db_refresh',
|
||||
'last_updated', 'git_branch', 'git_version')
|
||||
|
||||
|
||||
class MachineNoteAdmin(admin.ModelAdmin):
|
||||
list_display = ('machine', 'notes', 'user')
|
||||
|
||||
|
||||
admin.site.register(Machine, MachineAdmin)
|
||||
admin.site.register(MachineStatus, MachineStatusAdmin)
|
||||
admin.site.register(MachineNote, MachineNoteAdmin)
|
||||
|
@ -5,3 +5,4 @@ from django.apps import AppConfig
|
||||
|
||||
class MachinesConfig(AppConfig):
|
||||
name = 'machines'
|
||||
verbose_name = 'Machines'
|
||||
|
@ -1,5 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.10.6 on 2017-03-30 02:31
|
||||
# Generated by Django 1.10.6 on 2017-04-01 17:08
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.conf import settings
|
||||
@ -9,7 +9,7 @@ import django.db.models.deletion
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
replaces = [(b'machines', '0001_initial'), (b'machines', '0002_auto_20170330_0222'), (b'machines', '0003_auto_20170330_0228')]
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
@ -23,6 +23,15 @@ class Migration(migrations.Migration):
|
||||
('db_server', models.CharField(help_text='Database server host', max_length=256)),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='MachineNote',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('notes', models.CharField(help_text='Reason you are checking out the server.', max_length=256)),
|
||||
('machine', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to='machines.Machine')),
|
||||
('user', models.ForeignKey(help_text='Who checked out the server?', on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='MachineStatus',
|
||||
fields=[
|
||||
@ -31,9 +40,10 @@ class Migration(migrations.Migration):
|
||||
('git_version', models.CharField(help_text='Current tag of the git branch', max_length=256)),
|
||||
('last_db_refresh', models.DateTimeField(help_text='Time the last database refresh completed')),
|
||||
('last_updated', models.DateTimeField(auto_now=True, help_text='The time this was last modified')),
|
||||
('notes', models.CharField(blank=True, help_text='Reason you are checking out the server.', max_length=256)),
|
||||
('machine', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='machines.Machine')),
|
||||
('user', models.ForeignKey(blank=True, help_text='Who checked out the server', on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
|
||||
('machine', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to='machines.Machine')),
|
||||
],
|
||||
options={
|
||||
'verbose_name_plural': 'Machine Statuses',
|
||||
},
|
||||
),
|
||||
]
|
||||
|
@ -16,39 +16,45 @@ class Machine(models.Model):
|
||||
|
||||
db_server = models.CharField(
|
||||
max_length=256,
|
||||
help_text="Database server host")
|
||||
help_text='Database server host')
|
||||
|
||||
def __unicode__(self):
|
||||
return self.hostname
|
||||
|
||||
|
||||
class MachineStatus(models.Model):
|
||||
"""
|
||||
Represents the data that we store on each server.
|
||||
This data will change every time a machine is checked out,
|
||||
or nightly refreshes, or anything.
|
||||
"""
|
||||
machine = models.ForeignKey('Machine')
|
||||
machine = models.OneToOneField('Machine')
|
||||
|
||||
git_branch = models.CharField(
|
||||
max_length=256,
|
||||
help_text="Git branch checked out on server.")
|
||||
help_text='Git branch checked out on server.')
|
||||
git_version = models.CharField(
|
||||
max_length=256,
|
||||
help_text="Current tag of the git branch")
|
||||
help_text='Current tag of the git branch')
|
||||
last_db_refresh = models.DateTimeField(
|
||||
help_text="Time the last database refresh completed")
|
||||
help_text='Time the last database refresh completed')
|
||||
last_updated = models.DateTimeField(
|
||||
auto_now=True,
|
||||
help_text="The time this was last modified")
|
||||
|
||||
notes = models.CharField(
|
||||
blank=True,
|
||||
max_length=256,
|
||||
help_text="Reason you are checking out the server.")
|
||||
user = models.ForeignKey(
|
||||
User,
|
||||
blank=True,
|
||||
help_text="Who checked out the server")
|
||||
help_text='The time this was last modified')
|
||||
|
||||
class Meta:
|
||||
verbose_name_plural = "Machine Statuses"
|
||||
verbose_name_plural = 'Machine Statuses'
|
||||
|
||||
|
||||
class MachineNote(models.Model):
|
||||
"""
|
||||
Notes on the machine as well as who has it checked out.
|
||||
"""
|
||||
machine = models.OneToOneField('Machine')
|
||||
|
||||
notes = models.CharField(
|
||||
max_length=256,
|
||||
help_text='Reason you are checking out the server.')
|
||||
user = models.ForeignKey(
|
||||
User,
|
||||
help_text='Who checked out the server?')
|
||||
|
@ -1,6 +1,22 @@
|
||||
from __future__ import print_function
|
||||
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
||||
from model_mommy import mommy
|
||||
|
||||
# Models
|
||||
from django.contrib.auth.models import User
|
||||
from .models import MachineStatus
|
||||
|
||||
|
||||
class MachineTest(TestCase):
|
||||
pass
|
||||
def setUp(self):
|
||||
self.user = mommy.make(User)
|
||||
self.machinestatus = mommy.make(
|
||||
MachineStatus,
|
||||
user=self.user,
|
||||
make_m2m=True)
|
||||
self.machine = self.machinestatus.machine
|
||||
|
||||
def test_init(self):
|
||||
pass
|
||||
|
6
stagestatus/apps/machines/urls.py
Normal file
6
stagestatus/apps/machines/urls.py
Normal file
@ -0,0 +1,6 @@
|
||||
from django.conf.urls import url
|
||||
from django.views.generic import TemplateView
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^', TemplateView.as_view(template_name='machines/index.html')),
|
||||
]
|
@ -1,3 +1 @@
|
||||
from django.shortcuts import render
|
||||
|
||||
# Create your views here.
|
||||
|
@ -14,7 +14,6 @@ SECRET_KEY = 'CHANGE THIS!!!'
|
||||
|
||||
# SECURITY WARNING: don't run with debug turned on in production!
|
||||
DEBUG = True
|
||||
IN_TESTING = sys.argv[1:2] == ['test']
|
||||
|
||||
ALLOWED_HOSTS = []
|
||||
|
||||
@ -27,13 +26,13 @@ INSTALLED_APPS = [
|
||||
'django.contrib.sessions',
|
||||
'django.contrib.messages',
|
||||
'django.contrib.staticfiles',
|
||||
# Local apps
|
||||
'machines',
|
||||
# Third Party apps
|
||||
'rest_framework',
|
||||
]
|
||||
|
||||
PROJECT_APPS = []
|
||||
PROJECT_APPS = [
|
||||
'machines',
|
||||
]
|
||||
|
||||
INSTALLED_APPS += PROJECT_APPS
|
||||
|
||||
@ -57,20 +56,20 @@ WSGI_APPLICATION = 'stagestatus.wsgi.application'
|
||||
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.postgresql_psycopg2',
|
||||
'ENGINE': 'django.db.backends.mysql',
|
||||
'NAME': 'stagestatus',
|
||||
'USER': 'postgres',
|
||||
'USER': 'stagestatus',
|
||||
'PASSWORD': '',
|
||||
'HOST': '', # Empty for localhost through domain sockets or '127.0.0.1' for localhost through TCP.
|
||||
'PORT': '', # Set to empty string for default.
|
||||
'HOST': '',
|
||||
'PORT': '',
|
||||
}
|
||||
}
|
||||
|
||||
# Internationalization
|
||||
|
||||
LANGUAGE_CODE = 'en-gb'
|
||||
LANGUAGE_CODE = 'en-us'
|
||||
|
||||
TIME_ZONE = 'UTC'
|
||||
TIME_ZONE = 'EST'
|
||||
|
||||
USE_I18N = False
|
||||
|
||||
@ -130,13 +129,7 @@ AUTH_PASSWORD_VALIDATORS = [
|
||||
]
|
||||
|
||||
|
||||
# .local.py overrides all the common settings.
|
||||
try:
|
||||
from .local import * # noqa
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
|
||||
# importing test settings file if necessary
|
||||
if IN_TESTING:
|
||||
from .testing import * # noqa
|
||||
|
@ -1 +0,0 @@
|
||||
from .base import * # noqa
|
1
stagestatus/templates/machines/index.html
Normal file
1
stagestatus/templates/machines/index.html
Normal file
@ -0,0 +1 @@
|
||||
Hello
|
@ -1,6 +1,7 @@
|
||||
from django.conf.urls import url
|
||||
from django.conf.urls import url, include
|
||||
from django.contrib import admin
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^admin/', admin.site.urls),
|
||||
url(r'^$', include('machines.urls')),
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user