added stuff

This commit is contained in:
benjamyn 2020-10-17 22:39:07 -04:00
parent b64aa3e5e7
commit a891b7caed
10 changed files with 172 additions and 9 deletions

View File

@ -1,3 +1,14 @@
from django.contrib import admin
from .models import Migration
# Register your models here.
class MigrationAdmin(admin.ModelAdmin):
list_display = ('migration_status', 'booked_time',
'ticket_id', 'domain', 'brand', 'print_missed_migrations')
search_fields = ['domain', 'booked_time',
'username', 'ticket_id', 'migration_status']
admin.site.register(Migration, MigrationAdmin)

View File

@ -0,0 +1,29 @@
# Generated by Django 3.1.2 on 2020-10-18 01:53
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Migration',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('submit_time', models.DateTimeField(verbose_name='migrtation submitted on')),
('domain', models.CharField(max_length=200)),
('booked_time', models.DateTimeField(verbose_name='Migration booked for')),
('original_server', models.CharField(max_length=200)),
('new_server', models.CharField(max_length=200)),
('username', models.CharField(max_length=200)),
('notes', models.CharField(max_length=1024)),
('brand', models.CharField(max_length=200)),
('ticket_url', models.CharField(max_length=200)),
],
),
]

View File

@ -0,0 +1,18 @@
# Generated by Django 3.1.2 on 2020-10-18 01:56
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('api', '0001_initial'),
]
operations = [
migrations.RenameField(
model_name='migration',
old_name='ticket_url',
new_name='ticket_id',
),
]

View File

@ -0,0 +1,36 @@
# Generated by Django 3.1.2 on 2020-10-18 01:59
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('api', '0002_auto_20201018_1256'),
]
operations = [
migrations.AddField(
model_name='migration',
name='additional_domains',
field=models.CharField(default='', max_length=500),
preserve_default=False,
),
migrations.AddField(
model_name='migration',
name='agent_booked',
field=models.CharField(default='', max_length=10),
preserve_default=False,
),
migrations.AddField(
model_name='migration',
name='migration_status',
field=models.CharField(default='Booked', max_length=200),
),
migrations.AddField(
model_name='migration',
name='migration_type',
field=models.CharField(default='', max_length=200),
preserve_default=False,
),
]

View File

@ -1,3 +1,30 @@
from django.db import models
import datetime
# Create your models here.
from django.db import models
from django.utils import timezone
class Migration(models.Model):
submit_time = models.DateTimeField('migrtation submitted on')
domain = models.CharField(max_length=200)
booked_time = models.DateTimeField('Migration booked for')
original_server = models.CharField(max_length=200)
new_server = models.CharField(max_length=200)
username = models.CharField(max_length=200)
notes = models.CharField(max_length=1024)
brand = models.CharField(max_length=200)
ticket_id = models.CharField(max_length=200)
migration_status = models.CharField(max_length=200, default='Booked')
agent_booked = models.CharField(max_length=10)
additional_domains = models.CharField(max_length=500)
migration_type = models.CharField(max_length=200)
def print_missed_migrations(self):
now = timezone.now()
return now - datetime.timedelta(days=1) <= self.booked_time <= now
print_missed_migrations.admin_order_field = 'booked_time'
print_missed_migrations.boolean = True
print_missed_migrations.short_description = "Was this migration missed?"
def __str__(self):
return self.domain + ' ' + self.ticket_id

View File

@ -0,0 +1,9 @@
{% if latest_migrations %}
<ul>
{% for migration in latest_migrations %}
<li><a href=>{{ migration.booked_time }}, {{ migration.migration_status }}</a></li>
{% endfor %}
</ul>
{% else %}
<p>No polls are available.</p>
{% endif %}

7
migratorapi/api/urls.py Normal file
View File

@ -0,0 +1,7 @@
from django.urls import path
from . import views
app_name = 'api'
urlpatterns = [
path('', views.IndexView.as_view(), name='index')
]

View File

@ -1,3 +1,16 @@
from django.shortcuts import render
from django.shortcuts import get_object_or_404, render
from django.http import HttpResponseRedirect
from django.views import generic
from django.urls import reverse
from django.utils import timezone
# Create your views here.
from .models import Migration
class IndexView(generic.ListView):
template_name = 'api/index.html'
context_object_name = 'latest_migrations'
def get_queryset(self):
"""Return the last five published questions (not including those set in the future)."""
return Migration.objects.filter(booked_time__gte=timezone.now()).order_by('-booked_time')[:5]

View File

@ -25,12 +25,13 @@ SECRET_KEY = 'cq3daur*kk2+*-)@s%wq1c+pc7xi-c1ig@-%wq)m7pn3+zxbre'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
ALLOWED_HOSTS = ['10.6.9.42']
# Application definition
INSTALLED_APPS = [
'api.apps.ApiConfig',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
@ -75,11 +76,22 @@ WSGI_APPLICATION = 'migratorapi.wsgi.application'
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
'ENGINE': 'django.db.backends.mysql',
'NAME': 'migration',
'USER': 'migration',
'PASSWORD': 'migration123',
'HOST': '127.0.0.1',
'PORT': '3306',
}
}
# DATABASES = {
# 'default': {
# 'ENGINE': 'django.db.backends.sqlite3',
# 'NAME': BASE_DIR / 'db.sqlite3',
# }
# }
# Password validation
# https://docs.djangoproject.com/en/3.1/ref/settings/#auth-password-validators
@ -105,7 +117,7 @@ AUTH_PASSWORD_VALIDATORS = [
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
TIME_ZONE = 'Australia/Melbourne'
USE_I18N = True

View File

@ -14,8 +14,9 @@ Including another URLconf
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path
from django.urls import include, path
urlpatterns = [
path('', include('api.urls')),
path('admin/', admin.site.urls),
]