-
Notifications
You must be signed in to change notification settings - Fork 10
Feature Update: Unit Tests, Ticket Sorting, View Template Addons, Fault Tolerant Commands #54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Auwate
wants to merge
53
commits into
amlight:master
Choose a base branch
from
Auwate:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 52 commits
Commits
Show all changes
53 commits
Select commit
Hold shift + click to select a range
b31cce1
Align with fork repo
Auwate 74d43d8
Updated settings-dev.py to turn HTTPS off (FOR PRODUCTION)
Auwate 74baa0f
Changes:
Auwate 686f960
PRODUCTION CHANGE:
Auwate e46544d
ADDED README AND DEV_TIPS
Auwate 037ea75
CHANGES:
Auwate 88e1f2f
CHANGES:
Auwate 5963cea
Changes:
Auwate 3ddb08d
Changes:
Auwate 672f003
Development
Auwate 3adddb8
-
Auwate 214a4b1
-
Auwate 10e7062
Changes:
Auwate c508bf1
Merged changes
Auwate 8b3e69a
Removed UTC fields from admin.py and models.py
Auwate b4bbfa2
CHANGES - Sorting | Added action_notes
Auwate e2d7f61
CHANGES:
Auwate ef84c01
CHANGES:
Auwate 03c4839
CHANGES:
Auwate f71c667
Minor Change
Auwate c9c6f46
Minor changes
Auwate 7d81895
Added functionality:
Auwate 4d52c6b
Minor change
Auwate e66c374
Edited labels to show what each mean.
Auwate 68799b3
CHANGE
Auwate 4e9a385
MAJOR CHANGE:
Auwate 02ec4fe
Updates to background color
Auwate 67e6e94
Removing temporary development to start merging into production.
Auwate b505509
Added unit test for custom command.
Auwate e23b272
TEMPORARY COMMIT: TRYING DOCKER TESTING
Auwate 62d1f66
Removing docker-compose test command on startup.
Auwate 43dca1b
MAJOR COMMIT:
Auwate 2c05c5c
Updated documentation
Auwate c0182a8
Merge branch 'development'
Auwate 9461a1b
Update Dockerfile
Auwate 1c91ea6
COMMIT: Updated logging
Auwate 9f23c8e
Testing Commit: Turning off SESSION_COOKIE_SECURE
Auwate a9af0e8
Turned SESSION_COOKIE to True
Auwate 675fdcb
Merge branch 'merging'
Auwate b51d98c
Merge branch 'master' of https://github.com/Auwate/Services-Status
Auwate 98fde16
MAJOR COMMIT: Reducing fluff in merge request.
Auwate 13ea9c0
COMMIT: Fault tolerance by making sure an AttributeError does not occ…
Auwate 2d93cb8
COMMIT:
Auwate 824d671
Update settings-dev.py
Auwate c8d00ff
Update settings-dev.py
Auwate e238e57
Update settings-dev.py
Auwate 75f90f0
Align with master repo
Auwate 0f91357
Update services_status.html
Auwate 8838a68
Update test_models.py
Auwate 0da35f2
Update test_models.py
Auwate 2d6b081
Update test_models.py
Auwate 07a3c28
- Commit:
Auwate 0f242f7
Update Dockerfile
Auwate File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| # Reading Markdown Files | ||
|
|
||
| To read Markdown files (.md) in VS Code, press Ctrl+Shift+V for Markdown preview. | ||
|
|
||
| # Required Prerequisites | ||
|
|
||
| - Python | ||
| - HTML/CSS | ||
| - Django | ||
| - Docker | ||
| - SQL | ||
| - Linux/Unix | ||
|
|
||
| # Django | ||
|
|
||
| Documentation can be found at https://docs.djangoproject.com/en/3.0/ | ||
|
|
||
| ## Testing | ||
|
|
||
| In case of errors, turn on debug in settings-dev.py or by using the following command: | ||
| ``` | ||
| sed -i "s/DEBUG = False/DEBUG = True/g" /opt/Services-Status/ServiceStatus/settings.py | ||
| ``` | ||
|
|
||
| ## HTTPS to HTTP | ||
|
|
||
| Django uses HTTP in testing environments, so make sure to turn SESSION_COOKIE_SECURE to False. You can do that in settings-dev.py, or by using the following command: | ||
| ``` | ||
| sed -i "s/SESSION_COOKIE_SECURE = True/SESSION_COOKIE_SECURE = False/g" /opt/Services-Status/ServiceStatus/settings.py | ||
| ``` | ||
|
|
||
| # Unix/Linux Environment | ||
|
|
||
| The application is built for Unix/Linux development, so locally developing the application on other operating systems is **not** recommended. Ask a network engineer or your lead developer to help give you access to the remote server being used to test. | ||
|
|
||
| Unix/Linux documentation can be found at https://docs.kernel.org/, or by searching up common commands used. | ||
|
|
||
| # Docker | ||
|
|
||
| Documentation can be found at https://docs.docker.com/ | ||
|
|
||
| This application uses docker-compose to build and run, so before using any commands you must be in the deploy folder. | ||
|
|
||
| ## Common Docker commands | ||
| ``` | ||
| docker-compose build | ||
| ``` | ||
| This will run the build script, pulling the data from the 3 Docker files found in the folder. | ||
| ``` | ||
| docker-compose up | ||
| ``` | ||
| This will run the docker container in your terminal. | ||
| ``` | ||
| docker-compose up -d | ||
| ``` | ||
| This will run the docker container in the background. This is especially useful if you want to debug or enter into the shell. | ||
| ``` | ||
| docker-compose kill | ||
| ``` | ||
| This will terminate the running container so you do not consume excess resources. This is especially important if you run **docker-compose up -d** or if you run docker-compose up and disconnect from the terminal. | ||
| ``` | ||
| docker exec -it <container_name> /bin/bash | ||
| ``` | ||
| This will connect you into the container's bash terminal. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| # Services-Status | ||
|
|
||
| The Services-Status repository is used to power the status page used by network engineers at CIARA (https://status.amlight.net/) It uses Django + jQuery to run the web server, supplying templates based on what view you are currently in. | ||
|
|
||
| For documentation, on tech used and useful tips, check DEV_TIPS.md | ||
|
|
||
| ## Recent Changes | ||
|
|
||
| - Tickets are now ordered in descending order by the *begin* field (Newest first) | ||
| - Tickets in the main view now contain a latest_update field, which uses the action_description found in TicketLogs. | ||
| - Custom command added to immediately populate the database with Status objects, if they are not there already. | ||
| - Unit tests are being rolled out to test new features. | ||
| - Documentation is being rolled out on a daily basis. | ||
|
|
||
| ## Unit Testing | ||
|
|
||
| Testing is implemented by running the following command: | ||
| ``` | ||
| python3 manage.py test status.tests --settings=ServiceStatus.settings-test | ||
| ``` | ||
| (If python3 does not work, use **python**) | ||
|
|
||
| ### Development | ||
|
|
||
| To create more tests, navigate to the status/tests directory. Each test will be run since they start with *test_*, so write your tests under the test file that covers your domain. For example, if you're testing a new command, do it under *test_commands*. | ||
|
|
||
| ## Logging Driver | ||
|
|
||
| For quicker development and testing, the logging driver was commented out from docker-compose.yml. When pushing to production remember to uncomment this. | ||
|
|
||
| ## Deployment Methodology | ||
|
|
||
| The Service Status application uses Docker to gather its dependencies and deploy onto a remote server. It uses a .yml script to build, so this application uses docker-compose. | ||
|
|
||
| To **test**, make sure to turn Debug = True and SESSION_COOKIE_COOKIE = False. You can find more information on how to do this in the DEV_TIPS.md file. | ||
|
|
||
| ## Unix (remote environment) | ||
|
|
||
| The services-status application was created to run on a Unix environment, which is the environment used by the remote server. Currently, development is taking place on a virtual machine, so ask the networking team to help you gain access to the current VM the developers are using, or to create your own. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,164 @@ | ||
| """ | ||
| SPECIAL FILE | ||
|
|
||
| This settings.py file will be used strictly for testing. The | ||
| main difference between this one and settings-dev.py is the database used. This | ||
| one uses local memory and SQLite, rather than a remote docker container that | ||
| settings-dev.py uses. | ||
|
|
||
| For the full list of settings and their values, see | ||
| https://docs.djangoproject.com/en/3.0/ref/settings/ | ||
| """ | ||
|
|
||
| import os | ||
|
|
||
| from django.core.mail.utils import DNS_NAME | ||
|
|
||
| # Build paths inside the project like this: os.path.join(BASE_DIR, ...) | ||
| BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) | ||
|
|
||
| # Quick-start development settings - unsuitable for production | ||
| # See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/ | ||
|
|
||
| # SECURITY WARNING: keep the secret key used in production secret! | ||
| # For Django 1.10 and above you can use: | ||
| # from django.core.management.utils import get_random_secret_key | ||
| # get_random_secret_key() | ||
| SECRET_KEY = 'XXXSECRETKEYXXX' | ||
|
|
||
| # SECURITY WARNING: don't run with debug turned on in production! | ||
| DEBUG = True | ||
|
|
||
| ALLOWED_HOSTS = [] | ||
|
|
||
| # Application definition | ||
|
|
||
| INSTALLED_APPS = [ | ||
| 'django.contrib.admin', | ||
| 'django.contrib.auth', | ||
| 'django.contrib.contenttypes', | ||
| 'django.contrib.sessions', | ||
| 'django.contrib.messages', | ||
| 'django.contrib.staticfiles', | ||
| 'status.apps.StatusConfig', | ||
| 'django_extensions', | ||
| 'tinymce', | ||
| 'django_admin_listfilter_dropdown', | ||
| 'colorfield', | ||
| 'ckeditor', | ||
| 'ckeditor_uploader', | ||
| ] | ||
|
|
||
| MIDDLEWARE = [ | ||
| 'django.middleware.security.SecurityMiddleware', | ||
| 'django.contrib.sessions.middleware.SessionMiddleware', | ||
| 'django.middleware.common.CommonMiddleware', | ||
| 'django.middleware.csrf.CsrfViewMiddleware', | ||
| 'django.contrib.auth.middleware.AuthenticationMiddleware', | ||
| 'django.contrib.messages.middleware.MessageMiddleware', | ||
| 'django.middleware.clickjacking.XFrameOptionsMiddleware', | ||
| ] | ||
|
|
||
| ROOT_URLCONF = 'ServiceStatus.urls' | ||
|
|
||
| TEMPLATES = [ | ||
| { | ||
| 'BACKEND': 'django.template.backends.django.DjangoTemplates', | ||
| 'DIRS': [os.path.join(BASE_DIR, 'templates')] | ||
| , | ||
| 'APP_DIRS': True, | ||
| 'OPTIONS': { | ||
| 'context_processors': [ | ||
| 'django.template.context_processors.debug', | ||
| 'django.template.context_processors.request', | ||
| 'django.contrib.auth.context_processors.auth', | ||
| 'django.contrib.messages.context_processors.messages', | ||
| ], | ||
| }, | ||
| }, | ||
| ] | ||
|
|
||
| WSGI_APPLICATION = 'ServiceStatus.wsgi.application' | ||
|
|
||
| # Database | ||
| # https://docs.djangoproject.com/en/3.0/ref/settings/#databases | ||
|
|
||
| DATABASES = { | ||
| 'default':{ | ||
| 'ENGINE': 'django.db.backends.sqlite3', | ||
| 'NAME': ':memory:' | ||
| } | ||
| } | ||
|
|
||
| # Password validation | ||
| # https://docs.djangoproject.com/en/3.0/ref/settings/#auth-password-validators | ||
|
|
||
| AUTH_PASSWORD_VALIDATORS = [ | ||
| { | ||
| 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', | ||
| }, | ||
| { | ||
| 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', | ||
| }, | ||
| { | ||
| 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', | ||
| }, | ||
| { | ||
| 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', | ||
| }, | ||
| ] | ||
|
|
||
| # Internationalization | ||
| # https://docs.djangoproject.com/en/3.0/topics/i18n/ | ||
|
|
||
| LANGUAGE_CODE = 'en-us' | ||
|
|
||
| TIME_ZONE = 'America/New_York' | ||
|
|
||
| USE_I18N = True | ||
|
|
||
| USE_L10N = True | ||
|
|
||
| USE_TZ = True | ||
|
|
||
| # Static files (CSS, JavaScript, Images) | ||
| # https://docs.djangoproject.com/en/3.0/howto/static-files/ | ||
|
|
||
| STATIC_URL = '/static/' | ||
|
|
||
| PROJECT_DIR = os.path.dirname(os.path.abspath(__file__)) | ||
|
|
||
| STATIC_ROOT = os.path.join(PROJECT_DIR, 'static') | ||
|
|
||
| STATICFILES_DIRS = ( | ||
| os.path.join(BASE_DIR, 'static'), | ||
| ) | ||
|
|
||
| GRAPH_MODELS = { | ||
| 'all_applications': True, | ||
| 'group_models': True, | ||
| } | ||
|
|
||
| CKEDITOR_BASEPATH = "/static/ckeditor/ckeditor/" | ||
|
|
||
| CKEDITOR_UPLOAD_PATH = "/uploads/" | ||
|
|
||
| SMTP_HOST = "XXXSMTPHOSTXXX" | ||
| SMTP_PORT = 587 | ||
| SMTP_USER = "XXXSMTPUSERXXX" | ||
| SMTP_PASS = "XXXSMTPPASSXXX" | ||
|
|
||
| # SMTP Configuration | ||
| DNS_NAME._fqdn = 'localhost' | ||
| EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' | ||
| EMAIL_USE_TLS = True | ||
| EMAIL_HOST = 'XXXSMTPHOSTXXX' | ||
| DEFAULT_FROM_EMAIL = 'XXXSMTPUSERXXX' | ||
| EMAIL_HOST_USER = 'XXXSMTPUSERXXX' | ||
| EMAIL_HOST_PASSWORD = 'XXXSMTPPASSXXX' | ||
| EMAIL_PORT = 587 | ||
|
|
||
| # TURNED ON FOR DEVELOPMENT. TURN OFF FOR PRODUCTION. | ||
| SESSION_COOKIE_SECURE = False | ||
|
|
||
| CSRF_COOKIE_HTTPONLY = True |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| from django.core.management.base import BaseCommand | ||
| from status.models import Status | ||
|
|
||
| class Command(BaseCommand): | ||
|
|
||
| help = 'Creates the initial objects required to start the service-status application' | ||
|
|
||
| def handle(self, *args, **options): | ||
|
|
||
| if Status.objects.count() > 0: | ||
| return | ||
|
|
||
| initial_objects = [ | ||
| {"tag":"Alert", "color_name": "Orange", "color_hex":"#FC810D", "class_design": "fas fa-exclamation-circle"}, | ||
| {"tag":"In Process", "color_name": "Yellow", "color_hex":"#DBBF07", "class_design": "fas fa-tools"}, | ||
| {"tag":"No Issues", "color_name": "Green", "color_hex":"#0AC739", "class_design": "fas fa-check-circle"}, | ||
| {"tag":"Outage", "color_name": "Red", "color_hex":"#F00004", "class_design": "fas fa-times-circle"}, | ||
| {"tag":"Planned", "color_name": "Blue", "color_hex":"#041DBF", "class_design": "far fa-calendar-alt"} | ||
| ] | ||
|
|
||
| for data_objects in initial_objects: | ||
| Status.objects.create(**data_objects) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Austin, this particular change here does not seems necessary. Can you please clarify why we need this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I was testing using my forked repo, I'll fix that right now!